Skip to content

Commit

Permalink
Added ModelAnimation.name, initially with GLTF animation names loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredbaudisch committed May 7, 2023
1 parent 5356806 commit 9cfcb7e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/models/models_loading_gltf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
//----------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src/raylib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/rmodels.c
Original file line number Diff line number Diff line change
Expand Up @@ -5379,6 +5379,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 *));

Expand Down

0 comments on commit 9cfcb7e

Please sign in to comment.