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

ExCObject3D.cpp

Go to the documentation of this file.
00001 /*
00002  * ExNihilo 3D Engine
00003  * 
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  *
00018  * Please read AUTHORS file !!!
00019  * 
00020  
00021  *
00022  */
00023 
00024 #include "ExCObject3D.h"
00025 
00026 // Construction/Destruction
00027 
00028 ExCObject3D::ExCObject3D()
00029 {
00030         ExCObject::ExCObject();
00031         m_Size=1.0;
00032         m_RefreshTime=0.01f;
00033         m_Life=0;
00034         m_StartingLife=glutGet(GLUT_ELAPSED_TIME)/1000;
00035         m_Mass=100;
00036         m_ShowInfo=false;
00037         m_CurrentObject=false;
00038         m_Velocity.SetValue(0.01f,0.0f,0.0f);
00039         m_Position.SetValue(0.0f,0.0f,0.0f);
00040         m_Gravity.SetValue(0.0f,0.0f,0.0f);
00041         m_Acceleration=0.0f;
00042         m_AngleX=0.0f;
00043         m_AngleY=0.0f;
00044         m_AngleZ=0.0f;
00045         
00046         SetName("ExCObject3D");
00047         SetType(typeid(this).name());
00048 }
00049 
00050 ExCObject3D::~ExCObject3D()
00051 {
00052 
00053 }
00054 
00055 void ExCObject3D::ShowInfo(void)
00056 {
00057 Guard(void ExCObject3D::ShowInfo(void))
00058         
00059         char *CIdName;
00060         char *CPosition;
00061         char *CVelocity;
00062         char *CAcceleration;
00063         char *CGravity;
00064         char *CLife;
00065 
00066         CIdName= new char[strlen("Name : Id:")+strlen(GetName().data())+7];
00067         sprintf(CIdName,"Name :%s Id:%ld",GetName(),GetId());
00068 
00069         CPosition= new char[strlen("Position X: Y: Z:")+30];
00070         sprintf(CPosition,"Position X:%f Y:%f Z:%f",m_Position.GetX(),m_Position.GetY(),m_Position.GetZ());
00071 
00072         CVelocity= new char[strlen("Velocity X: Y: Z:")+30];
00073         sprintf(CVelocity,"Velocity X:%f Y:%f Z:%f",m_Velocity.GetX(),m_Velocity.GetY(),m_Velocity.GetZ());
00074 
00075         CGravity= new char[strlen("Gravity X: Y: Z:")+30];
00076         sprintf(CGravity,"Gravity X:%f Y:%f Z:%f",m_Gravity.GetX(),m_Gravity.GetY(),m_Gravity.GetZ());
00077 
00078         CAcceleration= new char[strlen("Acceleration :")+30];
00079         sprintf(CAcceleration,"Acceleration :%f",m_Acceleration);
00080 
00081         CLife= new char[strlen("Life :")+10];
00082         sprintf(CLife,"Life :%f",m_Life);
00083 
00084         /*ExNihilo::EnterOrthoMode();
00085                 glDisable(GL_LIGHTING);
00086                 ExNihilo::RenderBitmapString(500,500,(void *)GLUT_BITMAP_HELVETICA_12,CIdName); 
00087                 ExNihilo::RenderBitmapString(500,515,(void *)GLUT_BITMAP_HELVETICA_12,CPosition);
00088                 ExNihilo::RenderBitmapString(500,530,(void *)GLUT_BITMAP_HELVETICA_12,CVelocity);       
00089                 ExNihilo::RenderBitmapString(500,545,(void *)GLUT_BITMAP_HELVETICA_12,CAcceleration);   
00090                 ExNihilo::RenderBitmapString(500,560,(void *)GLUT_BITMAP_HELVETICA_12,CGravity);        
00091                 ExNihilo::RenderBitmapString(500,575,(void *)GLUT_BITMAP_HELVETICA_12,CLife);   
00092                 glEnable(GL_LIGHTING);
00093         ExNihilo::LeaveOrthoMode();*/
00094                 std::cout<<CIdName<<std::endl;  
00095                 std::cout<<CPosition<<std::endl;        
00096                 std::cout<<CVelocity<<std::endl;                
00097                 std::cout<<CAcceleration<<std::endl;            
00098                 std::cout<<CGravity<<std::endl;         
00099                 std::cout<<CLife<<std::endl;            
00100 
00101         delete CIdName;
00102         delete CPosition;
00103         delete CVelocity;
00104         delete CAcceleration;
00105         delete CGravity;
00106         delete CLife;   
00107 UnGuard
00108 }  
00109 
00110 void ExCObject3D::SetAngleX(float Angle)
00111 {
00112         if(m_AngleX<0)m_AngleX=359;
00113         if(m_AngleX>359)m_AngleX=0;
00114 }
00115 
00116 void ExCObject3D::SetAngleY(float Angle)
00117 {
00118         if(m_AngleY<0)m_AngleY=359;
00119         if(m_AngleY>359)m_AngleY=0;
00120 }
00121 
00122 void ExCObject3D::SetAngleZ(float Angle)
00123 {
00124         /*if(m_AngleZ<0)m_AngleZ=359;
00125         if(m_AngleZ>359)m_AngleZ=0;*/
00126         m_AngleZ=Angle;
00127 }
00128 
00129 
00130 void ExCObject3D::Rotate(float angleX,float angleY,float angleZ)
00131 {
00132         SetAngleX(angleX);
00133         SetAngleY(angleY);
00134         SetAngleZ(angleZ);
00135         Rotate();       
00136 }
00137 
00138 void ExCObject3D::Rotate(void)
00139 {
00140         if(m_AngleX<0)m_AngleX=359;
00141         if(m_AngleX>359)m_AngleX=0;
00142         if(m_AngleY<0)m_AngleY=359;
00143         if(m_AngleY>359)m_AngleY=0;
00144         if(m_AngleZ<0)m_AngleZ=359;
00145         if(m_AngleZ>359)m_AngleZ=0;
00146         
00147         ExQuaternion quat;
00148         ExCMatrix4x4 Matr;
00149         ExCVec3D VecX,VecY,VecZ,VecDir;
00150         
00151         quat=GetQuaternionFromEuler(m_AngleX,m_AngleY,m_AngleZ);
00152         //Matr=GetMatrixFromQuaternion(quat);
00153         //Matr=GetMatrixFromEuler(m_AngleX,m_AngleY,m_AngleZ);
00154         
00155         /*VecX.m_Vector[0]=(float)Matr.m_Matrix[0];
00156         VecX.m_Vector[1]=(float)Matr.m_Matrix[1];
00157         VecX.m_Vector[2]=(float)Matr.m_Matrix[2];
00158         VecY.m_Vector[0]=(float)Matr.m_Matrix[4];
00159         VecY.m_Vector[1]=(float)Matr.m_Matrix[5];
00160         VecY.m_Vector[2]=(float)Matr.m_Matrix[6];
00161         VecZ.m_Vector[0]=(float)Matr.m_Matrix[8];
00162         VecZ.m_Vector[1]=(float)Matr.m_Matrix[9];
00163         VecZ.m_Vector[2]=(float)Matr.m_Matrix[10];
00164 
00165         VecDir.m_Vector[0]=VecX.GetVectorLenght();
00166         VecDir.m_Vector[1]=VecY.GetVectorLenght();
00167         VecDir.m_Vector[2]=VecZ.GetVectorLenght();
00168         VecDir=VecX+VecY+VecZ;
00169         std::cout<<"Angle X:"<<m_AngleX<<" Y:"<<m_AngleY<<" Z:"<<m_AngleZ<<std::endl;
00170         std::cout<<"Quater :"<<quat<<std::endl;
00171         std::cout<<"Matrice:"<<Matr<<std::endl;
00172         std::cout<<"vec   X:"<<VecX<<std::endl;
00173         std::cout<<"vec   Y:"<<VecY<<std::endl;
00174         std::cout<<"vec   Z:"<<VecZ<<std::endl;
00175         std::cout<<"vec dir:"<<VecDir<<std::endl;
00176         std::cout<<"vel bef:"<<m_Velocity<<std::endl;
00177         //std::cout<<"vec aft:"<<m_Velocity<<std::endl;
00178         
00179 
00180         m_Target.SetX((Cos[(int)m_AngleY]));
00181         m_Target.SetZ((Sin[(int)m_AngleY]));
00182         m_Target.SetY((Sin[(int)m_AngleX]));
00183         std::cout<<"vec target:"<<m_Target<<std::endl;*/
00184         //VecDir=GetAxisFromQuaternion(quat);
00185         //m_Velocity=m_Velocity*VecDir;
00186         //std::cout<<"vec dir:"<<VecDir<<std::endl;
00187         //std::cout<<"vec vel:"<<m_Velocity<<std::endl;
00188         
00189 }
00190 

Generated on Tue Dec 10 18:20:04 2002 for ExNihilo by doxygen1.3-rc1