mirror of
https://github.com/raysan5/raylib.git
synced 2026-02-07 06:39:17 -05:00
Compare commits
3 Commits
ce1cd0d7e6
...
500494f791
| Author | SHA1 | Date | |
|---|---|---|---|
| 500494f791 | |||
| 1d17be6c1c | |||
| 8b0cbb6f47 |
@ -106,9 +106,9 @@ int main(void)
|
|||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
Vector2 mouse_delta = GetMouseDelta();
|
Vector2 mouseDelta = GetMouseDelta();
|
||||||
lookRotation.x -= mouse_delta.x*sensitivity.x;
|
lookRotation.x -= mouseDelta.x*sensitivity.x;
|
||||||
lookRotation.y += mouse_delta.y*sensitivity.y;
|
lookRotation.y += mouseDelta.y*sensitivity.y;
|
||||||
|
|
||||||
char sideway = (IsKeyDown(KEY_D) - IsKeyDown(KEY_A));
|
char sideway = (IsKeyDown(KEY_D) - IsKeyDown(KEY_A));
|
||||||
char forward = (IsKeyDown(KEY_W) - IsKeyDown(KEY_S));
|
char forward = (IsKeyDown(KEY_W) - IsKeyDown(KEY_S));
|
||||||
@ -261,7 +261,10 @@ static void UpdateCameraAngle(Camera *camera)
|
|||||||
Vector3 right = Vector3Normalize(Vector3CrossProduct(yaw, up));
|
Vector3 right = Vector3Normalize(Vector3CrossProduct(yaw, up));
|
||||||
|
|
||||||
// Rotate view vector around right axis
|
// Rotate view vector around right axis
|
||||||
Vector3 pitch = Vector3RotateByAxisAngle(yaw, right, -lookRotation.y - lean.y);
|
float pitchAngle = -lookRotation.y -
|
||||||
|
lean.y;
|
||||||
|
pitchAngle = Clamp(pitchAngle, -PI / 2 + 0.0001f, PI / 2 - 0.0001f); // Clamp angle so it doesn't go past straight up or straight down
|
||||||
|
Vector3 pitch = Vector3RotateByAxisAngle(yaw, right, pitchAngle);
|
||||||
|
|
||||||
// Head animation
|
// Head animation
|
||||||
// Rotate up direction around forward axis
|
// Rotate up direction around forward axis
|
||||||
|
|||||||
Reference in New Issue
Block a user