summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAlfred Reinold Baudisch <[email protected]>2023-05-07 10:33:14 +0200
committerGitHub <[email protected]>2023-05-07 10:33:14 +0200
commit53b7b26c45867e8b373ae1f9ab302117d3ba047d (patch)
tree3f9ca29b2a9deaf557227dd7673f67b29aae8c76
parentde748dfffefeba1ba9bcf0c90c538d32c9cb2020 (diff)
downloadraylib-53b7b26c45867e8b373ae1f9ab302117d3ba047d.tar.gz
raylib-53b7b26c45867e8b373ae1f9ab302117d3ba047d.zip
Added ModelAnimation.name, initially with GLTF animation names loaded (#3044)
-rw-r--r--examples/models/models_loading_gltf.c1
-rw-r--r--src/raylib.h1
-rw-r--r--src/rmodels.c3
3 files changed, 5 insertions, 0 deletions
diff --git a/examples/models/models_loading_gltf.c b/examples/models/models_loading_gltf.c
index d8b34efe..d5ebff23 100644
--- a/examples/models/models_loading_gltf.c
+++ b/examples/models/models_loading_gltf.c
@@ -86,6 +86,7 @@ int main(void)
EndMode3D();
DrawText("Use the UP/DOWN arrow keys to switch animation", 10, 10, 20, GRAY);
+ DrawText(TextFormat("Animation: %s", anim.name), 10, GetScreenHeight() - 20, 10, DARKGRAY);
EndDrawing();
//----------------------------------------------------------------------------------
diff --git a/src/raylib.h b/src/raylib.h
index 6e5d023b..2a5a2f63 100644
--- a/src/raylib.h
+++ b/src/raylib.h
@@ -402,6 +402,7 @@ typedef struct ModelAnimation {
int frameCount; // Number of animation frames
BoneInfo *bones; // Bones information (skeleton)
Transform **framePoses; // Poses array by frame
+ char name[32]; // Animation name
} ModelAnimation;
// Ray, ray for raycasting
diff --git a/src/rmodels.c b/src/rmodels.c
index 34352ec1..1aa045df 100644
--- a/src/rmodels.c
+++ b/src/rmodels.c
@@ -5375,6 +5375,9 @@ static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, unsigned in
animDuration = (t > animDuration)? t : animDuration;
}
+ strncpy(animations[i].name, animData.name, sizeof(animations[i].name));
+ animations[i].name[sizeof(animations[i].name) - 1] = '\0';
+
animations[i].frameCount = (int)(animDuration*1000.0f/GLTF_ANIMDELAY);
animations[i].framePoses = RL_MALLOC(animations[i].frameCount*sizeof(Transform *));