Page principale   Liste des namespaces   Hiérarchie des classes   Liste par ordre alphabétique   Liste des composants   Liste des fichiers   Composants   Déclarations  

ExCObject.cpp

Aller à la documentation de ce fichier.
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  * $Id: ExCObject.cpp,v 1.17 2002/08/01 19:37:50 binny Exp $
00021  *
00022  */
00023 
00024 #include "ExCObject.h"
00025 
00026 // Construction/Destruction
00027 
00028 ExCObject::ExCObject()
00029 {
00030         SetName("NoName");
00031         SetId(-1);
00032         m_Size=1.0;
00033         m_RefreshTime=0.01f;
00034         m_Life=0;
00035         m_StartingLife=glutGet(GLUT_ELAPSED_TIME)/1000;
00036         m_Mass=100;
00037         m_ShowInfo=false;
00038         m_CurrentObject=false;
00039         m_Velocity.SetValue(0.01f,0.0f,0.0f);
00040         m_Position.SetValue(0.0f,0.0f,0.0f);
00041         m_Gravity.SetValue(0.0f,0.0f,0.0f);
00042         m_Acceleration=0.0f;
00043         m_AngleX=0.0f;
00044         m_AngleY=0.0f;
00045         m_AngleZ=0.0f;
00046 }
00047 
00048 ExCObject::~ExCObject()
00049 {
00050 
00051 }
00052 
00053 void ExCObject::SetName(const char * Name)
00054 {
00055 Guard(void ExCObject::SetName(char * Name))
00056         m_ObjectName = new char[strlen(Name)];
00057         sprintf(m_ObjectName,Name);
00058 UnGuard
00059 }
00060 
00061 void ExCObject::Draw(void)
00062 {
00063 Guard(void ExCObject::Draw(void))
00064 UnGuard
00065 }  
00066 
00067 void ExCObject::ShowInfo(void)
00068 {
00069 Guard(void ExCObject::ShowInfo(void))
00070         
00071         char *CIdName;
00072         char *CPosition;
00073         char *CVelocity;
00074         char *CAcceleration;
00075         char *CGravity;
00076         char *CLife;
00077 
00078         CIdName= new char[strlen("Name : Id:")+strlen(GetName())+7];
00079         sprintf(CIdName,"Name :%s Id:%ld",GetName(),GetId());
00080 
00081         CPosition= new char[strlen("Position X: Y: Z:")+30];
00082         sprintf(CPosition,"Position X:%f Y:%f Z:%f",m_Position.GetX(),m_Position.GetY(),m_Position.GetZ());
00083 
00084         CVelocity= new char[strlen("Velocity X: Y: Z:")+30];
00085         sprintf(CVelocity,"Velocity X:%f Y:%f Z:%f",m_Velocity.GetX(),m_Velocity.GetY(),m_Velocity.GetZ());
00086 
00087         CGravity= new char[strlen("Gravity X: Y: Z:")+30];
00088         sprintf(CGravity,"Gravity X:%f Y:%f Z:%f",m_Gravity.GetX(),m_Gravity.GetY(),m_Gravity.GetZ());
00089 
00090         CAcceleration= new char[strlen("Acceleration :")+30];
00091         sprintf(CAcceleration,"Acceleration :%f",m_Acceleration);
00092 
00093         CLife= new char[strlen("Life :")+10];
00094         sprintf(CLife,"Life :%f",m_Life);
00095 
00096         EnterOrthoMode();
00097                 glDisable(GL_LIGHTING);
00098                 RenderBitmapString(500,500,(void *)GLUT_BITMAP_HELVETICA_12,CIdName);   
00099                 RenderBitmapString(500,515,(void *)GLUT_BITMAP_HELVETICA_12,CPosition);
00100                 RenderBitmapString(500,530,(void *)GLUT_BITMAP_HELVETICA_12,CVelocity); 
00101                 RenderBitmapString(500,545,(void *)GLUT_BITMAP_HELVETICA_12,CAcceleration);     
00102                 RenderBitmapString(500,560,(void *)GLUT_BITMAP_HELVETICA_12,CGravity);  
00103                 RenderBitmapString(500,575,(void *)GLUT_BITMAP_HELVETICA_12,CLife);     
00104                 glEnable(GL_LIGHTING);
00105         LeaveOrthoMode();
00106 UnGuard
00107 }  
00108 
00109 void ExCObject::SetIdName(IdName idname)
00110 {
00111         SetName(idname.second);
00112         SetId(idname.first);
00113 }
00114 
00115 void ExCObject::SetAngleX(float Angle)
00116 {
00117         if(m_AngleX<0)m_AngleX=359;
00118         if(m_AngleX>359)m_AngleX=0;
00119 }
00120 
00121 void ExCObject::SetAngleY(float Angle)
00122 {
00123         if(m_AngleY<0)m_AngleY=359;
00124         if(m_AngleY>359)m_AngleY=0;
00125 }
00126 
00127 void ExCObject::SetAngleZ(float Angle)
00128 {
00129         if(m_AngleZ<0)m_AngleZ=359;
00130         if(m_AngleZ>359)m_AngleZ=0;
00131 }
00132 
00133 void ExCObject::SetManagerTexture(ExManagerTexture * Texture)
00134 {
00135         ManagerTexture = Texture;
00136 }
00137 
00138 void ExCObject::Rotate(float angleX,float angleY,float angleZ)
00139 {
00140         SetAngleX(angleX);
00141         SetAngleY(angleY);
00142         SetAngleZ(angleZ);
00143         Rotate();       
00144 }
00145 
00146 void ExCObject::Rotate(void)
00147 {
00148         if(m_AngleX<0)m_AngleX=359;
00149         if(m_AngleX>359)m_AngleX=0;
00150         if(m_AngleY<0)m_AngleY=359;
00151         if(m_AngleY>359)m_AngleY=0;
00152         if(m_AngleZ<0)m_AngleZ=359;
00153         if(m_AngleZ>359)m_AngleZ=0;
00154         
00155         ExQuaternion quat;
00156         ExCMatrix4x4 Matr;
00157         ExCVec3D VecX,VecY,VecZ,VecDir;
00158         
00159         quat=GetQuaternionFromEuler(m_AngleX,m_AngleY,m_AngleZ);
00160         //Matr=GetMatrixFromQuaternion(quat);
00161         //Matr=GetMatrixFromEuler(m_AngleX,m_AngleY,m_AngleZ);
00162         
00163         /*VecX.m_Vector[0]=(float)Matr.m_Matrix[0];
00164         VecX.m_Vector[1]=(float)Matr.m_Matrix[1];
00165         VecX.m_Vector[2]=(float)Matr.m_Matrix[2];
00166         VecY.m_Vector[0]=(float)Matr.m_Matrix[4];
00167         VecY.m_Vector[1]=(float)Matr.m_Matrix[5];
00168         VecY.m_Vector[2]=(float)Matr.m_Matrix[6];
00169         VecZ.m_Vector[0]=(float)Matr.m_Matrix[8];
00170         VecZ.m_Vector[1]=(float)Matr.m_Matrix[9];
00171         VecZ.m_Vector[2]=(float)Matr.m_Matrix[10];
00172 
00173         VecDir.m_Vector[0]=VecX.GetVectorLenght();
00174         VecDir.m_Vector[1]=VecY.GetVectorLenght();
00175         VecDir.m_Vector[2]=VecZ.GetVectorLenght();
00176         VecDir=VecX+VecY+VecZ;
00177         std::cout<<"Angle X:"<<m_AngleX<<" Y:"<<m_AngleY<<" Z:"<<m_AngleZ<<std::endl;
00178         std::cout<<"Quater :"<<quat<<std::endl;
00179         std::cout<<"Matrice:"<<Matr<<std::endl;
00180         std::cout<<"vec   X:"<<VecX<<std::endl;
00181         std::cout<<"vec   Y:"<<VecY<<std::endl;
00182         std::cout<<"vec   Z:"<<VecZ<<std::endl;
00183         std::cout<<"vec dir:"<<VecDir<<std::endl;
00184         std::cout<<"vel bef:"<<m_Velocity<<std::endl;
00185         //std::cout<<"vec aft:"<<m_Velocity<<std::endl;
00186         
00187 
00188         m_Target.SetX((Cos[(int)m_AngleY]));
00189         m_Target.SetZ((Sin[(int)m_AngleY]));
00190         m_Target.SetY((Sin[(int)m_AngleX]));
00191         std::cout<<"vec target:"<<m_Target<<std::endl;*/
00192         //VecDir=GetAxisFromQuaternion(quat);
00193         //m_Velocity=m_Velocity*VecDir;
00194         //std::cout<<"vec dir:"<<VecDir<<std::endl;
00195         //std::cout<<"vec vel:"<<m_Velocity<<std::endl;
00196         
00197 }
00198 

Généré le Tue Aug 6 20:25:25 2002 pour ExNihilo par doxygen1.2.17