daily update on 20240828 by nitload youmu, autotexture added

This commit is contained in:
Nitload
2024-08-28 10:58:31 +08:00
parent d082071f2d
commit 1ee4e4a42f
586 changed files with 60910 additions and 123106 deletions
@@ -29,7 +29,7 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Graphics;
using StgSharp.Graphics.GL;
using StgSharp.Graphics.OpenGL;
using StgSharp.Graphics.ShaderEdit;
using StgSharp.Math;
@@ -116,7 +116,7 @@ namespace StgSharp.Graphics
{
if (uniformName.Length != 1)
{
throw new ArgumentException();
throw new ArgumentException("Camera needs only one uniform.", nameof(uniformName));
}
convertedUniform = source.GetUniform<Matrix44>(uniformName[0]);
}
@@ -142,8 +142,8 @@ namespace StgSharp.Graphics
public unsafe void SetAllUniforms()
{
//Console.WriteLine(Projection * View);
glFunc.SetUniformValue(convertedUniform, Projection * View);
//Console.WriteLine(Projection * ViewBase);
OpenGL.OpenGLFunction.CurrentGL.SetUniformValue(convertedUniform, Projection * View);
}
public void SetViewDirection(vec3d position, vec3d target, vec3d up)
+31 -1
View File
@@ -1,4 +1,34 @@
using System;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="IVector.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -1,4 +1,34 @@
using StgSharp.Data;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="Vector.Normalize.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.Data;
using StgSharp.Math;
using System;
@@ -13,6 +43,15 @@ namespace StgSharp.Math
{
public static partial class Linear
{
public static vec4d Normalize(vec4d vec)
{
return new vec4d { vec = Vector4.Normalize(vec.vec) };
}
public static vec3d Normalize(vec3d vec)
{
return new vec3d { vec = Vector4.Normalize(vec.vec) };
}
public static unsafe void Normalize(ref vec4d source, ref vec4d target)
{
Vector4 s = source.vec;
@@ -35,7 +74,7 @@ namespace StgSharp.Math
Vector3 t = target.v;
s = Vector3.Normalize(s);
Vector3 projection = Vector3.Dot(t, s) / Vector3.Dot(s, s) * s;
Vector3 projection = (Vector3.Dot(t, s) / Vector3.Dot(s, s)) * s;
t -= projection;
t = Vector3.Normalize(t);
@@ -43,13 +82,5 @@ namespace StgSharp.Math
target.v = t;
}
public static vec4d Normalize(vec4d vec)
{
return new vec4d() { vec = Vector4.Normalize(vec.vec) };
}
public static vec3d Normalize(vec3d vec)
{
return new vec3d() { vec = Vector4.Normalize(vec.vec) };
}
}
}
+5 -5
View File
@@ -39,7 +39,7 @@ namespace StgSharp.Math
/// Vec2Ds in StgSharp are default used as colum vector.
/// </summary>
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 16)]
public struct vec2d:IVector
public struct vec2d : IVector
{
[FieldOffset(0)] internal unsafe fixed float num[2];
@@ -97,15 +97,15 @@ namespace StgSharp.Math
{
return new vec2d(vec.v * value);
}
public static vec2d operator *(float value, vec2d vec)
{
return new vec2d(vec.v * value);
}
public static vec2d operator /(vec2d vec, float value)
{
return new vec2d(vec.v / value);
}
public static vec2d operator *(float value, vec2d vec)
{
return new vec2d(vec.v * value);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static vec2d operator +(vec2d left, vec2d right)
+12 -12
View File
@@ -82,6 +82,18 @@ namespace StgSharp.Math
v = new Vector3(x, y, z);
}
public unsafe vec2d XY
{
get => new vec2d(this.vec);
set
{
fixed (Vector3* vptr = &v)
{
*(Vector2*)vptr = value.v;
}
}
}
public vec3d XYZ
{
get { return new vec3d(v); }
@@ -200,18 +212,6 @@ namespace StgSharp.Math
return v;
}
public unsafe vec2d XY
{
get => new vec2d(this.vec);
set
{
fixed (Vector3* vptr = &v)
{
*(Vector2*)vptr = value.v;
}
}
}
}
public static class Vec3d
+27 -26
View File
@@ -1,6 +1,6 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="Vec4d.cs"
// file="vec4d.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
@@ -28,7 +28,6 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Data;
using StgSharp.Math;
@@ -85,6 +84,16 @@ namespace StgSharp.Math
vec = new Vector4(x, y, z, w);
}
public unsafe vec2d XY
{
get => new vec2d(vec);
set
{
X = value.X;
Y = value.Y;
}
}
public unsafe vec3d XYZ
{
get => new vec3d(vec);
@@ -95,14 +104,11 @@ namespace StgSharp.Math
W = w;
}
}
public unsafe vec2d XY
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static vec4d Add(vec4d left, vec4d right)
{
get => new vec2d(vec);
set
{
X = value.X;
Y = value.Y;
}
return left + right;
}
public override bool Equals(object obj)
@@ -115,11 +121,23 @@ namespace StgSharp.Math
return vec.GetHashCode();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static vec4d Subtract(vec4d left, vec4d right)
{
return left - right;
}
public override string ToString()
{
return vec.ToString();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static vec4d operator -(vec4d left, vec4d right)
{
return new vec4d(left.vec - right.vec);
}
public static bool operator !=(vec4d left, vec4d right)
{
return !(left == right);
@@ -143,12 +161,6 @@ namespace StgSharp.Math
return new vec4d(left.vec + right.vec);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static vec4d operator -(vec4d left, vec4d right)
{
return new vec4d(left.vec - right.vec);
}
public static bool operator ==(vec4d left, vec4d right)
{
return left.vec == right.vec;
@@ -164,16 +176,5 @@ namespace StgSharp.Math
return vec == other.vec;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static vec4d Subtract(vec4d left, vec4d right)
{
return left - right;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static vec4d Add(vec4d left, vec4d right)
{
return left + right;
}
}
}
+34 -3
View File
@@ -1,4 +1,34 @@
using System;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="Compare.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -8,10 +38,11 @@ namespace StgSharp.Math
{
public static partial class Scaler
{
public static float MaxOf(params float[] stream)
{
float ret = stream[0];
foreach (var num in stream)
foreach (float num in stream)
{
if (ret < num)
{
@@ -23,7 +54,7 @@ namespace StgSharp.Math
public static float MinOf(params float[] stream)
{
float ret = stream[0];
foreach (var num in stream)
foreach (float num in stream)
{
if (ret > num)
{
@@ -46,6 +46,14 @@ namespace StgSharp.Math
private static byte[] randomSeed;
internal static float currentSeed
#if DEBUG
= 0.5f;
#else
= Abs(System.DateTime.UtcNow.GetHashCode());
#endif
/// <summary>
/// returns a random float number between 0 and 1.
/// </summary>
@@ -123,13 +131,5 @@ namespace StgSharp.Math
return *(int*)&seedValue;
}
internal static float currentSeed
#if DEBUG
= 0.5f;
#else
= Abs(System.DateTime.UtcNow.GetHashCode());
#endif
}
}