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 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;
///
/// Animation name (char[32])
///
public fixed sbyte Name[32];
///
public FramePosesCollection FramePosesColl => 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] => ref _poses[index];
internal FramePoses(Transform* poses, int count)
{
this._poses = poses;
this._count = count;
}
}