daily update on 20240427 by nitload youmu

This commit is contained in:
YoumuLiu
2024-04-27 05:09:38 +08:00
parent dd6e8247bf
commit f83a130074
52 changed files with 1470 additions and 271 deletions
@@ -11,13 +11,19 @@ namespace StgSharp.Geometries
public abstract class ICoord
{
protected Matrix44 coordMat;
protected List<vec4d> pointBuffer;
public ICoord()
{
pointBuffer = new List<vec4d>();
}
public abstract Matrix44 GlobalCoordTransformation
{
get;
}
public abstract vec3d Center
public abstract vec3d Origin
{
get;
}
@@ -36,5 +42,18 @@ namespace StgSharp.Geometries
{
get;
}
public T BuildGeometry<T>(params vec4d[] defaultVertex) where T : IGeometry
{
T ret = Activator.CreateInstance<T>();
ret.GetVertexHandle(this, ret.VertexCount);
for (int i = 0; i < ret.VertexCount; i++)
{
ret[i] = defaultVertex[i];
}
return ret;
}
}
}
@@ -1,4 +1,6 @@
using System;
using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -6,9 +8,18 @@ using System.Threading.Tasks;
namespace StgSharp.Geometries
{
public class StreamLocalCoordinate:ICoord
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 Z_axis => throw new NotImplementedException();
}
}
@@ -0,0 +1,66 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="IGeometry.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.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Geometries
{
public interface IGeometry
{
public vec4d this[int index]
{
get;
set;
}
public int VertexCount
{
get;
}
public vec4d[] VertexStream
{
get;
}
public void GetVertexHandle(ICoord coordinate, int count);
public void Transform(Matrix44 transFormMatrix);
}
}
@@ -77,9 +77,9 @@ namespace StgSharp.Geometries
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);
center.Position = this.coordinate.Origin + MoveCenter(tick);
beginPoint.Position = this.coordinate.Origin + MovBegin(tick);
endPoint.Position = this.coordinate.Origin + MovEnd(tick);
}
}
@@ -79,9 +79,9 @@ namespace StgSharp.Geometries
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);
center.Position = this.coordinate.Origin + MoveCenter(tick);
pointOnCircle.Position = this.coordinate.Origin + UpdateRadius(tick);
pointOnPlain.Position = this.coordinate.Origin + UpdatePlain(tick);
}
}
@@ -96,8 +96,8 @@ namespace StgSharp.Geometries
internal override void UpdateCoordinate(int tick)
{
beginPoint.Position = coordinate.origin + MoveBeginPoint(time);
endPoint.Position = coordinate.origin + MoveEndPoint(time);
beginPoint.Position = coordinate.Origin + MoveBeginPoint(time);
endPoint.Position = coordinate.Origin + MoveEndPoint(time);
}
}
@@ -31,32 +31,44 @@
using StgSharp.Graphics;
using StgSharp.Math;
using System;
namespace StgSharp.Geometries
{
/// <summary>
/// 平面几何体。包含三角形,对称四边形,自由多边形等。最多可由16个点参数定义。
/// </summary>
public abstract class PlainGeometry
public abstract class PlainGeometry: IGeometry
{
protected TimeSpanProvider time;
internal PartialPlainCoordinate coordinate;
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 PartialPlainCoordinate ReferenceCoordinate => this.coordinate;
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>
@@ -72,6 +84,16 @@ namespace StgSharp.Geometries
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();
}
}
@@ -49,7 +49,7 @@ namespace StgSharp.Geometries
{
}
public Polygon4(PartialPlainCoordinate coordinate,
public Polygon4(ICoord coordinate,
vec2d topLeft,
vec2d topRight,
vec2d bottomRight,
@@ -153,11 +153,11 @@ namespace StgSharp.Geometries
internal override void UpdateCoordinate(int tick)
{
int nowTick = tick - BornTime;
vertexMat.vec0 = (coordinate.origin + movVertex01(nowTick)).vec;
vertexMat.vec1 = (coordinate.origin + movVertex02(nowTick)).vec;
vertexMat.vec2 = (coordinate.origin + movVertex03(nowTick)).vec;
vertexMat.vec3 = (coordinate.origin + movVertex04(nowTick)).vec;
vertexMat.vec4 = (coordinate.origin + movVertex05(nowTick)).vec;
vertexMat.vec0 = (coordinate.Origin + movVertex01(nowTick)).vec;
vertexMat.vec1 = (coordinate.Origin + movVertex02(nowTick)).vec;
vertexMat.vec2 = (coordinate.Origin + movVertex03(nowTick)).vec;
vertexMat.vec3 = (coordinate.Origin + movVertex04(nowTick)).vec;
vertexMat.vec4 = (coordinate.Origin + movVertex05(nowTick)).vec;
}
}
@@ -144,7 +144,7 @@ namespace StgSharp.Geometries
internal override void UpdateCoordinate(int tick)
{
int nowTick = tick - BornTime;
Vector4 origin = coordinate.origin.vec;
Vector4 origin = coordinate.Origin.vec;
vertexMat.vec0 = origin + movVertex0(nowTick).vec;
vertexMat.vec1 = origin + movVertex1(nowTick).vec;
vertexMat.vec2 = origin + movVertex2(nowTick).vec;
@@ -116,9 +116,9 @@ namespace StgSharp.Geometries
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.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;
}
}