Main Page   Namespace List   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

ExCCamera Class Reference

#include <ExCCamera.h>

Inheritance diagram for ExCCamera:

ExCObject ExCCameraTarget

Public Methods

 ExCCamera (void)
 ~ExCCamera (void)
void Draw (void)
void ZoomIn (void)
void ZoomOut (void)
void ResetZoom (void)
void ZoomIn (float zoom)
void ZoomOut (float zoom)
void SetZoom (float zoom)
void SetZoomMax (float zoom)
void SetZoomMin (float zoom)
void SetZoomDefault (float zoom)
void SetClipFar (float clip)
void SetClipNear (float clip)
float GetZoomMax (void)
float GetZoomMin (void)
float GetZoom (void)
float GetZoomDefault (void)
float GetClipFar (void)
float GetClipNear (void)
void GoToView (bool state)
void RotateView (float X, float Y, float Z)
void StrafeCamera (float speed)
void MoveCamera (float speed)

Data Fields

int m_speed

Protected Attributes

bool m_Actif
float m_Zoom
float m_ClipFar
float m_ClipNear
float m_ZoomDefault
float m_ZoomMax
float m_ZoomMin
ExCVec3D VecX
ExCVec3D VecY
ExCVec3D VecZ
ExCVec3D VecDir
ExCVec3D m_vPosition
ExCVec3D m_vView
ExCVec3D m_vUpVector

Constructor & Destructor Documentation

ExCCamera void   
 

Definition at line 27 of file ExCCamera.cpp.

References ExCCamera(), Guard, ExCObject::m_AngleX, ExCObject::m_AngleY, ExCObject::m_AngleZ, m_ClipFar, m_ClipNear, m_speed, m_vPosition, m_vUpVector, m_vView, m_Zoom, m_ZoomDefault, m_ZoomMax, m_ZoomMin, ExCVec3D::SetValue(), and UnGuard.

Referenced by ExCCamera(), and ~ExCCamera().

00028 {
00029 Guard(ExCCamera::ExCCamera(void))
00030         m_AngleX=0;
00031         m_AngleY=0;
00032         m_AngleZ=0;
00033         m_speed=0;
00034         m_ZoomDefault=40;
00035         m_Zoom=m_ZoomDefault;
00036         m_ZoomMin=1;
00037         m_ZoomMax=100;
00038         m_ClipFar=2000;
00039         m_ClipNear=1;
00040 
00041         m_vPosition.SetValue(0.0,0.0,1.0);
00042         m_vView.SetValue(0.0,1.0,0.5);
00043         m_vUpVector.SetValue(0.0,0.0,1.0);
00044 UnGuard
00045 }

~ExCCamera void   
 

Definition at line 47 of file ExCCamera.cpp.

References ExCCamera(), Guard, and UnGuard.

00048 {
00049 Guard(ExCCamera::~ExCCamera(void))
00050 UnGuard
00051 }


Member Function Documentation

void Draw void    [virtual]
 

Reimplemented from ExCObject.

Reimplemented in ExCCameraTarget.

Definition at line 53 of file ExCCamera.cpp.

References Draw(), GetMatrixFromQuaternion(), ExCVec3D::GetVectorLenght(), ExCVec3D::GetX(), ExCVec3D::GetY(), ExCVec3D::GetZ(), GoToView(), Guard, ExCObject::m_AngleX, ExCObject::m_AngleY, ExCObject::m_AngleZ, ExCMatrix4x4::m_Matrix, ExCObject::m_Position, m_speed, ExCObject::m_Target, ExCVec3D::m_Vector, ExQuaternion::SetEuler(), ExCVec3D::SetX(), ExCVec3D::SetY(), ExCVec3D::SetZ(), UnGuard, VecDir, VecX, VecY, and VecZ.

Referenced by ExManagerCam::Draw(), Draw(), and ExManagerOutput::Reshape().

