faire la norme
This commit is contained in:
+16
-8
@@ -26,29 +26,37 @@ static void update_camera_rotation(t_app *app)
|
||||
app->scene.camera.pitch = 1.57f - 0.01f;
|
||||
if (app->scene.camera.pitch < -1.57f + 0.01f)
|
||||
app->scene.camera.pitch = -1.57f + 0.01f;
|
||||
app->scene.camera.camDir.x = cosf(app->scene.camera.pitch) * sinf(app->scene.camera.yaw);
|
||||
app->scene.camera.camDir.x = cosf(app->scene.camera.pitch)
|
||||
* sinf(app->scene.camera.yaw);
|
||||
app->scene.camera.camDir.y = sinf(app->scene.camera.pitch);
|
||||
app->scene.camera.camDir.z = -cosf(app->scene.camera.pitch) * cosf(app->scene.camera.yaw);
|
||||
app->scene.camera.camDir.z = -cosf(app->scene.camera.pitch)
|
||||
* cosf(app->scene.camera.yaw);
|
||||
app->scene.camera.camDir = vec3_normalize(app->scene.camera.camDir);
|
||||
app->scene.camera.right = (t_vec3){cosf(app->scene.camera.yaw), 0, sinf(app->scene.camera.yaw)};
|
||||
app->scene.camera.right = (t_vec3){cosf(app->scene.camera.yaw), 0,
|
||||
sinf(app->scene.camera.yaw)};
|
||||
app->scene.camera.right = vec3_normalize(app->scene.camera.right);
|
||||
app->scene.camera.up = vec3_normalize(vec3_cross(app->scene.camera.right, app->scene.camera.camDir));
|
||||
app->scene.camera.up = vec3_normalize(vec3_cross(app->scene.camera.right,
|
||||
app->scene.camera.camDir));
|
||||
}
|
||||
|
||||
static void update_camera_movement(t_app *app)
|
||||
{
|
||||
if (app->key_w)
|
||||
app->scene.camera.camPos = vec3_add(app->scene.camera.camPos,
|
||||
vec3_scale(app->scene.camera.camDir, app->scene.camera.move_speed));
|
||||
vec3_scale(app->scene.camera.camDir,
|
||||
app->scene.camera.move_speed));
|
||||
if (app->key_s)
|
||||
app->scene.camera.camPos = vec3_sub(app->scene.camera.camPos,
|
||||
vec3_scale(app->scene.camera.camDir, app->scene.camera.move_speed));
|
||||
vec3_scale(app->scene.camera.camDir,
|
||||
app->scene.camera.move_speed));
|
||||
if (app->key_a)
|
||||
app->scene.camera.camPos = vec3_sub(app->scene.camera.camPos,
|
||||
vec3_scale(app->scene.camera.right, app->scene.camera.move_speed));
|
||||
vec3_scale(app->scene.camera.right,
|
||||
app->scene.camera.move_speed));
|
||||
if (app->key_d)
|
||||
app->scene.camera.camPos = vec3_add(app->scene.camera.camPos,
|
||||
vec3_scale(app->scene.camera.right, app->scene.camera.move_speed));
|
||||
vec3_scale(app->scene.camera.right,
|
||||
app->scene.camera.move_speed));
|
||||
}
|
||||
|
||||
void update_camera(t_app *app)
|
||||
|
||||
Reference in New Issue
Block a user