holds necessary information to produce projection matrix
#include <camera.hpp>
Inherits renderstack::frame.
Public Member Functions | |
camera () | |
void | update (viewport const &viewport) |
void | update_frame (frame const &frame) |
bool | connect (uniform_bindings &bindings, enum logical_uniform uniform, int slot) |
void | set_near_clip (float v) |
void | set_far_clip (float v) |
void | set_projection_type (enum camera_projection v) |
void | set_fov (float angle_radians) |
void | set_ortho_width (float v) |
void | set_ortho_height (float v) |
float | near_clip () const |
float | far_clip () const |
enum camera_projection | projection_type () const |
float | fov () const |
float | ortho_width () const |
float | ortho_height () const |
matrix const & | frame_to_clip () const |
matrix const & | frame_to_camera () const |
matrix const & | world_to_clip () const |
matrix const & | clip_to_world () const |
matrix const & | clip_to_local () const |
matrix const & | local_to_clip () const |
matrix & | frame_to_clip () |
matrix & | frame_to_camera () |
matrix & | world_to_clip () |
matrix & | clip_to_world () |
matrix & | clip_to_local () |
matrix & | local_to_clip () |
Definition at line 53 of file camera.hpp.
renderstack::camera::camera | ( | ) |
Definition at line 33 of file camera.cpp.
00034 { 00035 m_near_clip = 0.1f; 00036 m_far_clip = 100.0f; 00037 m_projection_type = camera_projection_perspective_vertical; 00038 m_fov = 90.0f * RS_PI / 180.0f; 00039 }
void renderstack::camera::update | ( | viewport const & | viewport | ) |
Definition at line 55 of file camera.cpp.
00056 { 00057 switch(m_projection_type) 00058 { 00059 case camera_projection_perspective_horizontal: 00060 { 00061 m_local_to_clip = make_matrix_perspective_horizontal( 00062 m_fov, 00063 viewport.aspect_ratio(), 00064 m_near_clip, 00065 m_far_clip 00066 ); 00067 break; 00068 } 00069 case camera_projection_perspective_vertical: 00070 { 00071 m_local_to_clip = make_matrix_perspective_vertical( 00072 m_fov, 00073 viewport.aspect_ratio(), 00074 m_near_clip, 00075 m_far_clip 00076 ); 00077 break; 00078 } 00079 case camera_projection_orthogonal_horizontal: 00080 { 00081 m_local_to_clip = make_matrix_orthogonal_centered( 00082 m_ortho_width, 00083 m_ortho_width / viewport.aspect_ratio(), 00084 m_near_clip, 00085 m_far_clip 00086 ); 00087 break; 00088 } 00089 case camera_projection_orthogonal_vertical: 00090 { 00091 m_local_to_clip = make_matrix_orthogonal_centered( 00092 m_ortho_height * viewport.aspect_ratio(), 00093 m_ortho_height, 00094 m_near_clip, 00095 m_far_clip 00096 ); 00097 break; 00098 } 00099 case camera_projection_orthogonal: 00100 { 00101 m_local_to_clip = make_matrix_orthogonal( 00102 0, 00103 m_ortho_width, 00104 0, 00105 m_ortho_height, 00106 m_near_clip, 00107 m_far_clip 00108 ); 00109 break; 00110 } 00111 default: 00112 { 00113 throw invalid_camera_projection_exception(); 00114 } 00115 } 00116 00117 { 00118 m_clip_to_local = inverse(m_local_to_clip); 00119 } 00120 00121 m_world_to_clip = local_to_clip() * world_to_local(); 00122 m_clip_to_world = local_to_world() * clip_to_local(); 00123 }
void renderstack::camera::update_frame | ( | frame const & | frame | ) |
Definition at line 125 of file camera.cpp.
00126 { 00127 m_frame_to_clip = this->world_to_clip() * frame.local_to_world(); 00128 m_frame_to_camera = this->world_to_local() * frame.local_to_world(); 00129 }
bool renderstack::camera::connect | ( | uniform_bindings & | bindings, | |
enum logical_uniform | uniform, | |||
int | slot | |||
) | [virtual] |
Reimplemented from renderstack::frame.
Definition at line 41 of file camera.cpp.
00042 { 00043 switch(uniform) 00044 { 00045 case logical_uniform_local_to_clip : return bindings.add(uniform_type_matrix_4, slot, 1, &frame_to_clip().m[0][0]); 00046 case logical_uniform_clip_to_local : return bindings.add(uniform_type_matrix_4, slot, 1, &clip_to_local().m[0][0]); 00047 case logical_uniform_world_to_clip : return bindings.add(uniform_type_matrix_4, slot, 1, &world_to_clip().m[0][0]); 00048 case logical_uniform_clip_to_world : return bindings.add(uniform_type_matrix_4, slot, 1, &clip_to_world().m[0][0]); 00049 case logical_uniform_view_position_in_world: return bindings.add(uniform_type_vec3, slot, 1, &local_to_world().m[3][0]); 00050 default: 00051 return false; 00052 } 00053 }
void renderstack::camera::set_near_clip | ( | float | v | ) | [inline] |
Definition at line 65 of file camera.hpp.
void renderstack::camera::set_far_clip | ( | float | v | ) | [inline] |
Definition at line 66 of file camera.hpp.
void renderstack::camera::set_projection_type | ( | enum camera_projection | v | ) | [inline] |
Definition at line 67 of file camera.hpp.
void renderstack::camera::set_fov | ( | float | angle_radians | ) | [inline] |
Definition at line 68 of file camera.hpp.
void renderstack::camera::set_ortho_width | ( | float | v | ) | [inline] |
Definition at line 69 of file camera.hpp.
void renderstack::camera::set_ortho_height | ( | float | v | ) | [inline] |
Definition at line 70 of file camera.hpp.
float renderstack::camera::near_clip | ( | ) | const [inline] |
Definition at line 72 of file camera.hpp.
float renderstack::camera::far_clip | ( | ) | const [inline] |
Definition at line 73 of file camera.hpp.
enum camera_projection renderstack::camera::projection_type | ( | ) | const [inline] |
Definition at line 74 of file camera.hpp.
float renderstack::camera::fov | ( | ) | const [inline] |
Definition at line 75 of file camera.hpp.
float renderstack::camera::ortho_width | ( | ) | const [inline] |
Definition at line 76 of file camera.hpp.
float renderstack::camera::ortho_height | ( | ) | const [inline] |
Definition at line 77 of file camera.hpp.
matrix const& renderstack::camera::frame_to_clip | ( | ) | const [inline] |
Definition at line 79 of file camera.hpp.
matrix const& renderstack::camera::frame_to_camera | ( | ) | const [inline] |
Definition at line 80 of file camera.hpp.
matrix const& renderstack::camera::world_to_clip | ( | ) | const [inline] |
Definition at line 81 of file camera.hpp.
matrix const& renderstack::camera::clip_to_world | ( | ) | const [inline] |
Definition at line 82 of file camera.hpp.
matrix const& renderstack::camera::clip_to_local | ( | ) | const [inline] |
Definition at line 83 of file camera.hpp.
matrix const& renderstack::camera::local_to_clip | ( | ) | const [inline] |
Definition at line 84 of file camera.hpp.
matrix& renderstack::camera::frame_to_clip | ( | ) | [inline] |
Definition at line 86 of file camera.hpp.
matrix& renderstack::camera::frame_to_camera | ( | ) | [inline] |
Definition at line 87 of file camera.hpp.
matrix& renderstack::camera::world_to_clip | ( | ) | [inline] |
Definition at line 88 of file camera.hpp.
matrix& renderstack::camera::clip_to_world | ( | ) | [inline] |
Definition at line 89 of file camera.hpp.
matrix& renderstack::camera::clip_to_local | ( | ) | [inline] |
Definition at line 90 of file camera.hpp.
matrix& renderstack::camera::local_to_clip | ( | ) | [inline] |
Definition at line 91 of file camera.hpp.