summaryrefslogtreecommitdiffhomepage
path: root/examples/models
diff options
context:
space:
mode:
authorAsdqwe <[email protected]>2023-08-27 16:15:02 -0300
committerGitHub <[email protected]>2023-08-27 21:15:02 +0200
commitde3dc94d5ba135f9e179d1513814134e850471b3 (patch)
treeb5d709c5e15d3ff3eb31de0ff42a072f6e1ff2a5 /examples/models
parent9393500bff8731c744f0693c7f6bc9db6c612b57 (diff)
downloadraylib-de3dc94d5ba135f9e179d1513814134e850471b3.tar.gz
raylib-de3dc94d5ba135f9e179d1513814134e850471b3.zip
Fix example/models/models_loading_m3d.c controls (#3269)
Diffstat (limited to 'examples/models')
-rw-r--r--examples/models/models_loading_m3d.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/examples/models/models_loading_m3d.c b/examples/models/models_loading_m3d.c
index b9674b6f..1e56d51c 100644
--- a/examples/models/models_loading_m3d.c
+++ b/examples/models/models_loading_m3d.c
@@ -40,7 +40,7 @@ int main(void)
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
-
+
char modelFileName[128] = "resources/models/m3d/cesium_man.m3d";
bool drawMesh = 1;
bool drawSkeleton = 1;
@@ -72,27 +72,27 @@ int main(void)
if (IsKeyDown(KEY_SPACE) || IsKeyPressed(KEY_N))
{
animFrameCounter++;
-
+
if (animFrameCounter >= anims[animId].frameCount) animFrameCounter = 0;
-
+
UpdateModelAnimation(model, anims[animId], animFrameCounter);
animPlaying = true;
}
-
- // Select animation by pressing A
- if (IsKeyPressed(KEY_A))
+
+ // Select animation by pressing C
+ if (IsKeyPressed(KEY_C))
{
animFrameCounter = 0;
animId++;
-
+
if (animId >= animsCount) animId = 0;
UpdateModelAnimation(model, anims[animId], 0);
animPlaying = true;
}
}
-
+
// Toggle skeleton drawing
- if (IsKeyPressed(KEY_S)) drawSkeleton ^= 1;
+ if (IsKeyPressed(KEY_B)) drawSkeleton ^= 1;
// Toggle mesh drawing
if (IsKeyPressed(KEY_M)) drawMesh ^= 1;
@@ -112,19 +112,19 @@ int main(void)
// Draw the animated skeleton
if (drawSkeleton)
{
- // Loop to (boneCount - 1) because the last one is a special "no bone" bone,
+ // Loop to (boneCount - 1) because the last one is a special "no bone" bone,
// needed to workaround buggy models
// without a -1, we would always draw a cube at the origin
for (int i = 0; i < model.boneCount - 1; i++)
{
- // By default the model is loaded in bind-pose by LoadModel().
- // But if UpdateModelAnimation() has been called at least once
+ // By default the model is loaded in bind-pose by LoadModel().
+ // But if UpdateModelAnimation() has been called at least once
// then the model is already in animation pose, so we need the animated skeleton
if (!animPlaying || !animsCount)
{
// Display the bind-pose skeleton
DrawCube(model.bindPose[i].translation, 0.04f, 0.04f, 0.04f, RED);
-
+
if (model.bones[i].parent >= 0)
{
DrawLine3D(model.bindPose[i].translation,
@@ -135,7 +135,7 @@ int main(void)
{
// Display the frame-pose skeleton
DrawCube(anims[animId].framePoses[animFrameCounter][i].translation, 0.05f, 0.05f, 0.05f, RED);
-
+
if (anims[animId].bones[i].parent >= 0)
{
DrawLine3D(anims[animId].framePoses[animFrameCounter][i].translation,
@@ -149,9 +149,10 @@ int main(void)
EndMode3D();
- DrawText("PRESS SPACE to PLAY MODEL ANIMATION", 10, GetScreenHeight() - 60, 10, MAROON);
- DrawText("PRESS A to CYCLE THROUGH ANIMATIONS", 10, GetScreenHeight() - 40, 10, DARKGRAY);
- DrawText("PRESS M to toggle MESH, S to toggle SKELETON DRAWING", 10, GetScreenHeight() - 20, 10, DARKGRAY);
+ DrawText("PRESS SPACE to PLAY MODEL ANIMATION", 10, GetScreenHeight() - 80, 10, MAROON);
+ DrawText("PRESS N to STEP ONE ANIMATION FRAME", 10, GetScreenHeight() - 60, 10, DARKGRAY);
+ DrawText("PRESS C to CYCLE THROUGH ANIMATIONS", 10, GetScreenHeight() - 40, 10, DARKGRAY);
+ DrawText("PRESS M to toggle MESH, B to toggle SKELETON DRAWING", 10, GetScreenHeight() - 20, 10, DARKGRAY);
DrawText("(c) CesiumMan model by KhronosGroup", GetScreenWidth() - 210, GetScreenHeight() - 20, 10, GRAY);
EndDrawing();