You.i Engine
YiCameraController.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2017. All rights reserved.
2 #ifndef _YI_CAMERA_CONTROLLER_H_
3 #define _YI_CAMERA_CONTROLLER_H_
4 
6 class CYISceneNode;
7 
8 #include <glm/gtc/epsilon.hpp>
9 #include <glm/vec3.hpp>
10 
11 #include "framework/YiPredef.h"
12 
18 /*
19  This camera control class is meant as a temporary and experimental way to animate the camera within You.i Engine. It is not a complete solution and should not be how camera animation is handled moving forward. This is meant to allow basic camera animation until the camera is fully integrated into the scene tree.
20 */
21 
23 {
24 public:
27 
36  };
37 
42 
47 
52  void CenterCameraOn(CYISceneNode *pTarget, CAMERA_CENTER_RULES eCenterRule, const glm::vec3 &staticOffset = glm::vec3());
53 
58  void AnimateCenterCameraOn(CYISceneNode *pTarget, CAMERA_CENTER_RULES eCenterRule, float fVelocity, const glm::vec3 &staticOffset = glm::vec3());
59 
63  void AnimateScrollBy(const glm::vec3 &offset);
64 
68  void ScrollBy(const glm::vec3 &offset);
69 
73  bool Update();
74 
79  void ReleaseDynamicCamera();
80 
85  void SetDynamicCameraRange(float fMaximumRange);
86 
91  float GetDynamicCameraRange();
92 
93 private:
97  struct CameraViewProperties {
98  glm::vec3 position;
99  glm::vec3 target;
100  glm::vec3 up;
101 
102  bool operator==(const CameraViewProperties &other)
103  {
104  return (glm::all(glm::epsilonEqual(position, other.position, glm::epsilon<glm::vec3::value_type>())) &&
105  glm::all(glm::epsilonEqual(target, other.target, glm::epsilon<glm::vec3::value_type>())) &&
106  glm::all(glm::epsilonEqual(up, other.up, glm::epsilon<glm::vec3::value_type>())));
107  }
108  };
109 
113  enum CAMERA_TARGET_FLAGS {
114  MAINTAIN_DISTANCE_X = 1,
115  MAINTAIN_DISTANCE_Y = 2,
116  MAINTAIN_DISTANCE_Z = 4
117  };
118 
119  CYIAbstractCameraSceneNode *m_pDynamicCamera;
120  CameraViewProperties m_StaticCameraProperties;
121  CameraViewProperties m_DynamicCameraDestination;
122  float m_fDynamicCameraVelocity;
123  float m_fDynamicCameraRange;
124  CameraViewProperties m_DynamicCameraTarget;
129  void RestoreDynamicCamera();
130 
139  CameraViewProperties DefineCameraForTarget(CYISceneNode *pNode, uint32_t eTargetMask);
140 };
141 
146 #endif // _YI_CAMERA_CONTROLLER_H_
Definition: YiCameraController.h:33
Provides a base for the definition of camera objects.
Definition: YiAbstractCameraSceneNode.h:30
void SetDynamicCamera(CYIAbstractCameraSceneNode *pCamera)
CAMERA_CENTER_RULES
Definition: YiCameraController.h:32
void AnimateScrollBy(const glm::vec3 &offset)
const CYIAbstractCameraSceneNode * GetDynamicCamera() const
Definition: YiCameraController.h:35
A scene node is the base type for all nodes which are used by the scene manager; it is an integral pa...
Definition: YiSceneNode.h:114
Definition: YiCameraController.h:34
bool operator==(const CYIVariant &rLHS, const CYIVariant &rRHS)
Supported types: Int, String, Float, FloatVector and Quaternion.
Definition: YiCameraController.h:22
void AnimateCenterCameraOn(CYISceneNode *pTarget, CAMERA_CENTER_RULES eCenterRule, float fVelocity, const glm::vec3 &staticOffset=glm::vec3())
void ScrollBy(const glm::vec3 &offset)
float GetDynamicCameraRange()
void CenterCameraOn(CYISceneNode *pTarget, CAMERA_CENTER_RULES eCenterRule, const glm::vec3 &staticOffset=glm::vec3())
void SetDynamicCameraRange(float fMaximumRange)