diff --git a/Raylib-cs/types/Mesh.cs b/Raylib-cs/types/Mesh.cs index b17e01c..6ef7c5b 100644 --- a/Raylib-cs/types/Mesh.cs +++ b/Raylib-cs/types/Mesh.cs @@ -189,22 +189,22 @@ public unsafe struct Mesh public int BoneCount; /// - /// Vertex bone ids, up to 4 bones influence by vertex (skinning) + /// Vertex bone indices, up to 4 bones influence by vertex (skinning) (shader-location = 6) /// - public byte* boneIndices = default; + public byte* BoneIndices = default; /// - /// Vertex bone weight, up to 4 bones influence by vertex (skinning) + /// Vertex bone weight, up to 4 bones influence by vertex (skinning) (shader-location = 7) /// public float* BoneWeights = default; /// - /// Animated vertex positions after bones transformations, CPU skinning + /// Animated vertex positions (after bones transformations) /// public float* AnimVertices = default; /// - /// Animated normals after bones transformations, CPU skinning + /// Animated normals (after bones transformations) /// public float* AnimNormals = default; @@ -218,7 +218,7 @@ public unsafe struct Mesh public uint VaoId = default; /// - /// OpenGL Vertex Buffer Objects id (default vertex data, uint[]) + /// OpenGL Vertex Buffer Objects id (default vertex data) /// public uint* VboId = default; diff --git a/Raylib-cs/types/Model.cs b/Raylib-cs/types/Model.cs index e6548b4..41c6968 100644 --- a/Raylib-cs/types/Model.cs +++ b/Raylib-cs/types/Model.cs @@ -20,6 +20,9 @@ public unsafe struct BoneInfo /// public int Parent; + /// + /// Bone name as string + /// public string NameToString() { fixed (sbyte* name = Name) @@ -48,16 +51,20 @@ public unsafe struct ModelSkeleton /// /// Bones base transformation (Transform[]) /// - public Transform* ModelAnimPose; + public Transform* BindPose; - public Span ModelAnimPoseAsSpan() + public Span BindPoseAsSpan() { - return new Span(ModelAnimPose, BoneCount); + if (BindPose == null || BoneCount <= 0) + { + return Span.Empty; + } + + return new Span(BindPose, BoneCount); } public Span BonesAsSpan() { - if (Bones == null || BoneCount <= 0) { return Span.Empty; @@ -69,7 +76,7 @@ public unsafe struct ModelSkeleton // Note: // Anim pose, an array of Transform[] -// typedef Transform *ModelAnimPose; It's just an pointer array. +// typedef Transform *ModelAnimPose; It's just a pointer array. /// /// Model type @@ -122,26 +129,48 @@ public unsafe struct Model /// public Matrix4x4* BoneMatrices; + /// + /// Bones animated transformation matrices as span. Based on Skeleton.BoneCount length + /// public Span BoneMatricesAsSpan() { + if (BoneMatrices == null || Skeleton.BoneCount <= 0) + { + return Span.Empty; + } + return new Span(BoneMatrices, Skeleton.BoneCount); } + /// + /// Current animation pose as span. Based on Skeleton.BoneCount length + /// public Span CurrentPoseAsSpan() { + if (CurrentPose == null || Skeleton.BoneCount <= 0) + { + return Span.Empty; + } + return new Span(CurrentPose, Skeleton.BoneCount); } + /// + /// Mesh material number as span. Based on MaterialCount length + /// public Span MeshMaterialAsSpan() { - if (MeshMaterial == null || MeshCount <= 0) + if (MeshMaterial == null || MaterialCount <= 0) { return Span.Empty; } - return new Span(MeshMaterial, MeshCount); + return new Span(MeshMaterial, MaterialCount); } + /// + /// Meshes as span. based on MeshCount length + /// public Span MeshesAsSpan() { if (Meshes == null || MeshCount <= 0) @@ -170,7 +199,7 @@ public unsafe struct ModelAnimation public readonly int BoneCount; /// - /// Number of animation frames + /// Number of animation key frames /// public readonly int KeyFrameCount; @@ -179,6 +208,10 @@ public unsafe struct ModelAnimation /// public Transform** KeyframePoses; + + /// + /// Animation sequence keyframe poses as span. Based on KeyFrameCount length + /// public Span GetKeyFramePoseAsSpan(int frame) { if (KeyframePoses == null || frame < 0 || frame >= KeyFrameCount) @@ -196,6 +229,9 @@ public unsafe struct ModelAnimation return new Span(KeyframePoses[frame], KeyFrameCount); } + /// + /// Animation name as string + /// public string NameToString() { fixed (sbyte* name = Name)