daily update on 20240508 by nitload youmu, partical added

This commit is contained in:
YoumuLiu
2024-05-09 04:14:36 +08:00
parent fc19ab3298
commit 56459deec5
58 changed files with 1507 additions and 431 deletions
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large Load Diff
Binary file not shown.
+1 -1
View File
@@ -1,3 +1,3 @@
System.Exception: Please select a driver project. Driver Verification Log cannot be created for the selected platform tool set: ''.
System.Exception: Driver Verification Log needs to be created on a 'Release' configuration. The current selected configuration is ''.
在 Microsoft.SdvMenuCommand.DriverVerificationLicense..ctor()
在 Microsoft.SdvMenuCommand.SdvMenuCommandPackage.StaticToolsLogoMenuItemCallback(Object sender, EventArgs e)
+57 -2
View File
@@ -8,11 +8,15 @@ using System.Threading.Tasks;
namespace StgSharp.Data
{
public partial class Area
/// <summary>
/// An independent storage area, used as the only folder type in root folder.
/// Contains several <see cref="SSD"/> files reference as virtual disc.
/// Data is actually stored in <see cref="SSD"/>s in certain RAID mode.
/// </summary>
public partial class Area:SSDFolder
{
private byte _id;
private List<SSD> discList;
private List<SSDrawHead> files;
public Area()
{
@@ -23,5 +27,56 @@ namespace StgSharp.Data
{
return discList[SSD].FindSegment(id);
}
/// <summary>
///
/// </summary>
/// <param name="head"></param>
/// <returns></returns>
public static SSDraw AnalyzeHead(SSDrawHead head)
{
if (head._head.globalID == 0)
{
return null;
}
SSDraw ret = new SSDraw();
foreach ((int, int) item in head)
{
}
return ret;
}
public SSDraw FindFile(string route, SerializableTypeCode typeCode)
{
int id = 0;
if (route.Contains('/'))
{
if (route.Contains(Serializer.GetNameTail(typeCode)))
{
route += Serializer.GetNameTail(typeCode);
}
id = idIndex[route];
return this.files[id];
}
if (route.Contains(Serializer.GetNameTail(typeCode)))
{
route += Serializer.GetNameTail(typeCode);
}
string[] folderRoute = route.Split('/');
int index = 0;
if (folderRoute[0] != ".")
{
index = 1;
}
SSDFolder temp = this;
for (; index < folderRoute.Length - 1; index++)
{
id = temp.idIndex[folderRoute[index]];
temp = temp.folders[id];
}
id = idIndex[folderRoute[folderRoute.Length-1]];
return temp.files[id];
}
}
}
+72 -13
View File
@@ -1,4 +1,34 @@
using StgSharp.Math;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="DataSegment.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;
@@ -10,31 +40,43 @@ using System.Threading.Tasks;
namespace StgSharp.Data
{
[StructLayout(LayoutKind.Explicit)]
public unsafe struct SSDSegment
[StructLayout(LayoutKind.Explicit, Size = StgSharp.ssdSegmentLength * 16)]
public unsafe struct SSDSegment : IComparable<int>, IComparable<SSDSegment>
{
[FieldOffset(16)] public fixed byte Data[16 * 16];
[FieldOffset(16)] public fixed byte Data[16 * (StgSharp.ssdSegmentLength - 1)];
[FieldOffset(12)] public int DataHash;
[FieldOffset(0 * 16)] public SSDSegmentHead Head;
[FieldOffset(8)] public int PreviousHash;
[FieldOffset(0 * 16)] public SSDSegmentHead Head;
public SSDSegment(int previousHash)
{
this.PreviousHash = previousHash;
}
public int ID
public static SSDSegment FromStream(byte[] stream)
{
get { return Head.globalID; }
set { Head.globalID = value; }
if (stream.Length != 16 * StgSharp.ssdSegmentLength)
{
throw new ArgumentException();
}
SSDSegment ret = new SSDSegment();
fixed (byte* bptr = stream)
{
ret.Head.data = *(M128*)bptr;
for (int i = 1; i < StgSharp.ssdSegmentLength; i++)
{
ret.WriteData<M128>(i - 1, *(M128*)(bptr + 16 * i));
}
}
return ret;
}
public byte this[int index]
{
get
{
if (index > (16 * 14) - 1)
if (index > (16 * (StgSharp.ssdSegmentLength - 1)) - 1)
{
throw new IndexOutOfRangeException();
}
@@ -43,7 +85,7 @@ namespace StgSharp.Data
set
{
if (index > (16 * 14) - 1)
if (index > (16 * (StgSharp.ssdSegmentLength - 1)) - 1)
{
throw new IndexOutOfRangeException();
}
@@ -51,6 +93,12 @@ namespace StgSharp.Data
}
}
public int ID
{
get { return Head.globalID; }
set { Head.globalID = value; }
}
public short Size => Head.size;
public void FillRandomBytes(int begin)
@@ -67,7 +115,7 @@ namespace StgSharp.Data
public byte[] GetBytes()
{
byte[] ret = new byte[16 * 18];
byte[] ret = new byte[16 * StgSharp.ssdSegmentLength];
fixed (M128* mptr = &Head.data)
{
fixed (byte* aptr = ret)
@@ -90,7 +138,7 @@ namespace StgSharp.Data
fixed (M128* mptr = &Head.data)
{
Vector4* vptr = (Vector4*)mptr;
for (int i = 0; i < 16; i += 1)
for (int i = 0; i < StgSharp.ssdSegmentLength - 1; i += 1)
{
v += (*vptr) * 31;
}
@@ -106,7 +154,7 @@ namespace StgSharp.Data
fixed (M128* mptr = &Head.data)
{
Vector4* vptr = (Vector4*)mptr;
for (int i = 0; i < 18; i++)
for (int i = 0; i < StgSharp.ssdSegmentLength; i++)
{
ret = (ret + (*vptr).GetHashCode()) * 31;
}
@@ -122,6 +170,7 @@ namespace StgSharp.Data
return *(tptr + index);
}
}
public unsafe void WriteData<T>(int index, T value) where T : struct
{
fixed (byte* bptr = Data)
@@ -131,6 +180,16 @@ namespace StgSharp.Data
}
}
int IComparable<int>.CompareTo(int other)
{
return ID.CompareTo(other);
}
int IComparable<SSDSegment>.CompareTo(SSDSegment other)
{
return ID.CompareTo(other.ID);
}
}
}
@@ -72,18 +72,18 @@ namespace StgSharp.Data
files = new Dictionary<int, SSDraw>();
}
public override byte SSDTypeCode => SerializableTypeCode.VirtualFolder;
public override SerializableTypeCode SSDTypeCode => SerializableTypeCode.VirtualFolder;
/// <summary>
/// Check out if this virtual folder contains certain file.
/// </summary>
/// <param name="name">Name of the file</param>
/// <param name="type">Type code defined in <see cref="SerializableTypeCode"/></param>
/// <param name="type">Type code defined as <see cref="SerializableTypeCode"/></param>
/// <returns>Id of the file in its virtual disc</returns>
public int FindFileId(string name, byte type)
public int FindFileId(string name, SerializableTypeCode type)
{
int fileid = 0;
if (idIndex.TryGetValue($"{name}{SerializableTypeCode.GetNameTail(type)}"
if (idIndex.TryGetValue($"{name}{Serializer.GetNameTail(type)}"
, out fileid) && !(type == SerializableTypeCode.VirtualFolder))
{
return fileid;
@@ -92,6 +92,7 @@ namespace StgSharp.Data
}
/// <summary>
/// Check out if this virtual folder contains certain file.
/// </summary>
@@ -107,9 +108,9 @@ namespace StgSharp.Data
return 0;
}
public SSDraw CreateFile(string name, byte type)
public SSDraw CreateFile(string name, SerializableTypeCode type)
{
SSDraw ret = new SSDraw(name + SerializableTypeCode.GetNameTail(type));
SSDraw ret = new SSDraw(name + Serializer.GetNameTail(type));
ret.ID = local.NewID();
return ret;
}
+75 -35
View File
@@ -49,7 +49,7 @@ namespace StgSharp.Data.FileIO
{
public const string FileType = "ssdraw";
public const int SegmentCapacity = 16 * 16;
public const int SegmentCapacity = 16 * (StgSharp.ssdSegmentLength - 1);
private Area home;
private int previousHash;
@@ -62,7 +62,6 @@ namespace StgSharp.Data.FileIO
internal SSDraw()
{
segments = new List<SSDSegment>();
}
public SSDraw(string name)
@@ -79,24 +78,11 @@ namespace StgSharp.Data.FileIO
internal SSDrawHead Head => _head;
//TODO 分析头,加载文件头,进一步加载全部的数据块
/// <summary>
///
/// </summary>
/// <param name="head"></param>
/// <returns></returns>
public static SSDraw AnalyzeHead(SSDrawHead head)
public SSDSegment[] GetSegments()
{
if (head._head.globalID == 0)
{
return null;
}
SSDraw ret = new SSDraw();
foreach ((int, int) item in head)
{
}
SSDSegment[] ret = segments.ToArray();
Array.Resize(ref ret, ret.Length + 1);
ret[ret.Length - 1] = Head.Data;
return ret;
}
@@ -118,7 +104,7 @@ namespace StgSharp.Data.FileIO
f.Close();
}
//TODO read raw 没写完
public static SSDraw readRaw(string route)
{
string[] routeFolders = route.Split('\\');
@@ -126,9 +112,20 @@ namespace StgSharp.Data.FileIO
{
throw new Exception($"File to open is not a {FileType} file.");
}
FileStream stream = File.Open(route, FileMode.Open);
return new SSDraw(string.Empty);
byte[] dataStream= new byte[16 * StgSharp.ssdSegmentLength];
SSDraw ret = new SSDraw();
using (FileStream stream = File.Open(route, FileMode.Open))
{
int offset = 0;
offset += stream.Read(dataStream,offset,16);
ret._head = new SSDrawHead(dataStream);
while (offset < stream.Length)
{
offset += stream.Read(dataStream, offset, 16);
ret.segments.Add(SSDSegment.FromStream(dataStream));
}
}
return ret;
}
public void WriteRaw(byte[] dataStream)
@@ -170,9 +167,26 @@ namespace StgSharp.Data.FileIO
public unsafe class SSDrawHead : IEnumerable<(int, int)>
{
private SSDSegment segmentRange;
private SSDSegment segmentData;
private string name;
internal SSDrawHead(byte[] data)
{
if (data.Length != 16* StgSharp.ssdSegmentLength)
{
throw new ArgumentException();
}
segmentData = new SSDSegment();
fixed (byte* bptr = data)
{
segmentData.Head.data = *(M128*)bptr;
for (int i = 1; i < StgSharp.ssdSegmentLength; i++)
{
segmentData.WriteData<M128>(i - 1,*(M128*)(bptr + 16 * i));
}
}
}
internal SSDrawHead(string name)
{
int hash;
@@ -190,16 +204,43 @@ namespace StgSharp.Data.FileIO
{
}
public (int begin, int end) this[byte index]
internal SSDSegment Data
{
get => segmentRange.ReadData<(int, int)>(index);
set => segmentRange.WriteData<(int, int)>(index, value);
get => segmentData;
}
public byte DiscIndex
public (int begin, int end) this[byte index]
{
get => _head.selfDefine_2;
internal set => _head.selfDefine_2 = value;
get => segmentData.ReadData<(int, int)>(index);
set => segmentData.WriteData<(int, int)>(index, value);
}
public unsafe string Name
{
get
{
byte[] bytes = new byte[15 * 16];
fixed (byte* bptr = segmentData.Data)
{
Marshal.Copy(
source: (IntPtr)bptr,
destination: bytes,
256, 15 * 16);
}
return Encoding.UTF8.GetString(bytes);
}
set
{
byte[] namecode = Encoding.UTF8.GetBytes(value);
fixed (byte* bptr = segmentData.Data)
{
Marshal.Copy(
source: namecode,
startIndex: 0,
destination: (IntPtr)(bptr + 256),
length: 15 * 16);
}
}
}
public byte TypeCode
@@ -210,7 +251,7 @@ namespace StgSharp.Data.FileIO
internal ref SSDSegmentHead _head
{
get => ref segmentRange.Head;
get => ref segmentData.Head;
}
internal byte pairCount
@@ -226,10 +267,9 @@ namespace StgSharp.Data.FileIO
}
}
public unsafe byte[] GetBytes()
{
return segmentRange.GetBytes();
return segmentData.GetBytes();
}
@@ -237,7 +277,7 @@ namespace StgSharp.Data.FileIO
{
for (int i = 0; i < pairCount; i++)
{
yield return segmentRange.ReadData<(int, int)>(i);
yield return segmentData.ReadData<(int, int)>(i);
}
}
@@ -245,7 +285,7 @@ namespace StgSharp.Data.FileIO
{
for (int i = 0; i < pairCount; i++)
{
yield return segmentRange.ReadData<(int, int)>(i);
yield return segmentData.ReadData<(int, int)>(i);
}
}
@@ -77,6 +77,14 @@ namespace StgSharp.Data
}
target = new BitArray(boolStream.ToArray());
}
/// <summary>
/// Serialize a <see cref="BitArray"/>, useful when writing
/// a Huffman tree index dictionary to file.
/// </summary>
/// <param name="bits"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public static byte[] Serialize(BitArray bits)
{
int size = (bits.Count / 4) + 1;
@@ -9,7 +9,7 @@ namespace StgSharp.Data
public abstract class SSDSerializable
{
public abstract byte SSDTypeCode { get; }
public abstract SerializableTypeCode SSDTypeCode { get; }
public abstract byte[] GetBytes();
@@ -18,39 +18,17 @@ namespace StgSharp.Data
internal abstract void BuildFromByteStream(byte[] stream);
}
public static class SerializableTypeCode
public enum SerializableTypeCode:byte
{
public const byte IndexTable = 1;
public const byte Image = 2;
public const byte Audio = 3;
public const byte Shader = 4;
public const byte Text = 5;
public const byte RawData = 6;
public const byte VirtualFolder = 7;
IndexTable = 1,
PixelImage = 2,
VectorImage = 3,
Audio = 4,
Shader = 5,
Text = 6,
RawData = 7,
VirtualFolder = 8,
public static string GetNameTail(byte typeCode)
{
switch (typeCode)
{
case IndexTable:
return "_indexT";
case Image:
return "_img";
case Audio:
return "_wav";
case Shader:
return "_gls";
case Text:
return "_txt";
case RawData:
return "_raw";
case VirtualFolder:
return "_f";
default:
throw new ArgumentException("Unknown file type");
}
}
}
public static partial class Serializer
@@ -66,5 +44,30 @@ namespace StgSharp.Data
serializableObject.BuildFromByteStream(stream);
return serializableObject;
}
public static string GetNameTail(SerializableTypeCode typeCode)
{
switch (typeCode)
{
case SerializableTypeCode.IndexTable:
return "_idt";
case SerializableTypeCode.PixelImage:
return "_pim";
case SerializableTypeCode.VectorImage:
return "_vim";
case SerializableTypeCode.Audio:
return "_wav";
case SerializableTypeCode.Shader:
return "_gls";
case SerializableTypeCode.Text:
return "_txt";
case SerializableTypeCode.RawData:
return "_raw";
case SerializableTypeCode.VirtualFolder:
return "_fod";
default:
throw new ArgumentException("Unknown file type");
}
}
}
}
+2 -1
View File
@@ -31,6 +31,7 @@
using StgSharp.Geometries;
using StgSharp.Math;
using System;
using System.Collections.Generic;
namespace StgSharp
@@ -42,7 +43,7 @@ namespace StgSharp
internal Point _basePoint;
internal LinkedList<PlainGeometry> _collisionBox;
internal Sensor<PlainGeometry> _collisionSensor;
internal GetLocationHandler _movHandler;
internal Func<int,vec3d> _movHandler;
internal Point _pos;
internal Point _position;
internal string _texture;
@@ -45,6 +45,7 @@ namespace StgSharp
static byte[] _currentHash;
private static bool _inited;
internal const int ssdSegmentLength = 16;
public static byte[] CurrentAssemblyHash
{
@@ -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;
}
}
@@ -65,7 +65,7 @@ namespace StgSharp.Graphics
internal readonly glHandleSet handle;
public readonly ShaderType type;
public override byte SSDTypeCode => SerializableTypeCode.Shader;
public override SerializableTypeCode SSDTypeCode => SerializableTypeCode.Shader;
internal unsafe Shader(glHandleSet handle, ShaderType usage)
{
+1 -1
View File
@@ -65,7 +65,7 @@ namespace StgSharp.Graphics
public int Width => info.width;
public override byte SSDTypeCode => SerializableTypeCode.Image;
public override SerializableTypeCode SSDTypeCode => SerializableTypeCode.PixelImage;
~Image()
{
+4
View File
@@ -59,6 +59,10 @@ namespace StgSharp.Math
{
v = vec;
}
internal vec2d(Vector4 vec)
{
this.vec = vec;
}
public vec2d(float x, float y)
{
-1
View File
@@ -36,7 +36,6 @@ using System.Collections.Generic;
using System.Data;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics.Arm;
using System.Security.Cryptography;
using System.Text;
@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+66efce19fcb461782c49255dc5500144f8c267e6")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+fc19ab32989e5a60c1061ad8ebea16cd5a3c6ff0")]
[assembly: System.Reflection.AssemblyProductAttribute("StgSharp")]
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharp")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
@@ -201,10 +201,17 @@ namespace StgSharp
protected override void ProcessInput()
{
float movement = 0.005f;
if (InternalIO.glfwGetKey(CanvasHandle, (int)KeyboardKey.ESCAPE)
== KeyStatus.PRESS)
{
InternalIO.glfwSetWindowShouldClose(CanvasHandle, 1);
return;
}
if (InternalIO.glfwGetKey(CanvasHandle, (int)KeyboardKey.LEFT_SHIFT)
== KeyStatus.PRESS)
{
movement = 0.002f;
}
if (InternalIO.glfwGetKey(this.CanvasHandle, GLconst.GLFW_KEY_UP) == KeyStatus.PRESS)
{
@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharpDebug")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+66efce19fcb461782c49255dc5500144f8c267e6")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+fc19ab32989e5a60c1061ad8ebea16cd5a3c6ff0")]
[assembly: System.Reflection.AssemblyProductAttribute("StgSharpDebug")]
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharpDebug")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
@@ -1 +1 @@
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/66efce19fcb461782c49255dc5500144f8c267e6/*"}}
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/fc19ab32989e5a60c1061ad8ebea16cd5a3c6ff0/*"}}
Binary file not shown.
@@ -181,8 +181,7 @@
"RelativeToolTip": "StgSharpData\\SSD\\SSD.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAABAAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-04-18T01:06:01.434Z",
"EditorCaption": ""
"WhenOpened": "2024-04-18T01:06:01.434Z"
},
{
"$type": "Document",
@@ -234,7 +233,7 @@
"RelativeDocumentMoniker": "StgSharpData\\SSD\\SSDraw.cs",
"ToolTip": "D:\\NitloadIndustry\\\u7814\u7A76\u9879\u76EE\\1-Flagship\\TH2020\\ProjectFile\\\u7F16\u7801\u5668\\StgSharpData\\SSD\\SSDraw.cs",
"RelativeToolTip": "StgSharpData\\SSD\\SSDraw.cs",
"ViewState": "AQIAADYAAAAAAAAAAAA1wDwAAAAnAAAA",
"ViewState": "AQIAAAAAAAAAAAAAAAAAADwAAAAnAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-04-16T18:46:55.737Z",
"EditorCaption": ""
@@ -326,8 +325,7 @@
"RelativeToolTip": "SSD_Test\\UnitTest1.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAACcAAAAqAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-04-15T08:44:36.91Z",
"EditorCaption": ""
"WhenOpened": "2024-04-15T08:44:36.91Z"
},
{
"$type": "Document",