Files
stgsharp/源代码/StgSharp/Geometries/PlainGeometry/Triangle.cs
T
2023-05-27 04:36:06 +08:00

90 lines
3.0 KiB
C#

using StgSharp;
using StgSharp.Control;
using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
namespace StgSharp.Geometries
{
public unsafe class Triangle :IPlainGeometry
{
internal triangleVertexArray vertexArray;
internal Point vertex1;
internal Point vertex2;
internal Point vertex3;
internal GetLocationHandler movVertex01Opearion = new GetLocationHandler(GeometryOperation.DefualtMotion);
internal GetLocationHandler movVertex02Opearion = new GetLocationHandler(GeometryOperation.DefualtMotion);
internal GetLocationHandler movVertex03Opearion = new GetLocationHandler(GeometryOperation.DefualtMotion);
public override sealed Point RefPoint01 => vertex1;
public override sealed Point RefPoint02 => vertex2;
public override sealed Point RefPoint03 => vertex3;
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);
public Triangle()
{
this.vertexArray = internalIO.initTriangleVertex();
this.vertex1 = new Point(vertexArray.vertex1Ptr);
this.vertex2 = new Point(vertexArray.vertex2Ptr);
this.vertex3 = new Point(vertexArray.vertex3Ptr);
/**/
ProgramTimeLine._currentPool.pointContainer.Add(vertex1);
ProgramTimeLine._currentPool.pointContainer.Add(vertex2);
ProgramTimeLine._currentPool.pointContainer.Add(vertex3);
/**/
}
public Triangle(
vec3d vertex01,
vec3d vertex02,
vec3d vertex03
)
{
vertex1.Position = vertex01;
vertex1.Position = vertex01;
vertex1.Position = vertex01;
}
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);
}
public override Line[] GetAllSides()
{
Line[] sides = new Line[3]
{
new Line(vertex1,vertex2),
new Line(vertex2,vertex3),
new Line(vertex3,vertex1)
};
return sides;
}
public override Plain GetPlain()
{
return new Plain(this.vertex1,this.vertex2,this.vertex3);
}
}
}