using System; using System.Numerics; using System.Runtime.InteropServices; namespace Raylib_cs { /// /// Bone information /// [StructLayout(LayoutKind.Sequential)] public unsafe partial struct BoneInfo { /// /// Bone name (char[32]) /// public fixed sbyte name[32]; /// /// Bone parent /// public int parent; } /// /// Model type /// [StructLayout(LayoutKind.Sequential)] public unsafe partial struct Model { /// /// Local transform matrix /// public Matrix4x4 transform; /// /// Number of meshes /// public int meshCount; /// /// Number of materials /// public int materialCount; /// /// Meshes array (Mesh *) /// public Mesh* meshes; /// /// Materials array (Material *) /// public Material* materials; /// /// Mesh material number (int *) /// public int* meshMaterial; /// /// Number of bones /// public int boneCount; //TODO: Span /// /// Bones information (skeleton, BoneInfo *) /// public BoneInfo* bones; //TODO: Span /// /// Bones base transformation (pose, Transform *) /// public Transform* bindPose; } /// /// Model animation /// [StructLayout(LayoutKind.Sequential)] public readonly unsafe partial struct ModelAnimation { /// /// Number of bones /// public readonly int boneCount; /// /// Number of animation frames /// public readonly int frameCount; /// /// Bones information (skeleton, BoneInfo *) /// public readonly BoneInfo* bones; /// public ReadOnlySpan BoneInfo => new(bones, boneCount); /// /// Poses array by frame (Transform **) /// public readonly Transform** framePoses; /// public FramePosesCollection FramePoses => new(framePoses, frameCount, boneCount); public struct FramePosesCollection { readonly Transform** framePoses; readonly int frameCount; readonly int boneCount; public FramePoses this[int index] => new(framePoses[index], boneCount); public Transform this[int index1, int index2] => new FramePoses(framePoses[index1], boneCount)[index2]; internal FramePosesCollection(Transform** framePoses, int frameCount, int boneCount) { this.framePoses = framePoses; this.frameCount = frameCount; this.boneCount = boneCount; } } } public unsafe struct FramePoses { readonly Transform* poses; readonly int count; public ref Transform this[int index] { get { return ref poses[index]; } } internal FramePoses(Transform* poses, int count) { this.poses = poses; this.count = count; } } }