Skylicht Engine
Loading...
Searching...
No Matches
Skylicht::C3rdCamera Class Reference

This is an object class that provides additional support for the camera, such as looking at a specific target or rotating around that target object. More...

#include <Camera/C3rdCamera.h>

Inheritance diagram for Skylicht::C3rdCamera:
Skylicht::CComponentSystem irr::IEventReceiver Skylicht::ILateUpdate Skylicht::IActivatorObject

Public Member Functions

virtual void initComponent ()
virtual void updateComponent ()
virtual void lateUpdate ()
virtual bool OnEvent (const SEvent &event)
 Called if an event happened.
CCameragetCamera ()
 Gets the attached camera component.
void setFollowPosition (const core::vector3df &pos)
 Sets a static world position for the camera to orbit.
const core::vector3dfgetFollowPosition ()
 Gets the static orbit position.
void setFollowTarget (CGameObject *object)
 Sets a GameObject as the orbit target.
void setFollowTarget (CEntity *entity)
 Sets an entity as the orbit target.
void setOrientation (float pan, float tilt, float distance)
 Configures initial orbit orientation and distance.
void setOrientation (float pan, float tilt)
 Configures initial orbit orientation.
void setMinMaxVerticaAngle (float min, float max)
 Sets vertical rotation limits.
float getMinVerticalAngle ()
 Gets the minimum vertical tilt angle.
float getMaxVerticalAngle ()
 Gets the maximum vertical tilt angle.
void setTargetDistance (float d)
 Sets the distance from the target.
float getCameraPan ()
 Gets the current horizontal rotation.
float getCameraTilt ()
 Gets the current vertical rotation.
float getTargetDistance ()
 Gets the current distance from the target.
void setTargetOffset (const core::vector3df &offset)
 Sets an offset from the follow target (e.g., to frame the character).
const core::vector3dfgetTargetOffset ()
 Gets the target offset.
Public Member Functions inherited from Skylicht::CComponentSystem
const char * getName ()
virtual void reset ()
virtual void startComponent ()
virtual void endUpdate ()
virtual void onEnable (bool b)
virtual void onUpdateCullingLayer (u32 mask)
virtual CObjectSerializablecreateSerializable ()
virtual void loadSerializable (CObjectSerializable *object)
void setEnable (bool b)
bool isEnable ()
CGameObject * getGameObject ()
void setEnableSerializable (bool b)
bool isSerializable ()
void addLinkComponent (CComponentSystem *comp)
void removeAllLink ()
Public Member Functions inherited from Skylicht::IActivatorObject
virtual ~IActivatorObject ()
 Virtual destructor for polymorphic activator objects.
Public Member Functions inherited from irr::IEventReceiver
virtual ~IEventReceiver ()
 Destructor.

Protected Member Functions

void updateInputRotate (float timeDiff)
 Internal helper to process rotation input.
Protected Member Functions inherited from Skylicht::CComponentSystem
void setOwner (CGameObject *obj)

Protected Attributes

CCameram_camera
 Pointer to the CCamera component.
CEntitym_followEntity
 The entity being followed.
core::vector3df m_followPosition
 The position being followed (if m_isFollowPosition is true).
core::vector3df m_targetOffset
 Offset from the follow target.
bool m_isFollowPosition
 Whether to follow a static position or an entity.
float m_minVerticalAngle
 Minimum vertical tilt angle.
float m_maxVerticalAngle
 Maximum vertical tilt angle.
float m_camPan
 Horizontal rotation angle (0-360).
float m_camTilt
 Vertical rotation angle (-89 to +89).
float m_targetDistance
 Distance from the target.
int m_touchId
 Tracking touch ID for rotation.
core::position2df m_centerCursor
 Normalized cursor position at start of drag.
core::position2df m_cursorPos
 Current normalized cursor position.
bool m_leftMousePress
 Whether the primary mouse button is pressed.
float m_rotateSpeed
 Rotation sensitivity.
Protected Attributes inherited from Skylicht::CComponentSystem
CGameObject * m_gameObject
bool m_enable
bool m_serializable
std::vector< CComponentSystem * > m_linkComponent

Additional Inherited Members

Static Public Member Functions inherited from Skylicht::CComponentSystem
static int useComponent (CComponentSystem *used)

Detailed Description

This is an object class that provides additional support for the camera, such as looking at a specific target or rotating around that target object.

The 3rd person camera support touch screen gestures or mouse dragging to rotate around the target. You can call the function CCamera::setInputReceiver(false) to disable this feature.

Example of setting up a follow camera

