daily update on 20230516 by nitload youmu, geometry interfaces created between cs and c
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,17 @@
|
||||
using StgSharp.Math;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public unsafe struct triangleVertexArray
|
||||
{
|
||||
public vec3d* vertex1Ptr;
|
||||
internal vec3d* vertex2Ptr;
|
||||
internal vec3d* vertex3Ptr;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -31,9 +31,9 @@ namespace StgSharp.Geometries
|
||||
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);
|
||||
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();
|
||||
|
||||
@@ -35,9 +35,9 @@ namespace StgSharp.Geometries
|
||||
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);
|
||||
center.Position = refOrigin.Position + MoveCenter(tick);
|
||||
pointOnCircle.Position = refOrigin.Position + UpdateRadius(tick);
|
||||
pointOnPlain.Position = refOrigin.Position + UpdatePlain(tick);
|
||||
}
|
||||
|
||||
public override Line[] GetAllSides()
|
||||
|
||||
@@ -15,7 +15,11 @@ namespace StgSharp.Geometries
|
||||
internal readonly Point refOrigin;
|
||||
|
||||
public Point RefOrigin { get { return refOrigin; } }
|
||||
public abstract Point RefPoint01{ get; }
|
||||
|
||||
public abstract Point RefPoint01
|
||||
{
|
||||
get;
|
||||
}
|
||||
public abstract Point RefPoint02{ get; }
|
||||
public abstract Point RefPoint03{ get; }
|
||||
public uint BornTime => bornTick;
|
||||
|
||||
@@ -39,8 +39,8 @@ namespace StgSharp.Geometries
|
||||
internal override void OnRender(uint tick)
|
||||
{
|
||||
tick -= bornTick;
|
||||
beginPoint._position = refOrigin._position + MoveBeginPoint(tick);
|
||||
endPoint._position = refOrigin._position + MoveEndPoint(tick);
|
||||
beginPoint.Position = refOrigin.Position + MoveBeginPoint(tick);
|
||||
endPoint.Position = refOrigin.Position + MoveEndPoint(tick);
|
||||
}
|
||||
|
||||
public override Line[] GetAllSides()
|
||||
|
||||
@@ -44,10 +44,10 @@ namespace StgSharp.Geometries
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ namespace StgSharp.Geometries
|
||||
|
||||
public Plain(Point p1, Point p2, Point p3)
|
||||
{
|
||||
vec3d origin = p1._position;
|
||||
vec3d v1 = p2._position - origin;
|
||||
vec3d v2 = p3._position - origin;
|
||||
vec3d origin = p1.Position;
|
||||
vec3d v1 = p2.Position - origin;
|
||||
vec3d v2 = p3.Position - origin;
|
||||
|
||||
|
||||
vec1 = v1 - v2 * (v1.Y / v2.Y); //计算平面在xz平面上的方向投影
|
||||
|
||||
@@ -3,25 +3,43 @@ using StgSharp.Math;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Security.Cryptography;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class Point : INode<Point>
|
||||
public unsafe class Point : INode<Point>
|
||||
{
|
||||
internal vec3d* postionPtr;
|
||||
|
||||
internal vec3d _position;
|
||||
internal Point(vec3d* ptr)
|
||||
{
|
||||
postionPtr = ptr;
|
||||
}
|
||||
|
||||
public vec3d Position
|
||||
{
|
||||
get { return (*this.postionPtr); }
|
||||
set { (*this.postionPtr) = value; }
|
||||
}
|
||||
|
||||
public float X
|
||||
{
|
||||
get { return this._position.X; }
|
||||
get { return (*this.postionPtr).X; }
|
||||
set { (*this.postionPtr).X = value; }
|
||||
}
|
||||
|
||||
public float Y
|
||||
{
|
||||
get { return this._position.Y; }
|
||||
get { return (*this.postionPtr).Y; }
|
||||
set { (*this.postionPtr).Y = value; }
|
||||
}
|
||||
|
||||
public float Z
|
||||
{
|
||||
get { return (*this.postionPtr).Z; }
|
||||
set { (*this.postionPtr).Z = value; }
|
||||
}
|
||||
|
||||
internal readonly bool isVertex;
|
||||
@@ -43,8 +61,10 @@ namespace StgSharp.Geometries
|
||||
|
||||
public bool IsOnPlain(IPlainGeometry geo)
|
||||
{
|
||||
return this._position * geo.GetPlain().plainParameter == 1;
|
||||
return (*this.postionPtr) * geo.GetPlain().plainParameter == 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,10 +65,10 @@ namespace StgSharp.Geometries
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,11 +65,11 @@ namespace StgSharp.Geometries
|
||||
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);
|
||||
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()
|
||||
|
||||
@@ -73,12 +73,12 @@ namespace StgSharp.Geometries
|
||||
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);
|
||||
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()
|
||||
|
||||
@@ -27,12 +27,12 @@ namespace StgSharp.Geometries
|
||||
|
||||
public sealed override vec3d MovVertex03(uint tick)
|
||||
{
|
||||
return this.center._position * 2 - this.vertex01._position;
|
||||
return this.center.Position * 2 - this.vertex01.Position;
|
||||
}
|
||||
|
||||
public sealed override vec3d MovVertex04(uint tick)
|
||||
{
|
||||
return this.center._position * 2 - this.vertex02._position;
|
||||
return this.center.Position * 2 - this.vertex02.Position;
|
||||
}
|
||||
|
||||
internal override sealed void OnRender(uint tick)
|
||||
|
||||
@@ -7,8 +7,12 @@ using System.Text;
|
||||
|
||||
namespace StgSharp.Geometries
|
||||
{
|
||||
public class Triangle :IPlainGeometry
|
||||
|
||||
|
||||
public unsafe class Triangle :IPlainGeometry
|
||||
{
|
||||
public triangleVertexArray vertexArray;
|
||||
|
||||
internal Point vertex1;
|
||||
internal Point vertex2;
|
||||
internal Point vertex3;
|
||||
@@ -16,11 +20,8 @@ namespace StgSharp.Geometries
|
||||
internal GetLocationHandler movVertex02Opearion = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal GetLocationHandler movVertex03Opearion = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
|
||||
|
||||
public override sealed Point RefPoint01=> vertex1;
|
||||
|
||||
public override sealed Point RefPoint01 => vertex1;
|
||||
public override sealed Point RefPoint02 => vertex2;
|
||||
|
||||
public override sealed Point RefPoint03 => vertex3;
|
||||
|
||||
public GetLocationHandler MovVertex01Operation => this.movVertex01Opearion;
|
||||
@@ -33,13 +34,20 @@ namespace StgSharp.Geometries
|
||||
|
||||
public virtual vec3d MovVertex03(uint tick) => movVertex03Opearion.Invoke(tick);
|
||||
|
||||
public Triangle()
|
||||
{
|
||||
this.vertexArray = GeometryIO.initTriangleVertex();
|
||||
this.vertex1.Position = *vertexArray.vertex1Ptr;
|
||||
this.vertex2.Position = *vertexArray.vertex2Ptr;
|
||||
this.vertex3.Position = *vertexArray.vertex3Ptr;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
vertex1.Position = RefOrigin.Position + MovVertex01(tick);
|
||||
vertex2.Position = RefOrigin.Position + MovVertex02(tick);
|
||||
vertex3.Position = RefOrigin.Position + MovVertex03(tick);
|
||||
}
|
||||
|
||||
public override Line[] GetAllSides()
|
||||
|
||||
@@ -10,18 +10,20 @@ namespace StgSharp
|
||||
public static class Graphic
|
||||
{
|
||||
private const string glPackageName = "StgSharpGraphics.dll";
|
||||
private static GraphicIO glIO;
|
||||
//private static GraphicIO glIO;
|
||||
|
||||
static Graphic()
|
||||
{
|
||||
glIO = InitPackage();
|
||||
initWindow = glIO.initWindowPtr;
|
||||
//glIO = InitPackage();
|
||||
//initWindow = glIO.initWindowPtr;
|
||||
}
|
||||
|
||||
public static InitWindow initWindow ;
|
||||
|
||||
/*
|
||||
[DllImport(glPackageName, EntryPoint = "initPackage")]
|
||||
internal static extern GraphicIO InitPackage();
|
||||
/**/
|
||||
|
||||
[DllImport(glPackageName, EntryPoint = "initWindow")]
|
||||
public static extern void Window(int width,int height);
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using StgSharp.Geometries;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
internal static unsafe class GeometryIO
|
||||
{
|
||||
[DllImport("StgSharpGraphics.dll", EntryPoint = "initTriangle")]
|
||||
internal static unsafe extern triangleVertexArray initTriangleVertex();
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ namespace StgSharp
|
||||
}
|
||||
public Pool( Geometries.Rectangle area)
|
||||
{
|
||||
vec3d vec = area.vertex01._position - area.vertex02._position;
|
||||
vec3d vec = area.vertex01.Position - area.vertex02.Position;
|
||||
if ((vec.X==0||vec.Y==0)&&vec.Z==0)
|
||||
{
|
||||
Line[] barders = area.GetAllSides();
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
599c74c5e84e14226e429f58dbf2e985f60f29fc
|
||||
e1462487ad425beae2b2fdc45a1ba680192e338c
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -6,48 +6,15 @@ using StgSharp.Math;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.Intrinsics.X86;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
internal class Program
|
||||
{
|
||||
private unsafe static void Main(string[] args)
|
||||
{
|
||||
#if DEBUG
|
||||
Graphic.Window(800,600);
|
||||
int a = Graphic.initWindow(800,600);
|
||||
/*
|
||||
double time;
|
||||
TimeSpan span;
|
||||
float mf = 1.2e10f;
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
Stopwatch stopwatch01 = Stopwatch.StartNew();
|
||||
stopwatch01.Start();
|
||||
for (int t = 0; t < 1000000; t++)
|
||||
{
|
||||
mf = MathF.Sqrt(t);
|
||||
}
|
||||
stopwatch01.Stop();
|
||||
span = stopwatch01.Elapsed;
|
||||
time = span.TotalMilliseconds;
|
||||
Console.WriteLine(time);
|
||||
|
||||
Stopwatch stopwatch02 = new Stopwatch();
|
||||
stopwatch02.Start();
|
||||
for (int t = 0; t < 1000000; t++)
|
||||
{
|
||||
mf = Calc.Sqrt(t);
|
||||
}
|
||||
stopwatch02.Stop();
|
||||
span = stopwatch02.Elapsed;
|
||||
time = span.TotalMilliseconds;
|
||||
Console.WriteLine(time);
|
||||
|
||||
Console.WriteLine();
|
||||
}
|
||||
/**/
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -73,3 +73,9 @@ STGSHARPGRAPHICS_API int initWindow(int width, int height)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void renderTriangle()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// 符号视为是被导出的。
|
||||
|
||||
#include "internal.h"
|
||||
#include "geometryHandler.h"
|
||||
|
||||
#define STGSHARPGRAPHICS_API __declspec(dllexport)
|
||||
|
||||
@@ -21,4 +22,6 @@ extern STGSHARPGRAPHICS_API int* versionInfo;
|
||||
|
||||
STGSHARPGRAPHICS_API int fnStgSharpGraphics(void);
|
||||
STGSHARPGRAPHICS_API int initWindow(int width, int height);
|
||||
STGSHARPGRAPHICS_API IOpackage initPackage(void);
|
||||
STGSHARPGRAPHICS_API IOpackage initPackage(void);
|
||||
|
||||
STGSHARPGRAPHICS_API TriangleVertexHandler initTriangle(void);
|
||||
|
||||
@@ -162,6 +162,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework.h" />
|
||||
<ClInclude Include="geometryHandler.h" />
|
||||
<ClInclude Include="glad\glad.h" />
|
||||
<ClInclude Include="GLFW\glfw3.h" />
|
||||
<ClInclude Include="GLFW\glfw3native.h" />
|
||||
@@ -172,6 +173,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.c" />
|
||||
<ClCompile Include="geometryHandler.c" />
|
||||
<ClCompile Include="glad.c" />
|
||||
<ClCompile Include="pch.c">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
|
||||
@@ -42,6 +42,9 @@
|
||||
<ClInclude Include="internal.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="geometryHandler.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="StgSharpGraphics.c">
|
||||
@@ -56,6 +59,9 @@
|
||||
<ClCompile Include="glad.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="geometryHandler.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Library Include="glfw3.lib">
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#include "glad/glad.h"
|
||||
#include "GLFW/glfw3.h"
|
||||
#include "stdio.h"
|
||||
#include "StgSharpGraphics.h"
|
||||
|
||||
|
||||
|
||||
STGSHARPGRAPHICS_API TriangleVertexHandler initTriangle(void)
|
||||
{
|
||||
float vertex[9] = {
|
||||
0,0,0,
|
||||
0,0,0,
|
||||
0,0,0,
|
||||
};
|
||||
|
||||
TriangleVertexHandler tri;
|
||||
|
||||
tri.vertex1 = &vertex[0];
|
||||
tri.vertex2 = &vertex[3];
|
||||
tri.vertex3 = &vertex[6];
|
||||
|
||||
return tri;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "glad/glad.h"
|
||||
#include "GLFW/glfw3.h"
|
||||
#include "stdio.h"
|
||||
|
||||
typedef struct TriangleVertexHandler
|
||||
{
|
||||
float* vertex1;
|
||||
float* vertex2;
|
||||
float* vertex3;
|
||||
}TriangleVertexHandler;
|
||||
@@ -7,10 +7,10 @@
|
||||
|
||||
#define init InitProgram;
|
||||
|
||||
|
||||
|
||||
typedef struct internalIO
|
||||
{
|
||||
void (*InitWindow)(int width,int height);
|
||||
}IOpackage;
|
||||
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user