diff options
| author | Ray <[email protected]> | 2023-02-14 20:00:51 +0100 |
|---|---|---|
| committer | Ray <[email protected]> | 2023-02-14 20:00:51 +0100 |
| commit | ea590c44a967075b3f6b420fa76e6387075ecf1d (patch) | |
| tree | b456de45fef83507415dcc309c05e64cb9232946 /examples/models/models_heightmap.c | |
| parent | 73989a49817225f11f547d270598e93745bf7df0 (diff) | |
| download | raylib-ea590c44a967075b3f6b420fa76e6387075ecf1d.tar.gz raylib-ea590c44a967075b3f6b420fa76e6387075ecf1d.zip | |
REVIEWED: Camera redesign PR
Diffstat (limited to 'examples/models/models_heightmap.c')
| -rw-r--r-- | examples/models/models_heightmap.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/examples/models/models_heightmap.c b/examples/models/models_heightmap.c index 25dc004d..8f32de9f 100644 --- a/examples/models/models_heightmap.c +++ b/examples/models/models_heightmap.c @@ -26,25 +26,31 @@ int main(void) InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing"); // Define our custom camera to look into our 3d world - Camera camera = { { 18.0f, 18.0f, 18.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 }; + Camera camera = { 0 }; + camera.position = (Vector3){ 18.0f, 21.0f, 18.0f }; // Camera position + camera.target = (Vector3){ 0.0f, 0.0f, 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.projection = CAMERA_PERSPECTIVE; // Camera projection type - Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM) - Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM) + Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM) + Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM) - Mesh mesh = GenMeshHeightmap(image, (Vector3){ 16, 8, 16 }); // Generate heightmap mesh (RAM and VRAM) - Model model = LoadModelFromMesh(mesh); // Load model from generated mesh + Mesh mesh = GenMeshHeightmap(image, (Vector3){ 16, 8, 16 }); // Generate heightmap mesh (RAM and VRAM) + Model model = LoadModelFromMesh(mesh); // Load model from generated mesh - model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture - Vector3 mapPosition = { -8.0f, 0.0f, -8.0f }; // Define model position + model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture + Vector3 mapPosition = { -8.0f, 0.0f, -8.0f }; // Define model position - UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM + UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM - DisableCursor(); // Catch cursor - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + DisableCursor(); // Limit cursor to relative movement inside the window + + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key + while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- |
