|
Untitled
|
Functions for camera. More...
#include "engine_types.h"Go to the source code of this file.
Functions | |
| mat4 | make_ortho (float left, float right, float bottom, float top, float near, float far) |
| Makes an 4x4 orthographic matrix. | |
| mat4 | make_projection (float fov_deg, float aspect, float near, float far) |
| Makes an 4x4 projection matrix. | |
| mat4 | make_look_at (Camera *cam, vec3 eye) |
| Makes a 4x4 view matrix using camera vectors. | |
| void | compute_camera_basis (Camera *cam, float yaw, float pitch, float roll, vec3 world_up) |
| Computes camera vectors based on yaw, pitch, and roll. | |
| void | update_camera (Skeleton *s, Camera *cam) |
| Updates a camera based on a skeleton's current neck and body position. | |
| void | update_light_camera (Camera *lcam, Light *light) |
| Updates a directional light camera and locks it to texel size. | |
| void | resolve_collisions (Camera *current_cam) |
| Resolves collisions between camera and geometry, uses player. | |
| void | apply_velocity (Camera *current_cam, vec3 move_dir, float dt) |
| Applies no-clip mode velocity to player with no gravity applied. | |
| void | apply_planet_velocity (Camera *current_cam, vec3 move_dir, float dt) |
| Applies normal velocity to player with gravity and friction applied. | |
| void | update_skeleton (Skeleton *s, Camera *cam, vec3 vel) |
| Moves feet, then solves a skeleton's leg IKs and updates the springs accordingly. | |
| void | update_body_from_legs (LegIK *left_leg, LegIK *right_leg, vec3 intended_vel, float dt) |
| Calculates velocity based on leg positions and integrates them into the player. | |
| void | reset_skeleton (Skeleton *s, vec3 pos) |
| Resets a skeleton to be relative to a new position. | |
| bool | collision (vec3 proposed, vec3 pts[3], vec3 normal, CollisionPoints *p) |
Variables | |
| Camera | cam |
| This is currently the player cam. | |
Functions for camera.
Definition in file camera.h.
| mat4 make_ortho | ( | float | left, |
| float | right, | ||
| float | bottom, | ||
| float | top, | ||
| float | near, | ||
| float | far ) |
Makes an 4x4 orthographic matrix.
| left | The left dist. |
| right | The right dist. |
| bottom | The bottom dist. |
| top | The top dist. |
| near | The near plane. |
| far | The far plane. |
Definition at line 178 of file camera.c.
References mat4::a0, mat4::a1, mat4::a2, mat4::a3, mat4::b0, mat4::b1, mat4::b2, mat4::b3, mat4::c0, mat4::c1, mat4::c2, mat4::c3, mat4::d0, mat4::d1, mat4::d2, mat4::d3, and make_ortho().
Referenced by make_ortho(), render(), and update_light_camera().
| mat4 make_projection | ( | float | fov_deg, |
| float | aspect, | ||
| float | near, | ||
| float | far ) |
Makes an 4x4 projection matrix.
| fov_deg | FOV in degrees. |
| aspect | The aspect ratio (W/H). |
| near | The near plane. |
| far | The far plane. |
Definition at line 220 of file camera.c.
References mat4::a0, mat4::a1, mat4::a2, mat4::a3, mat4::b0, mat4::b1, mat4::b2, mat4::b3, mat4::c0, mat4::c1, mat4::c2, mat4::c3, mat4::d0, mat4::d1, mat4::d2, mat4::d3, M_PI, and make_projection().
Referenced by bake_reflection_probes(), make_projection(), update_camera(), and write_point_light_shadows().
Makes a 4x4 view matrix using camera vectors.
| cam | The camera to use. |
| eye | The camera's "eye" position. |
Definition at line 257 of file camera.c.
References mat4::a0, mat4::a1, mat4::a2, mat4::a3, mat4::b0, mat4::b1, mat4::b2, mat4::b3, mat4::c0, mat4::c1, mat4::c2, mat4::c3, cam, mat4::d0, mat4::d1, mat4::d2, mat4::d3, Camera::forward, make_look_at(), Camera::right, Camera::up, vec3_dot(), vec3::x, vec3::y, and vec3::z.
Referenced by bake_reflection_probes(), make_look_at(), update_camera(), update_light_camera(), and write_point_light_shadows().
Computes camera vectors based on yaw, pitch, and roll.
| cam | The camera to effect. |
| yaw | The direction left-right in radians. |
| pitch | The direction up-down in radians. |
| roll | The rotation in radians. |
| world_up | The vector to cross with, normally (0,0,1). |
Definition at line 135 of file camera.c.
References cam, compute_camera_basis(), Camera::forward, Camera::right, Camera::up, vec3_add(), vec3_cross(), vec3_normalize(), vec3_scale(), vec3_sub(), vec3::x, vec3::y, and vec3::z.
Referenced by bake_reflection_probes(), compute_camera_basis(), update_camera(), and write_point_light_shadows().
Updates a camera based on a skeleton's current neck and body position.
| s | The skeleton to use to determine camera position. |
| cam | The camera to effect. |
Definition at line 476 of file camera.c.
References mat4::c0, mat4::c1, cam, Camera::cam_data, CamData::cam_pos, compute_camera_basis(), EDITOR_SETTINGS, Camera::forward, FOV, GLOBALS, HALTON_8, CamData::inv_proj, CamData::inv_view, JITTER_OFFSET, m4_inverse(), make_look_at(), make_projection(), master_frame, Skeleton::neck, Globals::noclip, Camera::pitch, player, Player::pos, Spring::pos, CamData::proj, RENDER_HEIGHT, RENDER_WIDTH, Camera::right, Camera::roll, Spring::rotation, EditorSettings::TAA, Camera::target, CamData::unjittered_inv_proj, CamData::unjittered_proj, Camera::up, update_camera(), vec3_add(), vec3_length(), vec3_to_vec4(), CamData::view, VIEW_FAR, VIEW_NEAR, vec2::x, vec3::x, vec4::x, vec2::y, vec3::y, vec4::y, Camera::yaw, vec3::z, and vec4::z.
Referenced by main(), and update_camera().
Updates a directional light camera and locks it to texel size.
| lcam | Pointer to the light camera. |
| light | Pointer to directional light. |
Definition at line 297 of file camera.c.
References cam, Camera::cam_data, Light::dir, Camera::forward, FOV, M_PI, make_look_at(), make_ortho(), mat4_mul_point(), Skeleton::neck, player, Spring::pos, CamData::proj, RENDER_HEIGHT, RENDER_WIDTH, Camera::right, SHADOW_MAP_FBO, Player::skeleton, Camera::target, Camera::up, update_light_camera(), vec3_add(), vec3_cross(), vec3_dot(), vec3_normalize(), vec3_scale(), vec3_sub(), CamData::view, Framebuffer::w, vec3::x, vec3::y, and vec3::z.
Referenced by main(), and update_light_camera().
| void resolve_collisions | ( | Camera * | current_cam | ) |
Resolves collisions between camera and geometry, uses player.
Definition at line 1377 of file camera.c.
References CollisionPoints::a, PhysicsComponent::at_rest, CollisionPoints::b, SceneData::bvh_nodes, cam, Player::cam, CAST_VEC, CollisionPoints::d, dt, GLOBALS, ground_hit, hit, MeshNode::id, MeshNode::local_matrix, mat4_mul_point(), MAX_PLAYER_CONTACTS, Globals::mesh_nodes, Globals::meshes, MIN_WALKABLE_SURFACE, CollisionPoints::mnB, CollisionPoints::normal, Camera::on_ground, MeshNode::parent, MeshNode::pc, Player::pc, player, player_find_collision(), player_resolve_impulse(), player_resolve_impulse_static(), Player::pos, RAYCAST_HEIGHT, raycast_scene(), resolve_collisions(), Globals::scene_data, MeshNode::static_mesh, Mesh::tris, vec3_add(), vec3_scale(), PhysicsComponent::vel, Mesh::vertices, vec3::x, vec3::y, and vec3::z.
Referenced by process_input(), and resolve_collisions().
Applies no-clip mode velocity to player with no gravity applied.
| move_dir | The move vectors from input. |
| dt | The frame time / simulation step time. |
Definition at line 659 of file camera.c.
References apply_velocity(), cam, dt, Player::pc, Camera::pitch, player, vec3_normalize(), vec3_scale(), PhysicsComponent::vel, vec3::x, vec3::y, Camera::yaw, and vec3::z.
Referenced by apply_velocity(), and process_input().
Applies normal velocity to player with gravity and friction applied.
| move_dir | The move vectors from input. |
| dt | The frame time / simulation step time. |
Definition at line 593 of file camera.c.
References apply_planet_velocity(), calculate_stride_governor(), cam, dt, Skeleton::left_leg, Camera::on_ground, Player::pc, Camera::pitch, player, Player::pos, Skeleton::right_leg, Player::skeleton, Player::sprinting, vec3_normalize(), vec3_scale(), PhysicsComponent::vel, vec3::x, vec3::y, Camera::yaw, and vec3::z.
Referenced by apply_planet_velocity().
Moves feet, then solves a skeleton's leg IKs and updates the springs accordingly.
| s | The skeleton to effect. |
| cam | The camera attached used to derive hip offsets. |
| vel | The incoming move input raw direction. |
Definition at line 1287 of file camera.c.
References PhysicsComponent::accel, ACCEL_BETA, calculate_camera_angles(), cam, D, dt, Camera::forward, Skeleton::hip_height, Skeleton::left_hip_pos, Skeleton::left_leg, left_leg_offset, mat3_mul_vec3(), MAX, Skeleton::neck, Skeleton::neck_pelvis_diff, PhysicsComponent::old_vel, Skeleton::p_left, Skeleton::p_right, Player::pc, Skeleton::pelvis, Skeleton::pelvis_height, player, LegIK::pos, Spring::pos, Skeleton::q_left, Skeleton::q_right, Camera::right, Skeleton::right_hip_pos, Skeleton::right_leg, right_leg_offset, rot(), Player::skeleton, solve_Q(), Spring::target, Camera::up, update_leg(), update_skeleton(), update_spring(), vec3_add(), vec3_length(), vec3_normalize(), vec3_scale(), vec3_sub(), PhysicsComponent::vel, vec3::x, vec3::y, and vec3::z.
Referenced by process_input(), and update_skeleton().
Calculates velocity based on leg positions and integrates them into the player.
Also handles falling off ledges by initiating a drop when raycasts to ground fail above a certain margin.
| left_leg | Left leg IK. |
| right_leg | Right leg IK. |
| intended_vel | The raw input direction. |
| dt | The frame time / simulation frame time. |
Definition at line 1052 of file camera.c.
References SceneData::bvh_nodes, cam, CAST_VEC, dt, GLOBALS, hit, RayHit::hit, Player::pc, Camera::pitch, player, LegIK::pos, Player::pos, RayHit::pos, raycast_scene(), Globals::scene_data, LegIK::stepping, LegIK::stepping_off_ledge, update_body_from_legs(), vec3_add(), vec3_normalize(), vec3_scale(), vec3_sub(), PhysicsComponent::vel, vec3::x, vec3::y, Camera::yaw, and vec3::z.
Referenced by process_input(), and update_body_from_legs().
Resets a skeleton to be relative to a new position.
| s | The skeleton to effect. |
| pos | The target position. |
Definition at line 963 of file camera.c.
References Spring::angular_vel, Skeleton::left_leg, Skeleton::neck, Skeleton::neck_height, Skeleton::pelvis, Skeleton::pelvis_height, LegIK::pos, Spring::pos, reset_skeleton(), Skeleton::right_leg, LegIK::stepping, Spring::velocity, and vec3::z.
Referenced by process_input(), and reset_skeleton().
| bool collision | ( | vec3 | proposed, |
| vec3 | pts[3], | ||
| vec3 | normal, | ||
| CollisionPoints * | p ) |
Definition at line 443 of file camera.c.
References CollisionPoints::a, closest_point_triangle(), collision(), CollisionPoints::d, vec3_length(), and vec3_sub().
Referenced by collision(), GJK(), player_find_collision(), and process_collision_node().
|
extern |
This is currently the player cam.
Definition at line 322 of file main.c.
Referenced by apply_planet_velocity(), apply_velocity(), calculate_camera_angles(), compute_camera_basis(), get_view_planes(), init_player(), main(), make_look_at(), PC_resolve_impulse(), PC_resolve_impulse_static(), player_resolve_impulse(), player_resolve_impulse_static(), process_input(), process_sdl_event(), render(), resolve_collisions(), update_body_from_legs(), update_camera(), update_leg(), update_light_camera(), update_player_ir(), and update_skeleton().