diff options
| author | Ray <[email protected]> | 2019-05-14 17:57:45 +0200 |
|---|---|---|
| committer | Ray <[email protected]> | 2019-05-14 17:57:45 +0200 |
| commit | 5a27bcaf7115e46a5123e9857007d940998f0650 (patch) | |
| tree | 7179c6a1b4d700c9685dd51cc76cb2b2c90b9609 /examples/src/models/models_obj_loading.c | |
| parent | 423fdd699225ee9686c44a606bf83272b4c77802 (diff) | |
| download | raylib.com-5a27bcaf7115e46a5123e9857007d940998f0650.tar.gz raylib.com-5a27bcaf7115e46a5123e9857007d940998f0650.zip | |
Review examples collection -WIP-
WARNING: Examples list has been reviewed but examples haven't been recompiled yet... that's not trivial...
Diffstat (limited to 'examples/src/models/models_obj_loading.c')
| -rw-r--r-- | examples/src/models/models_obj_loading.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/examples/src/models/models_obj_loading.c b/examples/src/models/models_obj_loading.c index 70f9216..74e7d08 100644 --- a/examples/src/models/models_obj_loading.c +++ b/examples/src/models/models_obj_loading.c @@ -21,11 +21,16 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [models] example - obj model loading"); // Define the camera to look into our 3d world - Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f }; - - Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model - Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture - dwarf.material.maps[MAP_DIFFUSE].texture = texture; // Set map diffuse texture + Camera camera = { 0 }; + camera.position = (Vector3){ 8.0f, 8.0f, 8.0f }; // Camera position + camera.target = (Vector3){ 0.0f, 2.5f, 0.0f }; // Camera looking at point + 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.type = CAMERA_PERSPECTIVE; // Camera mode type + + Model model = LoadModel("resources/models/castle.obj"); // Load OBJ model + Texture2D texture = LoadTexture("resources/models/castle_diffuse.png"); // Load model texture + model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set map diffuse texture Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position SetTargetFPS(60); // Set our game to run at 60 frames-per-second @@ -45,17 +50,17 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); - DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture + DrawModel(model, position, 0.2f, WHITE); // Draw 3d model with texture DrawGrid(10, 1.0f); // Draw a grid DrawGizmo(position); // Draw gizmo - End3dMode(); - - DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY); + EndMode3D(); + + DrawText("(c) Castle 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY); DrawFPS(10, 10); @@ -66,7 +71,7 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- UnloadTexture(texture); // Unload texture - UnloadModel(dwarf); // Unload model + UnloadModel(model); // Unload model CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- |
