xcal
基于 C++23 的现代图形渲染引擎
载入中...
搜索中...
未找到
perspectivecamera.hpp
浏览该文件的文档.
1
11#pragma once
12
13#include <xcal/public.h>
14
17#include <xcal/property/vec.hpp>
18#include <xcmath/xcmath.hpp>
19
20namespace xcal::camera {
21
30 private:
31 /* 投影参数 */
32 property::Scalar fov_;
33 property::Scalar aspect_;
34 property::Scalar near_;
35 property::Scalar far_;
36
37 /* 缓存 */
39 projection_matrix_cache_{};
40
41 public:
49 PerspectiveCamera(float fov, float aspect, float near, float far)
50 : AbsCamera(), fov_(fov), aspect_(aspect), near_(near), far_(far) {}
51
52 public:
53 /* 公共访问器方法 */
58 property::Scalar& fov() { return fov_; }
59
64 const property::Scalar& fov() const { return fov_; }
65
70 property::Scalar& aspect() { return aspect_; }
71
76 const property::Scalar& aspect() const { return aspect_; }
77
82 property::Scalar& near() { return near_; }
83
88 const property::Scalar& near() const { return near_; }
89
94 property::Scalar& far() { return far_; }
95
100 const property::Scalar& far() const { return far_; }
101
109 fov_ = fov;
110 projection_has_changed();
111 return this;
112 }
113
121 aspect_ = aspect;
122 projection_has_changed();
123 return this;
124 }
125
133 near_ = near;
134 projection_has_changed();
135 return this;
136 }
137
145 far_ = far;
146 projection_has_changed();
147 return this;
148 }
149
155 const xcmath::mat<float_t, 4, 4>& projection_matrix() const override;
156
162 bool_t projection_should_update() const override;
163
164 private:
169 void update_projection_matrix() const;
170};
171
172} // namespace xcal::camera
抽象相机基类
#define XCAL_CAMERA_TYPE(tp)
相机系统命名空间
PerspectiveCamera(float fov, float aspect, float near, float far)
构造函数
PerspectiveCamera * set_fov(float fov)
设置视野角度
const property::Scalar & far() const
获取远裁剪平面距离(只读)
PerspectiveCamera * set_far(float far)
设置远裁剪平面距离
property::Scalar & aspect()
获取宽高比(可修改)
PerspectiveCamera * set_aspect(float aspect)
设置宽高比
const property::Scalar & aspect() const
获取宽高比(只读)
property::Scalar & near()
获取近裁剪平面距离(可修改)
property::Scalar & far()
获取远裁剪平面距离(可修改)
PerspectiveCamera * set_near(float near)
设置近裁剪平面距离
const property::Scalar & near() const
获取近裁剪平面距离(只读)
const property::Scalar & fov() const
获取视野角度(只读)
property::Scalar & fov()
获取视野角度(可修改)
Matrix class template
Definition mat.hpp:27
PerspectiveCamera 测试套件
@ Perspective
透视相机
bool bool_t
Definition public.h:28
#define XCAL_API
Definition public.h:69