MVVM frame work done, under unit test

This commit is contained in:
Nitload
2024-07-25 04:41:24 +08:00
parent 924fe6eef7
commit da75200347
101 changed files with 8435 additions and 847 deletions
@@ -3,7 +3,9 @@ using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp.Graphics
@@ -11,11 +13,11 @@ namespace StgSharp.Graphics
public class PlainGeometryMesh
{
private PlainGeometry _shape;
private Image _texture;
private vec4d[] textureCoord;
private TextureProvider _texture;
//private Image _texture;
public PlainGeometryMesh(
PlainGeometry shape, Image texture, vec4d[] texCoord
PlainGeometry shape, Image texture, vec2d[] texCoord
)
{
if (shape==null)
@@ -27,19 +29,25 @@ namespace StgSharp.Graphics
throw new ArgumentNullException(nameof(texCoord));
}
_shape = shape;
_texture = texture;
if (shape.VertexCount > texCoord.Length)
{
throw new ArgumentException(paramName: nameof(texCoord), message: "Amount of texture coordination is too less");
}
textureCoord = texCoord;
return;
_texture = new TextureProvider(texture,texCoord);
}
public PlainGeometryMesh([NotNull]PlainGeometry shape, [NotNull]TextureProvider texture)
{
if (shape.VertexCount > texture.TextureCoordinate.Length)
{
throw new ArgumentException(paramName: nameof(texture), message: "Amount of texture coordination is too less");
}
_shape = shape;
}
public PlainGeometryMesh Resize(PlainGeometry newShape)
{
return new PlainGeometryMesh(newShape, _texture, textureCoord);
return new PlainGeometryMesh(newShape, _texture);
}
public ReadOnlySpan<int> MeshIndices => _shape.VertexIndices;
@@ -48,10 +56,10 @@ namespace StgSharp.Graphics
public Image TextureImage
{
get => _texture;
internal set => _texture = value;
get => _texture.ProvideImage();
internal set => _texture.ReadImage( value);
}
public vec4d[] TextureCoord => textureCoord;
public ReadOnlySpan<vec4d> TextureCoord => MemoryMarshal.Cast<vec2d,vec4d>( _texture.TextureCoordinate);
}
}