daily update on 20230516 by nitload youmu, geometry interfaces created between cs and c

This commit is contained in:
Nitload
2023-05-17 02:14:23 +08:00
parent dd891f7319
commit 3532f09fed
83 changed files with 1431 additions and 1220 deletions
@@ -0,0 +1,17 @@
using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp.Geometries
{
[StructLayout(LayoutKind.Sequential)]
public unsafe struct triangleVertexArray
{
public vec3d* vertex1Ptr;
internal vec3d* vertex2Ptr;
internal vec3d* vertex3Ptr;
}
}
@@ -31,9 +31,9 @@ namespace StgSharp.Geometries
internal override void OnRender(uint tick)
{
tick-= bornTick;
center._position = refOrigin._position + MoveCenter(tick);
beginPoint._position = refOrigin._position + MovBegin(tick);
endPoint._position = refOrigin._position + MovEnd(tick);
center.Position = refOrigin.Position + MoveCenter(tick);
beginPoint.Position = refOrigin.Position + MovBegin(tick);
endPoint.Position = refOrigin.Position + MovEnd(tick);
}
public override Line[] GetAllSides() => throw new NotImplementedException();
@@ -35,9 +35,9 @@ namespace StgSharp.Geometries
internal override void OnRender(uint tick)
{
tick-=bornTick;
center._position = refOrigin._position + MoveCenter(tick);
pointOnCircle._position = refOrigin._position + UpdateRadius(tick);
pointOnPlain._position = refOrigin._position + UpdatePlain(tick);
center.Position = refOrigin.Position + MoveCenter(tick);
pointOnCircle.Position = refOrigin.Position + UpdateRadius(tick);
pointOnPlain.Position = refOrigin.Position + UpdatePlain(tick);
}
public override Line[] GetAllSides()
@@ -15,7 +15,11 @@ namespace StgSharp.Geometries
internal readonly Point refOrigin;
public Point RefOrigin { get { return refOrigin; } }
public abstract Point RefPoint01{ get; }
public abstract Point RefPoint01
{
get;
}
public abstract Point RefPoint02{ get; }
public abstract Point RefPoint03{ get; }
public uint BornTime => bornTick;
@@ -39,8 +39,8 @@ namespace StgSharp.Geometries
internal override void OnRender(uint tick)
{
tick -= bornTick;
beginPoint._position = refOrigin._position + MoveBeginPoint(tick);
endPoint._position = refOrigin._position + MoveEndPoint(tick);
beginPoint.Position = refOrigin.Position + MoveBeginPoint(tick);
endPoint.Position = refOrigin.Position + MoveEndPoint(tick);
}
public override Line[] GetAllSides()
@@ -44,10 +44,10 @@ namespace StgSharp.Geometries
internal override sealed void OnRender(uint tick)
{
uint nowTick = GameTimeLine.tickCounter._value;
this.vertex01._position = RefOrigin._position + movVertex01Operation(nowTick);
this.vertex02._position = RefOrigin._position + movVertex02Operation(nowTick);
this.vertex03._position = 2 * center._position - vertex01._position;
this.vertex04._position = 2 * center._position - vertex02._position;
this.vertex01.Position = RefOrigin.Position + movVertex01Operation(nowTick);
this.vertex02.Position = RefOrigin.Position + movVertex02Operation(nowTick);
this.vertex03.Position = 2 * center.Position - vertex01.Position;
this.vertex04.Position = 2 * center.Position - vertex02.Position;
}
}
@@ -33,9 +33,9 @@ namespace StgSharp.Geometries
public Plain(Point p1, Point p2, Point p3)
{
vec3d origin = p1._position;
vec3d v1 = p2._position - origin;
vec3d v2 = p3._position - origin;
vec3d origin = p1.Position;
vec3d v1 = p2.Position - origin;
vec3d v2 = p3.Position - origin;
vec1 = v1 - v2 * (v1.Y / v2.Y); //计算平面在xz平面上的方向投影
@@ -3,25 +3,43 @@ using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Security.Cryptography;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp.Geometries
{
public class Point : INode<Point>
public unsafe class Point : INode<Point>
{
internal vec3d* postionPtr;
internal vec3d _position;
internal Point(vec3d* ptr)
{
postionPtr = ptr;
}
public vec3d Position
{
get { return (*this.postionPtr); }
set { (*this.postionPtr) = value; }
}
public float X
{
get { return this._position.X; }
get { return (*this.postionPtr).X; }
set { (*this.postionPtr).X = value; }
}
public float Y
{
get { return this._position.Y; }
get { return (*this.postionPtr).Y; }
set { (*this.postionPtr).Y = value; }
}
public float Z
{
get { return (*this.postionPtr).Z; }
set { (*this.postionPtr).Z = value; }
}
internal readonly bool isVertex;
@@ -43,8 +61,10 @@ namespace StgSharp.Geometries
public bool IsOnPlain(IPlainGeometry geo)
{
return this._position * geo.GetPlain().plainParameter == 1;
return (*this.postionPtr) * geo.GetPlain().plainParameter == 1;
}
}
}
@@ -65,10 +65,10 @@ namespace StgSharp.Geometries
internal override void OnRender(uint tick)
{
uint nowTick = GameTimeLine.tickCounter._value;
this.vertex01._position = RefOrigin._position + movVertex01Operation(nowTick);
this.vertex02._position = RefOrigin._position + movVertex02Operation(nowTick);
this.vertex03._position = RefOrigin._position + movVertex03Operation(nowTick);
this.vertex04._position = RefOrigin._position + movVertex04Operation(nowTick);
this.vertex01.Position = RefOrigin.Position + movVertex01Operation(nowTick);
this.vertex02.Position = RefOrigin.Position + movVertex02Operation(nowTick);
this.vertex03.Position = RefOrigin.Position + movVertex03Operation(nowTick);
this.vertex04.Position = RefOrigin.Position + movVertex04Operation(nowTick);
}
}
}
@@ -65,11 +65,11 @@ namespace StgSharp.Geometries
internal override void OnRender(uint tick)
{
uint nowTick = tick - BornTime;
vertex1._position = RefOrigin._position + movPoint01(nowTick);
vertex2._position = RefOrigin._position + movPoint02(nowTick);
vertex3._position = RefOrigin._position + movPoint03(nowTick);
vertex4._position = RefOrigin._position + movPoint04(nowTick);
vertex5._position = RefOrigin._position + movPoint05(nowTick);
vertex1.Position = RefOrigin.Position + movPoint01(nowTick);
vertex2.Position = RefOrigin.Position + movPoint02(nowTick);
vertex3.Position = RefOrigin.Position + movPoint03(nowTick);
vertex4.Position = RefOrigin.Position + movPoint04(nowTick);
vertex5.Position = RefOrigin.Position + movPoint05(nowTick);
}
public override Line[] GetAllSides()
@@ -73,12 +73,12 @@ namespace StgSharp.Geometries
internal override void OnRender(uint tick)
{
uint nowTick = tick - BornTime;
vertex1._position = RefOrigin._position + movPoint01(nowTick);
vertex2._position = RefOrigin._position + movPoint02(nowTick);
vertex3._position = RefOrigin._position + movPoint03(nowTick);
vertex4._position = RefOrigin._position + movPoint04(nowTick);
vertex5._position = RefOrigin._position + movPoint05(nowTick);
vertex6._position = RefOrigin._position + movPoint06(nowTick);
vertex1.Position = RefOrigin.Position + movPoint01(nowTick);
vertex2.Position = RefOrigin.Position + movPoint02(nowTick);
vertex3.Position = RefOrigin.Position + movPoint03(nowTick);
vertex4.Position = RefOrigin.Position + movPoint04(nowTick);
vertex5.Position = RefOrigin.Position + movPoint05(nowTick);
vertex6.Position = RefOrigin.Position + movPoint06(nowTick);
}
public override Line[] GetAllSides()
@@ -27,12 +27,12 @@ namespace StgSharp.Geometries
public sealed override vec3d MovVertex03(uint tick)
{
return this.center._position * 2 - this.vertex01._position;
return this.center.Position * 2 - this.vertex01.Position;
}
public sealed override vec3d MovVertex04(uint tick)
{
return this.center._position * 2 - this.vertex02._position;
return this.center.Position * 2 - this.vertex02.Position;
}
internal override sealed void OnRender(uint tick)
@@ -7,8 +7,12 @@ using System.Text;
namespace StgSharp.Geometries
{
public class Triangle :IPlainGeometry
public unsafe class Triangle :IPlainGeometry
{
public triangleVertexArray vertexArray;
internal Point vertex1;
internal Point vertex2;
internal Point vertex3;
@@ -16,11 +20,8 @@ namespace StgSharp.Geometries
internal GetLocationHandler movVertex02Opearion = new GetLocationHandler(GeometryOperation.DefualtMotion);
internal GetLocationHandler movVertex03Opearion = new GetLocationHandler(GeometryOperation.DefualtMotion);
public override sealed Point RefPoint01=> vertex1;
public override sealed Point RefPoint01 => vertex1;
public override sealed Point RefPoint02 => vertex2;
public override sealed Point RefPoint03 => vertex3;
public GetLocationHandler MovVertex01Operation => this.movVertex01Opearion;
@@ -33,13 +34,20 @@ namespace StgSharp.Geometries
public virtual vec3d MovVertex03(uint tick) => movVertex03Opearion.Invoke(tick);
public Triangle()
{
this.vertexArray = GeometryIO.initTriangleVertex();
this.vertex1.Position = *vertexArray.vertex1Ptr;
this.vertex2.Position = *vertexArray.vertex2Ptr;
this.vertex3.Position = *vertexArray.vertex3Ptr;
}
internal override sealed void OnRender(uint tick)
{
tick -= this.bornTick;
vertex1._position = RefOrigin._position + MovVertex01(tick);
vertex2._position = RefOrigin._position + MovVertex02(tick);
vertex3._position = RefOrigin._position + MovVertex03(tick);
vertex1.Position = RefOrigin.Position + MovVertex01(tick);
vertex2.Position = RefOrigin.Position + MovVertex02(tick);
vertex3.Position = RefOrigin.Position + MovVertex03(tick);
}
public override Line[] GetAllSides()
+5 -3
View File
@@ -10,18 +10,20 @@ namespace StgSharp
public static class Graphic
{
private const string glPackageName = "StgSharpGraphics.dll";
private static GraphicIO glIO;
//private static GraphicIO glIO;
static Graphic()
{
glIO = InitPackage();
initWindow = glIO.initWindowPtr;
//glIO = InitPackage();
//initWindow = glIO.initWindowPtr;
}
public static InitWindow initWindow ;
/*
[DllImport(glPackageName, EntryPoint = "initPackage")]
internal static extern GraphicIO InitPackage();
/**/
[DllImport(glPackageName, EntryPoint = "initWindow")]
public static extern void Window(int width,int height);
+14
View File
@@ -0,0 +1,14 @@
using StgSharp.Geometries;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp
{
internal static unsafe class GeometryIO
{
[DllImport("StgSharpGraphics.dll", EntryPoint = "initTriangle")]
internal static unsafe extern triangleVertexArray initTriangleVertex();
}
}
+1 -1
View File
@@ -40,7 +40,7 @@ namespace StgSharp
}
public Pool( Geometries.Rectangle area)
{
vec3d vec = area.vertex01._position - area.vertex02._position;
vec3d vec = area.vertex01.Position - area.vertex02.Position;
if ((vec.X==0||vec.Y==0)&&vec.Z==0)
{
Line[] barders = area.GetAllSides();
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
599c74c5e84e14226e429f58dbf2e985f60f29fc
e1462487ad425beae2b2fdc45a1ba680192e338c