using StgSharp.Geometries; using StgSharp.Math; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace StgSharp.Graphics { public class PlainGeometryMesh { private PlainGeometry _shape; private Image _texture; private vec4d[] textureCoord; public PlainGeometryMesh( PlainGeometry shape, Image texture, vec4d[] texCoord ) { if (shape==null) { throw new ArgumentNullException(nameof(shape)); } if (texCoord == null) { 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; } public PlainGeometryMesh Resize(PlainGeometry newShape) { return new PlainGeometryMesh(newShape, _texture, textureCoord); } public ReadOnlySpan MeshIndices => _shape.VertexIndices; public vec4d[] VertexArray => _shape.VertexStream; public Image TextureImage { get => _texture; internal set => _texture = value; } public vec4d[] TextureCoord => textureCoord; } }