00054 {
00055 Guard(ExCCamera::Draw(void))
00056 //cout<<"Draw "<<m_ObjectName<<" ID:"<<m_ObjectId<<endl;
00057 
00058         if(m_AngleX<0)m_AngleX=359;
00059         if(m_AngleX>359)m_AngleX=0;
00060         if(m_AngleY<0)m_AngleY=359;
00061         if(m_AngleY>359)m_AngleY=0;
00062         if(m_AngleZ<0)m_AngleZ=359;
00063         if(m_AngleZ>359)m_AngleZ=0;
00064 
00065         ExCMatrix4x4 Matrice,Matr;
00066         //ExCVec3D VecX,VecY,VecZ,VecDir;
00067 
00068         ExQuaternion Quat;
00069         
00070         
00071         Quat.SetEuler(m_AngleX,m_AngleY,m_AngleZ);
00072         Matr=GetMatrixFromQuaternion(Quat);
00073         
00074         //Matr=GetMatrixFromEuler(m_AngleX,m_AngleY,m_AngleZ);
00075 
00076 
00077         //glLoadMatrixf(Matr.m_Matrix); 
00078         
00079         /*glRotatef(m_AngleX,1.0,0.0,0.0);
00080         glRotatef(m_AngleY,0.0,1.0,0.0);
00081         glLoadIdentity();
00082         glLoadMatrixf(Matr.m_Matrix);
00083         cout<<Matr;
00084         cout<<Quat;*/
00085         
00086         VecX.m_Vector[0]=Matr.m_Matrix[0];
00087         VecX.m_Vector[1]=Matr.m_Matrix[1];
00088         VecX.m_Vector[2]=Matr.m_Matrix[2];
00089         VecY.m_Vector[0]=Matr.m_Matrix[4];
00090         VecY.m_Vector[1]=Matr.m_Matrix[5];
00091         VecY.m_Vector[2]=Matr.m_Matrix[6];
00092         VecZ.m_Vector[0]=Matr.m_Matrix[8];
00093         VecZ.m_Vector[1]=Matr.m_Matrix[9];
00094         VecZ.m_Vector[2]=Matr.m_Matrix[10];
00095 
00096         VecDir.m_Vector[0]=VecX.GetVectorLenght();
00097         VecDir.m_Vector[1]=VecY.GetVectorLenght();
00098         VecDir.m_Vector[2]=VecZ.GetVectorLenght();
00099 
00100         //cout<<VecDir<<endl;
00101         //glGetFloatv(GL_MODELVIEW_MATRIX,
00102         
00103         //glTranslatef(m_Position.GetX(),m_Position.GetY(),m_Position.GetZ()); 
00104         if(m_speed!=0)
00105         {
00106                 for(int i=0;i<m_speed;i++)
00107                 {
00108                         GoToView(true);
00109                 }
00110         }else
00111         {
00112         m_Target.SetX((Cos[(int)m_AngleY]+m_Position.GetX()));
00113         m_Target.SetZ((Sin[(int)m_AngleY]+m_Position.GetZ()));
00114         m_Target.SetY((Sin[(int)m_AngleX]+m_Position.GetY()));
00115         }
00116         //glRotatef(m_AngleZ,0.0,0.0,1.0);
00117         gluLookAt(m_Position.GetX(),m_Position.GetY(),m_Position.GetZ()
00118                         ,m_Target.GetX(),m_Target.GetY(),m_Target.GetZ()
00119                         ,0.0,1.0,0.0);
00120         
00121 UnGuard
00122 }

float GetClipFar void    [inline]
 

Definition at line 79 of file ExCCamera.h.

References m_ClipFar.

Referenced by ExManagerOutput::Reshape().

00079 {return m_ClipFar;}

float GetClipNear void    [inline]
 

Definition at line 80 of file ExCCamera.h.

References m_ClipNear.

Referenced by ExManagerOutput::Reshape().

00080 {return m_ClipNear;}

float GetZoom void    [inline]
 

Definition at line 77 of file ExCCamera.h.

References m_Zoom.

Referenced by ExManagerOutput::Reshape().

00077 {return m_Zoom;}

float GetZoomDefault void    [inline]
 

Definition at line 78 of file ExCCamera.h.

References m_ZoomDefault.

00078 {return m_ZoomDefault;}

float GetZoomMax void    [inline]
 

Definition at line 75 of file ExCCamera.h.

References m_ZoomMax.

