Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10237 was 10237, checked in by muellmic, 17 years ago

changed camera handling for the vertical-scroller playmode. the top-down view in vertical scroller is now a proper camera-viewmode. also added a bool-state in the camera class to override the camera's event-listener and handle the camera-events (view buttons) in other classes. i used this to handle the camera parenting with the space-ship class, so other views as the top-down get useful and nice-looking again…. *taking-a-look-at-the-watch* oops damnit… i hope i won't forget the last tram ;-)

File size: 3.0 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  virtual ~Camera();
39
40  void lookAt(PNode* target);
41  CameraTarget* getTarget() const { return this->target; };
42  PNode* getTargetNode() const;
43
44  void setAspectRatio(float aspectRatio);
45  void setClipRegion(float nearClip, float farClip);
46
47  /** @param fovy new field of view factor (in degrees) */
48  void setFovy(float fovy) { this->fovy = fovy; };
49  /** @param fovy new field of view factor (in degrees) to iterate to */
50  void setToFovy(float toFovy) { this->toFovy = toFovy; };
51
52  void setViewMode(Camera::ViewMode mode);
53  inline const Vector& getViewVector() const { return this->viewVector; }
54  inline const Vector& getUpVector() const { return this->upVector; }
55  inline const Plane& getViewFrustum() const { return this->frustumPlane; }
56
57  inline float distance(const Vector& distance) const { return this->frustumPlane.distancePoint(distance); }
58  inline float distance(const PNode* node) const { return distance(node->getAbsCoor()); }
59
60  inline void setEventHandling(bool b) {this->eventHandling = b;}
61  inline bool getEventHandling() {return this->eventHandling;}
62
63  void tick(float dt);
64  void apply ();
65  void project();
66
67  void process(const Event &event);
68
69private:
70  CameraTarget*     target;          //!< The Target of the Camera (where this Camera Looks at)
71
72  bool              eventHandling;    //!< True, if the Camera handles the processing of events itself. Set false to overwrite the standard handling.
73
74  float             fovy;            //!< The field of view Angle (in degrees).
75  float             aspectRatio;     //!< The aspect ratio (width / height).
76  float             nearClip;        //!< The near clipping plane.
77  float             farClip;         //!< The far clipping plane.
78
79  float             toFovy;          //!< The fovy-mode to iterate to.
80  Camera::ViewMode  currentMode;     //!< The ViewMode the camera is in
81
82  Vector            delay;
83  Plane             frustumPlane;    //!< plane that marks the view frustum
84  Vector            viewVector;      //!< the direction of the camera view
85  Vector            upVector;        //!< direction of the up vector
86};
87
88//! A CameraTarget is where the Camera is looking at.
89class CameraTarget : public PNode
90{
91  friend class Camera;             //! The CameraTarget is a friend of Camera. noone else needs a CameraTarget, so noone else can create it.
92  ObjectListDeclaration(CameraTarget);
93
94private:
95  CameraTarget();
96
97public:
98};
99
100
101#endif /* _CAMERA_H */
Note: See TracBrowser for help on using the repository browser.