Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/camera.h @ 10368

Last change on this file since 10368 was 10368, checked in by patrick, 18 years ago

merged the branche playability into the trunk

File size: 4.3 KB
Line 
1/*!
2 * @file camera.h
3 * Viewpoint controlling class definitions
4*/
5
6#ifndef _CAMERA_H
7#define _CAMERA_H
8
9#include "p_node.h"
10#include "event_listener.h"
11#include "plane.h"
12
13class World;
14class CameraTarget;
15class Event;
16
17
18//! Camera
19/**
20 * This class controls the viewpoint from which the World is rendered.
21*/
22class Camera : public PNode, public EventListener
23{
24  ObjectListDeclaration(Camera);
25public:
26  //! an enumerator for different types of view
27  typedef enum ViewMode
28  {
29    ViewNormal,
30    ViewBehind,
31    ViewFront,
32    ViewLeft,
33    ViewRight,
34    ViewTop
35  };
36
37  Camera();
38  Camera(const TiXmlElement* root);
39  virtual ~Camera();
40
41  void lookAt(PNode* target);
42  CameraTarget* getTarget() const { return this->target; };
43  PNode* getTargetNode() const;
44
45  void setAspectRatio(float aspectRatio);
46  inline float getAspectRatio() {return this->aspectRatio;};
47
48  void setClipRegion(float nearClip, float farClip);
49
50  /** @param fovy new field of view factor (in degrees) */
51  inline void setFovy(float fovy) 
52  { 
53    this->fovy = fovy; 
54    this->toFovy = fovy;
55  };
56
57  inline float getFovy() {return this->fovy;};
58  /** @param fovy new field of view factor (in degrees) to iterate to */
59  void setToFovy(float toFovy) { this->toFovy = toFovy; };
60
61  void setViewMode(Camera::ViewMode mode);
62  inline const Vector& getViewVector() const { return this->viewVector; }
63  inline const Vector& getUpVector() const { return this->upVector; }
64  inline const Plane& getViewFrustum() const { return this->frustumPlane; }
65
66  inline float distance(const Vector& distance) const { return this->frustumPlane.distancePoint(distance); }
67  inline float distance(const PNode* node) const { return distance(node->getAbsCoor()); }
68
69  inline void setEventHandling(bool b) {this->eventHandling = b;}
70  inline bool getEventHandling() {return this->eventHandling;}
71
72  void tick(float dt);
73  void apply ();
74  void project();
75
76  void process(const Event &event);
77
78  //virtual void loadParams(const TiXmlElement* root);
79
80  void              setViewTopFovy(float fovy);
81  void              setViewLeftFovy(float fovy);
82  void              setViewRightFovy(float fovy);
83  void              setViewBehindFovy(float fovy);
84  void              setViewFrontFovy(float fovy);
85  void              setViewNormalFovy(float fovy);
86
87  void              setViewTopDistance(float Distance);
88  void              setViewLeftDistance(float Distance);
89  void              setViewRightDistance(float Distance);
90  void              setViewBehindDistance(float Distance);
91  void              setViewFrontDistance(float Distance);
92  void              setViewNormalDistance(float Distance);
93
94private:
95
96  void              init();
97
98  CameraTarget*     target;          //!< The Target of the Camera (where this Camera Looks at)
99
100  bool              eventHandling;    //!< True, if the Camera handles the processing of events itself. Set false to overwrite the standard handling.
101
102  float             fovy;            //!< The field of view Angle (in degrees).
103  float             aspectRatio;     //!< The aspect ratio (width / height).
104  float             nearClip;        //!< The near clipping plane.
105  float             farClip;         //!< The far clipping plane.
106
107  float             toFovy;          //!< The fovy-mode to iterate to.
108  Camera::ViewMode  currentMode;     //!< The ViewMode the camera is in
109
110  Vector            delay;
111  Plane             frustumPlane;    //!< plane that marks the view frustum
112  Vector            viewVector;      //!< the direction of the camera view
113  Vector            upVector;        //!< direction of the up vector
114
115  float             viewTopFovy;
116  float             viewLeftFovy;
117  float             viewRightFovy;
118  float             viewBehindFovy;
119  float             viewFrontFovy;
120  float             viewNormalFovy;
121
122  float             viewTopDistance;
123  float             viewLeftDistance;
124  float             viewRightDistance;
125  float             viewBehindDistance;
126  float             viewFrontDistance;
127  float             viewNormalDistance;
128 
129};
130
131//! A CameraTarget is where the Camera is looking at.
132class CameraTarget : public PNode
133{
134  friend class Camera;             //! The CameraTarget is a friend of Camera. noone else needs a CameraTarget, so noone else can create it.
135  ObjectListDeclaration(CameraTarget);
136
137private:
138  CameraTarget();
139
140public:
141};
142
143
144#endif /* _CAMERA_H */
Note: See TracBrowser for help on using the repository browser.