Implementing the target camera
The target camera works the opposite way. Rather than the position, the target remains fixed, while the camera moves or rotates around the target. Some operations like panning, move both the target and the camera position together.
Getting ready
The following figure shows an illustration of a target camera. Note that the small box is the target position for the camera.
The code for this recipe resides in the Chapter2/TargetCamera
directory. The CTargetCamera
class is defined in the Chapter2/src/TargetCamera.[h/cpp]
files. The class declaration is as follows:
class CTargetCamera : public CAbstractCamera { public: CTargetCamera(void); ~CTargetCamera(void); void Update(); void Rotate(const float yaw, const float pitch, const float roll); void SetTarget(const glm::vec3 tgt); const glm::vec3 GetTarget() const; void Pan(const float dx, const float dy); void Zoom(const float amount ); void Move(const float dx, const float dz); protected: glm::vec3...