diff options
| author | hristo <[email protected]> | 2021-02-02 11:49:42 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-02-02 10:49:42 +0100 |
| commit | c8e427ad231652cfd68f7cfc2615c64a606c1e58 (patch) | |
| tree | 39fa007520c16201eef21c3628045a006d3b50b6 /examples/models | |
| parent | 2884b88101ca79b528d8bae89508760129722a70 (diff) | |
| download | raylib-c8e427ad231652cfd68f7cfc2615c64a606c1e58.tar.gz raylib-c8e427ad231652cfd68f7cfc2615c64a606c1e58.zip | |
Update loading of gltf animation. (#1561)
This is to account for GLTF info being more like instructions on how to build your animation instead of verbose description of each pose.
Diffstat (limited to 'examples/models')
| -rw-r--r-- | examples/models/models_gltf_animation.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/examples/models/models_gltf_animation.c b/examples/models/models_gltf_animation.c index e3120500..0efced5e 100644 --- a/examples/models/models_gltf_animation.c +++ b/examples/models/models_gltf_animation.c @@ -50,10 +50,11 @@ int main(void) int animsCount = 0; ModelAnimation *anims = LoadModelAnimations("resources/gltf/rigged_figure.glb", &animsCount); int animFrameCounter = 0; + int animationDirection = 1; SetCameraMode(camera, CAMERA_FREE); // Set free camera mode - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(30); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop @@ -66,9 +67,15 @@ int main(void) // Play animation when spacebar is held down if (IsKeyDown(KEY_SPACE)) { - animFrameCounter++; + animFrameCounter += animationDirection; + + if (animFrameCounter >= anims[0].frameCount || animFrameCounter <= 0) + { + animationDirection *= -1; + animFrameCounter += animationDirection; + } + UpdateModelAnimation(model, anims[0], animFrameCounter); - if (animFrameCounter >= anims[0].frameCount) animFrameCounter = 0; } //---------------------------------------------------------------------------------- |
