Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10362 was 10362, checked in by patrick, 17 years ago

merged playability. but got strange bug

File size: 4.3 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
[3635]9#include "p_node.h"
[4414]10#include "event_listener.h"
[7009]11#include "plane.h"
[2100]12
[2636]13class World;
[3635]14class CameraTarget;
[4414]15class Event;
[2100]16
[3635]17
[2096]18//! Camera
19/**
[5005]20 * This class controls the viewpoint from which the World is rendered.
[2096]21*/
[4414]22class Camera : public PNode, public EventListener
[3635]23{
[9869]24  ObjectListDeclaration(Camera);
[7347]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
[4746]37  Camera();
[10362]38  Camera(const TiXmlElement* root);
[4746]39  virtual ~Camera();
[3635]40
41  void lookAt(PNode* target);
[7014]42  CameraTarget* getTarget() const { return this->target; };
43  PNode* getTargetNode() const;
[3636]44
45  void setAspectRatio(float aspectRatio);
[10362]46  inline float getAspectRatio() {return this->aspectRatio;};
47
[3636]48  void setClipRegion(float nearClip, float farClip);
49
[7173]50  /** @param fovy new field of view factor (in degrees) */
[10362]51  inline void setFovy(float fovy) 
52  { 
53    this->fovy = fovy; 
54    this->toFovy = fovy;
55  };
56
57  inline float getFovy() {return this->fovy;};
[7173]58  /** @param fovy new field of view factor (in degrees) to iterate to */
59  void setToFovy(float toFovy) { this->toFovy = toFovy; };
60
[7347]61  void setViewMode(Camera::ViewMode mode);
[7009]62  inline const Vector& getViewVector() const { return this->viewVector; }
63  inline const Vector& getUpVector() const { return this->upVector; }
64  inline const Plane& getViewFrustum() const { return this->frustumPlane; }
65
[7013]66  inline float distance(const Vector& distance) const { return this->frustumPlane.distancePoint(distance); }
67  inline float distance(const PNode* node) const { return distance(node->getAbsCoor()); }
[7009]68
[10362]69  inline void setEventHandling(bool b) {this->eventHandling = b;}
70  inline bool getEventHandling() {return this->eventHandling;}
71
[3639]72  void tick(float dt);
[4746]73  void apply ();
[7108]74  void project();
[4414]75
76  void process(const Event &event);
[4490]77
[10362]78  //virtual void loadParams(const TiXmlElement* root);
79
80  void              setViewTopFovy(float fovy);
81  void              setViewLeftFovy(float fovy);
82  void              setViewRightFovy(float fovy);
83  void              setViewBehindFovy(float fovy);
84  void              setViewFrontFovy(float fovy);
85  void              setViewNormalFovy(float fovy);
86
87  void              setViewTopDistance(float Distance);
88  void              setViewLeftDistance(float Distance);
89  void              setViewRightDistance(float Distance);
90  void              setViewBehindDistance(float Distance);
91  void              setViewFrontDistance(float Distance);
92  void              setViewNormalDistance(float Distance);
93
[7347]94private:
[10362]95
96  void              init();
97
[4490]98  CameraTarget*     target;          //!< The Target of the Camera (where this Camera Looks at)
99
[10362]100  bool              eventHandling;    //!< True, if the Camera handles the processing of events itself. Set false to overwrite the standard handling.
101
[4490]102  float             fovy;            //!< The field of view Angle (in degrees).
103  float             aspectRatio;     //!< The aspect ratio (width / height).
104  float             nearClip;        //!< The near clipping plane.
105  float             farClip;         //!< The far clipping plane.
106
[4986]107  float             toFovy;          //!< The fovy-mode to iterate to.
[7347]108  Camera::ViewMode  currentMode;     //!< The ViewMode the camera is in
[6999]109
110  Vector            delay;
[7009]111  Plane             frustumPlane;    //!< plane that marks the view frustum
112  Vector            viewVector;      //!< the direction of the camera view
113  Vector            upVector;        //!< direction of the up vector
[10362]114
115  float             viewTopFovy;
116  float             viewLeftFovy;
117  float             viewRightFovy;
118  float             viewBehindFovy;
119  float             viewFrontFovy;
120  float             viewNormalFovy;
121
122  float             viewTopDistance;
123  float             viewLeftDistance;
124  float             viewRightDistance;
125  float             viewBehindDistance;
126  float             viewFrontDistance;
127  float             viewNormalDistance;
128 
[3635]129};
[2068]130
[3635]131//! A CameraTarget is where the Camera is looking at.
[4592]132class CameraTarget : public PNode
[3635]133{
[3636]134  friend class Camera;             //! The CameraTarget is a friend of Camera. noone else needs a CameraTarget, so noone else can create it.
[9869]135  ObjectListDeclaration(CameraTarget);
[4592]136
[7347]137private:
[4746]138  CameraTarget();
[4592]139
[7347]140public:
[3635]141};
[2068]142
143
[3224]144#endif /* _CAMERA_H */
Note: See TracBrowser for help on using the repository browser.