Files
stgsharp/源代码/StgSharp/Geometries/PlainGeometry/Polygon4.cs
T

86 lines
3.1 KiB
C#

using StgSharp.Controlling;
using StgSharp.Math;
namespace StgSharp.Geometries
{
public class Polygon4 : IPlainGeometry
{
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);
public override Point RefPoint0
{
get { return new Point(vertexMat.transpose.colum0); }
}
public override Point RefPoint1
{
get { return new Point(vertexMat.transpose.colum1); }
}
public override Point RefPoint2
{
get { return new Point(vertexMat.transpose.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()
{
}
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)
};
return sides;
}
public override Plain GetPlain()
{
vertexMat.InternalTranspose();
return new Plain(
vertexMat.mat.colum0,
vertexMat.mat.colum1,
vertexMat.mat.colum2);
}
public virtual Vec3d MoveVertex0(uint tick) => moveVertex0Operation.Invoke(tick);
public virtual Vec3d MoveVertex1(uint tick) => moveVertex1Operation.Invoke(tick);
public virtual Vec3d MoveVertex2(uint tick) => moveVertex2Operation.Invoke(tick);
public virtual Vec3d MoveVertex3(uint tick) => moveVertex3Operation.Invoke(tick);
internal override void OnRender(uint tick)
{
uint nowTick = TimeLine.tickCounter._value;
this.vertexMat.Colum0 = RefOrigin.position + moveVertex1Operation(nowTick);
this.vertexMat.Colum1 = RefOrigin.position + moveVertex1Operation(nowTick);
this.vertexMat.Colum2 = RefOrigin.position + moveVertex2Operation(nowTick);
this.vertexMat.Colum3 = RefOrigin.position + moveVertex3Operation(nowTick);
}
}
}