00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _CAMERA_H
00026 #define _CAMERA_H
00027
00028 #ifdef WIN32
00029 #include <windows.h>
00030 #endif
00031
00032
00033 #include "input.h"
00034 #include "vector3d.h"
00035 #include "frustum.h"
00036 #include "collision.h"
00037
00038
00039
00040 namespace ngn {
00041
00042 class Model;
00043
00050 class NGN_API Camera
00051 {
00052 public:
00054 Camera( InputHandler *input );
00056 Camera( const Camera& other );
00058 Camera operator=( const Camera& other );
00060 virtual ~Camera();
00061
00063 void set( float posX, float posY, float posZ, float viewX, float viewY, float viewZ, float upX, float upY, float upZ );
00065 void set( const core::Vector3df& pos, const core::Vector3df& view, const core::Vector3df& up );
00067 void setPosition( const core::Vector3df& pos );
00069 void setView( const core::Vector3df& view );
00071 void setUpVector( const core::Vector3df& up );
00073 const core::Vector3df& getPosition() const;
00075 const core::Vector3df& getView() const;
00077 const core::Vector3df& getUpVector() const;
00078
00080 void update();
00082 void look();
00084 void move( float speed );
00086 void strafe( float speed );
00088 void rotate( float angle, const core::Vector3df& pos );
00090 void jump();
00092 void rotateAround( const core::Vector3df& ref, const core::Vector3df& p );
00094 void mouseView();
00096 void fly( bool state );
00097
00099 void setAABB( AABB& aabb );
00101 void setFov( float fov );
00103 void setSpeed( float speed );
00105 void setMouseSpeed( float speed );
00107 static void setGravity( float gravity );
00108
00110 static float getGravity();
00112 AABB& getAABB();
00114 float getFov() const;
00116 float getSpeed() const;
00118 float getMouseSpeed() const;
00120 const core::Frustum& getFrustum() const;
00122 bool isFlying() const;
00123
00124
00125 protected:
00127 void checkMovements();
00129 void checkCollisions( const core::Vector3df& oldPos, const core::Vector3df& oldView );
00130
00131 private:
00132
00133 core::Vector3df m_pos;
00134 core::Vector3df m_view;
00135 core::Vector3df m_up;
00136 core::Vector3df m_strafe;
00137 core::Vector3df m_velocity;
00138
00139 static float m_gravity;
00140
00141 float m_fov;
00142 float m_speed;
00143 float m_move_speed;
00144 float m_mouse_speed;
00145 float m_jump_acceleration;
00146
00147 InputHandler *m_input;
00148
00149 core::Frustum m_frustum;
00150
00151 core::bsp::BSPCollision m_collision;
00152
00153
00154 const float m_min_fov;
00155
00156 const float m_max_fov;
00157
00158 bool m_move_back;
00159
00160 bool m_fly;
00161
00162 };
00163
00164
00165 }
00166 #endif
00167