11/*******************************************************************************************
22*
3- * raylib [models] example - animation playing
3+ * raylib [models] example - loading iqm
44*
55* Example complexity rating: [★★☆☆] 2/4
66*
@@ -33,7 +33,7 @@ int main(void)
3333 const int screenWidth = 800 ;
3434 const int screenHeight = 450 ;
3535
36- InitWindow (screenWidth , screenHeight , "raylib [models] example - animation playing " );
36+ InitWindow (screenWidth , screenHeight , "raylib [models] example - loading iqm " );
3737
3838 // Define the camera to look into our 3d world
3939 Camera camera = { 0 };
@@ -52,7 +52,7 @@ int main(void)
5252 // Load animation data
5353 int animsCount = 0 ;
5454 ModelAnimation * anims = LoadModelAnimations ("resources/models/iqm/guyanim.iqm" , & animsCount );
55- int animFrameCounter = 0 ;
55+ float animFrameCounter = 0 ;
5656
5757 DisableCursor (); // Catch cursor
5858 SetTargetFPS (60 ); // Set our game to run at 60 frames-per-second
@@ -63,15 +63,12 @@ int main(void)
6363 {
6464 // Update
6565 //----------------------------------------------------------------------------------
66- UpdateCamera (& camera , CAMERA_FIRST_PERSON );
66+ UpdateCamera (& camera , CAMERA_ORBITAL );
6767
6868 // Play animation when spacebar is held down
69- if (IsKeyDown (KEY_SPACE ))
70- {
71- animFrameCounter ++ ;
72- UpdateModelAnimation (model , anims [0 ], animFrameCounter );
73- if (animFrameCounter >= anims [0 ].frameCount ) animFrameCounter = 0 ;
74- }
69+ animFrameCounter += 1.0f ;
70+ UpdateModelAnimation (model , anims [0 ], animFrameCounter );
71+ if (animFrameCounter >= anims [0 ].keyframeCount ) animFrameCounter = 0 ;
7572 //----------------------------------------------------------------------------------
7673
7774 // Draw
@@ -84,9 +81,9 @@ int main(void)
8481
8582 DrawModelEx (model , position , (Vector3 ){ 1.0f , 0.0f , 0.0f }, -90.0f , (Vector3 ){ 1.0f , 1.0f , 1.0f }, WHITE );
8683
87- for (int i = 0 ; i < model .boneCount ; i ++ )
84+ for (int i = 0 ; i < model .skeleton . boneCount ; i ++ )
8885 {
89- DrawCube (anims [0 ].framePoses [animFrameCounter ][i ].translation , 0.2f , 0.2f , 0.2f , RED );
86+ // DrawCube(anims[0].keyframePoses [animFrameCounter][i].translation, 0.2f, 0.2f, 0.2f, RED);
9087 }
9188
9289 DrawGrid (10 , 1.0f ); // Draw a grid
0 commit comments