|
ShitEngine
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
|
相机组件,定义"从哪个角度观察世界" 更多...
#include <CameraComponent.h>
Public 成员函数 | |
| CameraComponent () | |
| void | onAttach () override |
| void | onDestroy () override |
| Vector2 | worldToScreen (const Vector2 &worldPosition) const |
| 世界坐标 → 屏幕像素坐标 | |
| Vector2 | screenToWorld (const Vector2 &screenPosition) const |
| 屏幕像素坐标 → 世界坐标 | |
| Vector2 | getPosition () const |
| 相机中心位置(从 TransformComponent 同步读取) | |
| Vector2 | getSize () const |
| 视口世界大小 | |
| float | getZoom () const |
| 缩放系数 | |
| int | getPriority () const |
| 渲染优先级(小值先画) | |
| float | getPixelPerUnit () const |
| 每逻辑单位对应的像素数 | |
| void | setSize (const Vector2 &worldSize) |
| void | setZoom (float zoom) |
| void | setPriority (int priority) |
| const SDL_FRect & | getViewportRatio () const |
| 视口比例 (0~1) | |
| void | setViewportRatio (const SDL_FRect &ratio) |
| 设置视口比例 | |
| Public 成员函数 继承自 Component | |
| Component () | |
| virtual | ~Component ()=default |
| virtual void | onCreate () |
| virtual void | onDetach () |
| Component (const Component &)=delete | |
| Component & | operator= (const Component &)=delete |
| Component (Component &&)=delete | |
| Component & | operator= (Component &&)=delete |
| GameObject * | getOwner () const |
| bool | isRegistered () const |
额外继承的成员函数 | |
| Protected 属性 继承自 Component | |
| GameObject * | m_owner = nullptr |
| bool | m_isRegistered = false |
相机组件,定义"从哪个角度观察世界"
相机的位置由同 GameObject 上的 TransformComponent 决定。 m_worldSize 决定能看到的世界范围,m_viewportRatio 决定渲染到屏幕的哪个区域。 支持多相机分屏渲染(按 priority 排序)。
| CameraComponent | ( | ) |
| float getPixelPerUnit | ( | ) | const |
每逻辑单位对应的像素数
| Vector2 getPosition | ( | ) | const |
相机中心位置(从 TransformComponent 同步读取)
|
inline |
渲染优先级(小值先画)
|
inline |
视口世界大小
|
inline |
视口比例 (0~1)
|
inline |
缩放系数
|
overridevirtual |
重载 Component .
|
overridevirtual |
重载 Component .
|
inline |
|
inline |
|
inline |
设置视口比例
|
inline |