daily update on 20240610 by nitload youmu
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public abstract class CoordinationBase
|
||||
{
|
||||
private CoordinationBase localCoordination;
|
||||
private Matrix44 coordMat;
|
||||
private bool globalCoordAvailable;
|
||||
|
||||
|
||||
public CoordinationBase(
|
||||
CoordinationBase localCoordination)
|
||||
{
|
||||
this.localCoordination = localCoordination;
|
||||
coordMat = new Matrix44();
|
||||
}
|
||||
|
||||
public virtual Point LocalOrigin
|
||||
{
|
||||
get => new Point( coordMat.colum3.XYZ);
|
||||
internal set => coordMat.colum3.XYZ = value.Coord;
|
||||
}
|
||||
|
||||
public virtual vec3d LocalX
|
||||
{
|
||||
get => coordMat.colum0.XYZ;
|
||||
internal set => coordMat.colum0.XYZ = value;
|
||||
}
|
||||
|
||||
public virtual vec3d LocalY
|
||||
{
|
||||
get => coordMat.colum1.XYZ;
|
||||
internal set => coordMat.colum1.XYZ = value;
|
||||
}
|
||||
|
||||
public virtual vec3d LocalZ
|
||||
{
|
||||
get => coordMat.colum2.XYZ;
|
||||
set => coordMat.colum2.XYZ = value;
|
||||
}
|
||||
|
||||
protected ref Matrix44 CoordMat
|
||||
{
|
||||
get => ref coordMat;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -37,31 +37,30 @@ using System.Text;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class PlainCoordinate : ICoord
|
||||
public class PlainCoordinate : CoordinationBase
|
||||
{
|
||||
|
||||
public PlainCoordinate(
|
||||
vec3d origin,
|
||||
CoordinationBase local,
|
||||
Point origin,
|
||||
vec3d xAxis,
|
||||
vec3d yAxis
|
||||
)
|
||||
) : base(local)
|
||||
{
|
||||
CoordMat = Matrix44.Unit;
|
||||
Linear.Orthogonalize(ref xAxis, ref yAxis);
|
||||
|
||||
CoordMat.colum0 = new vec4d(xAxis, 0);
|
||||
CoordMat.colum1 = new vec4d(yAxis, 0);
|
||||
CoordMat.colum2 = new vec4d(Vec3d.Cross(xAxis, yAxis), 0);
|
||||
CoordMat.colum2 = new vec4d(Linear.Normalize(Vec3d.Cross(xAxis, yAxis)), 0);
|
||||
|
||||
Origin = origin;
|
||||
LocalOrigin = origin;
|
||||
}
|
||||
|
||||
private static PlainCoordinate statndardPlainCoordination = new PlainCoordinate(
|
||||
null, new Point(0,0,0),
|
||||
new vec3d(1,0,0),
|
||||
new vec3d(0, 1, 0)
|
||||
);
|
||||
|
||||
public new vec3d Z_axis
|
||||
{
|
||||
get => Vec3d.Cross(X_axis, Y_axis);
|
||||
set => throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
public static PlainCoordinate StandardPlainCoordination => statndardPlainCoordination;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="Class1.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class SpaceCoordinate : CoordinationBase
|
||||
{
|
||||
public SpaceCoordinate(
|
||||
CoordinationBase localCoordination, Point origin,
|
||||
vec3d xAxis, vec3d yAxis, vec3d zAxis
|
||||
) : base(localCoordination)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class StreamLocalCoordinate : ICoord
|
||||
/*
|
||||
public class StreamLocalCoordinate : CoordinationBase
|
||||
{
|
||||
}
|
||||
/**/
|
||||
}
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="GemoryException.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public unsafe class ToUpperDimensionException : Exception
|
||||
{
|
||||
|
||||
protected ToUpperDimensionException(SerializationInfo info, StreamingContext context) : base(info, context)
|
||||
{
|
||||
}
|
||||
public ToUpperDimensionException()
|
||||
{
|
||||
}
|
||||
|
||||
public ToUpperDimensionException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public ToUpperDimensionException(string message, Exception innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当几何体调用了过多的CalcVec方法时,产生UnusedVertexException异常
|
||||
/// </summary>
|
||||
public class UnusedVertexException : Exception
|
||||
{
|
||||
|
||||
protected UnusedVertexException(SerializationInfo info, StreamingContext context) : base(info, context)
|
||||
{
|
||||
}
|
||||
public UnusedVertexException()
|
||||
{
|
||||
}
|
||||
|
||||
public UnusedVertexException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public UnusedVertexException(string message, Exception innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -41,8 +41,9 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
public interface IGeometry
|
||||
{
|
||||
public CoordinationBase Coordination { get; }
|
||||
|
||||
public vec4d this[int index]
|
||||
public Point this[int index]
|
||||
{
|
||||
get;
|
||||
set;
|
||||
|
||||
@@ -46,13 +46,13 @@ namespace StgSharp.Geometries
|
||||
public int BufferId
|
||||
{
|
||||
get;
|
||||
set;
|
||||
internal set;
|
||||
}
|
||||
|
||||
public vec3d CenterPositionGlobal
|
||||
{
|
||||
get;
|
||||
set;
|
||||
internal set;
|
||||
}
|
||||
|
||||
public vec3d Coord
|
||||
|
||||
@@ -16,14 +16,16 @@ namespace StgSharp.Geometries
|
||||
public bool CollideWith(IPlainEntity entity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class PlainEntity:IPlainEntity
|
||||
{
|
||||
private PlainGeometry _shape;
|
||||
|
||||
vec2d IPlainEntity.CenterPosition
|
||||
{
|
||||
get => throw new NotImplementedException();
|
||||
set => throw new NotImplementedException();
|
||||
get => _shape.Coordination.LocalOrigin.Coord.XY;
|
||||
set => throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
public PlainEntity(PlainGeometry shape)
|
||||
|
||||
@@ -76,7 +76,13 @@ namespace StgSharp.Geometries
|
||||
get;
|
||||
set;
|
||||
}
|
||||
vec2d IPlainEntity.CenterPosition { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
|
||||
vec2d IPlainEntity.CenterPosition
|
||||
{
|
||||
get => GlobalBuffer.CoordAndRotationList[BufferId].XY;
|
||||
set => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
bool IPlainEntity.CollideWith(IPlainEntity entity)
|
||||
{
|
||||
|
||||
@@ -42,19 +42,19 @@ namespace StgSharp.Geometries
|
||||
public abstract class PlainGeometry : IGeometry
|
||||
{
|
||||
protected vec4d[] vertexMat;
|
||||
internal ICoord coordinate;
|
||||
internal CoordinationBase coordinate;
|
||||
|
||||
public PlainGeometry()
|
||||
internal PlainGeometry(CoordinationBase coordination)
|
||||
{
|
||||
coordinate = coordination;
|
||||
}
|
||||
|
||||
public vec4d this[int index]
|
||||
public Point this[int index]
|
||||
{
|
||||
get => vertexMat[index];
|
||||
set => vertexMat[index] = value;
|
||||
get => new Point(vertexMat[index]);
|
||||
set => vertexMat[index].vec = value.coordVec;
|
||||
}
|
||||
|
||||
public ICoord ReferenceCoordinate => this.coordinate;
|
||||
|
||||
public int VertexCount => this.vertexMat.Length;
|
||||
|
||||
@@ -62,9 +62,11 @@ namespace StgSharp.Geometries
|
||||
|
||||
#pragma warning disable CA1819
|
||||
public vec4d[] VertexStream => vertexMat;
|
||||
#pragma warning restore CA1819
|
||||
|
||||
public CoordinationBase Coordination => this.coordinate;
|
||||
#pragma warning restore CA1819
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -38,32 +38,53 @@ namespace StgSharp.Geometries
|
||||
public class Parallelogram : Polygon4
|
||||
{
|
||||
|
||||
internal readonly Func<int, vec3d> movCenterOperation =
|
||||
new Func<int, vec3d>(GeometryOperation.DefaultMotion);
|
||||
|
||||
internal Point center;
|
||||
|
||||
internal readonly Func<int,vec3d> movCenterOperation =
|
||||
new Func<int,vec3d>(GeometryOperation.DefaultMotion);
|
||||
|
||||
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
|
||||
float v0x, float v0y,
|
||||
float v1x, float v1y,
|
||||
float v2x, float v2y,
|
||||
float v3x, float v3y
|
||||
) : base(
|
||||
v0x, v0y, v0z,
|
||||
v1x, v1y, v1z,
|
||||
v2x, v2y, v2z,
|
||||
v3x, v3y, v3z
|
||||
v0x, v0y, v1x, v1y,
|
||||
v2x, v2y, v3x, v3y
|
||||
)
|
||||
{
|
||||
#if DEBUG
|
||||
if (
|
||||
this[0] + this[2] !=
|
||||
this[1] + this[3]
|
||||
this[0].Coord + this[2].Coord !=
|
||||
this[1].Coord + this[3].Coord
|
||||
)
|
||||
{
|
||||
InternalIO.InternalWriteLog("Init of geometry item failed, because four vertices cannot form a rectangle.", LogType.Warning);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public Parallelogram(
|
||||
PlainCoordinate coordination,
|
||||
float v0x, float v0y,
|
||||
float v1x, float v1y,
|
||||
float v2x, float v2y,
|
||||
float v3x, float v3y
|
||||
) : base(coordination,
|
||||
v0x, v0y, v1x, v1y,
|
||||
v2x, v2y, v3x, v3y
|
||||
)
|
||||
{
|
||||
#if DEBUG
|
||||
if (
|
||||
this[0].Coord + this[2].Coord !=
|
||||
this[1].Coord + this[3].Coord
|
||||
)
|
||||
{
|
||||
InternalIO.InternalWriteLog("Init of geometry item failed, because four vertices cannot form a rectangle.", LogType.Warning);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,9 +71,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.Coord;
|
||||
vec3d v1 = p2.Coord - origin;
|
||||
vec3d v2 = p3.Coord - origin;
|
||||
|
||||
|
||||
vec1 = v1 - (v2 * (v1.Y / v2.Y)); //计算平面在xz平面上的方向投影
|
||||
|
||||
@@ -40,48 +40,80 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
protected static int[] Indices = [0, 1, 2, 0, 2, 3];
|
||||
|
||||
internal Polygon4()
|
||||
internal Polygon4():base(PlainCoordinate.StandardPlainCoordination)
|
||||
{
|
||||
vertexMat = new vec4d[4];
|
||||
}
|
||||
|
||||
public Polygon4(ICoord coordinate,
|
||||
vec3d topLeft,
|
||||
vec3d topRight,
|
||||
vec3d bottomRight,
|
||||
vec3d bottomLeft
|
||||
)
|
||||
internal Polygon4(vec4d[] rawCoord):
|
||||
base(PlainCoordinate.StandardPlainCoordination)
|
||||
{
|
||||
this.coordinate = coordinate;
|
||||
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 = this[0].vec;
|
||||
Vector4 minCoord = this[0].vec;
|
||||
|
||||
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, this[1].vec);
|
||||
minCoord = Vector4.Min(minCoord, this[2].vec);
|
||||
minCoord = Vector4.Min(minCoord, this[3].vec);
|
||||
if (rawCoord.Length != 4)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(rawCoord));
|
||||
}
|
||||
vertexMat = rawCoord;
|
||||
}
|
||||
|
||||
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
|
||||
)
|
||||
Point topLeft,
|
||||
Point topRight,
|
||||
Point bottomRight,
|
||||
Point bottomLeft
|
||||
):base(PlainCoordinate.StandardPlainCoordination)
|
||||
{
|
||||
this[0] = topLeft;
|
||||
this[1] = topRight;
|
||||
this[2] = bottomRight;
|
||||
this[3] = bottomLeft;
|
||||
|
||||
}
|
||||
|
||||
public Polygon4(
|
||||
float v0x, float v0y,
|
||||
float v1x, float v1y,
|
||||
float v2x, float v2y,
|
||||
float v3x, float v3y
|
||||
):base(PlainCoordinate.StandardPlainCoordination)
|
||||
{
|
||||
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);
|
||||
this[0] = new Point(v0x, v0y, 0);
|
||||
this[1] = new Point(v1x, v1y, 0);
|
||||
this[2] = new Point(v2x, v2y, 0);
|
||||
this[3] = new Point(v3x, v3y, 0);
|
||||
}
|
||||
|
||||
|
||||
public Polygon4(CoordinationBase coordinate,
|
||||
PlainCoordinate coordination,
|
||||
Point topLeft,
|
||||
Point topRight,
|
||||
Point bottomRight,
|
||||
Point bottomLeft
|
||||
) : base(coordinate)
|
||||
{
|
||||
this[0] = topLeft;
|
||||
this[1] = topRight;
|
||||
this[2] = bottomRight;
|
||||
this[3] = bottomLeft;
|
||||
|
||||
}
|
||||
|
||||
public Polygon4(
|
||||
PlainCoordinate coordination,
|
||||
float v0x, float v0y,
|
||||
float v1x, float v1y,
|
||||
float v2x, float v2y,
|
||||
float v3x, float v3y
|
||||
) : base(coordination)
|
||||
{
|
||||
vertexMat = new vec4d[4];
|
||||
|
||||
this[0] = new Point(v0x, v0y, 0);
|
||||
this[1] = new Point(v1x, v1y, 0);
|
||||
this[2] = new Point(v2x, v2y, 0);
|
||||
this[3] = new Point(v3x, v3y, 0);
|
||||
}
|
||||
|
||||
public override ReadOnlySpan<int> VertexIndices => Indices;
|
||||
|
||||
@@ -39,25 +39,42 @@ namespace StgSharp.Geometries
|
||||
public unsafe class Polygon5 : PlainGeometry
|
||||
{
|
||||
|
||||
public unsafe Polygon5()
|
||||
public unsafe Polygon5():base(PlainCoordinate.StandardPlainCoordination)
|
||||
{
|
||||
vertexMat = new vec4d[5];
|
||||
}
|
||||
|
||||
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
|
||||
)
|
||||
float v0x, float v0y,
|
||||
float v1x, float v1y,
|
||||
float v2x, float v2y,
|
||||
float v3x, float v3y,
|
||||
float v4x, float v4y
|
||||
):base(PlainCoordinate.StandardPlainCoordination)
|
||||
{
|
||||
vertexMat = new vec4d[5];
|
||||
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);
|
||||
this[4] = new vec4d(v4x, v4y, v4z, 0);
|
||||
this[0] = new Point(v0x, v0y, 0);
|
||||
this[1] = new Point(v1x, v1y, 0);
|
||||
this[2] = new Point(v2x, v2y, 0);
|
||||
this[3] = new Point(v3x, v3y, 0);
|
||||
this[4] = new Point(v4x, v4y, 0);
|
||||
}
|
||||
|
||||
public Polygon5(
|
||||
PlainCoordinate coordination,
|
||||
float v0x, float v0y,
|
||||
float v1x, float v1y,
|
||||
float v2x, float v2y,
|
||||
float v3x, float v3y,
|
||||
float v4x, float v4y
|
||||
):base(coordination)
|
||||
{
|
||||
vertexMat = new vec4d[5];
|
||||
this[0] = new Point(v0x, v0y, 0);
|
||||
this[1] = new Point(v1x, v1y, 0);
|
||||
this[2] = new Point(v2x, v2y, 0);
|
||||
this[3] = new Point(v3x, v3y, 0);
|
||||
this[4] = new Point(v4x, v4y, 0);
|
||||
}
|
||||
|
||||
internal static int[] Indices = [ 0, 1, 2, 0, 2, 3, 0, 3, 4 ];
|
||||
|
||||
@@ -38,11 +38,32 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
public class Polygon6 : PlainGeometry
|
||||
{
|
||||
public Polygon6()
|
||||
public Polygon6():base(PlainCoordinate.StandardPlainCoordination)
|
||||
{
|
||||
vertexMat = new vec4d[6];
|
||||
}
|
||||
|
||||
public Polygon6(
|
||||
PlainCoordinate coordination,
|
||||
vec2d vert0,
|
||||
vec2d vert1,
|
||||
vec2d vert2,
|
||||
vec2d vert3,
|
||||
vec2d vert4,
|
||||
vec2d vert5,
|
||||
vec2d vert6
|
||||
) : base(coordination)
|
||||
{
|
||||
vertexMat = new vec4d[6];
|
||||
vertexMat[0].vec = vert0.vec;
|
||||
vertexMat[1].vec = vert1.vec;
|
||||
vertexMat[2].vec = vert2.vec;
|
||||
vertexMat[3].vec = vert3.vec;
|
||||
vertexMat[4].vec = vert4.vec;
|
||||
vertexMat[5].vec = vert5.vec;
|
||||
vertexMat[6].vec = vert6.vec;
|
||||
}
|
||||
|
||||
internal static int[] Indices = [ 0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4, 5 ];
|
||||
|
||||
public override ReadOnlySpan<int> VertexIndices => Indices;
|
||||
|
||||
@@ -38,20 +38,44 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
|
||||
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
|
||||
float v0x, float v0y,
|
||||
float v1x, float v1y,
|
||||
float v2x, float v2y,
|
||||
float v3x, float v3y
|
||||
) : base(
|
||||
v0x, v0y, v0z,
|
||||
v1x, v1y, v1z,
|
||||
v2x, v2y, v2z,
|
||||
v3x, v3y, v3z
|
||||
v0x, v0y,
|
||||
v1x, v1y,
|
||||
v2x, v2y,
|
||||
v3x, v3y
|
||||
)
|
||||
{
|
||||
#if DEBUG
|
||||
vec2d side0 = (this[0] - this[1]).XY;
|
||||
vec2d side1 = (this[2] - this[1]).XY;
|
||||
vec2d side0 = (this[0].Coord - this[1].Coord).XY;
|
||||
vec2d side1 = (this[2].Coord - this[1].Coord).XY;
|
||||
if (side0.Cross(side1) == 0)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
public Rectangle(
|
||||
PlainCoordinate coordination,
|
||||
float v0x, float v0y,
|
||||
float v1x, float v1y,
|
||||
float v2x, float v2y,
|
||||
float v3x, float v3y
|
||||
) : base(coordination,
|
||||
v0x, v0y,
|
||||
v1x, v1y,
|
||||
v2x, v2y,
|
||||
v3x, v3y
|
||||
)
|
||||
{
|
||||
#if DEBUG
|
||||
vec2d side0 = (this[0].Coord - this[1].Coord).XY;
|
||||
vec2d side1 = (this[2].Coord - this[1].Coord).XY;
|
||||
if (side0.Cross(side1) == 0)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
|
||||
@@ -42,14 +42,14 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
|
||||
public Square(
|
||||
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, v3y, v3z)
|
||||
float v0x, float v0y,
|
||||
float v1x, float v1y,
|
||||
float v2x, float v2y,
|
||||
float v3x, float v3y)
|
||||
: base(v0x, v0y,
|
||||
v1x, v1y,
|
||||
v2x, v2y,
|
||||
v3x, v3y)
|
||||
{
|
||||
if (true)
|
||||
{
|
||||
|
||||
@@ -42,33 +42,54 @@ namespace StgSharp.Geometries
|
||||
public unsafe class Triangle : PlainGeometry
|
||||
{
|
||||
|
||||
public Triangle()
|
||||
public Triangle():base(PlainCoordinate.StandardPlainCoordination)
|
||||
{
|
||||
vertexMat = new vec4d[3];
|
||||
}
|
||||
|
||||
public Triangle(
|
||||
vec3d vertex01,
|
||||
vec3d vertex02,
|
||||
vec3d vertex03
|
||||
)
|
||||
Point vertex01,
|
||||
Point vertex02,
|
||||
Point vertex03
|
||||
) : base(PlainCoordinate.StandardPlainCoordination)
|
||||
{
|
||||
this[0] = new vec4d( vertex01.vec);
|
||||
this[1] = new vec4d( vertex02.vec);
|
||||
this[2] = new vec4d( vertex03.vec);
|
||||
this[0] = vertex01;
|
||||
this[1] = vertex02;
|
||||
this[2] = vertex03;
|
||||
}
|
||||
|
||||
public Triangle(
|
||||
float v0x, float v0y, float v0z,
|
||||
float v1x, float v1y, float v1z,
|
||||
float v2x, float v2y, float v2z
|
||||
)
|
||||
float v0x, float v0y,
|
||||
float v1x, float v1y,
|
||||
float v2x, float v2y
|
||||
) : base(PlainCoordinate.StandardPlainCoordination)
|
||||
{
|
||||
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[0] = new Point(v0x, v0y, 0);
|
||||
this[1] = new Point(v1x, v1y, 0);
|
||||
this[2] = new Point(v2x, v2y, 0);
|
||||
}
|
||||
|
||||
public Triangle(PlainCoordinate coordination,
|
||||
Point vertex01,
|
||||
Point vertex02,
|
||||
Point vertex03
|
||||
) : base(coordination)
|
||||
{
|
||||
this[0] = vertex01;
|
||||
this[1] = vertex02;
|
||||
this[2] = vertex03;
|
||||
}
|
||||
|
||||
public Triangle(PlainCoordinate coordination,
|
||||
float v0x, float v0y,
|
||||
float v1x, float v1y,
|
||||
float v2x, float v2y
|
||||
) : base(coordination)
|
||||
{
|
||||
this[0] = new Point(v0x, v0y, 0);
|
||||
this[1] = new Point(v1x, v1y, 0);
|
||||
this[2] = new Point(v2x, v2y, 0);
|
||||
}
|
||||
internal static int[] Indices = [ 0, 1, 2 ];
|
||||
|
||||
public override ReadOnlySpan<int> VertexIndices => Indices;
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = 16)]
|
||||
public struct Point
|
||||
{
|
||||
[FieldOffset(0)] private vec3d coord;
|
||||
[FieldOffset(0)] internal Vector4 coordVec;
|
||||
|
||||
public Point(float x, float y, float z)
|
||||
{
|
||||
coordVec = new Vector4(x,y,z,1);
|
||||
}
|
||||
|
||||
public Point(vec3d coord)
|
||||
{
|
||||
Coord = coord;
|
||||
coordVec.W = 1;
|
||||
}
|
||||
|
||||
internal Point(vec4d vector)
|
||||
{
|
||||
coordVec = vector.vec;
|
||||
coordVec.W = 1;
|
||||
}
|
||||
|
||||
public vec3d Coord
|
||||
{
|
||||
get => coord;
|
||||
set { coord = value; coordVec.W = 1; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user