daily update on 20240528 by nitload youmu
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Controlling;
|
||||
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
@@ -38,41 +38,35 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
public class Polygon4 : PlainGeometry
|
||||
{
|
||||
|
||||
internal readonly Func<int,vec3d> moveVertex0Operation = GeometryOperation.DefaultMotion;
|
||||
internal readonly Func<int,vec3d> moveVertex1Operation = GeometryOperation.DefaultMotion;
|
||||
internal readonly Func<int,vec3d> moveVertex2Operation = GeometryOperation.DefaultMotion;
|
||||
internal readonly Func<int,vec3d> moveVertex3Operation = GeometryOperation.DefaultMotion;
|
||||
|
||||
internal Mat4 vertexMat;
|
||||
protected static int[] Indices = [0, 1, 2, 0, 2, 3];
|
||||
|
||||
internal Polygon4()
|
||||
{
|
||||
}
|
||||
|
||||
public Polygon4(ICoord coordinate,
|
||||
vec2d topLeft,
|
||||
vec2d topRight,
|
||||
vec2d bottomRight,
|
||||
vec2d bottomLeft
|
||||
vec3d topLeft,
|
||||
vec3d topRight,
|
||||
vec3d bottomRight,
|
||||
vec3d bottomLeft
|
||||
)
|
||||
{
|
||||
this.coordinate = coordinate;
|
||||
vertexMat.colum0 = topLeft.vec;
|
||||
vertexMat.colum1 = topRight.vec;
|
||||
vertexMat.colum2 = bottomRight.vec;
|
||||
vertexMat.colum3 = bottomLeft.vec;
|
||||
this[0] = new vec4d(topLeft.vec);
|
||||
this[1] = new vec4d(topRight.vec);
|
||||
this[2] = new vec4d(bottomRight.vec);
|
||||
this[3] = new vec4d(bottomLeft.vec);
|
||||
|
||||
Vector4 maxCoord = vertexMat.colum0;
|
||||
Vector4 minCoord = vertexMat.colum0;
|
||||
Vector4 maxCoord = this[0].vec;
|
||||
Vector4 minCoord = this[0].vec;
|
||||
|
||||
maxCoord = Vector4.Max(maxCoord, vertexMat.colum1);
|
||||
maxCoord = Vector4.Max(maxCoord, vertexMat.colum2);
|
||||
maxCoord = Vector4.Max(maxCoord, vertexMat.colum3);
|
||||
maxCoord = Vector4.Max(maxCoord, this[1].vec);
|
||||
maxCoord = Vector4.Max(maxCoord, this[2].vec);
|
||||
maxCoord = Vector4.Max(maxCoord, this[3].vec);
|
||||
|
||||
minCoord = Vector4.Min(minCoord, vertexMat.colum1);
|
||||
minCoord = Vector4.Min(minCoord, vertexMat.colum2);
|
||||
minCoord = Vector4.Min(minCoord, vertexMat.colum3);
|
||||
minCoord = Vector4.Min(minCoord, this[1].vec);
|
||||
minCoord = Vector4.Min(minCoord, this[2].vec);
|
||||
minCoord = Vector4.Min(minCoord, this[3].vec);
|
||||
}
|
||||
|
||||
public Polygon4(
|
||||
@@ -82,92 +76,15 @@ namespace StgSharp.Geometries
|
||||
float v3x, float v3y, float v3z
|
||||
)
|
||||
{
|
||||
vertexMat.colum0 = new Vector4(v0x, v0y, v0z, 0);
|
||||
vertexMat.colum1 = new Vector4(v1x, v1y, v1z, 0);
|
||||
vertexMat.colum2 = new Vector4(v2x, v2y, v2z, 0);
|
||||
vertexMat.colum3 = new Vector4(v3x, v3y, v3z, 0);
|
||||
vertexMat = new vec4d[4];
|
||||
|
||||
this[0] = new vec4d(v0x, v0y, v0z, 0);
|
||||
this[1] = new vec4d(v1x, v1y, v1z, 0);
|
||||
this[2] = new vec4d(v2x, v2y, v2z, 0);
|
||||
this[3] = new vec4d(v3x, v3y, v3z, 0);
|
||||
}
|
||||
|
||||
public Func<int,vec3d> MovVertex0Operation => moveVertex0Operation;
|
||||
public Func<int,vec3d> MovVertex1Operation => moveVertex1Operation;
|
||||
public Func<int,vec3d> MovVertex2Operation => moveVertex2Operation;
|
||||
public Func<int,vec3d> MovVertex3Operation => moveVertex3Operation;
|
||||
|
||||
public Point Vertex0
|
||||
{
|
||||
get => new Point(vertexMat.colum0);
|
||||
set => vertexMat.colum0 = value.position.vec;
|
||||
}
|
||||
|
||||
public Point Vertex1
|
||||
{
|
||||
get => new Point(vertexMat.colum1);
|
||||
set => vertexMat.colum1 = value.position.vec;
|
||||
}
|
||||
|
||||
public Point Vertex2
|
||||
{
|
||||
get => new Point(vertexMat.colum2);
|
||||
set => vertexMat.colum1 = value.position.vec;
|
||||
}
|
||||
|
||||
public Mat4 VertexBuffer => vertexMat;
|
||||
|
||||
|
||||
|
||||
internal override sealed int[] Indices => new int[6] { 0, 1, 2, 0, 2, 3 };
|
||||
|
||||
internal Point Vertex3
|
||||
{
|
||||
get => new Point(vertexMat.colum3);
|
||||
set => vertexMat.colum1 = value.position.vec;
|
||||
}
|
||||
|
||||
|
||||
public override Line[] GetAllSides()
|
||||
{
|
||||
Line[] sides =
|
||||
[
|
||||
new Line(Vertex0, Vertex1),
|
||||
new Line(Vertex1, Vertex2),
|
||||
new Line(Vertex2, Vertex3),
|
||||
new Line(Vertex3, Vertex0)
|
||||
];
|
||||
|
||||
return sides;
|
||||
}
|
||||
|
||||
public override Plain GetPlain()
|
||||
{
|
||||
return new Plain(
|
||||
vertexMat.colum0,
|
||||
vertexMat.colum1,
|
||||
vertexMat.colum2);
|
||||
}
|
||||
|
||||
public virtual vec3d MoveVertex0(int tick)
|
||||
{
|
||||
return moveVertex0Operation(tick);
|
||||
}
|
||||
|
||||
public virtual vec3d MoveVertex1(int tick)
|
||||
{
|
||||
return moveVertex1Operation(tick);
|
||||
}
|
||||
|
||||
public virtual vec3d MoveVertex2(int tick)
|
||||
{
|
||||
return moveVertex2Operation(tick);
|
||||
}
|
||||
|
||||
public virtual vec3d MoveVertex3(int tick)
|
||||
{
|
||||
return moveVertex3Operation(tick);
|
||||
}
|
||||
|
||||
internal override void UpdateCoordinate(int tick)
|
||||
{
|
||||
}
|
||||
public override ReadOnlySpan<int> VertexIndices => Indices;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user