mirror of
				https://github.com/raysan5/raylib.git
				synced 2025-10-26 12:27:01 +00:00 
			
		
		
		
	Example review
This commit is contained in:
		| @@ -30,11 +30,11 @@ int main(void) | |||||||
|     const int screenWidth = 800; |     const int screenWidth = 800; | ||||||
|     const int screenHeight = 450; |     const int screenHeight = 450; | ||||||
|  |  | ||||||
|     InitWindow(screenWidth, screenHeight, "raylib [models] example - loading gltf"); |     InitWindow(screenWidth, screenHeight, "raylib [models] example - loading gltf animations"); | ||||||
|  |  | ||||||
|     // Define the camera to look into our 3d world |     // Define the camera to look into our 3d world | ||||||
|     Camera camera = { 0 }; |     Camera camera = { 0 }; | ||||||
|     camera.position = (Vector3){ 5.0f, 5.0f, 5.0f };    // Camera position |     camera.position = (Vector3){ 6.0f, 6.0f, 6.0f };    // Camera position | ||||||
|     camera.target = (Vector3){ 0.0f, 2.0f, 0.0f };      // Camera looking at point |     camera.target = (Vector3){ 0.0f, 2.0f, 0.0f };      // Camera looking at point | ||||||
|     camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };          // Camera up vector (rotation towards target) |     camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };          // Camera up vector (rotation towards target) | ||||||
|     camera.fovy = 45.0f;                                // Camera field-of-view Y |     camera.fovy = 45.0f;                                // Camera field-of-view Y | ||||||
| @@ -42,6 +42,7 @@ int main(void) | |||||||
|  |  | ||||||
|     // Load gltf model |     // Load gltf model | ||||||
|     Model model = LoadModel("resources/models/gltf/robot.glb"); |     Model model = LoadModel("resources/models/gltf/robot.glb"); | ||||||
|  |     Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position | ||||||
|      |      | ||||||
|     // Load gltf model animations |     // Load gltf model animations | ||||||
|     int animsCount = 0; |     int animsCount = 0; | ||||||
| @@ -49,10 +50,6 @@ int main(void) | |||||||
|     unsigned int animCurrentFrame = 0; |     unsigned int animCurrentFrame = 0; | ||||||
|     ModelAnimation *modelAnimations = LoadModelAnimations("resources/models/gltf/robot.glb", &animsCount); |     ModelAnimation *modelAnimations = LoadModelAnimations("resources/models/gltf/robot.glb", &animsCount); | ||||||
|  |  | ||||||
|     Vector3 position = { 0.0f, 0.0f, 0.0f };    // Set model position |  | ||||||
|  |  | ||||||
|     DisableCursor();                    // Limit cursor to relative movement inside the window |  | ||||||
|  |  | ||||||
|     SetTargetFPS(60);                   // Set our game to run at 60 frames-per-second |     SetTargetFPS(60);                   // Set our game to run at 60 frames-per-second | ||||||
|     //-------------------------------------------------------------------------------------- |     //-------------------------------------------------------------------------------------- | ||||||
|  |  | ||||||
| @@ -61,7 +58,8 @@ int main(void) | |||||||
|     { |     { | ||||||
|         // Update |         // Update | ||||||
|         //---------------------------------------------------------------------------------- |         //---------------------------------------------------------------------------------- | ||||||
|         UpdateCamera(&camera, CAMERA_THIRD_PERSON); |         UpdateCamera(&camera, CAMERA_ORBITAL); | ||||||
|  |  | ||||||
|         // Select current animation |         // Select current animation | ||||||
|         if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) animIndex = (animIndex + 1)%animsCount; |         if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) animIndex = (animIndex + 1)%animsCount; | ||||||
|         else if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) animIndex = (animIndex + animsCount - 1)%animsCount; |         else if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) animIndex = (animIndex + animsCount - 1)%animsCount; | ||||||
| @@ -79,10 +77,8 @@ int main(void) | |||||||
|             ClearBackground(RAYWHITE); |             ClearBackground(RAYWHITE); | ||||||
|  |  | ||||||
|             BeginMode3D(camera); |             BeginMode3D(camera); | ||||||
|  |  | ||||||
|                 DrawModel(model, position, 1.0f, WHITE);    // Draw animated model |                 DrawModel(model, position, 1.0f, WHITE);    // Draw animated model | ||||||
|                 DrawGrid(10, 1.0f); |                 DrawGrid(10, 1.0f); | ||||||
|  |  | ||||||
|             EndMode3D(); |             EndMode3D(); | ||||||
|  |  | ||||||
|             DrawText("Use the LEFT/RIGHT mouse buttons to switch animation", 10, 10, 20, GRAY); |             DrawText("Use the LEFT/RIGHT mouse buttons to switch animation", 10, 10, 20, GRAY); | ||||||
| @@ -101,3 +97,6 @@ int main(void) | |||||||
|  |  | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -376,6 +376,9 @@ | |||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <ClCompile Include="..\..\..\examples\models\models_loading_gltf.c" /> |     <ClCompile Include="..\..\..\examples\models\models_loading_gltf.c" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|  |   <ItemGroup> | ||||||
|  |     <ResourceCompile Include="..\..\..\examples\examples.rc" /> | ||||||
|  |   </ItemGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <ProjectReference Include="..\raylib\raylib.vcxproj"> |     <ProjectReference Include="..\raylib\raylib.vcxproj"> | ||||||
|       <Project>{e89d61ac-55de-4482-afd4-df7242ebc859}</Project> |       <Project>{e89d61ac-55de-4482-afd4-df7242ebc859}</Project> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Ray
					Ray