00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "ExCObject3D.h"
00025
00026
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
00085
00086
00087
00088
00089
00090
00091
00092
00093
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
00125
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
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189 }
00190