This commit is contained in:
Nitload
2024-06-10 15:12:08 +08:00
parent f6963b8e00
commit be6c2e6b92
305 changed files with 28336 additions and 5938 deletions
@@ -1,59 +0,0 @@
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 ICoord
{
private Matrix44 coordMat;
private Matrix44 origin;
public ICoord()
{
}
//A matrix can convert vertex to global coord.
public Matrix44 GlobalCoordTransformation
{
get
{
return coordMat * origin;
}
}
public vec3d Origin
{
get => origin.colum3.XYZ;
internal set => origin.colum3.XYZ = value;
}
public vec3d X_axis
{
get => coordMat.colum0.XYZ;
internal set => coordMat.colum0.XYZ = value;
}
public vec3d Y_axis
{
get => coordMat.colum1.XYZ;
internal set => coordMat.colum1.XYZ = value;
}
public vec3d Z_axis
{
get => coordMat.colum2.XYZ;
set => coordMat.colum2.XYZ = value;
}
protected ref Matrix44 CoordMat
{
get => ref coordMat;
}
}
}
@@ -1,144 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Math
{
public static partial class GeometryScaler
{
internal const float DegToRad = 180 / Scaler.Pi;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Degree ToDegree(float value)
{
return new Degree(value);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Sin(Radius r)
{
return MathF.Sin(r._radius);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Tan(Radius r)
{
return MathF.Tan(r._radius);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Cos(Radius r)
{
return MathF.Cos(r._radius);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Sin(Degree r)
{
return MathF.Sin(r._degree/DegToRad);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Tan(Degree r)
{
return MathF.Tan(r._degree / DegToRad);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Cos(Degree r)
{
return MathF.Cos(r._degree / DegToRad);
}
}
public struct Degree
{
internal float _degree;
internal Degree(float dgree)
{
_degree = dgree;
}
public static implicit operator Radius(Degree d)
{
return new Radius(d._degree / GeometryScaler.DegToRad);
}
}
public struct Radius
{
internal float _radius;
public static Radius Zero
{
get =>new Radius(0);
}
public Radius(float radius)
{
_radius = radius;
}
[Obsolete("Unsafe, you may forget this is radius.",true)]
public Radius() { }
public static implicit operator Degree(Radius r)
{
return new Degree(r._radius * 180 / Scaler.Pi);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Radius operator -(Radius r)
{
return new Radius(-r._radius);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Radius operator -(Radius left, Radius Right)
{
return new Radius(left._radius - Right._radius);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float operator /(Radius left, Radius right)
{
return left._radius / right._radius;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Radius operator +(Radius left, Radius Right)
{
return new Radius(left._radius + Right._radius);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Radius operator *(Radius left, float right)
{
return new Radius(left._radius * right);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Radius operator /(Radius left, float right)
{
return new Radius(left._radius / right);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Radius left, Radius right)
{
return left._radius == right._radius;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Radius left, Radius right)
{
return left._radius != right._radius;
}
}
}
@@ -1,87 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="Arc.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;
namespace StgSharp.Geometries
{
/// <summary>
/// Part of a circle. All points on a arc has the same distance to their center.
/// </summary>
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 override int[] Indices => throw new NotImplementedException();
public override Line[] GetAllSides()
{
throw new NotImplementedException();
}
public override Plain GetPlain()
{
return new Plain(this.center, this.beginPoint, this.endPoint);
}
public virtual vec3d MovBegin(int tick)
{
return movBeginOperation.Invoke(tick);
}
public virtual vec3d MoveCenter(int tick)
{
return movCenterOperation.Invoke(tick);
}
public virtual vec3d MovEnd(int tick)
{
return movEndOperation.Invoke(tick);
}
internal override void UpdateCoordinate(int tick)
{
tick = time;
center.Position = this.coordinate.Origin + MoveCenter(tick);
beginPoint.Position = this.coordinate.Origin + MovBegin(tick);
endPoint.Position = this.coordinate.Origin + MovEnd(tick);
}
}
}
@@ -1,88 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="Circle.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;
namespace StgSharp.Geometries
{
/// <summary>
/// A collection of all point on the same plain and has the same distance to a point
/// </summary>
public class Circle : PlainGeometry
{
internal Point center;
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;
internal override int[] Indices => throw new NotImplementedException();
public override Line[] GetAllSides()
{
throw new NotImplementedException();
}
public override Plain GetPlain()
{
return new Plain(center, pointOnCircle, pointOnPlain);
}
public virtual vec3d MoveCenter(int tick)
{
return movCenterOperation.Invoke(tick);
}
public virtual vec3d UpdatePlain(int tick)
{
return movEndOperation.Invoke(tick);
}
public virtual vec3d UpdateRadius(int tick)
{
return movBeginOperation.Invoke(tick);
}
internal override void UpdateCoordinate(int tick)
{
tick = time;
center.Position = this.coordinate.Origin + MoveCenter(tick);
pointOnCircle.Position = this.coordinate.Origin + UpdateRadius(tick);
pointOnPlain.Position = this.coordinate.Origin + UpdatePlain(tick);
}
}
}
@@ -1,39 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// 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
);
}
@@ -1,78 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// 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)
{
}
}
}
@@ -1,139 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// 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 vec3d CenterPositionGlobal
{
get;
set;
}
public vec3d Coord
{
get { return GlobalBuffer.CoordList[BufferId].XYZ; }
set { GlobalBuffer.CoordList[BufferId] = new vec4d( value.vec); }
}
public PlainInstancingBuffer<T> GlobalBuffer
{
get;
internal set;
}
public float Rotation
{
get { return GlobalBuffer.CoordList[BufferId].W; }
set
{
vec4d temp = GlobalBuffer.CoordList[BufferId];
temp.W = value;
GlobalBuffer.CoordList[BufferId] = temp;
}
}
public float Scale
{
get { return GlobalBuffer.ScalingList[BufferId]; }
set { GlobalBuffer.ScalingList[BufferId] = value; }
}
public GeometryMotion Motion
{
get; set;
}
public void Move()
{
(vec3d coord , float rotation) =(Coord, Rotation);
Motion.RunMotion(ref coord, ref rotation);
(Coord,Rotation) = (coord, rotation);
}
}
public class ParticleOnPlain : IInstancing<ParticleOnPlain>
{
public ParticleOnPlain(PlainInstancingBuffer<ParticleOnPlain> buffer)
{
if (buffer == null)
{
throw new ArgumentNullException(paramName: nameof(buffer));
}
GlobalBuffer = buffer;
BufferId = buffer.CreateInstanceID();
buffer.InstanceList.Add(this);
}
public int BufferId
{
get;
set;
}
public PlainInstancingBuffer<ParticleOnPlain> GlobalBuffer
{
get;
set;
}
public GeometryMotion Motion
{
get;
set;
}
vec3d IInstancing<ParticleOnPlain>.CenterPositionGlobal
{
get;
set;
}
}
}
@@ -1,39 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// 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
);
}
@@ -1,78 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// 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)
{
}
}
}
@@ -1,52 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// 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;
namespace StgSharp.Geometries
{
/// <summary>
/// Caculate the movement of a point.
/// </summary>
/// <param name="tick">The game tick represent time passed by</param>
/// <returns>A 3d vector representing movement</returns>
public delegate vec3d GetLocationHandler(int tick);
public static unsafe class GeometryOperation
{
public static vec3d DefualtMotion(int tick)
{
return default(vec3d);
}
}
}
@@ -1,107 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="Line.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.Numerics;
namespace StgSharp.Geometries
{
public class Line : PlainGeometry
{
internal Point basePoint;
internal Point beginPoint;
internal Point endPoint;
internal Func<int,vec3d> movBegin;
internal Func<int,vec3d> movEnd;
internal Line(Vector4 begin, Vector4 end)
{
beginPoint = new Point(begin);
endPoint = new Point(end);
}
public Line()
{
}
public Line(Point begin, Point end)
{
this.beginPoint = begin;
this.endPoint = end;
}
internal override int[] Indices => throw new NotSupportedException();
public override Line[] GetAllSides()
{
throw new NotImplementedException();
}
public override Plain GetPlain()
{
throw new ToUpperDimensionException();
}
/// <summary>
/// Move begin side of a line.
/// It is recommended to override this function rather than
/// loading an <see cref="Func{T, TResult}"/> with same function.
/// </summary>
/// <param name="tick">Time passed since current line was created.</param>
public virtual vec3d MoveBeginPoint(int tick)
{
return movBegin(time);
}
/// <summary>
/// Move end side of a line.
/// It is recommended to override this function rather than
/// loading an <see cref="Func{T,TResult}"/> with same function.
/// </summary>
/// <param name="tick">Time passed since current line was created.</param>
/// <returns></returns>
public virtual vec3d MoveEndPoint(int tick)
{
return movEnd.Invoke(time);
}
internal override void UpdateCoordinate(int tick)
{
beginPoint.Position = coordinate.Origin + MoveBeginPoint(time);
endPoint.Position = coordinate.Origin + MoveEndPoint(time);
}
}
}
@@ -1,99 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// 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;
internal Matrix24 textureFrame;
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"/> cincide 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();
}
}
@@ -1,107 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="Point.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.Numerics;
using System.Runtime.InteropServices;
using System.Threading;
namespace StgSharp.Geometries
{
public unsafe class Point
{
internal readonly bool isVertex;
internal vec3d position;
internal Point(vec3d p)
{
position = p;
}
internal Point(Vector4 vector)
{
position = new vec3d(vector);
}
public Point() { }
public Point(float x, float y, float z)
{
position = new vec3d(x, y, z);
}
public bool IsVertex => isVertex;
public vec3d Position
{
get => position;
set => position = value;
}
public float X
{
get => position.X;
set => position.X = value;
}
public float Y
{
get => position.Y;
set => position.Y = value;
}
public float Z
{
get => position.Z;
set => position.Z = value;
}
public bool IsInGeometry(PlainGeometry geo)
{
throw new NotImplementedException();
}
/// <summary>
/// Update the coordinate of the point. If this is a moving point,
/// (Points on sides or surface if other geometry items)
/// please do not define any motion here, codes will be ignored by program
/// </summary>
/// <param name="tick">Time passes since the program begin, counted by frames</param>
public virtual void Update(uint tick) { }
}
}
@@ -1,42 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// 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 System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Geometries
{
public class SpaceCoordinate
{
}
}