Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10706 was 10698, checked in by snellen, 18 years ago

merged adm, hud, vs-enhancements : beni's responsible for this commit. blame him!

File size: 5.2 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 "world_entity.h"
10#include "event_listener.h"
11#include "plane.h"
12
13
14class World;
15class CameraTarget;
16class Event;
17
18//! Camera
19/**
20 * This class controls the viewpoint from which the World is rendered.
21*/
22class Camera : public WorldEntity, public EventListener
23{
24  friend class CameraTarget;
25  friend class CameraMan;
26  ObjectListDeclaration(Camera);
27public:
28  //! an enumerator for different types of view
29  typedef enum ViewMode
30  {
31    ViewNormal,
32    ViewBehind,
33    ViewFront,
34    ViewLeft,
35    ViewRight,
36    ViewTop,
37    ViewFPS,
38    ViewFPSZoom
39  };
40  public:
41  Camera();
42  Camera(const TiXmlElement* root);
43  virtual ~Camera();
44
45  void lookAt(PNode* target);
46  CameraTarget* getTarget() const { return this->target; };
47  PNode* getTargetNode() const;
48  void setTargetNode(PNode* target);
49  void setAspectRatio(float aspectRatio);
50  inline float getAspectRatio() {return this->aspectRatio;};
51
52  void setClipRegion(float nearClip, float farClip);
53
54  /** @param fovy new field of view factor (in degrees) */
55  inline void setFovy(float fovy)
56  {
57    this->fovy = fovy;
58    this->toFovy = fovy;
59  };
60
61  inline float getFovy() {return this->fovy;};
62  /** @param fovy new field of view factor (in degrees) to iterate to */
63  void setToFovy(float toFovy) { this->toFovy = toFovy; };
64
65  void setViewMode(Camera::ViewMode mode);
66  inline const Vector& getViewVector() const { return this->viewVector; }
67  inline const Vector& getUpVector() const { return this->upVector; }
68  inline const Plane& getViewFrustum() const { return this->frustumPlane; }
69
70  inline float distance(const Vector& distance) const { return this->frustumPlane.distancePoint(distance); }
71  inline float distance(const PNode* node) const { return distance(node->getAbsCoor()); }
72
73  inline void setEventHandling(bool b) {this->eventHandling = b;}
74  inline bool getEventHandling() {return this->eventHandling;}
75
76  void glLookAt(float eyex, float eyey, float eyez, float centerx, float centery, float centerz, float upx, float upy, float upz);
77  Vector* VectorProd(Vector* v1, Vector* v2);
78  void Rotate();
79  void draw() const;
80  void tick(float dt);
81  void apply ();
82  void project();
83
84  void process(const Event &event);
85  //CameraTarget*     target;          //!< The Target of the Camera (where this Camera Looks at)
86
87  virtual void loadParams(const TiXmlElement* root);
88
89  void              setViewTopFovy(float fovy);
90  void              setViewLeftFovy(float fovy);
91  void              setViewRightFovy(float fovy);
92  void              setViewBehindFovy(float fovy);
93  void              setViewFrontFovy(float fovy);
94  void              setViewNormalFovy(float fovy);
95
96  void              setViewTopDistance(float Distance);
97  void              setViewLeftDistance(float Distance);
98  void              setViewRightDistance(float Distance);
99  void              setViewBehindDistance(float Distance);
100  void              setViewFrontDistance(float Distance);
101  void              setViewNormalDistance(float Distance);
102
103private:
104
105  void              init();
106
107  CameraTarget*     target;          //!< The Target of the Camera (where this Camera Looks at)
108
109  bool              eventHandling;    //!< True, if the Camera handles the processing of events itself. Set false to overwrite the standard handling.
110
111  float             fovy;            //!< The field of view Angle (in degrees).
112  float             aspectRatio;     //!< The aspect ratio (width / height).
113  float             nearClip;        //!< The near clipping plane.
114  float             farClip;         //!< The far clipping plane.
115
116  float             toFovy;          //!< The fovy-mode to iterate to.
117  Camera::ViewMode  currentMode;     //!< The ViewMode the camera is in
118
119  Vector            delay;
120  Plane             frustumPlane;    //!< plane that marks the view frustum
121  Vector            viewVector;      //!< the direction of the camera view
122  Vector            upVector;        //!< direction of the up vector
123
124  float             viewTopFovy;
125  float             viewLeftFovy;
126  float             viewRightFovy;
127  float             viewBehindFovy;
128  float             viewFrontFovy;
129  float             viewNormalFovy;
130
131  float             viewTopDistance;
132  float             viewLeftDistance;
133  float             viewRightDistance;
134  float             viewBehindDistance;
135  float             viewFrontDistance;
136  float             viewNormalDistance;
137
138};
139
140//! A CameraTarget is where the Camera is looking at.
141class CameraTarget : public PNode
142{
143  friend class Camera;        //! The CameraTarget is a friend of Camera. noone else needs a CameraTarget, so noone else can create it.
144  ObjectListDeclaration(CameraTarget);
145
146private:
147  CameraTarget();
148  virtual ~CameraTarget() {}
149  float speed;
150  PNode* target;
151  PNode* freeTarget;
152  Camera* masta;
153  Vector translateTo;
154  Vector rotateBy;
155
156
157public:
158
159  void detach();
160  void atach(PNode* object);
161  Vector iterate(float dt, const Vector* target, const Vector* cam);
162  void translate(float dt);
163  void changeSpeed(float speed);
164  Vector* rotate(Vector* newPos, float speed);
165  void jump(float x, float y, float z);
166  void translateNow(Vector* vec);
167  PNode* createStick();
168  void trans(float x, float y, float z);
169  bool isDone();
170};
171
172
173
174
175#endif /* _CAMERA_H */
176
Note: See TracBrowser for help on using the repository browser.