add zooms
This commit is contained in:
parent
97c02b2425
commit
84cbd0ea19
|
|
@ -14,6 +14,8 @@
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
#include "rcamera.h"
|
#include "rcamera.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#define MAX_COLUMNS 20
|
#define MAX_COLUMNS 20
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
|
|
@ -113,6 +115,25 @@ int main(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Camera zooming
|
||||||
|
float wheelMove = GetMouseWheelMove();
|
||||||
|
bool zoomIn = IsKeyDown(KEY_KP_ADD);
|
||||||
|
bool zoomOut = IsKeyDown(KEY_KP_SUBTRACT);
|
||||||
|
|
||||||
|
if (cameraMode != CAMERA_THIRD_PERSON && (wheelMove != 0 || zoomIn || zoomOut))
|
||||||
|
{
|
||||||
|
if ((wheelMove > 0 || zoomIn) && camera.fovy >= 20.0f)
|
||||||
|
{
|
||||||
|
camera.fovy -= 5.0f;
|
||||||
|
}
|
||||||
|
else if ((wheelMove < 0 || zoomOut) && camera.fovy <= 90.0f)
|
||||||
|
{
|
||||||
|
camera.fovy += 5.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("fov: %.2f\n", camera.fovy);
|
||||||
|
printf("bool: %d\n", (cameraMode != CAMERA_THIRD_PERSON && (wheelMove != 0 || zoomIn || zoomOut)));
|
||||||
// Update camera computes movement internally depending on the camera mode
|
// Update camera computes movement internally depending on the camera mode
|
||||||
// Some default standard keyboard/mouse inputs are hardcoded to simplify use
|
// Some default standard keyboard/mouse inputs are hardcoded to simplify use
|
||||||
// For advance camera controls, it's reecommended to compute camera movement manually
|
// For advance camera controls, it's reecommended to compute camera movement manually
|
||||||
|
|
@ -169,29 +190,31 @@ int main(void)
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
// Draw info boxes
|
// Draw info boxes
|
||||||
DrawRectangle(5, 5, 330, 100, Fade(SKYBLUE, 0.5f));
|
DrawRectangle(5, 5, 330, 120, Fade(SKYBLUE, 0.5f));
|
||||||
DrawRectangleLines(5, 5, 330, 100, BLUE);
|
DrawRectangleLines(5, 5, 330, 120, BLUE);
|
||||||
|
|
||||||
DrawText("Camera controls:", 15, 15, 10, BLACK);
|
DrawText("Camera controls:", 15, 15, 10, BLACK);
|
||||||
DrawText("- Move keys: W, A, S, D, Space, Left-Ctrl", 15, 30, 10, BLACK);
|
DrawText("- Move keys: W, A, S, D, Space, Left-Ctrl", 15, 30, 10, BLACK);
|
||||||
DrawText("- Look around: arrow keys or mouse", 15, 45, 10, BLACK);
|
DrawText(" (Space and Left-Ctrl in Free Camera mode only)", 15, 45, 10, DARKGRAY);
|
||||||
DrawText("- Camera mode keys: 1, 2, 3, 4", 15, 60, 10, BLACK);
|
DrawText("- Look around: arrow keys or mouse", 15, 60, 10, BLACK);
|
||||||
DrawText("- Zoom keys: num-plus, num-minus or mouse scroll", 15, 75, 10, BLACK);
|
DrawText("- Camera mode keys: 1, 2, 3, 4", 15, 75, 10, BLACK);
|
||||||
DrawText("- Camera projection key: P", 15, 90, 10, BLACK);
|
DrawText("- Zoom keys: num-plus, num-minus or mouse scroll", 15, 90, 10, BLACK);
|
||||||
|
DrawText("- Camera projection key: P", 15, 105, 10, BLACK);
|
||||||
|
|
||||||
DrawRectangle(600, 5, 195, 100, Fade(SKYBLUE, 0.5f));
|
DrawRectangle(600, 5, 195, 120, Fade(SKYBLUE, 0.5f));
|
||||||
DrawRectangleLines(600, 5, 195, 100, BLUE);
|
DrawRectangleLines(600, 5, 195, 120, BLUE);
|
||||||
|
|
||||||
DrawText("Camera status:", 610, 15, 10, BLACK);
|
DrawText("Camera status:", 610, 15, 10, BLACK);
|
||||||
DrawText(TextFormat("- Mode: %s", (cameraMode == CAMERA_FREE) ? "FREE" :
|
DrawText(TextFormat("- Mode: %s", (cameraMode == CAMERA_FREE) ? "FREE" :
|
||||||
(cameraMode == CAMERA_FIRST_PERSON) ? "FIRST_PERSON" :
|
(cameraMode == CAMERA_FIRST_PERSON) ? "FIRST_PERSON" :
|
||||||
(cameraMode == CAMERA_THIRD_PERSON) ? "THIRD_PERSON" :
|
(cameraMode == CAMERA_THIRD_PERSON) ? "THIRD_PERSON" :
|
||||||
(cameraMode == CAMERA_ORBITAL) ? "ORBITAL" : "CUSTOM"), 610, 30, 10, BLACK);
|
(cameraMode == CAMERA_ORBITAL) ? "ORBITAL" : "CUSTOM"), 610, 30, 10, BLACK);
|
||||||
DrawText(TextFormat("- Projection: %s", (camera.projection == CAMERA_PERSPECTIVE) ? "PERSPECTIVE" :
|
DrawText(TextFormat("- Projection: %s", (camera.projection == CAMERA_PERSPECTIVE) ? "PERSPECTIVE" :
|
||||||
(camera.projection == CAMERA_ORTHOGRAPHIC) ? "ORTHOGRAPHIC" : "CUSTOM"), 610, 45, 10, BLACK);
|
(camera.projection == CAMERA_ORTHOGRAPHIC) ? "ORTHOGRAPHIC" : "CUSTOM"), 610, 45, 10, BLACK);
|
||||||
DrawText(TextFormat("- Position: (%06.3f, %06.3f, %06.3f)", camera.position.x, camera.position.y, camera.position.z), 610, 60, 10, BLACK);
|
DrawText(TextFormat("- Position: (%06.3f, %06.3f, %06.3f)", camera.position.x, camera.position.y, camera.position.z), 610, 60, 10, BLACK);
|
||||||
DrawText(TextFormat("- Target: (%06.3f, %06.3f, %06.3f)", camera.target.x, camera.target.y, camera.target.z), 610, 75, 10, BLACK);
|
DrawText(TextFormat("- Target: (%06.3f, %06.3f, %06.3f)", camera.target.x, camera.target.y, camera.target.z), 610, 75, 10, BLACK);
|
||||||
DrawText(TextFormat("- Up: (%06.3f, %06.3f, %06.3f)", camera.up.x, camera.up.y, camera.up.z), 610, 90, 10, BLACK);
|
DrawText(TextFormat("- Up: (%06.3f, %06.3f, %06.3f)", camera.up.x, camera.up.y, camera.up.z), 610, 90, 10, BLACK);
|
||||||
|
DrawText(TextFormat("- FOV: %06.3f", camera.fovy), 610, 105, 10, BLACK);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user