OpenGL rebuild project start!
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
using StgSharp.Math;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class Arc : IPlainGeometry
|
||||
{
|
||||
internal Point center;
|
||||
internal Point beginPoint;
|
||||
internal Point endPoint;
|
||||
internal GetLocationHandler movCenterOperation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal GetLocationHandler movBeginOperation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal GetLocationHandler movEndOperation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
|
||||
public override Point RefPoint01 => center;
|
||||
|
||||
public override Point RefPoint02 => beginPoint;
|
||||
|
||||
public override Point RefPoint03 => endPoint;
|
||||
|
||||
public virtual vec3d MoveCenter(uint tick) => movCenterOperation.Invoke(tick);
|
||||
|
||||
public virtual vec3d MovBegin(uint tick) => movBeginOperation.Invoke(tick);
|
||||
|
||||
public virtual vec3d MovEnd(uint tick) => movEndOperation.Invoke(tick);
|
||||
|
||||
internal override void OnRender(uint tick)
|
||||
{
|
||||
tick-= bornTick;
|
||||
center._position = refOrigin._position + MoveCenter(tick);
|
||||
beginPoint._position = refOrigin._position + MovBegin(tick);
|
||||
endPoint._position = refOrigin._position + MovEnd(tick);
|
||||
}
|
||||
|
||||
public override Line[] GetAllSides() => throw new NotImplementedException();
|
||||
|
||||
public override Plain GetPlain()
|
||||
{
|
||||
return new Plain(this.center,this.beginPoint,this.endPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using StgSharp.Math;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class Circle : IPlainGeometry
|
||||
{
|
||||
internal Point center;
|
||||
internal Point pointOnCircle;
|
||||
internal Point pointOnPlain;
|
||||
internal GetLocationHandler movCenterOperation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal GetLocationHandler movBeginOperation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal GetLocationHandler movEndOperation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
|
||||
|
||||
public override Point RefPoint01 => center;
|
||||
|
||||
public override Point RefPoint02 => pointOnCircle;
|
||||
|
||||
public override Point RefPoint03 => pointOnPlain;
|
||||
|
||||
public virtual vec3d MoveCenter(uint tick) => movCenterOperation.Invoke(tick);
|
||||
|
||||
public virtual vec3d UpdateRadius(uint tick) => movBeginOperation.Invoke(tick);
|
||||
|
||||
public virtual vec3d UpdatePlain(uint tick) => movEndOperation.Invoke(tick);
|
||||
|
||||
public override Plain GetPlain()
|
||||
{
|
||||
return new Plain(center, pointOnCircle, pointOnPlain);
|
||||
}
|
||||
|
||||
internal override void OnRender(uint tick)
|
||||
{
|
||||
tick-=bornTick;
|
||||
center._position = refOrigin._position + MoveCenter(tick);
|
||||
pointOnCircle._position = refOrigin._position + UpdateRadius(tick);
|
||||
pointOnPlain._position = refOrigin._position + UpdatePlain(tick);
|
||||
}
|
||||
|
||||
public override Line[] GetAllSides()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public delegate float ExpressionHandler
|
||||
(
|
||||
Counter<uint> tickCounter,
|
||||
float beginRange,
|
||||
float endRange
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public unsafe class ToUpperDimensionException : Exception
|
||||
{
|
||||
public ToUpperDimensionException()
|
||||
{
|
||||
}
|
||||
|
||||
public ToUpperDimensionException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public ToUpperDimensionException(string message, Exception innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
protected ToUpperDimensionException(SerializationInfo info, StreamingContext context) : base(info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当几何体调用了过多的CalcVec方法时,产生UnusedVertexException异常
|
||||
/// </summary>
|
||||
public class UnusedVertexException : Exception
|
||||
{
|
||||
public UnusedVertexException()
|
||||
{
|
||||
}
|
||||
|
||||
public UnusedVertexException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public UnusedVertexException(string message, Exception innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
protected UnusedVertexException(SerializationInfo info, StreamingContext context) : base(info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using StgSharp;
|
||||
using StgSharp.Math;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
/// <summary>
|
||||
/// 计算位移失量,需要手动输入游戏刻以提供时间数据
|
||||
/// </summary>
|
||||
/// <param name="tickCounter"></param>
|
||||
/// <returns>表示位移量的三维矢量</returns>
|
||||
public delegate vec3d GetLocationHandler(uint tick);
|
||||
|
||||
public static unsafe class GeometryOperation
|
||||
{
|
||||
public static vec3d DefualtMotion(uint tick)
|
||||
{
|
||||
return default(vec3d);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using StgSharp.Math;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 平面几何体。包含三角形,对称四边形,自由多边形等。最多可由16个点参数定义。
|
||||
/// </summary>
|
||||
public abstract class IPlainGeometry:INode<IPlainGeometry>
|
||||
{
|
||||
protected readonly uint bornTick;
|
||||
internal readonly Point refOrigin;
|
||||
|
||||
public Point RefOrigin { get { return refOrigin; } }
|
||||
public abstract Point RefPoint01{ get; }
|
||||
public abstract Point RefPoint02{ get; }
|
||||
public abstract Point RefPoint03{ get; }
|
||||
public uint BornTime => bornTick;
|
||||
|
||||
public IPlainGeometry(uint bornTime)
|
||||
{
|
||||
bornTick=bornTime;
|
||||
}
|
||||
|
||||
public IPlainGeometry(Counter<uint> MainTimer)
|
||||
{
|
||||
bornTick = MainTimer.Value;
|
||||
}
|
||||
|
||||
public IPlainGeometry() { }
|
||||
|
||||
|
||||
internal abstract void OnRender(uint tick);
|
||||
|
||||
public abstract Line[] GetAllSides();
|
||||
|
||||
public abstract Plain GetPlain();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using Steamworks;
|
||||
using StgSharp;
|
||||
using StgSharp.Control;
|
||||
using StgSharp.Math;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class Line:IPlainGeometry
|
||||
{
|
||||
internal Point basePoint = default ;
|
||||
internal Point beginPoint = default ;
|
||||
internal Point endPoint = default;
|
||||
internal GetLocationHandler movBegin;
|
||||
internal GetLocationHandler movEnd;
|
||||
|
||||
public override Point RefPoint01 => beginPoint;
|
||||
public override Point RefPoint02 => endPoint;
|
||||
public override Point RefPoint03 => default;
|
||||
|
||||
public Line(Point begin, Point end)
|
||||
{
|
||||
this.beginPoint = begin;
|
||||
this.endPoint = end;
|
||||
}
|
||||
|
||||
public Line() { }
|
||||
|
||||
//计算线起点的方法,通过对线的派生的重写实现功能
|
||||
public virtual vec3d MoveBeginPoint(uint tick)
|
||||
=> movBegin.Invoke(tick);
|
||||
|
||||
//计算线重点的方法,通过对线的派生的重写实现功能
|
||||
public virtual vec3d MoveEndPoint(uint tick)
|
||||
=> movEnd.Invoke(tick);
|
||||
|
||||
internal override void OnRender(uint tick)
|
||||
{
|
||||
tick -= bornTick;
|
||||
beginPoint._position = refOrigin._position + MoveBeginPoint(tick);
|
||||
endPoint._position = refOrigin._position + MoveEndPoint(tick);
|
||||
}
|
||||
|
||||
public override Line[] GetAllSides()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override Plain GetPlain()
|
||||
{
|
||||
throw new ToUpperDimensionException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using StgSharp.Control;
|
||||
using StgSharp.Math;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
internal class Parallelogram : Polygon4
|
||||
{
|
||||
internal Point center;
|
||||
|
||||
public override sealed Point RefPoint01 => center;
|
||||
public sealed override Point RefPoint02 => vertex01;
|
||||
public sealed override Point RefPoint03 => vertex02;
|
||||
|
||||
internal readonly GetLocationHandler movCenterOperation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
|
||||
public GetLocationHandler MovCenterOperation { get { return movCenterOperation; } }
|
||||
public GetLocationHandler MovVertex01Operation { get { return movVertex01Operation; } }
|
||||
public GetLocationHandler MovVertex02Operation { get { return movVertex02Operation; } }
|
||||
|
||||
public virtual vec3d MovCenter(uint tick)
|
||||
{
|
||||
return movCenterOperation.Invoke(tick);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移动平行四边形的第三个顶点,是一个多余的方法,调用会引发多余变量异常
|
||||
/// </summary>
|
||||
/// <param name="tick">当前游戏刻</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="UnusedVertexException">几何体过定义</exception>
|
||||
public sealed override vec3d MovVertex03(uint tick)
|
||||
{
|
||||
throw new UnusedVertexException();
|
||||
}
|
||||
|
||||
public sealed override vec3d MovVertex04(uint tick)
|
||||
{
|
||||
throw new UnusedVertexException();
|
||||
}
|
||||
|
||||
internal override sealed void OnRender(uint tick)
|
||||
{
|
||||
uint nowTick = GameTimeLine.tickCounter._value;
|
||||
this.vertex01._position = RefOrigin._position + movVertex01Operation(nowTick);
|
||||
this.vertex02._position = RefOrigin._position + movVertex02Operation(nowTick);
|
||||
this.vertex03._position = 2 * center._position - vertex01._position;
|
||||
this.vertex04._position = 2 * center._position - vertex02._position;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using StgSharp.Math;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public unsafe class Plain
|
||||
{
|
||||
internal vec3d origin;
|
||||
internal vec3d vec1;
|
||||
internal vec3d vec2;
|
||||
|
||||
internal vec3d plainParameter;
|
||||
internal readonly float d = -1;
|
||||
|
||||
public Plain(vec3d o, vec3d v1, vec3d v2)
|
||||
{
|
||||
this.origin = o;
|
||||
this.vec1 = v1 - v2 * (v1.Y / v2.Y); //计算平面在xz平面上的方向投影
|
||||
this.vec2 = v2 - vec1 * (v2.X / v1.X); //计算平面在yz平面上的方向投影
|
||||
|
||||
//|origin|-k1*|vec1|-k2*|vec2|计算plainParameter.Z;
|
||||
plainParameter.Z = origin.Z - vec1.Z * (origin.X / vec1.X) - vec2.Z * (origin.Y / vec2.Y);
|
||||
//根据plainParameter.Z和对应的方向矢量计算plainParameter.X和plainParameter.Y
|
||||
plainParameter.X = vec1.X * (vec1.Z / plainParameter.Z);
|
||||
plainParameter.Y = vec2.Y * (vec2.Z / plainParameter.Z);
|
||||
|
||||
plainParameter.X = 1 / plainParameter.X;
|
||||
plainParameter.Y = 1 / plainParameter.Y;
|
||||
plainParameter.Z = 1 / plainParameter.Z;
|
||||
}
|
||||
|
||||
public Plain(Point p1, Point p2, Point p3)
|
||||
{
|
||||
vec3d origin = p1._position;
|
||||
vec3d v1 = p2._position - origin;
|
||||
vec3d v2 = p3._position - origin;
|
||||
|
||||
|
||||
vec1 = v1 - v2 * (v1.Y / v2.Y); //计算平面在xz平面上的方向投影
|
||||
vec2 = v2 - vec1 * (v2.X / v1.X); //计算平面在yz平面上的方向投影
|
||||
|
||||
//|origin|-k1*|vec1|-k2*|vec2|计算plainParameter.Z;
|
||||
plainParameter.Z = origin.Z - vec1.Z * (origin.X / vec1.X) - vec2.Z * (origin.Y / vec2.Y);
|
||||
//根据plainParameter.Z和对应的方向矢量计算plainParameter.X和plainParameter.Y
|
||||
plainParameter.X = vec1.X * (vec1.Z / plainParameter.Z);
|
||||
plainParameter.Y = vec2.Y * (vec2.Z / plainParameter.Z);
|
||||
|
||||
plainParameter.X = 1 / plainParameter.X;
|
||||
plainParameter.Y = 1 / plainParameter.Y;
|
||||
plainParameter.Z = 1 / plainParameter.Z;
|
||||
}
|
||||
|
||||
}}
|
||||
@@ -0,0 +1,50 @@
|
||||
using StgSharp;
|
||||
using StgSharp.Math;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class Point : INode<Point>
|
||||
{
|
||||
|
||||
internal vec3d _position;
|
||||
|
||||
public float X
|
||||
{
|
||||
get { return this._position.X; }
|
||||
}
|
||||
|
||||
public float Y
|
||||
{
|
||||
get { return this._position.Y; }
|
||||
}
|
||||
|
||||
internal readonly bool isVertex;
|
||||
|
||||
public bool IsVertex => isVertex;
|
||||
|
||||
/// <summary>
|
||||
/// 刷新点的位置,即移动点。当该点是某个几何体的从动点时
|
||||
/// (即点坐标由几何体其他点约束或点参数已经在创建几何体时定义)
|
||||
/// 请不要再次进行定义,程序将自行忽略此处的代码。
|
||||
/// </summary>
|
||||
/// <param name="tick">当前游戏刻</param>
|
||||
public virtual void Update(uint tick) {}
|
||||
|
||||
public bool IsInGeometry(IPlainGeometry geo)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool IsOnPlain(IPlainGeometry geo)
|
||||
{
|
||||
return this._position * geo.GetPlain().plainParameter == 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using StgSharp.Control;
|
||||
using StgSharp.Math;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class Polygon4 : IPlainGeometry
|
||||
{
|
||||
internal Point vertex01;
|
||||
internal Point vertex02;
|
||||
internal Point vertex03;
|
||||
internal Point vertex04;
|
||||
|
||||
internal readonly GetLocationHandler movVertex01Operation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal readonly GetLocationHandler movVertex02Operation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal readonly GetLocationHandler movVertex03Operation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal readonly GetLocationHandler movVertex04Operation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
|
||||
public override Point RefPoint01 => vertex01;
|
||||
|
||||
public override Point RefPoint02 => vertex02;
|
||||
|
||||
public override Point RefPoint03 => vertex03;
|
||||
|
||||
public GetLocationHandler MovVertex01Operaion { get { return movVertex01Operation; } }
|
||||
public GetLocationHandler MovVertex02Operaion { get { return movVertex02Operation; } }
|
||||
public GetLocationHandler MovVertex03Operaion { get { return movVertex03Operation; } }
|
||||
public GetLocationHandler MovVertex04Operaion { get { return movVertex04Operation; } }
|
||||
|
||||
public override Line[] GetAllSides()
|
||||
{
|
||||
Line[] sides = new Line[4]
|
||||
{
|
||||
new Line(vertex01,vertex02),
|
||||
new Line(vertex02, vertex03),
|
||||
new Line(vertex03, vertex04),
|
||||
new Line(vertex04, vertex01)
|
||||
};
|
||||
|
||||
sides[0] = new Line(vertex01,vertex02);
|
||||
sides[1] = new Line(vertex02,vertex03);
|
||||
sides[2] = new Line(vertex03,vertex04);
|
||||
sides[3] = new Line(vertex04,vertex01);
|
||||
|
||||
return sides;
|
||||
}
|
||||
|
||||
public override Plain GetPlain()
|
||||
{
|
||||
return new Plain(this.RefPoint01, this.RefPoint02, this.RefPoint03);
|
||||
}
|
||||
|
||||
|
||||
public virtual vec3d MovVertex01(uint tick) => movVertex01Operation.Invoke(tick);
|
||||
|
||||
public virtual vec3d MovVertex02(uint tick) => movVertex01Operation.Invoke(tick);
|
||||
|
||||
public virtual vec3d MovVertex03(uint tick) => movVertex01Operation.Invoke(tick);
|
||||
|
||||
public virtual vec3d MovVertex04(uint tick) => movVertex01Operation.Invoke(tick);
|
||||
|
||||
|
||||
internal override void OnRender(uint tick)
|
||||
{
|
||||
uint nowTick = GameTimeLine.tickCounter._value;
|
||||
this.vertex01._position = RefOrigin._position + movVertex01Operation(nowTick);
|
||||
this.vertex02._position = RefOrigin._position + movVertex02Operation(nowTick);
|
||||
this.vertex03._position = RefOrigin._position + movVertex03Operation(nowTick);
|
||||
this.vertex04._position = RefOrigin._position + movVertex04Operation(nowTick);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
using Steamworks;
|
||||
using StgSharp.Control;
|
||||
using StgSharp.Math;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class Polygon5 : IPlainGeometry
|
||||
{
|
||||
internal Point _refOrigin;
|
||||
internal Point vertex1;
|
||||
internal Point vertex2;
|
||||
internal Point vertex3;
|
||||
internal Point vertex4;
|
||||
internal Point vertex5;
|
||||
internal readonly int _vertexCount;
|
||||
|
||||
public override Point RefPoint01 => vertex1;
|
||||
|
||||
public override Point RefPoint02 => vertex2;
|
||||
|
||||
public override Point RefPoint03 => vertex3;
|
||||
|
||||
|
||||
internal GetLocationHandler movP01Operation = default;
|
||||
internal GetLocationHandler movP02Operation = default;
|
||||
internal GetLocationHandler movP03Operation = default;
|
||||
internal GetLocationHandler movP04Operation = default;
|
||||
internal GetLocationHandler movP05Operation = default;
|
||||
|
||||
public GetLocationHandler MovP01Operation { get => movP01Operation; }
|
||||
public GetLocationHandler MovP02Operation { get => movP02Operation; }
|
||||
public GetLocationHandler MovP03Operation { get => movP03Operation; }
|
||||
public GetLocationHandler MovP04Operation { get => movP04Operation; }
|
||||
public GetLocationHandler MovP05Operation { get => movP05Operation; }
|
||||
|
||||
public virtual vec3d movPoint01(uint tick)
|
||||
{
|
||||
return movP01Operation.Invoke(GameTimeLine.tickCounter._value);
|
||||
}
|
||||
|
||||
public virtual vec3d movPoint02(uint tick)
|
||||
{
|
||||
return movP02Operation.Invoke(GameTimeLine.tickCounter._value);
|
||||
}
|
||||
|
||||
public virtual vec3d movPoint03(uint tick)
|
||||
{
|
||||
return movP03Operation.Invoke(GameTimeLine.tickCounter._value);
|
||||
}
|
||||
|
||||
public virtual vec3d movPoint04(uint tick)
|
||||
{
|
||||
return movP04Operation.Invoke(GameTimeLine.tickCounter._value);
|
||||
}
|
||||
|
||||
public virtual vec3d movPoint05(uint tick)
|
||||
{
|
||||
return movP05Operation.Invoke(GameTimeLine.tickCounter._value);
|
||||
}
|
||||
|
||||
internal override void OnRender(uint tick)
|
||||
{
|
||||
uint nowTick = tick - BornTime;
|
||||
vertex1._position = RefOrigin._position + movPoint01(nowTick);
|
||||
vertex2._position = RefOrigin._position + movPoint02(nowTick);
|
||||
vertex3._position = RefOrigin._position + movPoint03(nowTick);
|
||||
vertex4._position = RefOrigin._position + movPoint04(nowTick);
|
||||
vertex5._position = RefOrigin._position + movPoint05(nowTick);
|
||||
}
|
||||
|
||||
public override Line[] GetAllSides()
|
||||
{
|
||||
return new Line[5]
|
||||
{
|
||||
new Line(vertex1,vertex2),
|
||||
new Line(vertex2,vertex3),
|
||||
new Line(vertex3,vertex4),
|
||||
new Line(vertex4,vertex5),
|
||||
new Line(vertex5,vertex1)
|
||||
};
|
||||
}
|
||||
|
||||
public override Plain GetPlain()
|
||||
{
|
||||
return new Plain(vertex1,vertex2,vertex3);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
using Steamworks;
|
||||
using StgSharp.Control;
|
||||
using StgSharp.Math;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class Polygon6 : IPlainGeometry
|
||||
{
|
||||
internal Point _refOrigin;
|
||||
internal Point vertex1;
|
||||
internal Point vertex2;
|
||||
internal Point vertex3;
|
||||
internal Point vertex4;
|
||||
internal Point vertex5;
|
||||
internal Point vertex6;
|
||||
internal readonly int _vertexCount;
|
||||
|
||||
public override Point RefPoint01 => vertex1;
|
||||
|
||||
public override Point RefPoint02 => vertex2;
|
||||
|
||||
public override Point RefPoint03 => vertex3;
|
||||
|
||||
|
||||
internal GetLocationHandler movP01Operation = default;
|
||||
internal GetLocationHandler movP02Operation = default;
|
||||
internal GetLocationHandler movP03Operation = default;
|
||||
internal GetLocationHandler movP04Operation = default;
|
||||
internal GetLocationHandler movP05Operation = default;
|
||||
internal GetLocationHandler movP06Operation = default;
|
||||
|
||||
public GetLocationHandler MovP01Operation { get => movP01Operation; }
|
||||
public GetLocationHandler MovP02Operation { get => movP02Operation; }
|
||||
public GetLocationHandler MovP03Operation { get => movP03Operation; }
|
||||
public GetLocationHandler MovP04Operation { get => movP04Operation; }
|
||||
public GetLocationHandler MovP05Operation { get => movP05Operation; }
|
||||
public GetLocationHandler MovP06Operation { get => movP06Operation; }
|
||||
|
||||
public virtual vec3d movPoint01(uint tick)
|
||||
{
|
||||
return movP01Operation.Invoke(GameTimeLine.tickCounter._value);
|
||||
}
|
||||
|
||||
public virtual vec3d movPoint02(uint tick)
|
||||
{
|
||||
return movP02Operation.Invoke(GameTimeLine.tickCounter._value);
|
||||
}
|
||||
|
||||
public virtual vec3d movPoint03(uint tick)
|
||||
{
|
||||
return movP03Operation.Invoke(GameTimeLine.tickCounter._value);
|
||||
}
|
||||
|
||||
public virtual vec3d movPoint04(uint tick)
|
||||
{
|
||||
return movP04Operation.Invoke(GameTimeLine.tickCounter._value);
|
||||
}
|
||||
|
||||
public virtual vec3d movPoint05(uint tick)
|
||||
{
|
||||
return movP05Operation.Invoke(GameTimeLine.tickCounter._value);
|
||||
}
|
||||
|
||||
public virtual vec3d movPoint06(uint tick)
|
||||
{
|
||||
return movP06Operation.Invoke(GameTimeLine.tickCounter._value);
|
||||
}
|
||||
|
||||
internal override void OnRender(uint tick)
|
||||
{
|
||||
uint nowTick = tick - BornTime;
|
||||
vertex1._position = RefOrigin._position + movPoint01(nowTick);
|
||||
vertex2._position = RefOrigin._position + movPoint02(nowTick);
|
||||
vertex3._position = RefOrigin._position + movPoint03(nowTick);
|
||||
vertex4._position = RefOrigin._position + movPoint04(nowTick);
|
||||
vertex5._position = RefOrigin._position + movPoint05(nowTick);
|
||||
vertex6._position = RefOrigin._position + movPoint06(nowTick);
|
||||
}
|
||||
|
||||
public override Line[] GetAllSides()
|
||||
{
|
||||
return new Line[6]
|
||||
{
|
||||
new Line(vertex1,vertex2),
|
||||
new Line(vertex2,vertex3),
|
||||
new Line(vertex3,vertex4),
|
||||
new Line(vertex4,vertex5),
|
||||
new Line(vertex5,vertex6),
|
||||
new Line(vertex6,vertex1)
|
||||
};
|
||||
}
|
||||
|
||||
public override Plain GetPlain()
|
||||
{
|
||||
return new Plain(vertex1,vertex2,vertex3);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using StgSharp.Control;
|
||||
using StgSharp.Math;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class Rectangle : Polygon4
|
||||
{
|
||||
internal Point center;
|
||||
|
||||
public override sealed Point RefPoint01=>center;
|
||||
|
||||
public override sealed Point RefPoint02 => vertex01;
|
||||
|
||||
public override sealed Point RefPoint03 => vertex02;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 计算中心点相对于参考原点的位移
|
||||
/// </summary>
|
||||
/// <param name="tick">当前游戏刻</param>
|
||||
/// <returns></returns>
|
||||
public virtual vec3d MovCenter(uint tick) => default(vec3d);
|
||||
|
||||
public sealed override vec3d MovVertex03(uint tick)
|
||||
{
|
||||
return this.center._position * 2 - this.vertex01._position;
|
||||
}
|
||||
|
||||
public sealed override vec3d MovVertex04(uint tick)
|
||||
{
|
||||
return this.center._position * 2 - this.vertex02._position;
|
||||
}
|
||||
|
||||
internal override sealed void OnRender(uint tick)
|
||||
{
|
||||
tick-=bornTick;
|
||||
this.MovCenter(tick);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using StgSharp;
|
||||
using StgSharp.Math;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class Triangle :IPlainGeometry
|
||||
{
|
||||
internal Point vertex1;
|
||||
internal Point vertex2;
|
||||
internal Point vertex3;
|
||||
internal GetLocationHandler movVertex01Opearion = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal GetLocationHandler movVertex02Opearion = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal GetLocationHandler movVertex03Opearion = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
|
||||
|
||||
public override sealed Point RefPoint01=> vertex1;
|
||||
|
||||
public override sealed Point RefPoint02 => vertex2;
|
||||
|
||||
public override sealed Point RefPoint03 => vertex3;
|
||||
|
||||
public GetLocationHandler MovVertex01Operation => this.movVertex01Opearion;
|
||||
public GetLocationHandler MovVertex02Operation => this.movVertex02Opearion;
|
||||
public GetLocationHandler MovVertex03Operation => this.movVertex03Opearion;
|
||||
|
||||
public virtual vec3d MovVertex01(uint tick) => movVertex01Opearion.Invoke(tick);
|
||||
|
||||
public virtual vec3d MovVertex02(uint tick) => movVertex02Opearion.Invoke(tick);
|
||||
|
||||
public virtual vec3d MovVertex03(uint tick) => movVertex03Opearion.Invoke(tick);
|
||||
|
||||
internal override sealed void OnRender(uint tick)
|
||||
{
|
||||
tick -= this.bornTick;
|
||||
vertex1._position = RefOrigin._position + MovVertex01(tick);
|
||||
vertex2._position = RefOrigin._position + MovVertex02(tick);
|
||||
vertex3._position = RefOrigin._position + MovVertex03(tick);
|
||||
|
||||
}
|
||||
|
||||
public override Line[] GetAllSides()
|
||||
{
|
||||
Line[] sides = new Line[3]
|
||||
{
|
||||
new Line(vertex1,vertex2),
|
||||
new Line(vertex2,vertex3),
|
||||
new Line(vertex3,vertex1)
|
||||
};
|
||||
|
||||
return sides;
|
||||
}
|
||||
|
||||
public override Plain GetPlain()
|
||||
{
|
||||
return new Plain(this.vertex1,this.vertex2,this.vertex3);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user