Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/playability/src/world_entities/camera.h @ 10274

Last change on this file since 10274 was 10270, checked in by muellmic, 18 years ago

1) the centerpoint of the radar is now the centerpoint of the camera, so the enemies won't move in the radar when the player is moving; 2)fovy and cameradistance of each viewmode can now be set dynamically. so one would't have to readjust the fovy for each viewmode, when it has been manually changed once. (it's better to just change the fovy or distance for the viewmode where you need it); 3)unlike in the last revision, it doesnt have a soft- zoom- effect when setting a fovy anymore.

File size: 4.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 "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  void setClipRegion(float nearClip, float farClip);
47
48  /** @param fovy new field of view factor (in degrees) */
49  inline void setFovy(float fovy) 
50  { 
51    this->fovy = fovy; 
52    this->toFovy = fovy;
53  };
54  /** @param fovy new field of view factor (in degrees) to iterate to */
55  void setToFovy(float toFovy) { this->toFovy = toFovy; };
56
57  void setViewMode(Camera::ViewMode mode);
58  inline const Vector& getViewVector() const { return this->viewVector; }
59  inline const Vector& getUpVector() const { return this->upVector; }
60  inline const Plane& getViewFrustum() const { return this->frustumPlane; }
61
62  inline float distance(const Vector& distance) const { return this->frustumPlane.distancePoint(distance); }
63  inline float distance(const PNode* node) const { return distance(node->getAbsCoor()); }
64
65  inline void setEventHandling(bool b) {this->eventHandling = b;}
66  inline bool getEventHandling() {return this->eventHandling;}
67
68  void tick(float dt);
69  void apply ();
70  void project();
71
72  void process(const Event &event);
73
74  //virtual void loadParams(const TiXmlElement* root);
75
76  void              setViewTopFovy(float fovy);
77  void              setViewLeftFovy(float fovy);
78  void              setViewRightFovy(float fovy);
79  void              setViewBehindFovy(float fovy);
80  void              setViewFrontFovy(float fovy);
81  void              setViewNormalFovy(float fovy);
82
83  void              setViewTopDistance(float Distance);
84  void              setViewLeftDistance(float Distance);
85  void              setViewRightDistance(float Distance);
86  void              setViewBehindDistance(float Distance);
87  void              setViewFrontDistance(float Distance);
88  void              setViewNormalDistance(float Distance);
89
90private:
91
92  void              init();
93
94  CameraTarget*     target;          //!< The Target of the Camera (where this Camera Looks at)
95
96  bool              eventHandling;    //!< True, if the Camera handles the processing of events itself. Set false to overwrite the standard handling.
97
98  float             fovy;            //!< The field of view Angle (in degrees).
99  float             aspectRatio;     //!< The aspect ratio (width / height).
100  float             nearClip;        //!< The near clipping plane.
101  float             farClip;         //!< The far clipping plane.
102
103  float             toFovy;          //!< The fovy-mode to iterate to.
104  Camera::ViewMode  currentMode;     //!< The ViewMode the camera is in
105
106  Vector            delay;
107  Plane             frustumPlane;    //!< plane that marks the view frustum
108  Vector            viewVector;      //!< the direction of the camera view
109  Vector            upVector;        //!< direction of the up vector
110
111  float             viewTopFovy;
112  float             viewLeftFovy;
113  float             viewRightFovy;
114  float             viewBehindFovy;
115  float             viewFrontFovy;
116  float             viewNormalFovy;
117
118  float             viewTopDistance;
119  float             viewLeftDistance;
120  float             viewRightDistance;
121  float             viewBehindDistance;
122  float             viewFrontDistance;
123  float             viewNormalDistance;
124 
125};
126
127//! A CameraTarget is where the Camera is looking at.
128class CameraTarget : public PNode
129{
130  friend class Camera;             //! The CameraTarget is a friend of Camera. noone else needs a CameraTarget, so noone else can create it.
131  ObjectListDeclaration(CameraTarget);
132
133private:
134  CameraTarget();
135
136public:
137};
138
139
140#endif /* _CAMERA_H */
Note: See TracBrowser for help on using the repository browser.