Graphics v0.0.0
A simple abstraction layer for the modern graphics APIs.
|
摄像机. 更多...
#include <Camera.h>
类 | |
struct | Orthographic |
struct | Perspective |
Public 类型 | |
enum class | Type { Perspective , Orthographic } |
投影类型. | |
Public 成员函数 | |
Camera (Type type) | |
默认构造函数. 更多... | |
void | set_perspective (float vFOV, float aspectRatio, float near, float far) |
设置截头锥体观察体, 用于透视投影. 更多... | |
void | set_orthographic (float width, float height, float near, float far) |
设置正投影观观察体, 用于正交投影. 更多... | |
Type | get_type () const |
获取投影类型. | |
float | get_vfov () const |
获取垂直视角范围, 单位: 弧度. | |
float | get_hfov () const |
获取水平视角范围, 单位: 弧度. | |
float | get_aspect_ratio () const |
获取宽高比. | |
float | get_near () const |
获取近裁剪平面距离. | |
float | get_far () const |
获取远裁剪平面距离. | |
void | set_position (const Vector3f &pos) |
设置相机坐标. 更多... | |
const Vector3f & | get_position () const |
获得相机坐标. | |
void | set_rotation (const Vector3f &rot) |
设置绕各轴旋转的角度. 更多... | |
const Vector3f & | get_rotation () const |
获取绕各轴旋转的角度. | |
Vector3f | get_front () const |
Vector3f | get_right () const |
Vector3f | get_up () const |
const Matrix4 & | get_view () const |
获取观察矩阵. | |
const Matrix4 & | get_projection () const |
获取投影矩阵. | |
Protected 成员函数 | |
void | update_projection_matrix () const |
更新投影矩阵. | |
void | update_view_matrix () const |
更新视图矩阵. | |
Protected 属性 | |
union { | |
Perspective perspective_ | |
Orthographic orthographic_ | |
}; | |
Type | type_ |
Vector3f | position_ |
Vector3f | rotation_ |
Vector3f | up_ = -Vector3f({0.f, 1.f, 0.f}) |
Matrix4 | projection_ |
bool | projection_dirty_ = true |
Matrix4 | view_ |
bool | view_dirty_ = true |
摄像机.
Camera::Camera | ( | Type | type | ) |
默认构造函数.
type | 投影类型. |
void Camera::set_orthographic | ( | float | width, |
float | height, | ||
float | near, | ||
float | far | ||
) |
设置正投影观观察体, 用于正交投影.
width | 宽度. |
height | 高度. |
near | 近裁剪平面距离, 最近可见范围. |
far | 远裁剪平面距离, 最远可见范围. |
void Camera::set_perspective | ( | float | vFOV, |
float | aspectRatio, | ||
float | near, | ||
float | far | ||
) |
设置截头锥体观察体, 用于透视投影.
vFOV | 垂直视角范围, 单位: 弧度. |
aspectRatio | 宽高比. |
near | 近裁剪平面距离, 最近可见范围. |
far | 远裁剪平面距离, 最远可见范围. |
void Camera::set_position | ( | const Vector3f & | pos | ) |
设置相机坐标.
pos | 相机坐标. |
void Camera::set_rotation | ( | const Vector3f & | rot | ) |
设置绕各轴旋转的角度.
rot | 绕各轴旋转的角度. rot.x 为绕 x 轴旋转的角度, rot.y 为绕 y 轴旋转的角度, rot.z 为绕 z 轴旋转的角度. |