00075 {return m_ZoomMax;}

float GetZoomMin void    [inline]
 

Definition at line 76 of file ExCCamera.h.

References m_ZoomMin.

00076 {return m_ZoomMin;}

void GoToView bool    state
 

Definition at line 124 of file ExCCamera.cpp.

References ExCVec3D::GetX(), ExCVec3D::GetY(), ExCVec3D::GetZ(), GoToView(), Guard, ExCObject::m_AngleX, ExCObject::m_AngleY, ExCObject::m_Position, ExCObject::m_Target, ExCVec3D::SetX(), ExCVec3D::SetY(), ExCVec3D::SetZ(), and UnGuard.

Referenced by Draw(), GoToView(), and ExManagerCommand::ProcessAction().

00125 {
00126 Guard(void ExCCamera::GoToView(void))
00127         //bool GoodY=true; // not used
00128         m_Position=m_Target;
00129         m_Target.SetX((Cos[(int)m_AngleY]+m_Position.GetX()));
00130         m_Target.SetZ((Sin[(int)m_AngleY]+m_Position.GetZ()));
00131         m_Target.SetY((Sin[(int)m_AngleX]+m_Position.GetY()));
00132 
00133 UnGuard
00134 }

void MoveCamera float    speed
 

Definition at line 253 of file ExCCamera.cpp.

References Guard, ExCVec3D::m_Vector, m_vPosition, m_vView, MoveCamera(), and UnGuard.

Referenced by MoveCamera().

00254 {
00255 Guard(void ExCCamera::MoveCamera(float speed))
00256         ExCVec3D vVector;                                       // Init a vVector for our view
00257 
00258         // Get our view vVector (The direciton we are facing)
00259         vVector.m_Vector[0] = m_vView.m_Vector[0] - m_vPosition.m_Vector[0];            // This gets the direction of the X     
00260         vVector.m_Vector[1] = m_vView.m_Vector[1] - m_vPosition.m_Vector[1];            // This gets the direction of the Y
00261         vVector.m_Vector[2] = m_vView.m_Vector[2] - m_vPosition.m_Vector[2];            // This gets the direction of the Z
00262 
00263         m_vPosition.m_Vector[0] += vVector.m_Vector[0] * speed;         // Add our acceleration to our position's X
00264         m_vPosition.m_Vector[2] += vVector.m_Vector[2] * speed;         // Add our acceleration to our position's Z
00265         m_vView.m_Vector[0] += vVector.m_Vector[0] * speed;                     // Add our acceleration to our view's X
00266         m_vView.m_Vector[2] += vVector.m_Vector[2] * speed;                     // Add our acceleration to our view's Z
00267 UnGuard
00268 }

void ResetZoom void   
 

Definition at line 136 of file ExCCamera.cpp.

References Guard, m_Zoom, m_ZoomDefault, ResetZoom(), and UnGuard.

Referenced by ResetZoom().

00137 {
00138 Guard(void ExCCamera::ResetZoom(void))
00139         m_Zoom=m_ZoomDefault;
00140 UnGuard
00141 }

void RotateView float    X,
float    Y,
float    Z
 

Definition at line 217 of file ExCCamera.cpp.

References Guard, ExCVec3D::m_Vector, m_vPosition, m_vView, RotateView(), and UnGuard.

Referenced by RotateView().

