daily update on 20240508 by nitload youmu, partical added
This commit is contained in:
@@ -10,16 +10,14 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
public class StreamLocalCoordinate : ICoord
|
||||
{
|
||||
|
||||
|
||||
public override Matrix44 GlobalCoordTransformation => throw new NotImplementedException();
|
||||
|
||||
public override vec3d Origin => Vec3d.Zero;
|
||||
|
||||
public override vec3d X_axis => coordMat.colum0.XYZ;
|
||||
|
||||
public override vec3d Y_axis => throw new NotImplementedException();
|
||||
public override vec3d Y_axis => coordMat.colum1.XYZ;
|
||||
|
||||
public override vec3d Z_axis => throw new NotImplementedException();
|
||||
public override vec3d Z_axis => coordMat.colum2.XYZ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,12 +40,13 @@ namespace StgSharp.Geometries
|
||||
public class Arc : PlainGeometry
|
||||
{
|
||||
|
||||
internal Func<int, vec3d> movBeginOperation = GeometryOperation.DefaultMotion;
|
||||
internal Func<int, vec3d> movCenterOperation = GeometryOperation.DefaultMotion;
|
||||
internal Func<int, vec3d> movEndOperation = GeometryOperation.DefaultMotion;
|
||||
|
||||
internal Point beginPoint;
|
||||
internal Point center;
|
||||
internal Point endPoint;
|
||||
internal GetLocationHandler movBeginOperation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal GetLocationHandler movCenterOperation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal GetLocationHandler movEndOperation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
|
||||
internal override int[] Indices => throw new NotImplementedException();
|
||||
|
||||
|
||||
@@ -41,9 +41,9 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
|
||||
internal Point center;
|
||||
internal GetLocationHandler movBeginOperation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal GetLocationHandler movCenterOperation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal GetLocationHandler movEndOperation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal Func<int,vec3d> movBeginOperation = GeometryOperation.DefaultMotion;
|
||||
internal Func<int,vec3d> movCenterOperation = GeometryOperation.DefaultMotion;
|
||||
internal Func<int,vec3d> movEndOperation = GeometryOperation.DefaultMotion;
|
||||
internal Point pointOnCircle;
|
||||
internal Point pointOnPlain;
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="ExpressionHandler.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.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public delegate float ExpressionHandler
|
||||
(
|
||||
Counter<uint> tickCounter,
|
||||
float beginRange,
|
||||
float endRange
|
||||
);
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="GeometryOperation.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.Runtime.CompilerServices;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
|
||||
public static unsafe class GeometryOperation
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static vec3d DefaultMotion(int tick)
|
||||
{
|
||||
return default(vec3d);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="IInstancing.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.Linq;
|
||||
using System.Numerics;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public interface IInstancing<T> where T : IInstancing<T>
|
||||
{
|
||||
public int BufferId
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public vec2d CenterPositionGlobal
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public vec2d Coord
|
||||
{
|
||||
get { return new(GlobalBuffer.CoordList[BufferId]); }
|
||||
set { GlobalBuffer.CoordList[BufferId] = value.vec; }
|
||||
}
|
||||
|
||||
public PlainInstancingBuffer<T> GlobalBuffer
|
||||
{
|
||||
get;
|
||||
internal set;
|
||||
}
|
||||
|
||||
public float Scale
|
||||
{
|
||||
get { return GlobalBuffer.ScalingList[BufferId]; }
|
||||
set { GlobalBuffer.ScalingList[BufferId] = value; }
|
||||
}
|
||||
}
|
||||
|
||||
public class ParticalOnPlain : IInstancing<ParticalOnPlain>
|
||||
{
|
||||
public int BufferId
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
vec2d IInstancing<ParticalOnPlain>.CenterPositionGlobal
|
||||
{
|
||||
get ;
|
||||
set ;
|
||||
}
|
||||
|
||||
public PlainInstancingBuffer<ParticalOnPlain> GlobalBuffer
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public ParticalOnPlain(PlainInstancingBuffer<ParticalOnPlain> buffer)
|
||||
{
|
||||
GlobalBuffer = buffer;
|
||||
BufferId = buffer.CreateInstanceID();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
|
||||
public interface IPlainEntity
|
||||
{
|
||||
public vec2d CenterPosition { get; set; }
|
||||
|
||||
public bool CollideWith(IPlainEntity entity);
|
||||
|
||||
}
|
||||
|
||||
public class PlainEntity:IPlainEntity
|
||||
{
|
||||
private PlainGeometry shape;
|
||||
|
||||
vec2d IPlainEntity.CenterPosition
|
||||
{
|
||||
get => throw new NotImplementedException();
|
||||
set => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
bool IPlainEntity.CollideWith(IPlainEntity entity)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="PlainGeometry.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.Graphics;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
/// <summary>
|
||||
/// 平面几何体。包含三角形,对称四边形,自由多边形等。最多可由16个点参数定义。
|
||||
/// </summary>
|
||||
public abstract class PlainGeometry: IGeometry
|
||||
{
|
||||
|
||||
protected TimeSpanProvider time;
|
||||
|
||||
internal ICoord coordinate;
|
||||
|
||||
public static int VertexCount { get; }
|
||||
|
||||
public PlainGeometry()
|
||||
{
|
||||
}
|
||||
|
||||
vec4d IGeometry.this[int index]
|
||||
{
|
||||
get => throw new NotImplementedException();
|
||||
set => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tick time this geometry eas crested
|
||||
/// </summary>
|
||||
public int BornTime => time;
|
||||
|
||||
public ICoord ReferenceCoordinate => this.coordinate;
|
||||
|
||||
internal abstract int[] Indices { get; }
|
||||
|
||||
int IGeometry.VertexCount => throw new NotImplementedException();
|
||||
|
||||
vec4d[] IGeometry.VertexStream => throw new NotImplementedException();
|
||||
|
||||
/// <summary>
|
||||
/// Get all sides of this <see cref="PlainGeometry"/>.
|
||||
/// </summary>
|
||||
/// <returns>A array contains all straight <see cref="Line"/>s of current geometry item.</returns>
|
||||
public abstract Line[] GetAllSides();
|
||||
|
||||
/// <summary>
|
||||
/// Get a flat <see cref="Plain"/> coincide with current geometry.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public abstract Plain GetPlain();
|
||||
|
||||
internal abstract void UpdateCoordinate(int tick);
|
||||
|
||||
void IGeometry.GetVertexHandle(ICoord coordinate, int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
void IGeometry.Transform(Matrix44 transFormMatrix)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
//public abstract Rectangle GetRenderFrame();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class PlainInstancingBuffer<T> where T : IInstancing<T>
|
||||
{
|
||||
private List<Vector4> coordList;
|
||||
private List<float> scalingList;
|
||||
private List<IInstancing<T>> instanceList;
|
||||
|
||||
public PlainInstancingBuffer()
|
||||
{
|
||||
coordList = new List<Vector4>();
|
||||
instanceList = new List<IInstancing<T>>();
|
||||
scalingList = new List<float>();
|
||||
}
|
||||
|
||||
internal List<Vector4> CoordList
|
||||
{
|
||||
get => coordList;
|
||||
}
|
||||
|
||||
internal List<float> ScalingList
|
||||
{
|
||||
get => scalingList;
|
||||
}
|
||||
|
||||
public int CreateInstanceID()
|
||||
{
|
||||
int ret = instanceList.Count;
|
||||
coordList.Add(new Vector4());
|
||||
scalingList.Add(0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void Remove(T instance)
|
||||
{
|
||||
if (instance.GlobalBuffer != this)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
int index = instance.BufferId;
|
||||
IInstancing<T> temp = instanceList[instanceList.Count - 1];
|
||||
instanceList[instance.BufferId] = temp;
|
||||
temp.BufferId = instance.BufferId;
|
||||
|
||||
coordList[instance.BufferId] = coordList[coordList.Count - 1];
|
||||
scalingList[instance.BufferId] = scalingList[scalingList.Count - 1];
|
||||
|
||||
instanceList.RemoveAt(instanceList.Count - 1);
|
||||
coordList.RemoveAt(coordList.Count - 1);
|
||||
scalingList.RemoveAt(scalingList.Count - 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -41,8 +41,8 @@ namespace StgSharp.Geometries
|
||||
internal Point basePoint;
|
||||
internal Point beginPoint;
|
||||
internal Point endPoint;
|
||||
internal GetLocationHandler movBegin;
|
||||
internal GetLocationHandler movEnd;
|
||||
internal Func<int,vec3d> movBegin;
|
||||
internal Func<int,vec3d> movEnd;
|
||||
|
||||
internal Line(Vector4 begin, Vector4 end)
|
||||
{
|
||||
@@ -74,7 +74,7 @@ namespace StgSharp.Geometries
|
||||
/// <summary>
|
||||
/// Move begin side of a line.
|
||||
/// It is recommended to override this function rather than
|
||||
/// loading an <see cref="GetLocationHandler"/> with same function.
|
||||
/// loading an <see cref="Func<int,vec3d>"/> with same function.
|
||||
/// </summary>
|
||||
/// <param name="tick">Time passed since current line was created.</param>
|
||||
public virtual vec3d MoveBeginPoint(int tick)
|
||||
@@ -85,7 +85,7 @@ namespace StgSharp.Geometries
|
||||
/// <summary>
|
||||
/// Move end side of a line.
|
||||
/// It is recommended to override this function rather than
|
||||
/// loading an <see cref="GetLocationHandler"/> with same function.
|
||||
/// loading an <see cref="Func<int,vec3d>"/> with same function.
|
||||
/// </summary>
|
||||
/// <param name="tick">Time passed since current line was created.</param>
|
||||
/// <returns></returns>
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
using StgSharp.Controlling;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class Parallelogram : Polygon4
|
||||
@@ -38,8 +40,8 @@ namespace StgSharp.Geometries
|
||||
|
||||
internal Point center;
|
||||
|
||||
internal readonly GetLocationHandler movCenterOperation =
|
||||
new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal readonly Func<int,vec3d> movCenterOperation =
|
||||
new Func<int,vec3d>(GeometryOperation.DefaultMotion);
|
||||
|
||||
public Parallelogram(
|
||||
float v0x, float v0y, float v0z,
|
||||
@@ -54,17 +56,17 @@ namespace StgSharp.Geometries
|
||||
)
|
||||
{
|
||||
if (
|
||||
vertexMat.Colum0 + vertexMat.Colum2 !=
|
||||
vertexMat.Colum1 + vertexMat.Colum3
|
||||
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 GetLocationHandler MovCenterOperation => movCenterOperation;
|
||||
public GetLocationHandler MovVertex01Operation => moveVertex0Operation;
|
||||
public GetLocationHandler MovVertex02Operation => moveVertex1Operation;
|
||||
public Func<int,vec3d> MovCenterOperation => movCenterOperation;
|
||||
public Func<int,vec3d> MovVertex01Operation => moveVertex0Operation;
|
||||
public Func<int,vec3d> MovVertex02Operation => moveVertex1Operation;
|
||||
|
||||
public virtual vec3d MovCenter(int tick)
|
||||
{
|
||||
@@ -72,22 +74,22 @@ namespace StgSharp.Geometries
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Move the third vertix. this is a useless method for Parallelograms.
|
||||
/// Move the third vertex. this is a useless method for Parallelograms.
|
||||
/// </summary>
|
||||
/// <param name="tick">Current time tick</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="UnusedVertexException">Geometry overdefined</exception>
|
||||
/// <exception cref="UnusedVertexException">Geometry over defined</exception>
|
||||
public override sealed vec3d MoveVertex2(int tick)
|
||||
{
|
||||
throw new UnusedVertexException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Move the third vertix. This method is useless for Parallelograms.
|
||||
/// Move the third vertex. This method is useless for Parallelograms.
|
||||
/// </summary>
|
||||
/// <param name="tick">Current time tick</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="UnusedVertexException">Geometry overdefined</exception>
|
||||
/// <exception cref="UnusedVertexException">Geometry over defined</exception>
|
||||
public override sealed vec3d MoveVertex3(int tick)
|
||||
{
|
||||
throw new UnusedVertexException();
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
using StgSharp.Controlling;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
@@ -38,12 +39,12 @@ namespace StgSharp.Geometries
|
||||
public class Polygon4 : PlainGeometry
|
||||
{
|
||||
|
||||
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 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 Matrix24 vertexMat;
|
||||
internal Mat4 vertexMat;
|
||||
|
||||
internal Polygon4()
|
||||
{
|
||||
@@ -53,31 +54,25 @@ namespace StgSharp.Geometries
|
||||
vec2d topLeft,
|
||||
vec2d topRight,
|
||||
vec2d bottomRight,
|
||||
vec2d bottomLeft,
|
||||
bool Orth
|
||||
vec2d bottomLeft
|
||||
)
|
||||
{
|
||||
this.coordinate = coordinate;
|
||||
vertexMat.Colum0 = topLeft;
|
||||
vertexMat.Colum1 = topRight;
|
||||
vertexMat.Colum2 = bottomRight;
|
||||
vertexMat.Colum3 = bottomLeft;
|
||||
vertexMat.colum0 = topLeft.vec;
|
||||
vertexMat.colum1 = topRight.vec;
|
||||
vertexMat.colum2 = bottomRight.vec;
|
||||
vertexMat.colum3 = bottomLeft.vec;
|
||||
|
||||
Vector4 maxCoord = vertexMat.mat.colum0;
|
||||
Vector4 minCoord = vertexMat.mat.colum0;
|
||||
Vector4 maxCoord = vertexMat.colum0;
|
||||
Vector4 minCoord = vertexMat.colum0;
|
||||
|
||||
maxCoord = Vector4.Max(maxCoord, vertexMat.mat.colum1);
|
||||
maxCoord = Vector4.Max(maxCoord, vertexMat.mat.colum2);
|
||||
maxCoord = Vector4.Max(maxCoord, vertexMat.mat.colum3);
|
||||
maxCoord = Vector4.Max(maxCoord, vertexMat.colum1);
|
||||
maxCoord = Vector4.Max(maxCoord, vertexMat.colum2);
|
||||
maxCoord = Vector4.Max(maxCoord, vertexMat.colum3);
|
||||
|
||||
minCoord = Vector4.Min(minCoord, vertexMat.mat.colum1);
|
||||
minCoord = Vector4.Min(minCoord, vertexMat.mat.colum2);
|
||||
minCoord = Vector4.Min(minCoord, vertexMat.mat.colum3);
|
||||
|
||||
textureFrame.mat.colum1 = maxCoord;
|
||||
textureFrame.mat.colum3 = minCoord;
|
||||
textureFrame.Colum0 = new vec2d(minCoord.X, maxCoord.Y);
|
||||
textureFrame.Colum2 = new vec2d(maxCoord.X, minCoord.Y);
|
||||
minCoord = Vector4.Min(minCoord, vertexMat.colum1);
|
||||
minCoord = Vector4.Min(minCoord, vertexMat.colum2);
|
||||
minCoord = Vector4.Min(minCoord, vertexMat.colum3);
|
||||
}
|
||||
|
||||
public Polygon4(
|
||||
@@ -87,36 +82,36 @@ namespace StgSharp.Geometries
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
public GetLocationHandler MovVertex0Operation => moveVertex0Operation;
|
||||
public GetLocationHandler MovVertex1Operation => moveVertex1Operation;
|
||||
public GetLocationHandler MovVertex2Operation => moveVertex2Operation;
|
||||
public GetLocationHandler MovVertex3Operation => moveVertex3Operation;
|
||||
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.mat.colum0);
|
||||
set => vertexMat.mat.colum0 = value.position.vec;
|
||||
get => new Point(vertexMat.colum0);
|
||||
set => vertexMat.colum0 = value.position.vec;
|
||||
}
|
||||
|
||||
public Point Vertex1
|
||||
{
|
||||
get => new Point(vertexMat.mat.colum1);
|
||||
set => vertexMat.mat.colum1 = value.position.vec;
|
||||
get => new Point(vertexMat.colum1);
|
||||
set => vertexMat.colum1 = value.position.vec;
|
||||
}
|
||||
|
||||
public Point Vertex2
|
||||
{
|
||||
get => new Point(vertexMat.mat.colum2);
|
||||
set => vertexMat.mat.colum1 = value.position.vec;
|
||||
get => new Point(vertexMat.colum2);
|
||||
set => vertexMat.colum1 = value.position.vec;
|
||||
}
|
||||
|
||||
public Mat4 VertexBuffer => vertexMat.mat;
|
||||
public Mat4 VertexBuffer => vertexMat;
|
||||
|
||||
|
||||
|
||||
@@ -124,31 +119,30 @@ namespace StgSharp.Geometries
|
||||
|
||||
internal Point Vertex3
|
||||
{
|
||||
get => new Point(vertexMat.mat.colum3);
|
||||
set => vertexMat.mat.colum1 = value.position.vec;
|
||||
get => new Point(vertexMat.colum3);
|
||||
set => vertexMat.colum1 = value.position.vec;
|
||||
}
|
||||
|
||||
|
||||
public override Line[] GetAllSides()
|
||||
{
|
||||
Line[] sides = new Line[4]
|
||||
{
|
||||
Line[] sides =
|
||||
[
|
||||
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);
|
||||
vertexMat.colum0,
|
||||
vertexMat.colum1,
|
||||
vertexMat.colum2);
|
||||
}
|
||||
|
||||
public virtual vec3d MoveVertex0(int tick)
|
||||
@@ -171,8 +165,6 @@ namespace StgSharp.Geometries
|
||||
return moveVertex3Operation(tick);
|
||||
}
|
||||
|
||||
|
||||
|
||||
internal override void UpdateCoordinate(int tick)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Controlling;
|
||||
using StgSharp.Math;
|
||||
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
@@ -40,11 +40,11 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
|
||||
internal Point _refOrigin;
|
||||
internal GetLocationHandler movP01Operation = default;
|
||||
internal GetLocationHandler movP02Operation = default;
|
||||
internal GetLocationHandler movP03Operation = default;
|
||||
internal GetLocationHandler movP04Operation = default;
|
||||
internal GetLocationHandler movP05Operation = default;
|
||||
internal Func<int,vec3d> movP01Operation = default;
|
||||
internal Func<int,vec3d> movP02Operation = default;
|
||||
internal Func<int,vec3d> movP03Operation = default;
|
||||
internal Func<int,vec3d> movP04Operation = default;
|
||||
internal Func<int,vec3d> movP05Operation = default;
|
||||
internal mat5 vertexMat;
|
||||
|
||||
public unsafe Polygon5()
|
||||
@@ -67,11 +67,11 @@ namespace StgSharp.Geometries
|
||||
}
|
||||
|
||||
|
||||
public GetLocationHandler MovP01Operation => movP01Operation;
|
||||
public GetLocationHandler MovP02Operation => movP02Operation;
|
||||
public GetLocationHandler MovP03Operation => movP03Operation;
|
||||
public GetLocationHandler MovP04Operation => movP04Operation;
|
||||
public GetLocationHandler MovP05Operation => movP05Operation;
|
||||
public Func<int,vec3d> MovP01Operation => movP01Operation;
|
||||
public Func<int,vec3d> MovP02Operation => movP02Operation;
|
||||
public Func<int,vec3d> MovP03Operation => movP03Operation;
|
||||
public Func<int,vec3d> MovP04Operation => movP04Operation;
|
||||
public Func<int,vec3d> MovP05Operation => movP05Operation;
|
||||
|
||||
public Point Vertex0
|
||||
{
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Controlling;
|
||||
using StgSharp.Math;
|
||||
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
@@ -40,20 +40,20 @@ namespace StgSharp.Geometries
|
||||
{
|
||||
|
||||
internal Point _refOrigin;
|
||||
internal GetLocationHandler movVertex0Operation;
|
||||
internal GetLocationHandler movVertex1Operation;
|
||||
internal GetLocationHandler movVertex2Operation;
|
||||
internal GetLocationHandler movVertex3Operation;
|
||||
internal GetLocationHandler movVertex4Operation;
|
||||
internal GetLocationHandler movVertex5Operation;
|
||||
internal Func<int,vec3d> movVertex0Operation;
|
||||
internal Func<int,vec3d> movVertex1Operation;
|
||||
internal Func<int,vec3d> movVertex2Operation;
|
||||
internal Func<int,vec3d> movVertex3Operation;
|
||||
internal Func<int,vec3d> movVertex4Operation;
|
||||
internal Func<int,vec3d> movVertex5Operation;
|
||||
internal mat6 vertexMat;
|
||||
|
||||
public GetLocationHandler MovVertex0Operation => movVertex0Operation;
|
||||
public GetLocationHandler MovVertex1Operation => movVertex1Operation;
|
||||
public GetLocationHandler MovVertex2Operation => movVertex2Operation;
|
||||
public GetLocationHandler MovVertex3Operation => movVertex3Operation;
|
||||
public GetLocationHandler MovVertex4Operation => movVertex4Operation;
|
||||
public GetLocationHandler MovVertex5Operation => movVertex5Operation;
|
||||
public Func<int,vec3d> MovVertex0Operation => movVertex0Operation;
|
||||
public Func<int,vec3d> MovVertex1Operation => movVertex1Operation;
|
||||
public Func<int,vec3d> MovVertex2Operation => movVertex2Operation;
|
||||
public Func<int,vec3d> MovVertex3Operation => movVertex3Operation;
|
||||
public Func<int,vec3d> MovVertex4Operation => movVertex4Operation;
|
||||
public Func<int,vec3d> MovVertex5Operation => movVertex5Operation;
|
||||
|
||||
public Point Vertex0
|
||||
{
|
||||
|
||||
@@ -49,18 +49,20 @@ namespace StgSharp.Geometries
|
||||
v3x, v2y, v3z
|
||||
)
|
||||
{
|
||||
vec2d side0 = vertexMat.Colum0 - vertexMat.Colum1;
|
||||
vec2d side1 = vertexMat.Colum2 - vertexMat.Colum1;
|
||||
#if DEBUG
|
||||
vec2d side0 = new vec2d( vertexMat.colum0 - vertexMat.colum1);
|
||||
vec2d side1 = new vec2d( vertexMat.colum2 - vertexMat.colum1);
|
||||
if (side0.Cross(side1) == 0)
|
||||
{
|
||||
|
||||
throw new ArgumentException();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算中心点相对于参考原点的位移
|
||||
/// Calculate movement to center
|
||||
/// </summary>
|
||||
/// <param name="tick">当前游戏刻</param>
|
||||
/// <param name="tick">Current time tick</param>
|
||||
/// <returns></returns>
|
||||
public virtual vec3d MovCenter(uint tick)
|
||||
{
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
using StgSharp.Controlling;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
@@ -40,15 +41,15 @@ namespace StgSharp.Geometries
|
||||
public unsafe class Triangle : PlainGeometry
|
||||
{
|
||||
|
||||
internal GetLocationHandler movVertex01Opearion = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal GetLocationHandler movVertex02Opearion = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal GetLocationHandler movVertex03Opearion = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal Func<int,vec3d> movVertex01Operation = GeometryOperation.DefaultMotion;
|
||||
internal Func<int,vec3d> movVertex02Operation = GeometryOperation.DefaultMotion;
|
||||
internal Func<int,vec3d> movVertex03Operation = GeometryOperation.DefaultMotion;
|
||||
|
||||
internal Matrix33 vertexMat;
|
||||
internal Mat3 vertexMat;
|
||||
|
||||
public Triangle()
|
||||
{
|
||||
vertexMat = new Matrix33();
|
||||
vertexMat = new Mat3();
|
||||
}
|
||||
|
||||
public Triangle(
|
||||
@@ -57,9 +58,9 @@ namespace StgSharp.Geometries
|
||||
vec3d vertex03
|
||||
)
|
||||
{
|
||||
vertexMat.mat.colum0 = vertex01.vec;
|
||||
vertexMat.mat.colum1 = vertex02.vec;
|
||||
vertexMat.mat.colum2 = vertex03.vec;
|
||||
vertexMat.colum0 = vertex01.vec;
|
||||
vertexMat.colum1 = vertex02.vec;
|
||||
vertexMat.colum2 = vertex03.vec;
|
||||
}
|
||||
|
||||
public Triangle(
|
||||
@@ -68,57 +69,55 @@ namespace StgSharp.Geometries
|
||||
float v2x, float v2y, float v2z
|
||||
)
|
||||
{
|
||||
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.colum0 = new Vector4(v0x, v0y, v0z, 0);
|
||||
vertexMat.colum1 = new Vector4(v1x, v1y, v1z, 0);
|
||||
vertexMat.colum2 = new Vector4(v2x, v2y, v2z, 0);
|
||||
}
|
||||
|
||||
public GetLocationHandler MovVertex01Operation => this.movVertex01Opearion;
|
||||
public GetLocationHandler MovVertex02Operation => this.movVertex02Opearion;
|
||||
public GetLocationHandler MovVertex03Operation => this.movVertex03Opearion;
|
||||
public Func<int,vec3d> MovVertex01Operation => this.movVertex01Operation;
|
||||
public Func<int,vec3d> MovVertex02Operation => this.movVertex02Operation;
|
||||
public Func<int,vec3d> MovVertex03Operation => this.movVertex03Operation;
|
||||
|
||||
public Mat3 VertexBuffer => vertexMat.mat;
|
||||
public Mat3 VertexBuffer => vertexMat;
|
||||
|
||||
internal override sealed int[] Indices => new int[3] { 0, 1, 2 };
|
||||
|
||||
public override Line[] GetAllSides()
|
||||
{
|
||||
Line[] sides = new Line[3]
|
||||
{
|
||||
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;
|
||||
return
|
||||
[
|
||||
new Line(vertexMat.colum0,vertexMat.colum1),
|
||||
new Line(vertexMat.colum1,vertexMat.colum2),
|
||||
new Line(vertexMat.colum2,vertexMat.colum0)
|
||||
];
|
||||
}
|
||||
|
||||
public override Plain GetPlain()
|
||||
{
|
||||
return new Plain(this.vertexMat.mat.colum0, this.vertexMat.mat.colum1, this.vertexMat.mat.colum2);
|
||||
return new Plain(this.vertexMat.colum0, this.vertexMat.colum1, this.vertexMat.colum2);
|
||||
}
|
||||
|
||||
public virtual vec3d MovVertex01(int tick)
|
||||
{
|
||||
return movVertex01Opearion.Invoke(tick);
|
||||
return movVertex01Operation(tick);
|
||||
}
|
||||
|
||||
public virtual vec3d MovVertex02(int tick)
|
||||
{
|
||||
return movVertex02Opearion.Invoke(tick);
|
||||
return movVertex02Operation(tick);
|
||||
}
|
||||
|
||||
public virtual vec3d MovVertex03(int tick)
|
||||
{
|
||||
return movVertex03Opearion.Invoke(tick);
|
||||
return movVertex03Operation(tick);
|
||||
}
|
||||
|
||||
internal override sealed void UpdateCoordinate(int tick)
|
||||
{
|
||||
tick = time;
|
||||
vertexMat.mat.colum0 = coordinate.Origin.vec + MovVertex01(time).vec;
|
||||
vertexMat.mat.colum1 = coordinate.Origin.vec + MovVertex02(time).vec;
|
||||
vertexMat.mat.colum2 = coordinate.Origin.vec + MovVertex03(time).vec;
|
||||
vertexMat.colum0 = coordinate.Origin.vec + MovVertex01(time).vec;
|
||||
vertexMat.colum1 = coordinate.Origin.vec + MovVertex02(time).vec;
|
||||
vertexMat.colum2 = coordinate.Origin.vec + MovVertex03(time).vec;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user