| 
                Last change
                  on this file since 4462 was
                  4414,
                  checked in by patrick, 20 years ago
           | 
        
        
          | 
               
orxonox/trunk: connected the viewport change functions in the camera system with the event handling system - works great 
 
           | 
        
        | 
            File size:
            1.5 KB
           | 
      
      
        
  | Line |   | 
|---|
| 1 | /*!  | 
|---|
| 2 |     \file camera.h | 
|---|
| 3 |     \brief Viewpoint controlling class definitions | 
|---|
| 4 | */  | 
|---|
| 5 |  | 
|---|
| 6 | #ifndef _CAMERA_H | 
|---|
| 7 | #define _CAMERA_H | 
|---|
| 8 |  | 
|---|
| 9 | #include "p_node.h" | 
|---|
| 10 | #include "vector.h" | 
|---|
| 11 | #include "event_listener.h" | 
|---|
| 12 |  | 
|---|
| 13 | class World; | 
|---|
| 14 | class CameraTarget; | 
|---|
| 15 | class Event; | 
|---|
| 16 |  | 
|---|
| 17 | enum ViewMode{VIEW_NORMAL, VIEW_BEHIND, VIEW_FRONT, VIEW_LEFT, VIEW_RIGHT, VIEW_TOP}; | 
|---|
| 18 |  | 
|---|
| 19 | //! Camera | 
|---|
| 20 | /** | 
|---|
| 21 |    This class controls the viewpoint from which the World is rendered. | 
|---|
| 22 | */ | 
|---|
| 23 | class Camera : public PNode, public EventListener | 
|---|
| 24 | { | 
|---|
| 25 |  private: | 
|---|
| 26 |   CameraTarget* target;            //!< The Target of the Camera (where this Camera Looks at) | 
|---|
| 27 |  | 
|---|
| 28 |   float fovy;                      //!< The field of view Angle (in degrees). | 
|---|
| 29 |   float aspectRatio;               //!< The aspect ratio (width / height). | 
|---|
| 30 |   float nearClip;                  //!< The near clipping plane. | 
|---|
| 31 |   float farClip;                   //!< The far clipping plane. | 
|---|
| 32 |  | 
|---|
| 33 |   Vector toRelCoor; | 
|---|
| 34 |   float toFovy; | 
|---|
| 35 |    | 
|---|
| 36 |  public: | 
|---|
| 37 |   Camera(void); | 
|---|
| 38 |   virtual ~Camera(void); | 
|---|
| 39 |  | 
|---|
| 40 |   void lookAt(PNode* target); | 
|---|
| 41 |   PNode* getTarget(); | 
|---|
| 42 |  | 
|---|
| 43 |   void setAspectRatio(float aspectRatio); | 
|---|
| 44 |   void setFovy(float fovy); | 
|---|
| 45 |   void setClipRegion(float nearClip, float farClip); | 
|---|
| 46 |  | 
|---|
| 47 |   void setViewMode(ViewMode mode); | 
|---|
| 48 |   void tick(float dt); | 
|---|
| 49 |   void apply (void); | 
|---|
| 50 |  | 
|---|
| 51 |   void process(const Event &event); | 
|---|
| 52 | }; | 
|---|
| 53 |  | 
|---|
| 54 | //! A CameraTarget is where the Camera is looking at. | 
|---|
| 55 | class CameraTarget : public PNode  | 
|---|
| 56 | { | 
|---|
| 57 |   friend class Camera;             //! The CameraTarget is a friend of Camera. noone else needs a CameraTarget, so noone else can create it. | 
|---|
| 58 |    | 
|---|
| 59 |  private: | 
|---|
| 60 |   CameraTarget(void); | 
|---|
| 61 |    | 
|---|
| 62 |  public: | 
|---|
| 63 |   virtual ~CameraTarget(void); | 
|---|
| 64 | }; | 
|---|
| 65 |  | 
|---|
| 66 |  | 
|---|
| 67 | #endif /* _CAMERA_H */ | 
|---|
       
      
      Note: See 
TracBrowser
        for help on using the repository browser.