From 753b549aa5c6a010fc4de8acc2f64afdfce69cee Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sun, 25 Sep 2016 14:28:24 +0200 Subject: Improving camera system -IN PROGRESS- --- examples/core_3d_camera_first_person.c | 9 +++------ examples/core_3d_camera_free.c | 5 +---- examples/models_cubicmap.c | 10 ++++------ 3 files changed, 8 insertions(+), 16 deletions(-) (limited to 'examples') diff --git a/examples/core_3d_camera_first_person.c b/examples/core_3d_camera_first_person.c index 56e38a23..3675d46a 100644 --- a/examples/core_3d_camera_first_person.c +++ b/examples/core_3d_camera_first_person.c @@ -23,7 +23,7 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera first person"); // Define the camera to look into our 3d world (position, target, up vector) - Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 60.0f }; + Camera camera = {{ 4.0f, 2.0f, 4.0f }, { 0.0f, 2.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 60.0f }; // Generates some random columns float heights[MAX_COLUMNS]; @@ -37,10 +37,7 @@ int main() colors[i] = (Color){ GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 }; } - Vector3 playerPosition = { 4.0f, 2.0f, 4.0f }; // Define player position - - SetCameraMode(CAMERA_FIRST_PERSON); // Set a first person camera mode - SetCameraFovy(camera.fovy); // Set internal camera field-of-view Y + SetCameraMode(camera, CAMERA_FIRST_PERSON); // Set a first person camera mode SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- @@ -50,7 +47,7 @@ int main() { // Update //---------------------------------------------------------------------------------- - UpdateCameraPlayer(&camera, &playerPosition); // Update camera and player position + UpdateCamera(&camera); // Update camera and player position //---------------------------------------------------------------------------------- // Draw diff --git a/examples/core_3d_camera_free.c b/examples/core_3d_camera_free.c index fa7ad85f..257bb789 100644 --- a/examples/core_3d_camera_free.c +++ b/examples/core_3d_camera_free.c @@ -29,10 +29,7 @@ int main() Vector3 cubePosition = { 0.0f, 0.0f, 0.0f }; - SetCameraMode(CAMERA_FREE); // Set a free camera mode - SetCameraPosition(camera.position); // Set internal camera position to match our camera position - SetCameraTarget(camera.target); // Set internal camera target to match our camera target - SetCameraFovy(camera.fovy); // Set internal camera field-of-view Y + SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- diff --git a/examples/models_cubicmap.c b/examples/models_cubicmap.c index 89bc75cf..df700d65 100644 --- a/examples/models_cubicmap.c +++ b/examples/models_cubicmap.c @@ -35,19 +35,17 @@ int main() UnloadImage(image); // Unload cubesmap image from RAM, already uploaded to VRAM - SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode - SetCameraPosition(camera.position); // Set internal camera position to match our custom camera position - SetCameraFovy(camera.fovy); // Set internal camera field-of-view Y + SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + 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 //---------------------------------------------------------------------------------- - UpdateCamera(&camera); // Update internal camera and our camera + UpdateCamera(&camera); // Update internal camera and our camera //---------------------------------------------------------------------------------- // Draw -- cgit v1.2.3