// create follow 3rd top camera
CGameObject* camera3rdTopObj = zone->createEmptyObject();
CCamera* camera3rdTop = camera3rdTopObj->addComponent<CCamera>();
camera3rdTop->setPosition(core::vector3df(0.0f, 1.8f, 3.0f));
camera3rdTop->lookAt(core::vector3df(0.0f, 1.0f, 0.0f), core::vector3df(0.0f, 1.0f, 0.0f));
camera3rdTop->setInputReceiver(false);
core::vector3df targetOffset(0.0f, 0.5f, 0.0f);
C3rdCamera* followTopCam = camera3rdTopObj->addComponent<C3rdCamera>();
followTopCam->setOrientation(45.0f, -45.0f);
followTopCam->setTargetDistance(5.0f);
followTopCam->setTargetOffset(targetOffset);
followTopCam->setFollowTarget(getFollowEntity());
void setTargetOffset(const core::vector3df &offset)
Sets an offset from the follow target (e.g., to frame the character).
Definition C3rdCamera.h:276
void setFollowTarget(CGameObject *object)
Sets a GameObject as the orbit target.
Definition C3rdCamera.h:166
void setOrientation(float pan, float tilt, float distance)
Configures initial orbit orientation and distance.
Definition C3rdCamera.h:188
void setTargetDistance(float d)
Sets the distance from the target.
Definition C3rdCamera.h:240
This is an object class used to set up the camera, including its position, viewing angle,...
Definition CCamera.h:70
void lookAt(const core::vector3df &position, const core::vector3df &target, const core::vector3df &up)
Configures the camera to look at a target from a specific position.
void setInputReceiver(bool b)
Enables or disables input reception for this camera.
Definition CCamera.h:406
void setPosition(const core::vector3df &position)
Sets the world position of the camera.
This object class stores information for a GameObject.
Definition CGameObject.h:52
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition vector3d.h:445
See also
CCamera

Member Function Documentation

◆ getCamera()

CCamera * Skylicht::C3rdCamera::getCamera ( )
inline

Gets the attached camera component.

Returns
Pointer to CCamera.

◆ getCameraPan()

float Skylicht::C3rdCamera::getCameraPan ( )
inline

Gets the current horizontal rotation.

Returns
Pan angle.

◆ getCameraTilt()

float Skylicht::C3rdCamera::getCameraTilt ( )
inline

Gets the current vertical rotation.

Returns
Tilt angle.

◆ getFollowPosition()

const core::vector3df & Skylicht::C3rdCamera::getFollowPosition ( )
inline

Gets the static orbit position.

Returns
Position vector.

◆ getMaxVerticalAngle()

float Skylicht::C3rdCamera::getMaxVerticalAngle ( )
inline

Gets the maximum vertical tilt angle.

Returns
Angle in degrees.

◆ getMinVerticalAngle()

float Skylicht::C3rdCamera::getMinVerticalAngle ( )
inline

Gets the minimum vertical tilt angle.

Returns
Angle in degrees.

◆ getTargetDistance()

float Skylicht::C3rdCamera::getTargetDistance ( )
inline

Gets the current distance from the target.

Returns
Distance.

◆ getTargetOffset()

const core::vector3df & Skylicht::C3rdCamera::getTargetOffset ( )
inline

Gets the target offset.

Returns
Offset vector.

◆ initComponent()

virtual void Skylicht::C3rdCamera::initComponent ( )
virtual

◆ lateUpdate()

virtual void Skylicht::C3rdCamera::lateUpdate ( )
virtual

Implements Skylicht::ILateUpdate.

◆ OnEvent()

virtual bool Skylicht::C3rdCamera::OnEvent ( const SEvent & event)
virtual

Called if an event happened.

Please take care that you should only return 'true' when you want to prevent Irrlicht from processing the event any further. So 'true' does mean that an event is completely done. Therefore your return value for all unprocessed events should be 'false'.

Returns
True if the event was processed.

Implements irr::IEventReceiver.

◆ setFollowPosition()

void Skylicht::C3rdCamera::setFollowPosition ( const core::vector3df & pos)
inline

Sets a static world position for the camera to orbit.

Parameters
posPosition vector.

◆ setFollowTarget() [1/2]

void Skylicht::C3rdCamera::setFollowTarget ( CEntity * entity)
inline

Sets an entity as the orbit target.

Parameters
entityPointer to target entity.

◆ setFollowTarget() [2/2]

void Skylicht::C3rdCamera::setFollowTarget ( CGameObject * object)
inline

Sets a GameObject as the orbit target.

Parameters
objectPointer to target object.

◆ setMinMaxVerticaAngle()

void Skylicht::C3rdCamera::setMinMaxVerticaAngle ( float min,
float max )
inline

Sets vertical rotation limits.

Parameters
minMin tilt angle.
maxMax tilt angle.

◆ setOrientation() [1/2]

void Skylicht::C3rdCamera::setOrientation ( float pan,
float tilt )
inline

Configures initial orbit orientation.

Parameters
panHorizontal angle.
tiltVertical angle.

◆ setOrientation() [2/2]

void Skylicht::C3rdCamera::setOrientation ( float pan,
float tilt,
float distance )
inline

Configures initial orbit orientation and distance.

Parameters
panHorizontal angle.
tiltVertical angle.
distanceDistance from target.

◆ setTargetDistance()

void Skylicht::C3rdCamera::setTargetDistance ( float d)
inline

Sets the distance from the target.

Parameters
dDistance.

◆ setTargetOffset()

void Skylicht::C3rdCamera::setTargetOffset ( const core::vector3df & offset)
inline

Sets an offset from the follow target (e.g., to frame the character).

Parameters
offsetOffset vector.

◆ updateComponent()

virtual void Skylicht::C3rdCamera::updateComponent ( )
virtual

◆ updateInputRotate()

void Skylicht::C3rdCamera::updateInputRotate ( float timeDiff)
protected

Internal helper to process rotation input.

Parameters
timeDiffElapsed time.

The documentation for this class was generated from the following file: