Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

camera is a WE and some other stuff

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();
[3639]77  void tick(float dt);
[4746]78  void apply ();
[7108]79  void project();
[4414]80
81  void process(const Event &event);
[10379]82  //CameraTarget*     target;          //!< The Target of the Camera (where this Camera Looks at)
[4490]83
[10379]84  virtual void loadParams(const TiXmlElement* root);
[10368]85
86  void              setViewTopFovy(float fovy);
87  void              setViewLeftFovy(float fovy);
88  void              setViewRightFovy(float fovy);
89  void              setViewBehindFovy(float fovy);
90  void              setViewFrontFovy(float fovy);
91  void              setViewNormalFovy(float fovy);
92
93  void              setViewTopDistance(float Distance);
94  void              setViewLeftDistance(float Distance);
95  void              setViewRightDistance(float Distance);
96  void              setViewBehindDistance(float Distance);
97  void              setViewFrontDistance(float Distance);
98  void              setViewNormalDistance(float Distance);
99
[7347]100private:
[10368]101
102  void              init();
103
[4490]104  CameraTarget*     target;          //!< The Target of the Camera (where this Camera Looks at)
105
[10368]106  bool              eventHandling;    //!< True, if the Camera handles the processing of events itself. Set false to overwrite the standard handling.
107
[4490]108  float             fovy;            //!< The field of view Angle (in degrees).
109  float             aspectRatio;     //!< The aspect ratio (width / height).
110  float             nearClip;        //!< The near clipping plane.
111  float             farClip;         //!< The far clipping plane.
112
[4986]113  float             toFovy;          //!< The fovy-mode to iterate to.
[7347]114  Camera::ViewMode  currentMode;     //!< The ViewMode the camera is in
[6999]115
116  Vector            delay;
[7009]117  Plane             frustumPlane;    //!< plane that marks the view frustum
118  Vector            viewVector;      //!< the direction of the camera view
119  Vector            upVector;        //!< direction of the up vector
[10368]120
121  float             viewTopFovy;
122  float             viewLeftFovy;
123  float             viewRightFovy;
124  float             viewBehindFovy;
125  float             viewFrontFovy;
126  float             viewNormalFovy;
127
128  float             viewTopDistance;
129  float             viewLeftDistance;
130  float             viewRightDistance;
131  float             viewBehindDistance;
132  float             viewFrontDistance;
133  float             viewNormalDistance;
[10386]134
[3635]135};
[2068]136
[3635]137//! A CameraTarget is where the Camera is looking at.
[4592]138class CameraTarget : public PNode
[3635]139{
[10379]140  friend class Camera;        //! The CameraTarget is a friend of Camera. noone else needs a CameraTarget, so noone else can create it.
[9869]141  ObjectListDeclaration(CameraTarget);
[4592]142
[7347]143private:
[4746]144  CameraTarget();
[10379]145  virtual ~CameraTarget() {}
146  float speed;
147  PNode* target;
148  PNode* freeTarget;
149  Camera* masta;
150  Vector translateTo;
151  Vector rotateBy;
[4592]152
[10379]153
[7347]154public:
[10379]155
156  void detach();
157  void atach(PNode* object);
158  Vector iterate(float dt, const Vector* target, const Vector* cam);
159  void translate(float dt);
160  void changeSpeed(float speed);
161  Vector* rotate(Vector* newPos, float speed);
162  void jump(float x, float y, float z);
163  void translateNow(Vector* vec);
164  PNode* createStick();
165  void trans(float x, float y, float z);
166  bool isDone();
[3635]167};
[2068]168
169
[10379]170
171
[3224]172#endif /* _CAMERA_H */
[10379]173
Note: See TracBrowser for help on using the repository browser.