00218 {
00219 Guard(void ExCCamera::RotateView(float X, float Y, float Z))
00220         ExCVec3D vVector;                                                       // Vector for the position/view.
00221 
00222         // Get our view vVector (The direction we are facing)
00223         vVector.m_Vector[0] = m_vView.m_Vector[0] - m_vPosition.m_Vector[0];            // This gets the direction of the X     
00224         vVector.m_Vector[1] = m_vView.m_Vector[1] - m_vPosition.m_Vector[1];            // This gets the direction of the Y
00225         vVector.m_Vector[2]= m_vView.m_Vector[2] - m_vPosition.m_Vector[2];             // This gets the direction of the Z
00226 
00227         // If we pass in a negative X Y or Z, it will rotate the opposite way,
00228         // so we only need one function for a left and right , up or down rotation.
00229         // I suppose we could have one move function too, but I decided not too.
00230 
00231         if(X) {
00232                 m_vView.m_Vector[2] = (float)(m_vPosition.m_Vector[2] + sin(X)*vVector.m_Vector[1] + cos(X)*vVector.m_Vector[2]);
00233                 m_vView.m_Vector[1] = (float)(m_vPosition.m_Vector[1] + cos(X)*vVector.m_Vector[1] - sin(X)*vVector.m_Vector[2]);
00234         }
00235         if(Y) {
00236                 m_vView.m_Vector[2] = (float)(m_vPosition.m_Vector[2] + sin(Y)*vVector.m_Vector[0] + cos(Y)*vVector.m_Vector[2]);
00237                 m_vView.m_Vector[0] = (float)(m_vPosition.m_Vector[0] + cos(Y)*vVector.m_Vector[0] - sin(Y)*vVector.m_Vector[2]);
00238         }
00239         if(Z) {
00240                 m_vView.m_Vector[0] = (float)(m_vPosition.m_Vector[0] + sin(Z)*vVector.m_Vector[1] + cos(Z)*vVector.m_Vector[0]);               
00241                 m_vView.m_Vector[1] = (float)(m_vPosition.m_Vector[1] + cos(Z)*vVector.m_Vector[1] - sin(Z)*vVector.m_Vector[0]);
00242         }
00243 UnGuard
00244 }

void SetClipFar float    clip
 

Definition at line 201 of file ExCCamera.cpp.

References Guard, m_ClipFar, m_ClipNear, SetClipFar(), and UnGuard.

Referenced by SetClipFar().

00202 {
00203         Guard(void ExCCamera::SetClipFar(float clip))
00204         m_ClipFar=clip;
00205         if(m_ClipFar<m_ClipNear)m_ClipFar=m_ClipNear+1;
00206 UnGuard
00207 }

void SetClipNear float    clip
 

Definition at line 209 of file ExCCamera.cpp.

References Guard, m_ClipFar, m_ClipNear, SetClipNear(), and UnGuard.

Referenced by SetClipNear().

00210 {
00211         Guard(void ExCCamera::SetClipNear(float clip))
00212         m_ClipNear=clip;
00213         if(m_ClipNear>m_ClipFar)m_ClipNear=m_ClipFar-1;
00214 UnGuard
00215 }

void SetZoom float    zoom
 

Definition at line 183 of file ExCCamera.cpp.

References Guard, SetZoom(), and UnGuard.

Referenced by SetZoom().

00184 {
00185 Guard(void ExCCamera::SetZoom(float zoom))
00186 UnGuard
00187 }

void SetZoomDefault float    zoom
 

Definition at line 143 of file ExCCamera.cpp.

References Guard, m_ZoomDefault, m_ZoomMin, and UnGuard.

00144 {
00145 Guard(void ExCCamera:: SetZoomDefault(float zoom))
00146         if(zoom<m_ZoomMax&&zoom>m_ZoomMin)
00147                 m_ZoomDefault=zoom;
00148 UnGuard
00149 }

void SetZoomMax float    zoom
 

Definition at line 189 of file ExCCamera.cpp.

References Guard, SetZoomMax(), and UnGuard.

Referenced by SetZoomMax().

00190 {
00191 Guard(void ExCCamera::SetZoomMax(float zoom))
00192 UnGuard
00193 }

void SetZoomMin float    zoom
 

Definition at line 195 of file ExCCamera.cpp.

References Guard, SetZoomMin(), and UnGuard.

Referenced by SetZoomMin().

00196 {
00197 Guard(void ExCCamera::SetZoomMin(float zoom))
00198 UnGuard
00199 }

void StrafeCamera float    speed
 

Definition at line 246 of file ExCCamera.cpp.

References Guard, StrafeCamera(), and UnGuard.

Referenced by StrafeCamera().

00247 {
00248 Guard(void ExCCamera::StrafeCamera(float speed))
00249 
00250 UnGuard
00251 }

void ZoomIn float    zoom
 

Definition at line 167 of file ExCCamera.cpp.

References Guard, m_Zoom, m_ZoomMin, UnGuard, and ZoomIn().

