Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10767 was 10698, checked in by snellen, 17 years ago

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

File size: 5.2 KB
RevLine 
[4592]1/*!
[5005]2 * @file camera.h
3 * Viewpoint controlling class definitions
[4592]4*/
[2068]5
[3224]6#ifndef _CAMERA_H
7#define _CAMERA_H
[2068]8
[10386]9#include "world_entity.h"
[4414]10#include "event_listener.h"
[7009]11#include "plane.h"
[2100]12
[10379]13
[2636]14class World;
[3635]15class CameraTarget;
[4414]16class Event;
[2100]17
[2096]18//! Camera
19/**
[5005]20 * This class controls the viewpoint from which the World is rendered.
[2096]21*/
[10386]22class Camera : public WorldEntity, public EventListener
[3635]23{
[10379]24  friend class CameraTarget;
25  friend class CameraMan;
[9869]26  ObjectListDeclaration(Camera);
[7347]27public:
28  //! an enumerator for different types of view
29  typedef enum ViewMode
30  {
31    ViewNormal,
32    ViewBehind,
33    ViewFront,
34    ViewLeft,
35    ViewRight,
[10698]36    ViewTop,
37    ViewFPS,
38    ViewFPSZoom
[7347]39  };
[10379]40  public:
[4746]41  Camera();
[10368]42  Camera(const TiXmlElement* root);
[4746]43  virtual ~Camera();
[3635]44
45  void lookAt(PNode* target);
[7014]46  CameraTarget* getTarget() const { return this->target; };
47  PNode* getTargetNode() const;
[10379]48  void setTargetNode(PNode* target);
[3636]49  void setAspectRatio(float aspectRatio);
[10368]50  inline float getAspectRatio() {return this->aspectRatio;};
51
[3636]52  void setClipRegion(float nearClip, float farClip);
53
[7173]54  /** @param fovy new field of view factor (in degrees) */
[10386]55  inline void setFovy(float fovy)
56  {
57    this->fovy = fovy;
[10368]58    this->toFovy = fovy;
59  };
60
61  inline float getFovy() {return this->fovy;};
[7173]62  /** @param fovy new field of view factor (in degrees) to iterate to */
63  void setToFovy(float toFovy) { this->toFovy = toFovy; };
64
[7347]65  void setViewMode(Camera::ViewMode mode);
[7009]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
[7013]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()); }
[7009]72
[10368]73  inline void setEventHandling(bool b) {this->eventHandling = b;}
74  inline bool getEventHandling() {return this->eventHandling;}
75
[10379]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();
[10410]79  void draw() const;
[3639]80  void tick(float dt);
[4746]81  void apply ();
[7108]82  void project();
[4414]83
84  void process(const Event &event);
[10379]85  //CameraTarget*     target;          //!< The Target of the Camera (where this Camera Looks at)
[4490]86
[10379]87  virtual void loadParams(const TiXmlElement* root);
[10368]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
[7347]103private:
[10368]104
105  void              init();
106
[4490]107  CameraTarget*     target;          //!< The Target of the Camera (where this Camera Looks at)
108
[10368]109  bool              eventHandling;    //!< True, if the Camera handles the processing of events itself. Set false to overwrite the standard handling.
110
[4490]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
[4986]116  float             toFovy;          //!< The fovy-mode to iterate to.
[7347]117  Camera::ViewMode  currentMode;     //!< The ViewMode the camera is in
[6999]118
119  Vector            delay;
[7009]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
[10368]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;
[10386]137
[3635]138};
[2068]139
[3635]140//! A CameraTarget is where the Camera is looking at.
[4592]141class CameraTarget : public PNode
[3635]142{
[10379]143  friend class Camera;        //! The CameraTarget is a friend of Camera. noone else needs a CameraTarget, so noone else can create it.
[9869]144  ObjectListDeclaration(CameraTarget);
[4592]145
[7347]146private:
[4746]147  CameraTarget();
[10379]148  virtual ~CameraTarget() {}
149  float speed;
150  PNode* target;
151  PNode* freeTarget;
152  Camera* masta;
153  Vector translateTo;
154  Vector rotateBy;
[4592]155
[10379]156
[7347]157public:
[10379]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();
[3635]170};
[2068]171
172
[10379]173
174
[3224]175#endif /* _CAMERA_H */
[10379]176
Note: See TracBrowser for help on using the repository browser.