Graphics v0.0.0
A simple abstraction layer for the modern graphics APIs.
载入中...
搜索中...
未找到
Camera类 参考

摄像机. 更多...

#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::Camera ( Type  type)

默认构造函数.

参数
type投影类型.

成员函数说明

◆ set_orthographic()

void Camera::set_orthographic ( float  width,
float  height,
float  near,
float  far 
)

设置正投影观观察体, 用于正交投影.

参数
width宽度.
height高度.
near近裁剪平面距离, 最近可见范围.
far远裁剪平面距离, 最远可见范围.

◆ set_perspective()

void Camera::set_perspective ( float  vFOV,
float  aspectRatio,
float  near,
float  far 
)

设置截头锥体观察体, 用于透视投影.

参数
vFOV垂直视角范围, 单位: 弧度.
aspectRatio宽高比.
near近裁剪平面距离, 最近可见范围.
far远裁剪平面距离, 最远可见范围.

◆ set_position()

void Camera::set_position ( const Vector3f &  pos)

设置相机坐标.

参数
pos相机坐标.

◆ set_rotation()

void Camera::set_rotation ( const Vector3f &  rot)

设置绕各轴旋转的角度.

参数
rot绕各轴旋转的角度. rot.x 为绕 x 轴旋转的角度, rot.y 为绕 y 轴旋转的角度, rot.z 为绕 z 轴旋转的角度.

该类的文档由以下文件生成: