daily update on 20231016 by nitload youmu, vao,vbo,ebo struct added
This commit is contained in:
@@ -3,7 +3,7 @@ using System;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class Arc : IPlainGeometry
|
||||
public class Arc : PlainGeometry
|
||||
{
|
||||
internal Point center;
|
||||
internal Point beginPoint;
|
||||
@@ -18,11 +18,13 @@ namespace StgSharp.Geometries
|
||||
|
||||
public override Point RefPoint2 => endPoint;
|
||||
|
||||
public virtual Vec3d MoveCenter(uint tick) => movCenterOperation.Invoke(tick);
|
||||
internal override int[] Indices => throw new NotImplementedException();
|
||||
|
||||
public virtual Vec3d MovBegin(uint tick) => movBeginOperation.Invoke(tick);
|
||||
public virtual vec3d MoveCenter(uint tick) => movCenterOperation.Invoke(tick);
|
||||
|
||||
public virtual Vec3d MovEnd(uint tick) => movEndOperation.Invoke(tick);
|
||||
public virtual vec3d MovBegin(uint tick) => movBeginOperation.Invoke(tick);
|
||||
|
||||
public virtual vec3d MovEnd(uint tick) => movEndOperation.Invoke(tick);
|
||||
|
||||
internal override void OnRender(uint tick)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ using System;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class Circle : IPlainGeometry
|
||||
public class Circle : PlainGeometry
|
||||
{
|
||||
internal Point center;
|
||||
internal Point pointOnCircle;
|
||||
@@ -19,11 +19,13 @@ namespace StgSharp.Geometries
|
||||
|
||||
public override Point RefPoint2 => pointOnPlain;
|
||||
|
||||
public virtual Vec3d MoveCenter(uint tick) => movCenterOperation.Invoke(tick);
|
||||
internal override int[] Indices => throw new NotImplementedException();
|
||||
|
||||
public virtual Vec3d UpdateRadius(uint tick) => movBeginOperation.Invoke(tick);
|
||||
public virtual vec3d MoveCenter(uint tick) => movCenterOperation.Invoke(tick);
|
||||
|
||||
public virtual Vec3d UpdatePlain(uint tick) => movEndOperation.Invoke(tick);
|
||||
public virtual vec3d UpdateRadius(uint tick) => movBeginOperation.Invoke(tick);
|
||||
|
||||
public virtual vec3d UpdatePlain(uint tick) => movEndOperation.Invoke(tick);
|
||||
|
||||
public override Plain GetPlain()
|
||||
{
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
/// <summary>
|
||||
/// 计算位移失量,需要手动输入游戏刻以提供时间数据
|
||||
/// Caculate the movement of a point.
|
||||
/// </summary>
|
||||
/// <param name="tick"></param>
|
||||
/// <returns>表示位移量的三维矢量</returns>
|
||||
public delegate Vec3d GetLocationHandler(uint tick);
|
||||
/// <param name="tick">The game tick represent time passed by</param>
|
||||
/// <returns>A 3d vector representing movement</returns>
|
||||
public delegate vec3d GetLocationHandler(uint tick);
|
||||
|
||||
public static unsafe class GeometryOperation
|
||||
{
|
||||
public static Vec3d DefualtMotion(uint tick)
|
||||
public static vec3d DefualtMotion(uint tick)
|
||||
{
|
||||
return default(Vec3d);
|
||||
return default(vec3d);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Numerics;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class Line : IPlainGeometry
|
||||
public class Line : PlainGeometry
|
||||
{
|
||||
internal Point basePoint;
|
||||
internal Point beginPoint;
|
||||
@@ -16,6 +16,11 @@ namespace StgSharp.Geometries
|
||||
public override Point RefPoint1 => endPoint;
|
||||
public override Point RefPoint2 => default;
|
||||
|
||||
internal override int[] Indices
|
||||
{
|
||||
get { throw new Exception(); }
|
||||
}
|
||||
|
||||
public Line(Point begin, Point end)
|
||||
{
|
||||
this.beginPoint = begin;
|
||||
@@ -31,11 +36,11 @@ namespace StgSharp.Geometries
|
||||
public Line() { }
|
||||
|
||||
//计算线起点的方法,通过对线的派生的重写实现功能
|
||||
public virtual Vec3d MoveBeginPoint(uint tick)
|
||||
public virtual vec3d MoveBeginPoint(uint tick)
|
||||
=> movBegin.Invoke(tick);
|
||||
|
||||
//计算线重点的方法,通过对线的派生的重写实现功能
|
||||
public virtual Vec3d MoveEndPoint(uint tick)
|
||||
public virtual vec3d MoveEndPoint(uint tick)
|
||||
=> movEnd.Invoke(tick);
|
||||
|
||||
internal override void OnRender(uint tick)
|
||||
|
||||
@@ -3,7 +3,7 @@ using StgSharp.Math;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
internal class Parallelogram : Polygon4
|
||||
public class Parallelogram : Polygon4
|
||||
{
|
||||
internal Point center;
|
||||
|
||||
@@ -11,13 +11,35 @@ namespace StgSharp.Geometries
|
||||
public sealed override Point RefPoint1 => new Point(vertexMat.mat.colum0);
|
||||
public sealed override Point RefPoint2 => new Point(vertexMat.mat.colum1);
|
||||
|
||||
internal readonly GetLocationHandler movCenterOperation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal readonly GetLocationHandler movCenterOperation =
|
||||
new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
|
||||
public GetLocationHandler MovCenterOperation { get { return movCenterOperation; } }
|
||||
public GetLocationHandler MovVertex01Operation { get { return moveVertex0Operation; } }
|
||||
public GetLocationHandler MovVertex02Operation { get { return moveVertex1Operation; } }
|
||||
|
||||
public virtual Vec3d MovCenter(uint tick)
|
||||
public Parallelogram(
|
||||
float v0x, float v0y, float v0z,
|
||||
float v1x, float v1y, float v1z,
|
||||
float v2x, float v2y, float v2z,
|
||||
float v3x, float v3y, float v3z
|
||||
) : base(
|
||||
v0x, v0y, v0z,
|
||||
v1x, v1y, v1z,
|
||||
v2x, v2y, v2z,
|
||||
v3x, v2y, v3z
|
||||
)
|
||||
{
|
||||
if (
|
||||
vertexMat.Colum0 + vertexMat.Colum2 !=
|
||||
vertexMat.Colum1 + vertexMat.Colum3
|
||||
)
|
||||
{
|
||||
internalIO.InternalWriteLog("Init of geometry item failed, because four vertices cannot form a rectangle.", LogType.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual vec3d MovCenter(uint tick)
|
||||
{
|
||||
return movCenterOperation.Invoke(tick);
|
||||
}
|
||||
@@ -28,7 +50,7 @@ namespace StgSharp.Geometries
|
||||
/// <param name="tick">Current time tick</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="UnusedVertexException">Geometry overdefined</exception>
|
||||
public sealed override Vec3d MoveVertex2(uint tick)
|
||||
public sealed override vec3d MoveVertex2(uint tick)
|
||||
{
|
||||
throw new UnusedVertexException();
|
||||
}
|
||||
@@ -39,7 +61,7 @@ namespace StgSharp.Geometries
|
||||
/// <param name="tick">Current time tick</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="UnusedVertexException">Geometry overdefined</exception>
|
||||
public sealed override Vec3d MoveVertex3(uint tick)
|
||||
public sealed override vec3d MoveVertex3(uint tick)
|
||||
{
|
||||
throw new UnusedVertexException();
|
||||
}
|
||||
|
||||
@@ -5,22 +5,22 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
public unsafe class Plain
|
||||
{
|
||||
internal Vec3d origin;
|
||||
internal Vec3d vec1;
|
||||
internal Vec3d vec2;
|
||||
internal vec3d origin;
|
||||
internal vec3d vec1;
|
||||
internal vec3d vec2;
|
||||
|
||||
internal Vec3d plainParameter;
|
||||
internal vec3d plainParameter;
|
||||
internal readonly float d = -1;
|
||||
|
||||
internal Plain(Vector4 origin, Vector4 p1, Vector4 p2)
|
||||
{
|
||||
this.origin = new Vec3d(origin);
|
||||
this.origin = new vec3d(origin);
|
||||
|
||||
vec1 = new Vec3d(p1 - origin);
|
||||
vec2 = new Vec3d(p2 - origin);
|
||||
vec1 = new vec3d(p1 - origin);
|
||||
vec2 = new vec3d(p2 - origin);
|
||||
}
|
||||
|
||||
public Plain(Vec3d o, Vec3d v1, Vec3d v2)
|
||||
public Plain(vec3d o, vec3d v1, vec3d v2)
|
||||
{
|
||||
this.origin = o;
|
||||
this.vec1 = v1 - v2 * (v1.Y / v2.Y); //计算平面在xz平面上的方向投影
|
||||
@@ -39,9 +39,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平面上的方向投影
|
||||
|
||||
+10
-5
@@ -1,10 +1,12 @@
|
||||
namespace StgSharp.Geometries
|
||||
using StgSharp.Math;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 平面几何体。包含三角形,对称四边形,自由多边形等。最多可由16个点参数定义。
|
||||
/// </summary>
|
||||
public abstract class IPlainGeometry
|
||||
public abstract class PlainGeometry
|
||||
{
|
||||
protected readonly uint bornTick;
|
||||
internal readonly Point refOrigin;
|
||||
@@ -14,19 +16,22 @@
|
||||
public abstract Point RefPoint0 { get; }
|
||||
public abstract Point RefPoint1 { get; }
|
||||
public abstract Point RefPoint2 { get; }
|
||||
|
||||
public uint BornTime => bornTick;
|
||||
|
||||
public IPlainGeometry(uint bornTime)
|
||||
internal abstract int[] Indices { get; }
|
||||
|
||||
public PlainGeometry(uint bornTime)
|
||||
{
|
||||
bornTick = bornTime;
|
||||
}
|
||||
|
||||
public IPlainGeometry(Counter<uint> MainTimer)
|
||||
public PlainGeometry(Counter<uint> MainTimer)
|
||||
{
|
||||
bornTick = MainTimer.Value;
|
||||
}
|
||||
|
||||
public IPlainGeometry() { }
|
||||
public PlainGeometry() { }
|
||||
|
||||
|
||||
internal abstract void OnRender(uint tick);
|
||||
@@ -8,27 +8,27 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
public unsafe class Point
|
||||
{
|
||||
internal Vec3d position;
|
||||
internal vec3d position;
|
||||
internal readonly bool isVertex;
|
||||
|
||||
public Point() { }
|
||||
|
||||
internal Point(Vec3d p)
|
||||
internal Point(vec3d p)
|
||||
{
|
||||
position = p;
|
||||
}
|
||||
|
||||
internal Point(Vector4 vector)
|
||||
{
|
||||
position = new Vec3d(vector);
|
||||
position = new vec3d(vector);
|
||||
}
|
||||
|
||||
public Point(float x, float y, float z)
|
||||
{
|
||||
position = new Vec3d(x, y, z);
|
||||
position = new vec3d(x, y, z);
|
||||
}
|
||||
|
||||
public Vec3d Position
|
||||
public vec3d Position
|
||||
{
|
||||
get { return position; }
|
||||
set { position = value; }
|
||||
@@ -64,12 +64,12 @@ namespace StgSharp.Geometries
|
||||
/// <param name="tick">Time passes since the program begin, counted by frames</param>
|
||||
public virtual void Update(uint tick) { }
|
||||
|
||||
public bool IsInGeometry(IPlainGeometry geo)
|
||||
public bool IsInGeometry(PlainGeometry geo)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool IsOnPlain(IPlainGeometry geo)
|
||||
public bool IsOnPlain(PlainGeometry geo)
|
||||
{
|
||||
return position * geo.GetPlain().plainParameter == 1;
|
||||
}
|
||||
|
||||
@@ -1,54 +1,102 @@
|
||||
using StgSharp.Controlling;
|
||||
using StgSharp.Math;
|
||||
using System.Numerics;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class Polygon4 : IPlainGeometry
|
||||
public class Polygon4 : PlainGeometry
|
||||
{
|
||||
internal Matrix3x4 vertexMat;
|
||||
|
||||
internal Point vertex0 { get; set; }
|
||||
internal Point vertex1 { get; set; }
|
||||
internal Point vertex2 { get; set; }
|
||||
internal Point vertex3 { get; set; }
|
||||
|
||||
internal readonly GetLocationHandler moveVertex0Operation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal readonly GetLocationHandler moveVertex1Operation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal readonly GetLocationHandler moveVertex2Operation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal readonly GetLocationHandler moveVertex3Operation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
|
||||
internal Matrix3x4 vertexMat;
|
||||
|
||||
internal Polygon4()
|
||||
{
|
||||
}
|
||||
|
||||
public Polygon4(
|
||||
float v0x, float v0y, float v0z,
|
||||
float v1x, float v1y, float v1z,
|
||||
float v2x, float v2y, float v2z,
|
||||
float v3x, float v3y, float v3z
|
||||
)
|
||||
{
|
||||
vertexMat.mat.colum0 = new Vector4(v0x, v0y, v0z, 0);
|
||||
vertexMat.mat.colum1 = new Vector4(v1x, v1y, v1z, 0);
|
||||
vertexMat.mat.colum2 = new Vector4(v2x, v2y, v2z, 0);
|
||||
vertexMat.mat.colum3 = new Vector4(v3x, v3y, v3z, 0);
|
||||
}
|
||||
|
||||
public GetLocationHandler MovVertex0Operaion { get { return moveVertex0Operation; } }
|
||||
public GetLocationHandler MovVertex1Operaion { get { return moveVertex1Operation; } }
|
||||
public GetLocationHandler MovVertex2Operaion { get { return moveVertex2Operation; } }
|
||||
public GetLocationHandler MovVertex3Operaion { get { return moveVertex3Operation; } }
|
||||
|
||||
public override Point RefPoint0
|
||||
{
|
||||
get { return new Point(vertexMat.transpose.colum0); }
|
||||
get { return new Point(vertexMat.mat.colum0); }
|
||||
}
|
||||
|
||||
public override Point RefPoint1
|
||||
{
|
||||
get { return new Point(vertexMat.transpose.colum1); }
|
||||
get { return new Point(vertexMat.mat.colum1); }
|
||||
}
|
||||
|
||||
public override Point RefPoint2
|
||||
{
|
||||
get { return new Point(vertexMat.transpose.colum2); }
|
||||
get { return new Point(vertexMat.mat.colum2); }
|
||||
}
|
||||
|
||||
public GetLocationHandler MovVertex01Operaion { get { return moveVertex0Operation; } }
|
||||
public GetLocationHandler MovVertex02Operaion { get { return moveVertex1Operation; } }
|
||||
public GetLocationHandler MovVertex03Operaion { get { return moveVertex2Operation; } }
|
||||
public GetLocationHandler MovVertex04Operaion { get { return moveVertex3Operation; } }
|
||||
|
||||
public unsafe Polygon4()
|
||||
internal sealed override int[] Indices
|
||||
{
|
||||
get
|
||||
{
|
||||
return new int[6] {
|
||||
0,1,2,
|
||||
0,2,3};
|
||||
}
|
||||
}
|
||||
|
||||
public Mat4 VertexBuffer
|
||||
{
|
||||
get { return vertexMat.mat; }
|
||||
}
|
||||
|
||||
public Point Vertex0
|
||||
{
|
||||
get => new Point(vertexMat.mat.colum0);
|
||||
set { vertexMat.mat.colum0 = value.position.vec; }
|
||||
}
|
||||
|
||||
public Point Vertex1
|
||||
{
|
||||
get => new Point(vertexMat.mat.colum1);
|
||||
set { vertexMat.mat.colum1 = value.position.vec; }
|
||||
}
|
||||
|
||||
public Point Vertex2
|
||||
{
|
||||
get => new Point(vertexMat.mat.colum2);
|
||||
set { vertexMat.mat.colum1 = value.position.vec; }
|
||||
}
|
||||
|
||||
internal Point Vertex3
|
||||
{
|
||||
get => new Point(vertexMat.mat.colum3);
|
||||
set { vertexMat.mat.colum1 = value.position.vec; }
|
||||
}
|
||||
|
||||
public override Line[] GetAllSides()
|
||||
{
|
||||
Line[] sides = new Line[4]
|
||||
{
|
||||
new Line(vertex0,vertex1),
|
||||
new Line(vertex1, vertex2),
|
||||
new Line(vertex2, vertex3),
|
||||
new Line(vertex3, vertex0)
|
||||
new Line(Vertex0, Vertex1),
|
||||
new Line(Vertex1, Vertex2),
|
||||
new Line(Vertex2, Vertex3),
|
||||
new Line(Vertex3, Vertex0)
|
||||
};
|
||||
|
||||
return sides;
|
||||
@@ -63,14 +111,17 @@ namespace StgSharp.Geometries
|
||||
vertexMat.mat.colum2);
|
||||
}
|
||||
|
||||
public virtual vec3d MoveVertex0(uint tick)
|
||||
=> moveVertex0Operation.Invoke(tick);
|
||||
|
||||
public virtual Vec3d MoveVertex0(uint tick) => moveVertex0Operation.Invoke(tick);
|
||||
public virtual vec3d MoveVertex1(uint tick)
|
||||
=> moveVertex1Operation.Invoke(tick);
|
||||
|
||||
public virtual Vec3d MoveVertex1(uint tick) => moveVertex1Operation.Invoke(tick);
|
||||
public virtual vec3d MoveVertex2(uint tick)
|
||||
=> moveVertex2Operation.Invoke(tick);
|
||||
|
||||
public virtual Vec3d MoveVertex2(uint tick) => moveVertex2Operation.Invoke(tick);
|
||||
|
||||
public virtual Vec3d MoveVertex3(uint tick) => moveVertex3Operation.Invoke(tick);
|
||||
public virtual vec3d MoveVertex3(uint tick)
|
||||
=> moveVertex3Operation.Invoke(tick);
|
||||
|
||||
|
||||
internal override void OnRender(uint tick)
|
||||
|
||||
@@ -1,30 +1,39 @@
|
||||
using StgSharp.Controlling;
|
||||
using StgSharp.Math;
|
||||
using StgSharp.Math.Linear;
|
||||
using System.Numerics;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public unsafe class Polygon5 : IPlainGeometry
|
||||
public unsafe class Polygon5 : PlainGeometry
|
||||
{
|
||||
|
||||
internal Point _refOrigin;
|
||||
internal readonly Point vertex1;
|
||||
internal readonly Point vertex2;
|
||||
internal readonly Point vertex3;
|
||||
internal readonly Point vertex4;
|
||||
internal readonly Point vertex5;
|
||||
internal readonly int _vertexCount;
|
||||
|
||||
public override Point RefPoint0 => vertex1;
|
||||
|
||||
public override Point RefPoint1 => vertex2;
|
||||
|
||||
public override Point RefPoint2 => vertex3;
|
||||
|
||||
internal GetLocationHandler movP01Operation = default;
|
||||
internal GetLocationHandler movP02Operation = default;
|
||||
internal GetLocationHandler movP03Operation = default;
|
||||
internal GetLocationHandler movP04Operation = default;
|
||||
internal GetLocationHandler movP05Operation = default;
|
||||
internal mat5 vertexMat;
|
||||
|
||||
public unsafe Polygon5()
|
||||
{
|
||||
}
|
||||
|
||||
public Polygon5(
|
||||
float v0x, float v0y, float v0z,
|
||||
float v1x, float v1y, float v1z,
|
||||
float v2x, float v2y, float v2z,
|
||||
float v3x, float v3y, float v3z,
|
||||
float v4x, float v4y, float v4z
|
||||
)
|
||||
{
|
||||
vertexMat.vec0 = new Vector4(v0x, v0y, v0z, 0);
|
||||
vertexMat.vec1 = new Vector4(v1x, v1y, v1z, 0);
|
||||
vertexMat.vec2 = new Vector4(v2x, v2y, v2z, 0);
|
||||
vertexMat.vec3 = new Vector4(v3x, v3y, v3z, 0);
|
||||
vertexMat.vec4 = new Vector4(v4x, v4y, v4z, 0);
|
||||
}
|
||||
|
||||
|
||||
public GetLocationHandler MovP01Operation { get => movP01Operation; }
|
||||
public GetLocationHandler MovP02Operation { get => movP02Operation; }
|
||||
@@ -32,46 +41,91 @@ namespace StgSharp.Geometries
|
||||
public GetLocationHandler MovP04Operation { get => movP04Operation; }
|
||||
public GetLocationHandler MovP05Operation { get => movP05Operation; }
|
||||
|
||||
public unsafe Polygon5()
|
||||
public override Point RefPoint0 => Vertex0;
|
||||
public override Point RefPoint1 => Vertex1;
|
||||
public override Point RefPoint2 => Vertex2;
|
||||
|
||||
public mat5 VertexBuffer
|
||||
{
|
||||
get { return vertexMat; }
|
||||
}
|
||||
|
||||
public virtual Vec3d movPoint01(uint tick) => movP01Operation.Invoke(TimeLine.tickCounter._value);
|
||||
|
||||
public virtual Vec3d movPoint02(uint tick) => movP02Operation.Invoke(TimeLine.tickCounter._value);
|
||||
|
||||
public virtual Vec3d movPoint03(uint tick) => movP03Operation.Invoke(TimeLine.tickCounter._value);
|
||||
|
||||
public virtual Vec3d movPoint04(uint tick) => movP04Operation.Invoke(TimeLine.tickCounter._value);
|
||||
|
||||
public virtual Vec3d movPoint05(uint tick) => movP05Operation.Invoke(TimeLine.tickCounter._value);
|
||||
|
||||
|
||||
internal override void OnRender(uint tick)
|
||||
public Point Vertex0
|
||||
{
|
||||
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);
|
||||
get => new Point(vertexMat.vec0);
|
||||
set { vertexMat.vec0 = value.position.vec; }
|
||||
}
|
||||
|
||||
public Point Vertex1
|
||||
{
|
||||
get => new Point(vertexMat.vec1);
|
||||
set { vertexMat.vec1 = value.position.vec; }
|
||||
}
|
||||
|
||||
public Point Vertex2
|
||||
{
|
||||
get => new Point(vertexMat.vec2);
|
||||
set { vertexMat.vec2 = value.position.vec; }
|
||||
}
|
||||
|
||||
public Point Vertex3
|
||||
{
|
||||
get => new Point(vertexMat.vec3);
|
||||
set { vertexMat.vec3 = value.position.vec; }
|
||||
}
|
||||
|
||||
public Point Vertex4
|
||||
{
|
||||
get => new Point(vertexMat.vec4);
|
||||
set { vertexMat.vec4 = value.position.vec; }
|
||||
}
|
||||
|
||||
internal override int[] Indices
|
||||
{
|
||||
get
|
||||
{
|
||||
return new int[9]{
|
||||
0,1,2,
|
||||
0,2,3,
|
||||
0,3,4};
|
||||
}
|
||||
}
|
||||
public override Line[] GetAllSides()
|
||||
{
|
||||
return new Line[5]
|
||||
{
|
||||
new Line(vertex1,vertex2),
|
||||
new Line(vertex2,vertex3),
|
||||
new Line(vertex3,vertex4),
|
||||
new Line(vertex4,vertex5),
|
||||
new Line(vertex5,vertex1)
|
||||
new Line(Vertex0,Vertex1),
|
||||
new Line(Vertex1,Vertex2),
|
||||
new Line(Vertex2,Vertex3),
|
||||
new Line(Vertex3,Vertex4),
|
||||
new Line(Vertex4,Vertex0)
|
||||
};
|
||||
}
|
||||
|
||||
public override Plain GetPlain()
|
||||
{
|
||||
return new Plain(vertex1, vertex2, vertex3);
|
||||
return new Plain(Vertex0, Vertex1, Vertex2);
|
||||
}
|
||||
|
||||
public virtual vec3d movVertex01(uint tick) => movP01Operation.Invoke(TimeLine.tickCounter._value);
|
||||
|
||||
public virtual vec3d movVertex02(uint tick) => movP02Operation.Invoke(TimeLine.tickCounter._value);
|
||||
|
||||
public virtual vec3d movVertex03(uint tick) => movP03Operation.Invoke(TimeLine.tickCounter._value);
|
||||
|
||||
public virtual vec3d movVertex04(uint tick) => movP04Operation.Invoke(TimeLine.tickCounter._value);
|
||||
|
||||
public virtual vec3d movVertex05(uint tick) => movP05Operation.Invoke(TimeLine.tickCounter._value);
|
||||
|
||||
|
||||
internal override void OnRender(uint tick)
|
||||
{
|
||||
uint nowTick = tick - BornTime;
|
||||
vertexMat.vec0 = (RefOrigin.Position + movVertex01(nowTick)).vec;
|
||||
vertexMat.vec1 = (RefOrigin.Position + movVertex02(nowTick)).vec;
|
||||
vertexMat.vec2 = (RefOrigin.Position + movVertex03(nowTick)).vec;
|
||||
vertexMat.vec3 = (RefOrigin.Position + movVertex04(nowTick)).vec;
|
||||
vertexMat.vec4 = (RefOrigin.Position + movVertex05(nowTick)).vec;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,97 +1,139 @@
|
||||
using StgSharp.Controlling;
|
||||
using StgSharp.Math;
|
||||
using StgSharp.Math.Linear;
|
||||
using System.Numerics;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class Polygon6 : IPlainGeometry
|
||||
public class Polygon6 : PlainGeometry
|
||||
{
|
||||
internal Point _refOrigin;
|
||||
internal Point vertex1;
|
||||
internal Point vertex2;
|
||||
internal Point vertex3;
|
||||
internal Point vertex4;
|
||||
internal Point vertex5;
|
||||
internal Point vertex6;
|
||||
internal readonly int _vertexCount;
|
||||
|
||||
public override Point RefPoint0 => vertex1;
|
||||
|
||||
public override Point RefPoint1 => vertex2;
|
||||
|
||||
public override Point RefPoint2 => vertex3;
|
||||
internal GetLocationHandler movVertex0Operation = default;
|
||||
internal GetLocationHandler movVertex1Operation = default;
|
||||
internal GetLocationHandler movVertex2Operation = default;
|
||||
internal GetLocationHandler movVertex3Operation = default;
|
||||
internal GetLocationHandler movVertex4Operation = default;
|
||||
internal GetLocationHandler movVertex5Operation = default;
|
||||
internal mat6 vertexMat;
|
||||
|
||||
|
||||
internal GetLocationHandler movP01Operation = default;
|
||||
internal GetLocationHandler movP02Operation = default;
|
||||
internal GetLocationHandler movP03Operation = default;
|
||||
internal GetLocationHandler movP04Operation = default;
|
||||
internal GetLocationHandler movP05Operation = default;
|
||||
internal GetLocationHandler movP06Operation = default;
|
||||
public GetLocationHandler MovVertex0Operation { get => movVertex0Operation; }
|
||||
public GetLocationHandler MovVertex1Operation { get => movVertex1Operation; }
|
||||
public GetLocationHandler MovVertex2Operation { get => movVertex2Operation; }
|
||||
public GetLocationHandler MovVertex3Operation { get => movVertex3Operation; }
|
||||
public GetLocationHandler MovVertex4Operation { get => movVertex4Operation; }
|
||||
public GetLocationHandler MovVertex5Operation { get => movVertex5Operation; }
|
||||
|
||||
public GetLocationHandler MovP01Operation { get => movP01Operation; }
|
||||
public GetLocationHandler MovP02Operation { get => movP02Operation; }
|
||||
public GetLocationHandler MovP03Operation { get => movP03Operation; }
|
||||
public GetLocationHandler MovP04Operation { get => movP04Operation; }
|
||||
public GetLocationHandler MovP05Operation { get => movP05Operation; }
|
||||
public GetLocationHandler MovP06Operation { get => movP06Operation; }
|
||||
public override Point RefPoint0 => Vertex0;
|
||||
public override Point RefPoint1 => Vertex1;
|
||||
public override Point RefPoint2 => Vertex2;
|
||||
|
||||
public virtual Vec3d movPoint01(uint tick)
|
||||
internal override int[] Indices
|
||||
{
|
||||
return movP01Operation.Invoke(TimeLine.tickCounter._value);
|
||||
get
|
||||
{
|
||||
return new int[12] {
|
||||
0,1,2,
|
||||
0,2,3,
|
||||
0,3,4,
|
||||
0,4,5};
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Vec3d movPoint02(uint tick)
|
||||
public Point Vertex0
|
||||
{
|
||||
return movP02Operation.Invoke(TimeLine.tickCounter._value);
|
||||
get => new Point(vertexMat.vec0);
|
||||
set { vertexMat.vec0 = value.position.vec; }
|
||||
}
|
||||
|
||||
public virtual Vec3d movPoint03(uint tick)
|
||||
public Point Vertex1
|
||||
{
|
||||
return movP03Operation.Invoke(TimeLine.tickCounter._value);
|
||||
get => new Point(vertexMat.vec1);
|
||||
set { vertexMat.vec1 = value.position.vec; }
|
||||
}
|
||||
|
||||
public virtual Vec3d movPoint04(uint tick)
|
||||
public Point Vertex2
|
||||
{
|
||||
return movP04Operation.Invoke(TimeLine.tickCounter._value);
|
||||
get => new Point(vertexMat.vec2);
|
||||
set { vertexMat.vec2 = value.position.vec; }
|
||||
}
|
||||
|
||||
public virtual Vec3d movPoint05(uint tick)
|
||||
public Point Vertex3
|
||||
{
|
||||
return movP05Operation.Invoke(TimeLine.tickCounter._value);
|
||||
get => new Point(vertexMat.vec3);
|
||||
set { vertexMat.vec3 = value.position.vec; }
|
||||
}
|
||||
|
||||
public virtual Vec3d movPoint06(uint tick)
|
||||
public Point Vertex4
|
||||
{
|
||||
return movP06Operation.Invoke(TimeLine.tickCounter._value);
|
||||
get => new Point(vertexMat.vec4);
|
||||
set { vertexMat.vec4 = value.position.vec; }
|
||||
}
|
||||
|
||||
internal override void OnRender(uint tick)
|
||||
public Point Vertex5
|
||||
{
|
||||
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);
|
||||
get => new Point(vertexMat.vec5);
|
||||
set { vertexMat.vec5 = value.position.vec; }
|
||||
}
|
||||
|
||||
public override Line[] GetAllSides()
|
||||
{
|
||||
return new Line[6]
|
||||
{
|
||||
new Line(vertex1,vertex2),
|
||||
new Line(vertex2,vertex3),
|
||||
new Line(vertex3,vertex4),
|
||||
new Line(vertex4,vertex5),
|
||||
new Line(vertex5,vertex6),
|
||||
new Line(vertex6,vertex1)
|
||||
new Line(Vertex0,Vertex1),
|
||||
new Line(Vertex1,Vertex2),
|
||||
new Line(Vertex2,Vertex3),
|
||||
new Line(Vertex3,Vertex4),
|
||||
new Line(Vertex4,Vertex5),
|
||||
new Line(Vertex5,Vertex0)
|
||||
};
|
||||
}
|
||||
|
||||
public override Plain GetPlain()
|
||||
{
|
||||
return new Plain(vertex1, vertex2, vertex3);
|
||||
return new Plain(Vertex0, Vertex1, Vertex2);
|
||||
}
|
||||
|
||||
public virtual vec3d movVertex0(uint tick)
|
||||
{
|
||||
return movVertex0Operation.Invoke(TimeLine.tickCounter._value);
|
||||
}
|
||||
|
||||
public virtual vec3d movVertex1(uint tick)
|
||||
{
|
||||
return movVertex1Operation.Invoke(TimeLine.tickCounter._value);
|
||||
}
|
||||
|
||||
public virtual vec3d movVertex2(uint tick)
|
||||
{
|
||||
return movVertex2Operation.Invoke(TimeLine.tickCounter._value);
|
||||
}
|
||||
|
||||
public virtual vec3d movVertex3(uint tick)
|
||||
{
|
||||
return movVertex3Operation.Invoke(TimeLine.tickCounter._value);
|
||||
}
|
||||
|
||||
public virtual vec3d movVertex4(uint tick)
|
||||
{
|
||||
return movVertex4Operation.Invoke(TimeLine.tickCounter._value);
|
||||
}
|
||||
|
||||
public virtual vec3d movVertex5(uint tick)
|
||||
{
|
||||
return movVertex5Operation.Invoke(TimeLine.tickCounter._value);
|
||||
}
|
||||
|
||||
internal override void OnRender(uint tick)
|
||||
{
|
||||
uint nowTick = tick - BornTime;
|
||||
Vector4 origin = RefOrigin.Position.vec;
|
||||
vertexMat.vec0 = origin + movVertex0(nowTick).vec;
|
||||
vertexMat.vec1 = origin + movVertex1(nowTick).vec;
|
||||
vertexMat.vec2 = origin + movVertex2(nowTick).vec;
|
||||
vertexMat.vec3 = origin + movVertex3(nowTick).vec;
|
||||
vertexMat.vec4 = origin + movVertex4(nowTick).vec;
|
||||
vertexMat.vec5 = origin + movVertex5(nowTick).vec;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,27 +3,28 @@ using System.Numerics;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class Rectangle : Polygon4
|
||||
public class Rectangle : Parallelogram
|
||||
{
|
||||
internal Point center;
|
||||
|
||||
public sealed override Point RefPoint0 => center;
|
||||
|
||||
public sealed override Point RefPoint1 => new Point(vertexMat.transpose.colum0);
|
||||
|
||||
public sealed override Point RefPoint2 => new Point(vertexMat.transpose.colum1);
|
||||
|
||||
public Rectangle(
|
||||
float v0x, float v0y, float v0z,
|
||||
float v1x, float v1y, float v1z,
|
||||
float v2x, float v2y, float v2z,
|
||||
float v3x, float v3y, float v3z
|
||||
)
|
||||
) : base(
|
||||
v0x, v0y, v0z,
|
||||
v1x, v1y, v1z,
|
||||
v2x, v2y, v2z,
|
||||
v3x, v2y, v3z
|
||||
)
|
||||
{
|
||||
vertexMat.mat.colum0 = new Vector4(v0x, v0y, v0z, 0);
|
||||
vertexMat.mat.colum1 = new Vector4(v1x, v1y, v1z, 0);
|
||||
vertexMat.mat.colum2 = new Vector4(v2x, v2y, v2z, 0);
|
||||
vertexMat.mat.colum3 = new Vector4(v3x, v3y, v3z, 0);
|
||||
vec3d side0 = vertexMat.Colum0 - vertexMat.Colum1;
|
||||
vec3d side1 = vertexMat.Colum2 - vertexMat.Colum1;
|
||||
if (side0.Cross(side1) == Vec3d.Zero)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,25 +34,9 @@ namespace StgSharp.Geometries
|
||||
/// </summary>
|
||||
/// <param name="tick">当前游戏刻</param>
|
||||
/// <returns></returns>
|
||||
public virtual Vec3d MovCenter(uint tick) => default(Vec3d);
|
||||
public virtual vec3d MovCenter(uint tick) => default(vec3d);
|
||||
|
||||
public sealed override Vec3d MoveVertex2(uint tick)
|
||||
{
|
||||
return
|
||||
new Vec3d(this.center.position.vec * 2 - vertexMat.mat.colum0);
|
||||
}
|
||||
|
||||
public sealed override Vec3d MoveVertex3(uint tick)
|
||||
{
|
||||
return
|
||||
new Vec3d(this.center.position.vec * 2 - vertexMat.mat.colum1);
|
||||
}
|
||||
|
||||
internal sealed override void OnRender(uint tick)
|
||||
{
|
||||
tick -= bornTick;
|
||||
this.MovCenter(tick);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
}
|
||||
|
||||
public sealed override Vec3d MoveVertex1(uint tick)
|
||||
public sealed override vec3d MoveVertex1(uint tick)
|
||||
{
|
||||
return this.center.Position * 2 - this.vertexMat.Colum0;
|
||||
}
|
||||
|
||||
@@ -6,43 +6,29 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
|
||||
|
||||
public unsafe class Triangle : IPlainGeometry
|
||||
public unsafe class Triangle : PlainGeometry
|
||||
{
|
||||
|
||||
internal Matrix3x3 vertexMap;
|
||||
|
||||
internal GetLocationHandler movVertex01Opearion = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal GetLocationHandler movVertex02Opearion = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal GetLocationHandler movVertex03Opearion = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
|
||||
public sealed override Point RefPoint0 => new Point(vertexMap.mat.colum0);
|
||||
public sealed override Point RefPoint1 => new Point(vertexMap.mat.colum1);
|
||||
public sealed override Point RefPoint2 => new Point(vertexMap.mat.colum2);
|
||||
|
||||
public GetLocationHandler MovVertex01Operation => this.movVertex01Opearion;
|
||||
public GetLocationHandler MovVertex02Operation => this.movVertex02Opearion;
|
||||
public GetLocationHandler MovVertex03Operation => this.movVertex03Opearion;
|
||||
|
||||
public virtual Vec3d MovVertex01(uint tick) => movVertex01Opearion.Invoke(tick);
|
||||
|
||||
public virtual Vec3d MovVertex02(uint tick) => movVertex02Opearion.Invoke(tick);
|
||||
|
||||
public virtual Vec3d MovVertex03(uint tick) => movVertex03Opearion.Invoke(tick);
|
||||
internal Matrix3x3 vertexMat;
|
||||
|
||||
public Triangle()
|
||||
{
|
||||
vertexMap = new Matrix3x3();
|
||||
vertexMat = new Matrix3x3();
|
||||
}
|
||||
|
||||
public Triangle(
|
||||
Vec3d vertex01,
|
||||
Vec3d vertex02,
|
||||
Vec3d vertex03
|
||||
vec3d vertex01,
|
||||
vec3d vertex02,
|
||||
vec3d vertex03
|
||||
)
|
||||
{
|
||||
vertexMap.mat.colum0 = vertex01.vec;
|
||||
vertexMap.mat.colum1 = vertex02.vec;
|
||||
vertexMap.mat.colum2 = vertex03.vec;
|
||||
vertexMat.mat.colum0 = vertex01.vec;
|
||||
vertexMat.mat.colum1 = vertex02.vec;
|
||||
vertexMat.mat.colum2 = vertex03.vec;
|
||||
}
|
||||
|
||||
public Triangle(
|
||||
@@ -51,26 +37,35 @@ namespace StgSharp.Geometries
|
||||
float v2x, float v2y, float v2z
|
||||
)
|
||||
{
|
||||
vertexMap.mat.colum0 = new Vector4(v0x, v0y, v0z, 0);
|
||||
vertexMap.mat.colum1 = new Vector4(v1x, v1y, v1z, 0);
|
||||
vertexMap.mat.colum2 = new Vector4(v2x, v2y, v2z, 0);
|
||||
vertexMat.mat.colum0 = new Vector4(v0x, v0y, v0z, 0);
|
||||
vertexMat.mat.colum1 = new Vector4(v1x, v1y, v1z, 0);
|
||||
vertexMat.mat.colum2 = new Vector4(v2x, v2y, v2z, 0);
|
||||
}
|
||||
|
||||
internal sealed override void OnRender(uint tick)
|
||||
public GetLocationHandler MovVertex01Operation => this.movVertex01Opearion;
|
||||
public GetLocationHandler MovVertex02Operation => this.movVertex02Opearion;
|
||||
public GetLocationHandler MovVertex03Operation => this.movVertex03Opearion;
|
||||
public sealed override Point RefPoint0 => new Point(vertexMat.mat.colum0);
|
||||
public sealed override Point RefPoint1 => new Point(vertexMat.mat.colum1);
|
||||
public sealed override Point RefPoint2 => new Point(vertexMat.mat.colum2);
|
||||
|
||||
public Mat3 VertexBuffer
|
||||
{
|
||||
tick -= this.bornTick;
|
||||
vertexMap.mat.colum0 = RefOrigin.Position.vec + MovVertex01(tick).vec;
|
||||
vertexMap.mat.colum1 = RefOrigin.Position.vec + MovVertex02(tick).vec;
|
||||
vertexMap.mat.colum2 = RefOrigin.Position.vec + MovVertex03(tick).vec;
|
||||
get { return vertexMat.mat; }
|
||||
}
|
||||
|
||||
internal sealed override int[] Indices
|
||||
{
|
||||
get { return new int[3] { 0, 1, 2 }; }
|
||||
}
|
||||
|
||||
public override Line[] GetAllSides()
|
||||
{
|
||||
Line[] sides = new Line[3]
|
||||
{
|
||||
new Line(vertexMap.mat.colum0,vertexMap.mat.colum1),
|
||||
new Line(vertexMap.mat.colum1,vertexMap.mat.colum2),
|
||||
new Line(vertexMap.mat.colum2,vertexMap.mat.colum0)
|
||||
new Line(vertexMat.mat.colum0,vertexMat.mat.colum1),
|
||||
new Line(vertexMat.mat.colum1,vertexMat.mat.colum2),
|
||||
new Line(vertexMat.mat.colum2,vertexMat.mat.colum0)
|
||||
};
|
||||
|
||||
return sides;
|
||||
@@ -78,8 +73,20 @@ namespace StgSharp.Geometries
|
||||
|
||||
public override Plain GetPlain()
|
||||
{
|
||||
return new Plain(this.vertexMap.mat.colum0, this.vertexMap.mat.colum1, this.vertexMap.mat.colum2);
|
||||
return new Plain(this.vertexMat.mat.colum0, this.vertexMat.mat.colum1, this.vertexMat.mat.colum2);
|
||||
}
|
||||
|
||||
public virtual vec3d MovVertex01(uint tick) => movVertex01Opearion.Invoke(tick);
|
||||
|
||||
public virtual vec3d MovVertex02(uint tick) => movVertex02Opearion.Invoke(tick);
|
||||
|
||||
public virtual vec3d MovVertex03(uint tick) => movVertex03Opearion.Invoke(tick);
|
||||
internal sealed override void OnRender(uint tick)
|
||||
{
|
||||
tick -= this.bornTick;
|
||||
vertexMat.mat.colum0 = RefOrigin.Position.vec + MovVertex01(tick).vec;
|
||||
vertexMat.mat.colum1 = RefOrigin.Position.vec + MovVertex02(tick).vec;
|
||||
vertexMat.mat.colum2 = RefOrigin.Position.vec + MovVertex03(tick).vec;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user