Skylicht Engine
Loading...
Searching...
No Matches
C3rdCamera.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
29#include "Utils/CActivator.h"
30
31#include "Components/CComponentSystem.h"
32#include "Components/ILateUpdate.h"
33
34#include "GameObject/CGameObject.h"
35#include "Entity/CEntity.h"
36#include "Transform/CWorldTransformData.h"
37
38namespace Skylicht
39{
68 class SKYLICHT_API C3rdCamera :
69 public CComponentSystem,
70 public IEventReceiver,
71 public ILateUpdate
72 {
73 public:
74
75 protected:
78
81
84
87
90
93
96
98 float m_camPan;
99
102
105
108
111
114
117
120
121 public:
122 C3rdCamera();
123
124 virtual ~C3rdCamera();
125
126 virtual void initComponent();
127
128 virtual void updateComponent();
129
130 virtual void lateUpdate();
131
132 virtual bool OnEvent(const SEvent& event);
133
139 {
140 return m_camera;
141 }
142
147 inline void setFollowPosition(const core::vector3df& pos)
148 {
149 m_followPosition = pos;
150 m_isFollowPosition = true;
151 }
152
158 {
159 return m_followPosition;
160 }
161
166 inline void setFollowTarget(CGameObject* object)
167 {
168 m_followEntity = object->getEntity();
169 m_isFollowPosition = false;
170 }
171
176 inline void setFollowTarget(CEntity* entity)
177 {
178 m_followEntity = entity;
179 m_isFollowPosition = false;
180 }
181
188 inline void setOrientation(float pan, float tilt, float distance)
189 {
190 m_camPan = pan;
191 m_camTilt = tilt;
192 m_targetDistance = distance;
193 }
194
200 inline void setOrientation(float pan, float tilt)
201 {
202 m_camPan = pan;
203 m_camTilt = tilt;
205 }
206
212 inline void setMinMaxVerticaAngle(float min, float max)
213 {
214 m_minVerticalAngle = min;
215 m_maxVerticalAngle = max;
216 }
217
222 inline float getMinVerticalAngle()
223 {
224 return m_minVerticalAngle;
225 }
226
231 inline float getMaxVerticalAngle()
232 {
233 return m_maxVerticalAngle;
234 }
235
240 inline void setTargetDistance(float d)
241 {
243 }
244
249 inline float getCameraPan()
250 {
251 return m_camPan;
252 }
253
258 inline float getCameraTilt()
259 {
260 return m_camTilt;
261 }
262
267 inline float getTargetDistance()
268 {
269 return m_targetDistance;
270 }
271
276 inline void setTargetOffset(const core::vector3df& offset)
277 {
278 m_targetOffset = offset;
279 }
280
286 {
287 return m_targetOffset;
288 }
289
290 DECLARE_GETTYPENAME(C3rdCamera)
291
292 protected:
293
298 void updateInputRotate(float timeDiff);
299
300 };
301}
This is an object class that provides additional support for the camera, such as looking at a specifi...
Definition C3rdCamera.h:72
const core::vector3df & getTargetOffset()
Gets the target offset.
Definition C3rdCamera.h:285
void setTargetOffset(const core::vector3df &offset)
Sets an offset from the follow target (e.g., to frame the character).
Definition C3rdCamera.h:276
void setOrientation(float pan, float tilt)
Configures initial orbit orientation.
Definition C3rdCamera.h:200
float m_maxVerticalAngle
Maximum vertical tilt angle.
Definition C3rdCamera.h:95
int m_touchId
Tracking touch ID for rotation.
Definition C3rdCamera.h:107
core::position2df m_centerCursor
Normalized cursor position at start of drag.
Definition C3rdCamera.h:110
void setFollowTarget(CEntity *entity)
Sets an entity as the orbit target.
Definition C3rdCamera.h:176
CCamera * getCamera()
Gets the attached camera component.
Definition C3rdCamera.h:138
float getMaxVerticalAngle()
Gets the maximum vertical tilt angle.
Definition C3rdCamera.h:231
float getTargetDistance()
Gets the current distance from the target.
Definition C3rdCamera.h:267
float m_camTilt
Vertical rotation angle (-89 to +89).
Definition C3rdCamera.h:101
void setFollowTarget(CGameObject *object)
Sets a GameObject as the orbit target.
Definition C3rdCamera.h:166
void setFollowPosition(const core::vector3df &pos)
Sets a static world position for the camera to orbit.
Definition C3rdCamera.h:147
core::position2df m_cursorPos
Current normalized cursor position.
Definition C3rdCamera.h:113
float getCameraTilt()
Gets the current vertical rotation.
Definition C3rdCamera.h:258
void setOrientation(float pan, float tilt, float distance)
Configures initial orbit orientation and distance.
Definition C3rdCamera.h:188
float m_camPan
Horizontal rotation angle (0-360).
Definition C3rdCamera.h:98
core::vector3df m_targetOffset
Offset from the follow target.
Definition C3rdCamera.h:86
core::vector3df m_followPosition
The position being followed (if m_isFollowPosition is true).
Definition C3rdCamera.h:83
void setTargetDistance(float d)
Sets the distance from the target.
Definition C3rdCamera.h:240
float getMinVerticalAngle()
Gets the minimum vertical tilt angle.
Definition C3rdCamera.h:222
CEntity * m_followEntity
The entity being followed.
Definition C3rdCamera.h:80
bool m_isFollowPosition
Whether to follow a static position or an entity.
Definition C3rdCamera.h:89
CCamera * m_camera
Pointer to the CCamera component.
Definition C3rdCamera.h:77
float getCameraPan()
Gets the current horizontal rotation.
Definition C3rdCamera.h:249
void setMinMaxVerticaAngle(float min, float max)
Sets vertical rotation limits.
Definition C3rdCamera.h:212
void updateInputRotate(float timeDiff)
Internal helper to process rotation input.
float m_targetDistance
Distance from the target.
Definition C3rdCamera.h:104
virtual bool OnEvent(const SEvent &event)
Called if an event happened.
float m_rotateSpeed
Rotation sensitivity.
Definition C3rdCamera.h:119
const core::vector3df & getFollowPosition()
Gets the static orbit position.
Definition C3rdCamera.h:157
bool m_leftMousePress
Whether the primary mouse button is pressed.
Definition C3rdCamera.h:116
float m_minVerticalAngle
Minimum vertical tilt angle.
Definition C3rdCamera.h:92
This is an object class used to set up the camera, including its position, viewing angle,...
Definition CCamera.h:70
This is the object class that describes an entity.
Definition CEntity.h:58
Definition ILateUpdate.h:6
Interface of an object which can receive events.
Definition IEventReceiver.h:474
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition vector3d.h:445
const T clamp(const T &value, const T &low, const T &high)
clamps a value between low and high
Definition irrMath.h:166
vector2d< f32 > position2df
Definition position2d.h:21
SEvents hold information about an event. See irr::IEventReceiver for details on event handling.
Definition IEventReceiver.h:273