summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2016-09-26 19:15:44 +0200
committerraysan5 <[email protected]>2016-09-26 19:15:44 +0200
commit978c49472a1cdffa0bf12aba1638806c65e3f8ba (patch)
tree53081835a4626e7a97948996a5bee4fcdcece4c1 /examples
parent753b549aa5c6a010fc4de8acc2f64afdfce69cee (diff)
downloadraylib-978c49472a1cdffa0bf12aba1638806c65e3f8ba.tar.gz
raylib-978c49472a1cdffa0bf12aba1638806c65e3f8ba.zip
Working on camera system...
Diffstat (limited to 'examples')
-rw-r--r--examples/core_3d_camera_first_person.c2
-rw-r--r--examples/core_3d_camera_free.c4
-rw-r--r--examples/shaders_model_shader.c17
3 files changed, 11 insertions, 12 deletions
diff --git a/examples/core_3d_camera_first_person.c b/examples/core_3d_camera_first_person.c
index 3675d46a..27ff5135 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 = {{ 4.0f, 2.0f, 4.0f }, { 0.0f, 2.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 60.0f };
+ Camera camera = {{ 4.0f, 2.0f, 4.0f }, { 0.0f, 1.8f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 60.0f };
// Generates some random columns
float heights[MAX_COLUMNS];
diff --git a/examples/core_3d_camera_free.c b/examples/core_3d_camera_free.c
index 257bb789..c798f225 100644
--- a/examples/core_3d_camera_free.c
+++ b/examples/core_3d_camera_free.c
@@ -22,7 +22,7 @@ int main()
// Define the camera to look into our 3d world
Camera camera;
- camera.position = (Vector3){ 0.0f, 10.0f, 10.0f }; // Camera position
+ camera.position = (Vector3){ 10.0f, 10.0f, 10.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
@@ -40,6 +40,8 @@ int main()
// Update
//----------------------------------------------------------------------------------
UpdateCamera(&camera); // Update internal camera and our camera
+
+ if (IsKeyDown('Z')) camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
//----------------------------------------------------------------------------------
// Draw
diff --git a/examples/shaders_model_shader.c b/examples/shaders_model_shader.c
index a1e00671..a5516eba 100644
--- a/examples/shaders_model_shader.c
+++ b/examples/shaders_model_shader.c
@@ -37,25 +37,22 @@ int main()
Shader shader = LoadShader("resources/shaders/glsl330/base.vs",
"resources/shaders/glsl330/grayscale.fs"); // Load model shader
- dwarf.material.shader = shader; // Set shader effect to 3d model
- dwarf.material.texDiffuse = texture; // Bind texture to model
+ dwarf.material.shader = shader; // Set shader effect to 3d model
+ dwarf.material.texDiffuse = texture; // Bind texture to model
- Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
+ Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
- // Setup orbital camera
- SetCameraMode(CAMERA_ORBITAL); // Set an orbital 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
+ 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