Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

the track now is been drawn for the camera

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