Skylicht Engine
Loading...
Searching...
No Matches
CCameraBrain.h
1/*
2!@
3MIT License
4
5Copyright (c) 2024 Skylicht Technology CO., LTD
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
8(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
9merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20This file is part of the "Skylicht Engine".
21https://github.com/skylicht-lab/skylicht-engine
22!#
23*/
24
25#pragma once
26
27#include "CCamera.h"
28#include "Components/CComponentSystem.h"
29#include "Components/ILateUpdate.h"
30
31namespace Skylicht
32{
88 class SKYLICHT_API CCameraBrain :
89 public CComponentSystem,
90 public ILateUpdate
91 {
92 protected:
95
98
100 float m_blend;
101
103 core::vector3df m_position;
104
106 core::vector3df m_lookAt;
107
109 core::vector3df m_upVector;
110
113
116
119
121 core::vector3df m_lastPosition;
122
124 core::vector3df m_lastLookAt;
125
127 core::vector3df m_lastUpVector;
128
131
134
137
138 public:
139 CCameraBrain();
140
141 virtual ~CCameraBrain();
142
143 virtual void initComponent();
144
145 virtual void updateComponent();
146
147 virtual void lateUpdate();
148
154 void setTargetCamera(CCamera* cam, float blendTarget = 1.0f);
155
161 {
162 return m_camera;
163 }
164
170 {
171 return m_targetCamera;
172 }
173
178 inline void setBlendValue(float value)
179 {
180 m_blend = value;
181 }
182
187 inline float getBlendValue()
188 {
189 return m_blend;
190 }
191
196 inline const core::vector3df& getPosition()
197 {
198 return m_position;
199 }
200
205 inline const core::vector3df& getLookAt()
206 {
207 return m_lookAt;
208 }
209
214 inline const core::vector3df& getUp()
215 {
216 return m_upVector;
217 }
218 };
219}
float m_viewNear
Current blended near plane.
Definition CCameraBrain.h:115
CCamera * m_targetCamera
The target camera to blend towards.
Definition CCameraBrain.h:97
float m_lastFar
Last far plane before starting a new blend.
Definition CCameraBrain.h:136
CCamera * m_camera
Pointer to the main camera component being controlled.
Definition CCameraBrain.h:94
float m_lastNear
Last near plane before starting a new blend.
Definition CCameraBrain.h:133
core::vector3df m_lookAt
Current blended forward direction.
Definition CCameraBrain.h:106
const core::vector3df & getLookAt()
Gets the current blended forward look direction.
Definition CCameraBrain.h:205
const core::vector3df & getPosition()
Gets the current blended world position.
Definition CCameraBrain.h:196
core::vector3df m_lastPosition
Last position before starting a new blend.
Definition CCameraBrain.h:121
CCamera * getCamera()
Gets the main camera component controlled by this brain.
Definition CCameraBrain.h:160
float m_viewFar
Current blended far plane.
Definition CCameraBrain.h:118
void setTargetCamera(CCamera *cam, float blendTarget=1.0f)
Sets a new target camera and initiates blending.
core::vector3df m_lastUpVector
Last up direction before starting a new blend.
Definition CCameraBrain.h:127
core::vector3df m_lastLookAt
Last forward direction before starting a new blend.
Definition CCameraBrain.h:124
float m_lastFov
Last FOV before starting a new blend.
Definition CCameraBrain.h:130
const core::vector3df & getUp()
Gets the current blended 'up' vector.
Definition CCameraBrain.h:214
float m_blend
Current blending factor (0 to 1).
Definition CCameraBrain.h:100
float m_viewFov
Current blended FOV.
Definition CCameraBrain.h:112
core::vector3df m_upVector
Current blended up direction.
Definition CCameraBrain.h:109
void setBlendValue(float value)
Manually sets the blending factor.
Definition CCameraBrain.h:178
CCamera * getTargetCamera()
Gets the current target camera.
Definition CCameraBrain.h:169
core::vector3df m_position
Current blended world position.
Definition CCameraBrain.h:103
float getBlendValue()
Gets the current blending factor.
Definition CCameraBrain.h:187
This is an object class used to set up the camera, including its position, viewing angle,...
Definition CCamera.h:70
Definition ILateUpdate.h:6
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29