/*! * @file camera.h * Viewpoint controlling class definitions */ #ifndef _CAMERA_H #define _CAMERA_H #include "p_node.h" #include "event_listener.h" #include "plane.h" class World; class CameraTarget; class Event; //! an enumerator for different types of view typedef enum ViewMode { VIEW_NORMAL, VIEW_BEHIND, VIEW_FRONT, VIEW_LEFT, VIEW_RIGHT, VIEW_TOP }; //! Camera /** * This class controls the viewpoint from which the World is rendered. */ class Camera : public PNode, public EventListener { public: Camera(); virtual ~Camera(); void lookAt(PNode* target); PNode* getTarget(); void setAspectRatio(float aspectRatio); void setFovy(float fovy); void setClipRegion(float nearClip, float farClip); void setViewMode(ViewMode mode); inline const Vector& getViewVector() const { return this->viewVector; } inline const Vector& getUpVector() const { return this->upVector; } inline const Plane& getViewFrustum() const { return this->frustumPlane; } void tick(float dt); void apply (); void process(const Event &event); private: CameraTarget* target; //!< The Target of the Camera (where this Camera Looks at) float fovy; //!< The field of view Angle (in degrees). float aspectRatio; //!< The aspect ratio (width / height). float nearClip; //!< The near clipping plane. float farClip; //!< The far clipping plane. float toFovy; //!< The fovy-mode to iterate to. ViewMode currentMode; //!< The ViewMode the camera is in Vector delay; Plane frustumPlane; //!< plane that marks the view frustum Vector viewVector; //!< the direction of the camera view Vector upVector; //!< direction of the up vector }; //! A CameraTarget is where the Camera is looking at. class CameraTarget : public PNode { friend class Camera; //! The CameraTarget is a friend of Camera. noone else needs a CameraTarget, so noone else can create it. private: CameraTarget(); public: }; #endif /* _CAMERA_H */