Class Info |
|---|
class Camera : public IComponent 相机类,主要提供相机的位置、投影类型、视场角、近裁平面、远裁平面的设置和获取。 |
Qualifier and Type |
Method Name and Description |
|---|---|
virtual void |
Start() override 初始化相机的视锥体。 |
virtual void |
Update(f32 deltaTime) override 更新相机视口、投影矩阵、视图矩阵和视锥体。 |
void |
SetProjectionType(ProjectionType projectionType) 设置相机投影类型。 |
void |
SetPerspective(f32 fov, f32 aspectRatio, f32 zNear, f32 zFar) 设置视场角、宽高比、相机距近裁平面距离、相机距远裁平面距离。 |
void |
SetOrthogonal(f32 left, f32 right, f32 bottom, f32 top, f32 zNear, f32 zFar) 设置相机正交投影参数。 |
void |
设置相机到近裁平面的距离。 |
void |
设置相机到远裁平面的距离。 |
void |
设置视场角。 |
void |
SetViewport(u32 x, u32 y, u32 width, u32 height, f32 minDepth = 0.0f, f32 maxDepth = 1.0f) 设置视口。 |
void |
SetEyePos(const Vector3& eyePos) 设置相机位置。 |
void |
SetTarget(const Vector3& targetPos) 设置相机目标位置。 |
void |
SetPreRotation(const Matrix4& preRotation) 设置相机旋转角度。 |
const Frustum* |
GetFrustum() const 获取相机的视锥体。 |
const Matrix4& |
GetProjectionMatrix() const 获取相机投影矩阵。 |
const Matrix4& |
GetViewMatrix() const 获取相机视图矩阵。 |
GetProjectionType() const 获取相机投影类型,如正投影、透视投影。 |
|
GetAspectRatio() const 获取宽高比。 |
|
GetFOV() const 获取视场角。 |
|
GetZNear() const 获取相机到近裁平面的距离。 |
|
GetZFar() const 获取相机到远裁平面的距离。 |
|
GetLeft() const 获取相机距左边界平面距离。 |
|
GetRight() const 获取相机距右边界平面距离。 |
|
GetBottom() const 获取相机距下边界平面距离。 |
|
GetTop() const 获取相机距上边界平面距离。 |
|
const Vector3& |
GetEyePos() const 获取相机位置。 |
const Vector3& |
GetTarget() const 获取相机移动的目标位置。 |
const Vector3& |
GetLookDir() const 获取相机的向前方向向量。 |
const Vector3& |
GetUpDir() const 获取相机的向上方向向量。 |
const Vector3& |
GetRightDir() const 获取相机的向右方向向量。 |
void |
SetMainCamera(bool bMain) 设置相机是否为主相机。 |
bool |
IsMainCamera() const 判断相机是否为主相机。 |
GetLayerMask() const 获取相机的渲染对象类型掩码。 |
|
void |
SetLayerMask(u32 layerMask) 设置相机的渲染对象类型掩码。 |
void |
SetRenderingPath(RenderingPathType type, RenderTargetType targetType =RenderTargetType::FROM_SWAPCHAIN) 设置相机的渲染路径以及渲染目标类型。 |
const Viewport& |
GetViewPort() const 获取相机的渲染视口。 |
virtual void |
PostUpdate(f32 deltaTime) override 更新相机的资源裁剪信息以及渲染路径。 |
void |
重置相机渲染目标的宽度和高度。 |
virtual void |
Render() 执行相机渲染流程。 |
void |
Pause() 暂停相机渲染流程操作。 |
void |
Resume() 恢复相机渲染流程操作。 |
void |
SetScreenRatio(const Vector4& ratio) 设置相机占据屏幕位置的比例。 |
GetRenderTargetType() const 获取渲染目标的类型。 |
|
virtual void |
SetMultiSampleInfo(const MultiSampleInfo& sampleInfo) 设置多重采样抗锯齿参数。 |
const MultiSampleInfo& |
GetMultiSampleInfo() const 获取多重采样抗锯齿参数。 |
void |
SetClearColor(const Color& color) 设置清屏色参数。 |
const RenderingPath* |
GetRenderingPath() const 获取相机的渲染路径。 |
template <typename T> T* |
添加后处理到camera,并返回已添加的后处理的指针变量。 |
template <typename T> void |
删除某个已添加的后处理。 |
Constructor |
|---|
Camera(SceneObject* sceneObject = nullptr) 构造函数。 |
Parameters
Name |
Description |
|---|---|
sceneObject |
指定初始化的场景对象。 |
Method |
|---|
virtual void Update(f32 deltaTime) override 更新相机视口、投影矩阵、视图矩阵和视锥体。 |
Parameters
Name |
Description |
|---|---|
deltaTime |
帧间隔时间,单位为秒。 |
Method |
|---|
void SetProjectionType(ProjectionType projectionType) 设置相机投影类型。 |
Parameters
Name |
Description |
|---|---|
projectionType |
ProjectionType枚举值,如正投影、透视投影。 |
Method |
|---|
void SetPerspective(f32 fov, f32 aspectRatio, f32 zNear, f32 zFar) 设置透视相机的视场角、宽高比、相机距近裁平面距离、相机距远裁平面距离。 |
Parameters
Name |
Description |
|---|---|
fov |
视场角。 |
aspectRatio |
宽高比。 |
zNear |
相机距近裁平面距离。 |
zFar |
相机距远裁平面距离。 |
Method |
|---|
void SetOrthogonal(f32 left, f32 right, f32 bottom, f32 top, f32 zNear, f32 zFar) 设置相机正交投影参数。 |
Parameters
Name |
Description |
|---|---|
left |
相机距左边界平面距离。 |
right |
相机距右边界平面距离。 |
bottom |
相机距下边界平面距离。 |
top |
相机距上边界平面距离。 |
zNear |
相机距近边界平面距离。 |
zFar |
相机距远边界平面距离。 |
Method |
|---|
void SetFOV(f32 fov) 设置视场角。 |
Parameters
Name |
Description |
|---|---|
fov |
待设置视场角,非弧度,fov指垂直视场角度。 |
Method |
|---|
void SetViewport(u32 x, u32 y, u32 width, u32 height, f32 minDepth = 0.0f, f32 maxDepth = 1.0f) 设置视口。 |
Parameters
Name |
Description |
|---|---|
x |
视口左上角X坐标。 |
y |
视口左上角Y坐标。 |
width |
视口宽度。 |
height |
视口高度。 |
minDepth |
视口最小深度,默认值为0.0f。 |
maxDepth |
视口最大深度,默认值为1.0f。 |
Method |
|---|
void SetZNear(f32 zNear) 设置相机到近裁平面的距离。 |
Parameters
Name |
Description |
|---|---|
zNear |
相机到近裁平面的距离。 |
Method |
|---|
void SetZFar(f32 zFar) 设置相机到远裁平面的距离。 |
Parameters
Name |
Description |
|---|---|
zFar |
相机到远裁平面的距离。 |
Method |
|---|
void SetEyePos(const Vector3& eyePos) 设置相机位置。 |
Parameters
Name |
Description |
|---|---|
eyePos |
相机位置。 |
Method |
|---|
void SetTarget(const Vector3& targetPos) 设置相机目标位置。 |
Parameters
Name |
Description |
|---|---|
targetPos |
相机目标位置。 |
Method |
|---|
void SetPreRotation(const Matrix4& preRotation) 设置相机旋转角度。 |
Parameters
Name |
Description |
|---|---|
preRotation |
相机角度。 |
Method |
|---|
const Frustum* GetFrustum() const 获取相机的视锥体。 |
Returns
Type |
Description |
|---|---|
const Frustum* |
返回相机视锥体对象引用。 |
Method |
|---|
const Matrix4& GetProjectionMatrix() const 获取相机投影矩阵。 |
Returns
Type |
Description |
|---|---|
const Matrix4& |
返回相机投影矩阵。 |
Method |
|---|
const Matrix4& GetViewMatrix() const 获取相机视图矩阵。 |
Returns
Type |
Description |
|---|---|
const Matrix4& |
返回相机视图矩阵。 |
Method |
|---|
ProjectionType GetProjectionType() const 获取相机投影类型,如正投影、透视投影。 |
Returns
Type |
Description |
|---|---|
返回相机投影类型,如正投影、透视投影。 |
Method |
|---|
const Vector3& GetEyePos() const 获取相机位置。 |
Returns
Type |
Description |
|---|---|
const Vector3& |
返回相机位置。 |
Method |
|---|
const Vector3& GetTarget() const 获取相机移动的目标位置。 |
Returns
Type |
Description |
|---|---|
const Vector3& |
返回相机移动的目标位置。 |
Method |
|---|
const Vector3& GetLookDir() const 获取相机的向前方向向量。 |
Returns
Type |
Description |
|---|---|
const Vector3& |
返回相机的向前方向向量。 |
Method |
|---|
const Vector3& GetUpDir() const 获取相机的向上方向向量。 |
Returns
Type |
Description |
|---|---|
const Vector3& |
返回相机的向上方向向量。 |
Method |
|---|
const Vector3& GetRightDir() const 获取相机的向右方向向量。 |
Returns
Type |
Description |
|---|---|
const Vector3& |
返回相机的向右方向向量。 |
Method |
|---|
void SetMainCamera(bool bMain) 设置相机是否为主相机。 |
Parameters
Name |
Description |
|---|---|
bMain |
设置相机是否为主相机。
|
Method |
|---|
bool IsMainCamera() const 判断相机是否为主相机。 |
Returns
Type |
Description |
|---|---|
bool |
|
Method |
|---|
void SetLayerMask(u32 layerMask) 设置相机的渲染对象类型掩码。 |
Parameters
Name |
Description |
|---|---|
layerMask |
相机的渲染对象类型掩码,以位域形式表示,掩码值请参考LayerType。例如要渲染天空盒和几何体类型的场景对象,调用方式为: SetLayerMask(LAYER_TYPE_GEOMETRY | LAYER_TYPE_SKYBOX)。 |
Method |
|---|
void SetRenderingPath(RenderingPathType type, RenderTargetType targetType = RenderTargetType::FROM_SWAPCHAIN) 设置相机的渲染路径以及渲染目标类型。 |
Parameters
Name |
Description |
|---|---|
type |
渲染路径,具体请参见RenderingPathType。 |
targetType |
渲染目标类型,默认值为FROM_SWAPCHAIN,具体请参见RenderTargetType。 |
Method |
|---|
virtual void PostUpdate(f32 deltaTime) override 更新相机的资源裁剪信息以及渲染路径。 |
Parameters
Name |
Description |
|---|---|
deltaTime |
帧间隔时间,单位为秒。 |
Method |
|---|
void SetScreenRatio(const Vector4& ratio) 设置相机占据屏幕位置的比例。 |
Parameters
Name |
Description |
|---|---|
ratio |
Vector4类型相机渲染目标在屏幕上的起始点与终点位置信息。 |
Method |
|---|
RenderTargetType GetRenderTargetType() const 获取渲染目标的类型。 |
Returns
Type |
Description |
|---|---|
返回RenderTargetType类型的渲染目标的类型。 |
Method |
|---|
virtual void SetMultiSampleInfo(const MultiSampleInfo& sampleInfo) 设置多重采样抗锯齿参数。 |
Parameters
Name |
Description |
|---|---|
sampleInfo |
多重采样抗锯齿参数。 |
Method |
|---|
const MultiSampleInfo& GetMultiSampleInfo() const 获取多重采样抗锯齿参数。 |
Returns
Type |
Description |
|---|---|
返回多重采样抗锯齿参数。 |
Method |
|---|
void SetClearColor(const Color& color) 设置清屏色参数。 |
Parameters
Name |
Description |
|---|---|
color |
清屏色参数。 |
Method |
|---|
const RenderingPath* GetRenderingPath() const 获取相机的渲染路径。 |
Returns
Type |
Description |
|---|---|
返回相机的渲染路径。 |