Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/terrain.older/src/world_entities/camera.h @ 10656

Last change on this file since 10656 was 7347, checked in by bensch, 19 years ago

orxonox/trunk: some more stuff (now one can play around with them using the Shell →
GameWorld Urban Playmode …. Vertical/Full3D/Horizontal

File size: 2.6 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{
24public:
25  //! an enumerator for different types of view
26  typedef enum ViewMode
27  {
28    ViewNormal,
29    ViewBehind,
30    ViewFront,
31    ViewLeft,
32    ViewRight,
33    ViewTop
34  };
35
36  Camera();
37  virtual ~Camera();
38
39  void lookAt(PNode* target);
40  CameraTarget* getTarget() const { return this->target; };
41  PNode* getTargetNode() const;
42
43  void setAspectRatio(float aspectRatio);
44  void setClipRegion(float nearClip, float farClip);
45
46  /** @param fovy new field of view factor (in degrees) */
47  void setFovy(float fovy) { this->fovy = fovy; };
48  /** @param fovy new field of view factor (in degrees) to iterate to */
49  void setToFovy(float toFovy) { this->toFovy = toFovy; };
50
51  void setViewMode(Camera::ViewMode mode);
52  inline const Vector& getViewVector() const { return this->viewVector; }
53  inline const Vector& getUpVector() const { return this->upVector; }
54  inline const Plane& getViewFrustum() const { return this->frustumPlane; }
55
56  inline float distance(const Vector& distance) const { return this->frustumPlane.distancePoint(distance); }
57  inline float distance(const PNode* node) const { return distance(node->getAbsCoor()); }
58
59  void tick(float dt);
60  void apply ();
61  void project();
62
63  void process(const Event &event);
64
65private:
66  CameraTarget*     target;          //!< The Target of the Camera (where this Camera Looks at)
67
68  float             fovy;            //!< The field of view Angle (in degrees).
69  float             aspectRatio;     //!< The aspect ratio (width / height).
70  float             nearClip;        //!< The near clipping plane.
71  float             farClip;         //!< The far clipping plane.
72
73  float             toFovy;          //!< The fovy-mode to iterate to.
74  Camera::ViewMode  currentMode;     //!< The ViewMode the camera is in
75
76  Vector            delay;
77  Plane             frustumPlane;    //!< plane that marks the view frustum
78  Vector            viewVector;      //!< the direction of the camera view
79  Vector            upVector;        //!< direction of the up vector
80};
81
82//! A CameraTarget is where the Camera is looking at.
83class CameraTarget : public PNode
84{
85  friend class Camera;             //! The CameraTarget is a friend of Camera. noone else needs a CameraTarget, so noone else can create it.
86
87private:
88  CameraTarget();
89
90public:
91};
92
93
94#endif /* _CAMERA_H */
Note: See TracBrowser for help on using the repository browser.