00168 {
00169 Guard(void ExCCamera::ZoomIn(float zoom))
00170         m_Zoom=m_Zoom-zoom;
00171         if(m_Zoom<=m_ZoomMin)m_Zoom=m_ZoomMin+1;
00172 UnGuard
00173 }

void ZoomIn void   
 

Definition at line 151 of file ExCCamera.cpp.

References Guard, m_Zoom, m_ZoomMin, UnGuard, and ZoomIn().

Referenced by ZoomIn().

00152 {
00153 Guard(void ExCCamera::ZoomIn(void))
00154         m_Zoom--;
00155         if(m_Zoom<=m_ZoomMin)m_Zoom=m_ZoomMin+1;
00156 UnGuard
00157 }

void ZoomOut float    zoom
 

Definition at line 175 of file ExCCamera.cpp.

References Guard, m_Zoom, m_ZoomMax, UnGuard, and ZoomOut().

00176 {
00177 Guard(void ExCCamera::ZoomOut(float zoom))
00178         m_Zoom=m_Zoom+m_ZoomMax;
00179         if(m_Zoom>=m_ZoomMax)m_Zoom=m_ZoomMax-1;
00180 UnGuard
00181 }

void ZoomOut void   
 

Definition at line 159 of file ExCCamera.cpp.

References Guard, m_Zoom, m_ZoomMax, UnGuard, and ZoomOut().

Referenced by ZoomOut().

00160 {
00161 Guard(void ExCCamera::ZoomOut(void))
00162         m_Zoom++;
00163         if(m_Zoom>=m_ZoomMax)m_Zoom=m_ZoomMax-1;
00164 UnGuard
00165 }


Field Documentation

bool m_Actif [protected]
 

Definition at line 41 of file ExCCamera.h.

float m_ClipFar [protected]
 

Definition at line 43 of file ExCCamera.h.

Referenced by ExCCamera(), GetClipFar(), SetClipFar(), and SetClipNear().

float m_ClipNear [protected]
 

Definition at line 44 of file ExCCamera.h.

Referenced by ExCCamera(), GetClipNear(), SetClipFar(), and SetClipNear().

int m_speed
 

Definition at line 51 of file ExCCamera.h.

Referenced by Draw(), ExCCamera(), and ExManagerCommand::ProcessAction().

ExCVec3D m_vPosition [protected]
 

Definition at line 49 of file ExCCamera.h.

Referenced by ExCCamera(), MoveCamera(), and RotateView().

ExCVec3D m_vUpVector [protected]
 

Definition at line 49 of file ExCCamera.h.

Referenced by ExCCamera().

ExCVec3D m_vView [protected]
 

Definition at line 49 of file ExCCamera.h.

Referenced by ExCCamera(), MoveCamera(), and RotateView().

float m_Zoom [protected]
 

Definition at line 42 of file ExCCamera.h.

Referenced by ExCCamera(), GetZoom(), ResetZoom(), ZoomIn(), and ZoomOut().

float m_ZoomDefault [protected]
 

Definition at line 45 of file ExCCamera.h.

Referenced by ExCCamera(), GetZoomDefault(), ResetZoom(), and SetZoomDefault().

float m_ZoomMax [protected]
 

Definition at line 46 of file ExCCamera.h.

Referenced by ExCCamera(), GetZoomMax(), and ZoomOut().

float m_ZoomMin [protected]
 

Definition at line 47 of file ExCCamera.h.

Referenced by ExCCamera(), GetZoomMin(), SetZoomDefault(), and ZoomIn().

ExCVec3D VecDir [protected]
 

Definition at line 48 of file ExCCamera.h.

Referenced by Draw().

ExCVec3D VecX [protected]
 

Definition at line 48 of file ExCCamera.h.

Referenced by Draw().

ExCVec3D VecY [protected]
 

Definition at line 48 of file ExCCamera.h.

Referenced by Draw().

ExCVec3D VecZ [protected]
 

Definition at line 48 of file ExCCamera.h.

Referenced by Draw().


The documentation for this class was generated from the following files:
Generated on Tue Aug 6 20:27:18 2002 for ExNihilo by doxygen1.2.17