00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef L3_CAMERA_INCLUDED
00024 #define L3_CAMERA_INCLUDED
00025
00026 #include "../grinliz/glgeometry.h"
00027 #include "../grinliz/glpublisher.h"
00028 #include "worlddefine.h"
00029
00030 namespace lilith3d
00031 {
00032
00033 class Camera;
00034 class TimeClock;
00035 class TerrainMesh;
00036
00037
00038 class CameraListener : public grinliz::Listener< CameraListener >
00039 {
00040 public:
00041 virtual void CameraEvent( Camera* ) = 0;
00042 };
00043
00057 class Camera
00058 {
00059 public:
00060 Camera();
00061
00062 grinliz::Publisher< CameraListener > publish;
00063
00067 void MoveCamera( float xVelocity, float yVelocity, float zVelocity );
00068
00072 void MoveCameraAxial2D( float axialVelocity, float perpVelocity );
00073
00077 void MoveCameraAxial3D( float axialVelocity );
00078
00079 enum CameraAxis
00080 {
00081 PITCH,
00082 YAW
00083 };
00084
00086 void MoveCameraRotation( CameraAxis axis, float deltaRotation );
00087
00089 void SetCameraRotation( float yaw, float pitch );
00090
00092 void SetCamera( float x, float y, float z, float yaw, float pitch );
00093
00095 void SetCameraPosition( float x, float y, float z ) {
00096 SetCamera( x, y, z, CalcYaw(), CalcPitch() );
00097 }
00098
00100 void PanCamera( float x, float y, float z, float yaw, float pitch );
00101
00103 void PanCamera( U32 millisec, float x, float y, float z, float yaw, float pitch );
00104
00106 const grinliz::Vector3F& Eye() { return pos.loc; }
00107
00111 float CalcPitch();
00115 float CalcYaw();
00116
00117 const grinliz::Matrix4& RotationMatrix() { return pos.rot; }
00118
00120 grinliz::Vector3F Direction() { grinliz::Vector3F dir = { pos.rot.x[0], pos.rot.x[4], pos.rot.x[8] }; return dir; }
00121
00122
00123 void DoTick( TimeClock* tc, TerrainMesh* tmesh );
00124
00125 void Operate( float farPlaneDistance = FAR_PLANE_DISTANCE );
00126
00127 void RotationToMatrix( float _yaw, float _pitch, grinliz::Matrix4* matrix );
00128
00129 private:
00130
00131 struct Position
00132 {
00133 grinliz::Vector3F loc;
00134 grinliz::Matrix4 rot;
00135
00136 void Clamp();
00137 };
00138
00139 struct Pan
00140 {
00141 grinliz::Quaternion startQuat;
00142 grinliz::Vector3F startLoc;
00143 grinliz::Quaternion endQuat;
00144 grinliz::Vector3F endLoc;
00145 U32 startTime;
00146 U32 endTime;
00147 };
00148
00149 Position pos;
00150 Pan pan;
00151 bool panning;
00152 };
00153 };
00154
00155 #endif