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

# ExCModel3DS.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: ExCModel3DS.cpp,v 1.11 2002/11/24 11:59:01 data Exp $
    00021  *
    00022  */
    00023
    00024 #include "ExCModel3DS.h"
    00025
    00026 ExCModel3DS::ExCModel3DS(void)
    00027 {
    00028 Guard(ExCModel3DS::ExCModel3DS(void))
    00029         ExCModel::ExCModel();
    00030         SetName("ExCModel3DS");
    00031         SetType(typeid(this).name());
    00032         m_ListId=-1;
    00033         m_CollisionGizmo=new ExCGizmoRectangle;
    00034         m_CollisionCounter=0;
    00035         HasList=false;
    00036         HasArray=false;
    00037         m_AlwaysDraw=false;
    00038         SetVisibleState(true);
    00039 UnGuard
    00040 }
    00041
    00042 ExCModel3DS::~ExCModel3DS(void)
    00043 {
    00044 Guard(ExCModel3DS::~ExCModel3DS(void))
    00045 UnGuard
    00046 }
    00047 void ExCModel3DS::BuildArray(int Rendu)
    00048 {
    00049 Guard(void ExCModel3DS::BuildArray(int Rendu))
    00050
    00051         ExCVec3D VecAB,VecBC,VecCA,VecFace;
    00052         ExCVec3D VecX,VecY,VecZ;
    00053         ExCVec2D VecTAB,VecTBC,VecTCA;
    00054
    00055         for(unsigned int i=0;i<m_VecObject->size();i++)//draw all objects
    00056         {
    00057
    00058                 m_VecObject->at(i).TabVertices= new float[m_VecObject->at(i).Faces.size()*9];
    00059                 m_VecObject->at(i).TabTextures= new float[m_VecObject->at(i).Faces.size()*6];
    00060
    00061                 for(unsigned int j=0;j<m_VecObject->at(i).Faces.size();j++)//draw all faces
    00062                 {
    00063                         VecFace.SetX(m_VecObject->at(i).Faces.at(j).vertIndex[0]);
    00064                         VecFace.SetY(m_VecObject->at(i).Faces.at(j).vertIndex[1]);
    00065                         VecFace.SetZ(m_VecObject->at(i).Faces.at(j).vertIndex[2]);
    00066                         //----------------
    00067                         //Texture coord
    00068                         //----------------
    00069                         VecTAB.SetX(m_VecObject->at(i).TexVerts.at(VecFace.GetX()).GetX());
    00070                         VecTAB.SetY(m_VecObject->at(i).TexVerts.at(VecFace.GetX()).GetY());
    00071
    00072                         VecTBC.SetX(m_VecObject->at(i).TexVerts.at(VecFace.GetY()).GetX());
    00073                         VecTBC.SetY(m_VecObject->at(i).TexVerts.at(VecFace.GetY()).GetY());
    00074
    00075                         VecTCA.SetX(m_VecObject->at(i).TexVerts.at(VecFace.GetZ()).GetX());
    00076                         VecTCA.SetY(m_VecObject->at(i).TexVerts.at(VecFace.GetZ()).GetY());
    00077
    00078                 /*      std::cout<<"Builded zrrzy Texture :"<<j<<":"<<VecTAB<<std::endl;
    00079                         std::cout<<"Builded zrrzy Texture :"<<j<<":"<<VecTBC<<std::endl;
    00080                         std::cout<<"Builded zrrzy Texture :"<<j<<":"<<VecTCA<<std::endl;
    00081
    00082                         std::cout<<"Build list TExture :"<<j<<" DONE"<<std::endl;*/
    00083                         //----------------
    00084                         //Vertex coord
    00085                         //----------------
    00086
    00087                         VecX.SetX(m_VecObject->at(i).Verts.at(VecFace.GetX()).GetX());
    00088                         VecX.SetY(m_VecObject->at(i).Verts.at(VecFace.GetX()).GetY());
    00089                         VecX.SetZ(m_VecObject->at(i).Verts.at(VecFace.GetX()).GetZ());
    00090
    00091                         VecY.SetX(m_VecObject->at(i).Verts.at(VecFace.GetY()).GetX());
    00092                         VecY.SetY(m_VecObject->at(i).Verts.at(VecFace.GetY()).GetY());
    00093                         VecY.SetZ(m_VecObject->at(i).Verts.at(VecFace.GetY()).GetZ());
    00094
    00095                         VecZ.SetX(m_VecObject->at(i).Verts.at(VecFace.GetZ()).GetX());
    00096                         VecZ.SetY(m_VecObject->at(i).Verts.at(VecFace.GetZ()).GetY());
    00097                         VecZ.SetZ(m_VecObject->at(i).Verts.at(VecFace.GetZ()).GetZ());
    00098
    00099                         //std::cout<<"Vec FACE num:"<<j<<" "<<VecFace<<//std::endl;
    00100
    00101
    00102                         //std::cout<<"Vec FACE num:"<<j<<" "<<VecFace<<//std::endl;
    00103
    00104                         ManagerTexture->SetCurrentObject(m_VecObject->at(i).Material);
    00105
    00106
    00107
    00108                         m_VecObject->at(i).TabVertices[0+j*9]=VecX.GetX();
    00109                         m_VecObject->at(i).TabVertices[1+j*9]=VecX.GetY();
    00110                         m_VecObject->at(i).TabVertices[2+j*9]=VecX.GetZ();
    00111                         m_VecObject->at(i).TabVertices[3+j*9]=VecY.GetX();
    00112                         m_VecObject->at(i).TabVertices[4+j*9]=VecY.GetY();
    00113                         m_VecObject->at(i).TabVertices[5+j*9]=VecY.GetZ();
    00114                         m_VecObject->at(i).TabVertices[6+j*9]=VecZ.GetX();
    00115                         m_VecObject->at(i).TabVertices[7+j*9]=VecZ.GetY();
    00116                         m_VecObject->at(i).TabVertices[8+j*9]=VecZ.GetZ();
    00117
    00118                         m_VecObject->at(i).TabTextures[0+j*6]=VecTAB.GetX();
    00119                         m_VecObject->at(i).TabTextures[1+j*6]=VecTAB.GetY();
    00120                         m_VecObject->at(i).TabTextures[2+j*6]=VecTBC.GetX();
    00121                         m_VecObject->at(i).TabTextures[3+j*6]=VecTBC.GetY();
    00122                         m_VecObject->at(i).TabTextures[4+j*6]=VecTCA.GetX();
    00123                         m_VecObject->at(i).TabTextures[5+j*6]=VecTCA.GetY();
    00124
    00125 /*                      std::cout<<"Builded array Face :"<<j<<":"<<m_VecObject->at(i).TabVertices[0+j*9]<<std::endl;
    00126                         std::cout<<"Builded array Face :"<<j<<":"<<m_VecObject->at(i).TabVertices[1+j*9]<<std::endl;
    00127                         std::cout<<"Builded array Face :"<<j<<":"<<m_VecObject->at(i).TabVertices[2+j*9]<<std::endl;
    00128                         std::cout<<"Builded array Face :"<<j<<":"<<m_VecObject->at(i).TabVertices[3+j*9]<<std::endl;
    00129                         std::cout<<"Builded array Face :"<<j<<":"<<m_VecObject->at(i).TabVertices[4+j*9]<<std::endl;
    00130                         std::cout<<"Builded array Face :"<<j<<":"<<m_VecObject->at(i).TabVertices[5+j*9]<<std::endl;
    00131                         std::cout<<"Builded array Face :"<<j<<":"<<m_VecObject->at(i).TabVertices[6+j*9]<<std::endl;
    00132                         std::cout<<"Builded array Face :"<<j<<":"<<m_VecObject->at(i).TabVertices[7+j*9]<<std::endl;
    00133                         std::cout<<"Builded array Face :"<<j<<":"<<m_VecObject->at(i).TabVertices[8+j*9]<<std::endl;
    00134                         std::cout<<"Build array Face :"<<j<<" DONE"<<std::endl;
    00135
    00136                         std::cout<<"Builded array Texture :"<<j<<":"<<m_VecObject->at(i).TabTextures[0+j*6]<<std::endl;
    00137                         std::cout<<"Builded array Texture :"<<j<<":"<<m_VecObject->at(i).TabTextures[1+j*6]<<std::endl;
    00138                         std::cout<<"Builded array Texture :"<<j<<":"<<m_VecObject->at(i).TabTextures[2+j*6]<<std::endl;
    00139                         std::cout<<"Builded array Texture :"<<j<<":"<<m_VecObject->at(i).TabTextures[3+j*6]<<std::endl;
    00140                         std::cout<<"Builded array Texture :"<<j<<":"<<m_VecObject->at(i).TabTextures[4+j*6]<<std::endl;
    00141                         std::cout<<"Builded array Texture :"<<j<<":"<<m_VecObject->at(i).TabTextures[5+j*6]<<std::endl;
    00142                         std::cout<<"Build array TExture :"<<j<<" DONE"<<std::endl;*/
    00143                 }
    00144         }
    00145         HasArray=true;
    00146 UnGuard
    00147 }
    00148
    00149 void ExCModel3DS::Draw(void)
    00150 {
    00151 Guard(void ExCModel3DS::Draw(void))
    00152         ExCVec3D VecAB,VecBC,VecCA,VecFace;
    00153         ExCVec3D VecX,VecY,VecZ;
    00154         bool DrawIt=false;
    00155         ProcessAllAction();
    00156         if(!m_Visible)return;
    00157         if(HasList==false)BuildList(RENDER_TEXTURES);
    00158         if(HasArray==false)BuildArray(RENDER_TEXTURES);
    00159         glPushMatrix();
    00160                 //ExCModel::Draw();
    00161                 //glTranslatef(m_Position.GetX(),m_Position.GetY(),m_Position.GetZ());
    00162                 glRotatef(-90,1,0,0);
    00163                 if(m_AlwaysDraw)
    00164                 {
    00165                 //      CallAllList();
    00166                         CallAllArray();
    00167                 }else
    00168                 {
    00169                         //Draw only objet in frustrum
    00170                         ExCFrustum Frustrum;
    00171                         Frustrum.CalculateFrustum();
    00172                         for(unsigned int i=0;i<m_VecObject->size();i++)//draw all objects
    00173                         {
    00174                                 DrawIt=false;
    00175                                 for(unsigned int j=0;j<m_VecObject->at(i).Faces.size();j++)//draw all faces
    00176                                 {
    00177                                         VecFace.SetX(m_VecObject->at(i).Faces.at(j).vertIndex[0]);
    00178                                         VecFace.SetY(m_VecObject->at(i).Faces.at(j).vertIndex[1]);
    00179                                         VecFace.SetZ(m_VecObject->at(i).Faces.at(j).vertIndex[2]);
    00180                                         //----------------
    00181                                         //Vertex coord
    00182                                         //----------------
    00183                                         VecX.SetX(m_VecObject->at(i).Verts.at(VecFace.GetX()).GetX());
    00184                                         VecX.SetY(m_VecObject->at(i).Verts.at(VecFace.GetX()).GetY());
    00185                                         VecX.SetZ(m_VecObject->at(i).Verts.at(VecFace.GetX()).GetZ());
    00186                                         VecY.SetX(m_VecObject->at(i).Verts.at(VecFace.GetY()).GetX());
    00187                                         VecY.SetY(m_VecObject->at(i).Verts.at(VecFace.GetY()).GetY());
    00188                                         VecY.SetZ(m_VecObject->at(i).Verts.at(VecFace.GetY()).GetZ());
    00189                                         VecZ.SetX(m_VecObject->at(i).Verts.at(VecFace.GetZ()).GetX());
    00190                                         VecZ.SetY(m_VecObject->at(i).Verts.at(VecFace.GetZ()).GetY());
    00191                                         VecZ.SetZ(m_VecObject->at(i).Verts.at(VecFace.GetZ()).GetZ());
    00192                                         VecX=VecX+m_Position;
    00193                                         VecY=VecY+m_Position;
    00194                                         VecZ=VecZ+m_Position;
    00195                                         if(Frustrum.PointInFrustum(VecX.GetX(),VecX.GetY(),VecX.GetZ())){DrawIt=true;}
    00196                                         if(Frustrum.PointInFrustum(VecY.GetX(),VecY.GetY(),VecY.GetZ())){DrawIt=true;}
    00197                                         if(Frustrum.PointInFrustum(VecZ.GetX(),VecZ.GetY(),VecZ.GetZ())){DrawIt=true;}
    00198                                 }
    00199                                 if(DrawIt)
    00200                                 {
    00201                                         //glCallList(m_VecObject->at(i).m_ListId);
    00202
    00203                                         //glPushMatrix();
    00204                                                 glDisable(GL_LIGHTING);
    00205                                                 glColor3f(1.0f,1.0f,1.0f);
    00206                                                 ManagerTexture->SetTexture(0,m_VecObject->at(i).Material);
    00207                                                 glTexCoordPointer(2,GL_FLOAT,0,m_VecObject->at(i).TabTextures);
    00208                                                 glEnableClientState(GL_VERTEX_ARRAY);
    00209                                                 glVertexPointer(3,GL_FLOAT,0,m_VecObject->at(i).TabVertices);
    00210                                                 glDrawArrays( GL_TRIANGLES, 0, m_VecObject->at(i).Faces.size()*3 );
    00211                                                 ManagerTexture->ResetMultitexture();
    00212                                         //glPopMatrix();
    00213                                 }
    00214                         }
    00215                 }
    00216
    00217         glPopMatrix();
    00218 UnGuard
    00219 }
    00220
    00221 void ExCModel3DS::CallAllList(void)
    00222 {
    00223 Guard(void ExCModel3DS::CallAllList(void))
    00224         for(unsigned int i=0;i<m_VecObject->size();i++)//draw all objects
    00225         {
    00226                 glCallList(m_VecObject->at(i).m_ListId);
    00227         }
    00228 UnGuard
    00229 }
    00230
    00231 void ExCModel3DS::CallAllArray(void)
    00232 {
    00233 Guard(void ExCModel3DS::CallAllArray(void))
    00234         for(unsigned int i=0;i<m_VecObject->size();i++)//draw all objects
    00235         {
    00236                 glDisable(GL_LIGHTING);
    00237                 glColor3f(1.0f,1.0f,1.0f);
    00238                 ManagerTexture->SetTexture(0,m_VecObject->at(i).Material);
    00239                 glTexCoordPointer(2,GL_FLOAT,0,m_VecObject->at(i).TabTextures);
    00240                 glEnableClientState(GL_VERTEX_ARRAY);
    00241                 glVertexPointer(3,GL_FLOAT,0,m_VecObject->at(i).TabVertices);
    00242                 glDrawArrays( GL_TRIANGLES, 0, m_VecObject->at(i).Faces.size()*3 );
    00243                 ManagerTexture->ResetMultitexture();
    00244         }
    00245 UnGuard
    00246 }
    00247
    00248
    00249 void ExCModel3DS::BuildList(int Rendu)
    00250 {
    00251 Guard(void ExCModel3DS::BuildList(int Rendu))
    00252
    00253 //---------------------------------------------------
    00254                 ExCVec3D VecAB,VecBC,VecCA,VecFace;
    00255                 ExCVec3D VecX,VecY,VecZ;
    00256                 ExCVec2D VecTAB,VecTBC,VecTCA;
    00257                 glPushMatrix();
    00258                 //ExCModel::Draw();
    00259                 glDisable(GL_LIGHTING);
    00260                 for(unsigned int i=0;i<m_VecObject->size();i++)//draw all objects
    00261                 {
    00262                         try
    00263                         {
    00264                                 glDeleteLists(m_VecObject->at(i).m_ListId,1);   //delete old list
    00265                                 m_VecObject->at(i).m_ListId=glGenLists(1);      //Ask for a new free list
    00266                                 glNewList(m_VecObject->at(i).m_ListId,GL_COMPILE);
    00267                                 for(unsigned int j=0;j<m_VecObject->at(i).Faces.size();j++)//draw all faces
    00268                                 {
    00269                                         VecFace.SetX(m_VecObject->at(i).Faces.at(j).vertIndex[0]);
    00270                                         VecFace.SetY(m_VecObject->at(i).Faces.at(j).vertIndex[1]);
    00271                                         VecFace.SetZ(m_VecObject->at(i).Faces.at(j).vertIndex[2]);
    00272                                         //----------------
    00273                                         //Texture coord
    00274                                         //----------------
    00275                                         VecTAB.SetX(m_VecObject->at(i).TexVerts.at(VecFace.GetX()).GetX());
    00276                                         VecTAB.SetY(m_VecObject->at(i).TexVerts.at(VecFace.GetX()).GetY());
    00277
    00278                                         VecTBC.SetX(m_VecObject->at(i).TexVerts.at(VecFace.GetY()).GetX());
    00279                                         VecTBC.SetY(m_VecObject->at(i).TexVerts.at(VecFace.GetY()).GetY());
    00280
    00281                                         VecTCA.SetX(m_VecObject->at(i).TexVerts.at(VecFace.GetZ()).GetX());
    00282                                         VecTCA.SetY(m_VecObject->at(i).TexVerts.at(VecFace.GetZ()).GetY());
    00283
    00284                                 /*      std::cout<<"Builded list Texture :"<<j<<":"<<VecTAB<<std::endl;
    00285                                         std::cout<<"Builded list Texture :"<<j<<":"<<VecTBC<<std::endl;
    00286                                         std::cout<<"Builded list Texture :"<<j<<":"<<VecTCA<<std::endl;
    00287
    00288                                         std::cout<<"Build list TExture :"<<j<<" DONE"<<std::endl;*/
    00289
    00290                                         //----------------
    00291                                         //Vertex coord
    00292                                         //----------------
    00293
    00294                                         VecX.SetX(m_VecObject->at(i).Verts.at(VecFace.GetX()).GetX());
    00295                                         VecX.SetY(m_VecObject->at(i).Verts.at(VecFace.GetX()).GetY());
    00296                                         VecX.SetZ(m_VecObject->at(i).Verts.at(VecFace.GetX()).GetZ());
    00297
    00298                                         VecY.SetX(m_VecObject->at(i).Verts.at(VecFace.GetY()).GetX());
    00299                                         VecY.SetY(m_VecObject->at(i).Verts.at(VecFace.GetY()).GetY());
    00300                                         VecY.SetZ(m_VecObject->at(i).Verts.at(VecFace.GetY()).GetZ());
    00301
    00302                                         VecZ.SetX(m_VecObject->at(i).Verts.at(VecFace.GetZ()).GetX());
    00303                                         VecZ.SetY(m_VecObject->at(i).Verts.at(VecFace.GetZ()).GetY());
    00304                                         VecZ.SetZ(m_VecObject->at(i).Verts.at(VecFace.GetZ()).GetZ());
    00305
    00306                                         //std::cout<<"Vec FACE num:"<<j<<" "<<VecFace<<//std::endl;
    00307
    00308
    00309
    00310
    00311                                         ManagerTexture->SetCurrentObject(m_VecObject->at(i).Material);
    00312
    00313                                         glColor3f(1.0f,1.0f,1.0f);
    00314                                         glEnable(GL_TEXTURE_2D);
    00315                                         glBegin(GL_TRIANGLES);
    00316                                                 glTexCoord2f(VecTAB.GetX(),VecTAB.GetY());
    00317                                                 glVertex3fv(VecX.m_Vector);
    00318                                                 glTexCoord2f(VecTBC.GetX(),VecTBC.GetY());
    00319                                                 glVertex3fv(VecY.m_Vector);
    00320                                                 glTexCoord2f(VecTCA.GetX(),VecTCA.GetY());
    00321                                                 glVertex3fv(VecZ.m_Vector);
    00322                                         glEnd();
    00323                                         glDisable(GL_TEXTURE_2D);
    00324
    00325                                 }
    00326                                 glEndList();
    00327                         }catch (...)
    00328                         {
    00329                                 //std::cout<<"error building list"<<//std::endl;
    00330                         }
    00331
    00332                 }
    00333                 glPopMatrix();
    00334 //---------------------------------------------------
    00335
    00336         HasList=true;
    00337         //std::cout<<"building list ok"<<//std::endl;
    00338 UnGuard
    00339 }
    00340
    00341 ExCAction ExCModel3DS::InputAction(ExCAction Action)
    00342 {
    00343         //std::cout<<"MODEL"<<Action;
    00344         switch(Action.m_Action)
    00345         {
    00346         case NEXT_FRAME:
    00347                 NextFrame();
    00348                 break;
    00349         case PREVIOUS_FRAME:
    00350                 break;
    00351         case SET_CURENT_FRAME:
    00352                 break;
    00353         case START_ACTION:
    00354                 StartAction(Action.m_Param);
    00355                 break;
    00356         case STOP_ACTION:
    00357                 StopAction(Action.m_Param);
    00358                 break;
    00359         case TURN_LEFT:
    00360                 StartAction("TURN_LEFT");
    00361                 break;
    00362         case TURN_RIGHT:
    00363                 StartAction("TURN_RIGHT");
    00364         case LOOK_UP:
    00365                 StartAction(Action.m_Param);
    00366                 break;
    00367         case LOOK_DOWN:
    00368                 StartAction(Action.m_Param);
    00369                 break;
    00370         case MODEL_SET_POS_X:
    00371                 std::cout<<"MODEL"<<Action<<atof(Action.m_Param.data());
    00372                 m_Position.SetX(atof(Action.m_Param.data()));
    00373                 break;
    00374         case MODEL_SET_POS_Y:
    00375                 m_Position.SetY(atof(Action.m_Param.data()));
    00376                 break;
    00377         case MODEL_SET_POS_Z:
    00378                 m_Position.SetZ(atof(Action.m_Param.data()));
    00379                 break;
    00380         case MODEL_SET_ANGLE_X:
    00381                 m_Angle.SetX(atof(Action.m_Param.data()));
    00382                 break;
    00383         case MODEL_SET_ANGLE_Y:
    00384                 m_Angle.SetY(atof(Action.m_Param.data()));
    00385                 break;
    00386         case MODEL_SET_ANGLE_Z:
    00387                 m_Angle.SetZ(atof(Action.m_Param.data()));
    00388                 break;
    00389         case MODEL_START_ROTATE_Y_DOWN:
    00390                 StartAction("TURN_RIGHT");
    00391                 break;
    00392         case MODEL_STOP_ROTATE_Y_DOWN:
    00393                 StopAction("TURN_RIGHT");
    00394                 if(!IsAction("RUN")){StartAction("IDLE");}
    00395                 break;
    00396         case MODEL_START_ROTATE_Y_UP:
    00397                 StartAction("TURN_LEFT");
    00398                 break;
    00399         case MODEL_STOP_ROTATE_Y_UP:
    00400                 StopAction("TURN_LEFT");
    00401                 if(!IsAction("RUN")){StartAction("IDLE");}
    00402                 break;
    00403         case MODEL_START_ROTATE_Z_DOWN:
    00404                 StartAction("LOOK_UP");
    00405                 break;
    00406         case MODEL_STOP_ROTATE_Z_DOWN:
    00407                 StopAction("LOOK_UP");
    00408                 break;
    00409         case MODEL_START_ROTATE_Z_UP:
    00410                 StartAction("LOOK_DOWN");
    00411                 break;
    00412         case MODEL_STOP_ROTATE_Z_UP:
    00413                 StopAction("LOOK_DOWN");
    00414                 break;
    00415         case MODEL_START_ROTATE_X_DOWN:
    00416                 StartAction("X_DOWN");
    00417                 break;
    00418         case MODEL_STOP_ROTATE_X_DOWN:
    00419                 StopAction("X_DOWN");
    00420                 break;
    00421         case MODEL_START_ROTATE_X_UP:
    00422                 StartAction("X_UP");
    00423                 break;
    00424         case MODEL_STOP_ROTATE_X_UP:
    00425                 StopAction("X_UP");
    00426                 break;
    00427         case MODEL_START_MOVE_FORWARD:
    00428                 StartAction("RUN");
    00429                 m_Acceleration=m_Acceleration+0.01;
    00430                 break;
    00431         case MODEL_STOP_MOVE_FORWARD:
    00432                 StopAction("RUN");
    00433                 StartAction("IDLE");
    00434                 m_Acceleration.SetValue(0.0f,0.0f,0.0f);
    00435                 break;
    00436         case MODEL_JUMP:
    00437                 StartAction("JUMP");
    00438                 break;
    00439         case MODEL_SET_ACTION:
    00440                 break;
    00441         case MODEL_STOP_ALL:
    00442                 m_VecAction.clear();
    00443                 m_Velocity.SetValue(0.0f,0.0f,0.0f);
    00444                 m_Acceleration.SetValue(0.0f,0.0f,0.0f);
    00445                 break;
    00446         case MODEL_SHOW_COLLISION_SPHERE:
    00447
    00448                 break;
    00449         case MODEL_START_STRAFE_LEFT:
    00450                 StartAction("STRAFE_LEFT");
    00451                 break;
    00452         case MODEL_STOP_STRAFE_LEFT     :
    00453                 StopAction("STRAFE_LEFT");
    00454                 break;
    00455         case MODEL_START_STRAFE_RIGHT:
    00456                 StartAction("STRAFE_RIGHT");
    00457                 break;
    00458         case MODEL_STOP_STREFA_RIGHT:
    00459                 StopAction("STRAFE_RIGHT");
    00460                 break;
    00461         case MODEL_TOGGLE_VISIBLESTATE:
    00462                 SetVisibleState(!GetVisibleState());
    00463                 //std::cout<<m_ObjectName<<" toggle"<<std::endl;
    00464                 break;
    00465         case MODEL_HIDE:
    00466                 SetVisibleState(false);
    00467                 //std::cout<<m_ObjectName<<" hide"<<std::endl;
    00468                 break;
    00469         case MODEL_SHOW:
    00470                 SetVisibleState(true);
    00471                 //std::cout<<m_ObjectName<<" show"<<std::endl;
    00472                 break;
    00473         case MODEL_TOGGLE_ALWAYS_DRAW:
    00474                 m_AlwaysDraw=!m_AlwaysDraw;
    00475                 break;
    00476         case MODEL_ALWAYS_DRAW_ON:
    00477                 m_AlwaysDraw=true;
    00478                 break;
    00479         case MODEL_ALWAYS_DRAW_OFF:
    00480                 m_AlwaysDraw=false;
    00481                 break;
    00482
    00483         }
    00484         return NOTHING;
    00485 }
    00486
    00487 void ExCModel3DS::Process(std::string Action)
    00488 {
    00489         Guard(void ExCModel3DS::Process(std::string Action))
    00490                 if(m_Angle.GetX()<0)m_Angle.SetX(359);
    00491         if(m_Angle.GetX()>359)m_Angle.SetX(0);
    00492         if(m_Angle.GetY()<0)m_Angle.SetY(359);
    00493         if(m_Angle.GetY()>359)m_Angle.SetY(0);
    00494         if(m_Angle.GetZ()<0)m_Angle.SetZ(359);
    00495         if(m_Angle.GetZ()>359)m_Angle.SetZ(0);
    00496         //process action
    00497         if(Action=="RUN")
    00498         {
    00499                 //m_Position=m_Target;
    00500                 //return;
    00501                 //m_Velocity.SetX(0.01f);
    00502         }
    00503         if(Action=="STRAFE_LEFT")
    00504         {
    00505                 float angle;
    00506                 angle=m_Angle.GetY()+90;
    00507                 if(angle>360)angle=angle-360;
    00508                 m_Position=m_Position+ExCVec3D(Cos[(int)angle],0.0f,Sin[(int)angle]);
    00509                 return;
    00510         }
    00511         if(Action=="STRAFE_RIGHT")
    00512         {
    00513                 float angle;
    00514                 angle=m_Angle.GetY()+90;
    00515                 if(angle>360)angle=angle-360;
    00516                 m_Position=m_Position-ExCVec3D(Cos[(int)angle],0.0f,Sin[(int)angle]);
    00517                 return;
    00518         }
    00519
    00520         if(Action=="TURN_LEFT"){m_Angle.DecY(2);return;}
    00521         if(Action=="TURN_RIGHT"){m_Angle.IncY(2);return;}
    00522         if(Action=="LOOK_UP"){m_Angle.IncZ(2);return;}
    00523         if(Action=="LOOK_DOWN"){m_Angle.DecZ(2);return;}
    00524         if(Action=="X_UP"){m_Angle.IncX(2);return;}
    00525         if(Action=="X_DOWN"){m_Angle.DecX(2);return;}
    00526         if(Action=="JUMP")
    00527         {
    00528                 if(m_CurrentFrames=72)
    00529                 {
    00530                         StopAction("JUMP");
    00531                         if(!IsAction("RUN")){StartAction("IDLE");}
    00532                 }
    00533         }
    00534         UnGuard
    00535 }
    00536 void ExCModel3DS::ProcessAllAction(void)
    00537 {
    00538         Guard(void ExCModel3DS::ProcessAllAction(void))
    00539                 for(unsigned int i=0;i< m_VecAction.size();i++)
    00540                 {
    00541                         Process(m_VecAction.at(i));
    00542                 }
    00543                 UnGuard
    00544 }
    00545
    00546 void ExCModel3DS::StopAction(std::string         Action)
    00547 {
    00548         Guard(void ExCModel3DS::StopAction(std::string   Action))
    00549                 for(m_IVecAction= m_VecAction.begin();m_IVecAction!= m_VecAction.end();m_IVecAction++)
    00550                 {
    00551                         if(strcmp(m_IVecAction->data(),Action.data())==0)
    00552                         {
    00553                                 m_VecAction.erase(m_IVecAction);
    00554                                 return;
    00555                         }
    00556                 }
    00557                 UnGuard
    00558 }
    00559
    00560 bool ExCModel3DS::IsAction(std::string Action)
    00561 {
    00562         Guard(bool ExCModel3DS::IsAction(std::string Action))
    00563                 for(m_IVecAction= m_VecAction.begin();m_IVecAction!= m_VecAction.end();m_IVecAction++)
    00564                 {
    00565                         if(strcmp(m_IVecAction->data(),Action.data())==0)
    00566                         {
    00567                                 return true;
    00568                         }
    00569                 }
    00570                 return false;
    00571                 UnGuard
    00572 }
    00573 void ExCModel3DS::StartAction(std::string        Action)
    00574 {
    00575         Guard(void ExCModel3DS::StartAction(std::string  Action))
    00576                 m_VecAction.push_back(Action);
    00577         m_CurrentAction=Action;
    00578         UnGuard
    00579 }
    00580
    00581
    00582 bool ExCModel3DS::Load(std::string FileName)
    00583 {
    00584 Guard(bool ExCModel3DS::Load(std::string FileName))
    00585
    00586         m_VecObject= new std::vector<t3DObject> ;
    00587         numOfObjects=0;
    00588         numOfMaterials=0;
    00589         m_VecMaterials.clear();
    00590         m_VecObject->clear();
    00591         HasList=false;
    00592         unsigned int version=0;
    00593         int buffer[50000] = {0};
    00594         char bufferc[255];memset(bufferc,0,255);
    00595
    00596
    00597         m_filePtr = fopen(FileName.data(), "rb");
    00598     if (m_filePtr == NULL)
    00599         {
    00600                 throw ExCExpFileNotFound();
    00601                 return false;
    00602         }
    00603         tChunk *chunk;
    00604         chunk = new tChunk;
    00605         ReadChunk(chunk);
    00606         //------------------------------------------------------------------------------
    00607         if(chunk->ID==PRIMARY)
    00608         {
    00609                 //std::cout<<"Primary chunk file lenght:"<<chunk->length<<//std::endl;
    00610                 m_CurrentChunk = new tChunk;
    00611                 while (chunk->bytesRead < chunk->length)
    00612                 {
    00613                         ReadChunk(m_CurrentChunk);
    00614                         switch(m_CurrentChunk->ID)
    00615                         {
    00616                         case FILEVERSION:
    00617                                 m_CurrentChunk->bytesRead += fread(&version, 1,m_CurrentChunk->length - m_CurrentChunk->bytesRead, m_filePtr);
    00618                                 //std::cout<<"Read FILEVERSION :"<<version<<//std::endl;
    00619                                 break;
    00620                         case OBJECTINFO:
    00621                                 //std::cout<<"Read OBJECTINFO"<<//std::endl;
    00622                                 ReadObjectInfo(m_CurrentChunk);
    00623                                 break;
    00624                         case EDITKEYFRAME:
    00625                                 //std::cout<<"Read EDITKEYFRAME"<<//std::endl;
    00626                                 Skip(m_CurrentChunk);
    00627                                 break;
    00628                         default:
    00629                                 //std::cout<<"Skip unused ,Chunk ID:"<<//std::hex<<m_CurrentChunk->ID<<" Chunk Lenght:"<<//std::dec<<m_CurrentChunk->length<<//std::endl;
    00630                                 Skip(m_CurrentChunk);
    00631                                 break;
    00632                         }
    00633                         chunk->bytesRead += m_CurrentChunk->bytesRead;
    00634                 }
    00635                 delete m_CurrentChunk;
    00636                 m_CurrentChunk = chunk;
    00637         }//end of if(chunk->ID==PRIMARY)
    00638         //------------------------------------------------------------------------------
    00639         fclose(m_filePtr);
    00640         //BuildArray(0);
    00641         return true;
    00642 UnGuard
    00643 }
    00644
    00645 void ExCModel3DS::ReadObjectInfo(tChunk *chunk)
    00646 {
    00647 Guard(void ExCModel3DS::ReadObjectInfo(tChunk *chunk))
    00648                 int buffer[50000] = {0};
    00649                 char bufferc[255],b;
    00650                 std::string BuffObject;
    00651                 m_CurrentChunk = new tChunk;
    00652                 while (chunk->bytesRead < chunk->length)
    00653                 {
    00654                         ReadChunk(m_CurrentChunk);
    00655                         switch(m_CurrentChunk->ID)
    00656                         {
    00657                         case MATERIAL:
    00658                                 //std::cout<<"  Read MATERIAL"<<//std::endl;
    00659                                 ReadObjectMaterial(m_CurrentChunk);
    00660                                 break;
    00661                         case OBJECT:
    00662                                 memset(bufferc,0,255);
    00663                                 //m_CurrentChunk->bytesRead += 8;
    00664                                 //m_CurrentChunk->bytesRead += fread(&bufferc, 1,8, m_filePtr);
    00666                                 BuffObject.erase(BuffObject.begin(),BuffObject.end());
    00667                                 do
    00668                                 {
    00669                                         m_CurrentChunk->bytesRead += fread(&b, 1, sizeof(char), m_filePtr);
    00670                                         if(b!=0)BuffObject=BuffObject+b;
    00671                                 }while(b!=0);
    00672                                 //std::cout<<"  Read OBJECT :"<<BuffObject<<//std::endl;
    00673                                 ReadObject(m_CurrentChunk);
    00674                                 break;
    00675                         case MESH_VERSION:
    00676                                 //std::cout<<"  Read MESH_VERSION"<<//std::endl;
    00677                                 Skip(m_CurrentChunk);
    00678                                 break;
    00679                         case MASTER_SCALE:
    00680                                 //std::cout<<"  Read MASTER_SCALE"<<//std::endl;
    00681                                 Skip(m_CurrentChunk);
    00682                                 break;
    00683                         default:
    00684                                 //std::cout<<"  Skip unused ,Chunk ID:"<<//std::hex<<m_CurrentChunk->ID<<" Chunk Lenght:"<<//std::dec<<m_CurrentChunk->length<<//std::endl;
    00685                                 Skip(m_CurrentChunk);
    00686                                 break;
    00687                         }
    00688                         chunk->bytesRead += m_CurrentChunk->bytesRead;
    00689                 }
    00690                 delete m_CurrentChunk;
    00691                 m_CurrentChunk = chunk;
    00692 UnGuard
    00693 }
    00694 void ExCModel3DS::ReadObject(tChunk *chunk)
    00695 {
    00696 Guard(void ExCModel3DS::ReadObject(tChunk *chunk))
    00697         int buffer[50000] = {0};
    00698         t3DObject *pObject;
    00699         pObject = new t3DObject;
    00700         m_CurrentChunk = new tChunk;
    00701         while (chunk->bytesRead < chunk->length)
    00702         {
    00703                 ReadChunk(m_CurrentChunk);
    00704                 switch(m_CurrentChunk->ID)
    00705                 {
    00706                 case OBJECT_MESH:
    00707                         //std::cout<<"          Read object OBJECT_MESH"<<//std::endl;
    00708                         ReadObject(m_CurrentChunk);
    00709                         break;
    00710                 case OBJECT_VERTICES:
    00711                         //std::cout<<"                  Read object OBJECT_VERTICES"<<//std::endl;
    00712                         //Skip(m_CurrentChunk);
    00713                         ReadVertices(pObject,m_CurrentChunk);
    00714                         break;
    00715         case OBJECT_FACES:
    00716                         //std::cout<<"                  Read object OBJECT_FACES"<<//std::endl;
    00717                         ReadFace(pObject,m_CurrentChunk);
    00718                         break;
    00719         case OBJECT_MATERIAL:
    00720
    00721                         //std::cout<<"                  Read object OBJECT_MATERIAL"<<//std::endl;
    00722                         ReadObjectMaterial(pObject,m_CurrentChunk);
    00723                         break;
    00724         case OBJECT_UV:
    00725                         //std::cout<<"                  Read object OBJECT_UV"<<//std::endl;
    00726                         ReadUVCoordinates(pObject,m_CurrentChunk);
    00727                         break;
    00728                 case OBJECT_MESH_MATRIX:
    00729                         //std::cout<<"                  Read object OBJECT_MESH_MATRIX"<<//std::endl;
    00730                         Skip(m_CurrentChunk);
    00731                         break;
    00732                 default:
    00733                         //std::cout<<"                  Skip unused ,Chunk ID:"<<//std::hex<<m_CurrentChunk->ID<<" Chunk Lenght:"<<//std::dec<<m_CurrentChunk->length<<//std::endl;
    00734                         Skip(m_CurrentChunk);
    00735                         break;
    00736                 }
    00737                 chunk->bytesRead += m_CurrentChunk->bytesRead;
    00738         }
    00739
    00740         m_VecObject->push_back(*pObject);
    00741         delete m_CurrentChunk;
    00742         m_CurrentChunk = chunk;
    00743 UnGuard
    00744 }
    00745
    00746 void ExCModel3DS::ReadObjectMaterial(tChunk *chunk)
    00747 {
    00748 Guard(void ExCModel3DS::ReadObjectMaterial(tChunk *chunk))
    00749                 int buffer[50000] = {0};
    00750                 char bufferc[255];
    00751                 m_CurrentChunk = new tChunk;
    00752                 while (chunk->bytesRead < chunk->length)
    00753                 {
    00754                         ReadChunk(m_CurrentChunk);
    00755                         switch(m_CurrentChunk->ID)
    00756                         {
    00757                         case MATNAME:
    00758                                 memset(bufferc,0,255);
    00759                                 m_CurrentChunk->bytesRead += fread(bufferc, 1, m_CurrentChunk->length - m_CurrentChunk->bytesRead, m_filePtr);
    00760                                 //std::cout<<"          Read MATNAME:"<<bufferc<<//std::endl;
    00761                                 break;
    00762                         case MATAMBIENTCOLOR:
    00763                                 //std::cout<<"          Read MATAMBIENTCOLOR"<<//std::endl;
    00764                                 Skip(m_CurrentChunk);
    00765                                 break;
    00766                         case MATDIFFUSE:
    00767                                 //std::cout<<"          Read MATDIFFUSE"<<//std::endl;
    00768                                 Skip(m_CurrentChunk);
    00769                                 break;
    00770                         case MATSPECULAR:
    00771                                 //std::cout<<"          Read MATSPECULAR"<<//std::endl;
    00772                                 Skip(m_CurrentChunk);
    00773                                 break;
    00774                         case MATSHININESS:
    00775                                 //std::cout<<"          Read MATSHININESS"<<//std::endl;
    00776                                 Skip(m_CurrentChunk);
    00777                                 break;
    00778                         case MATSHININESSSTR:
    00779                                 //std::cout<<"          Read MATSHININESSSTR"<<//std::endl;
    00780                                 Skip(m_CurrentChunk);
    00781                                 break;
    00782                         case MATTRANSPARENCY:
    00783                                 //std::cout<<"          Read MATTRANSPARENCY"<<//std::endl;
    00784                                 Skip(m_CurrentChunk);
    00785                                 break;
    00786                         case MATTRANSFALLOFF:
    00787                                 //std::cout<<"          Read MATTRANSFALLOFF"<<//std::endl;
    00788                                 Skip(m_CurrentChunk);
    00789                                 break;
    00790                         case MATREFLECTBLUR:
    00791                                 //std::cout<<"          Read MATREFLECTBLUR"<<//std::endl;
    00792                                 Skip(m_CurrentChunk);
    00793                                 break;
    00794                         case MATTWOSIDED:
    00795                                 //std::cout<<"          Read MATTWOSIDED"<<//std::endl;
    00796                                 Skip(m_CurrentChunk);
    00797                                 break;
    00798                         case MATTRANSPARENCYADD:
    00799                                 //std::cout<<"          Read MATTRANSPARENCYADD"<<//std::endl;
    00800                                 Skip(m_CurrentChunk);
    00801                                 break;
    00802                         case MATSELFILUM:
    00803                                 //std::cout<<"          Read MATSELFILUM"<<//std::endl;
    00804                                 Skip(m_CurrentChunk);
    00805                                 break;
    00806                         case MATWIREON:
    00807                                 //std::cout<<"          Read MATWIREON"<<//std::endl;
    00808                                 Skip(m_CurrentChunk);
    00809                                 break;
    00810                         case MATWIRETHICKNESS:
    00811                                 //std::cout<<"          Read MATWIRETHICKNESS"<<//std::endl;
    00812                                 Skip(m_CurrentChunk);
    00813                                 break;
    00814                         case MATFACEMAP:
    00815                                 //std::cout<<"          Read MATFACEMAP"<<//std::endl;
    00816                                 Skip(m_CurrentChunk);
    00817                                 break;
    00818                         case MATTRANSFALLOFFIN:
    00819                                 //std::cout<<"          Read MATTRANSFALLOFFIN"<<//std::endl;
    00820                                 Skip(m_CurrentChunk);
    00821                                 break;
    00822                         case MATSOFTEN:
    00823                                 //std::cout<<"          Read MATSOFTEN"<<//std::endl;
    00824                                 Skip(m_CurrentChunk);
    00825                                 break;
    00826                         case MAT3DWIRETHICKNESS:
    00827                                 //std::cout<<"          Read MAT3DWIRETHICKNESS"<<//std::endl;
    00828                                 Skip(m_CurrentChunk);
    00829                                 break;
    00830                         case MATTYPE:                                                   // This is the header for the texture info
    00831                                 //std::cout<<"          Read MATTYPE"<<//std::endl;
    00832                                 Skip(m_CurrentChunk);
    00833                                 break;
    00834                         case MATMAP:                                                    // This is the header for the texture info
    00835                                 //std::cout<<"          Read MATMAP"<<//std::endl;
    00836                                 ReadObjectMaterial(m_CurrentChunk);
    00837                                 break;
    00838                         case MATMAPFILE:
    00839                                 //std::cout<<"          Read MATMAPFILE"<<//std::endl;
    00840                                 Skip(m_CurrentChunk);
    00841                                 break;
    00842                         case MATMAPOPTION:
    00843                                 //std::cout<<"          Read MATMAPOPTION"<<//std::endl;
    00844                                 Skip(m_CurrentChunk);
    00845                                 break;
    00846                         case MATMAPFILTERINGBLUR:
    00847                                 //std::cout<<"          Read MATMAPFILTERINGBLUR"<<//std::endl;
    00848                                 //Skip(m_CurrentChunk);
    00849                                 Skip(m_CurrentChunk);
    00850                                 break;
    00851                         default:
    00852                                 //std::cout<<"          Skip unused ,Chunk ID:"<<//std::hex<<m_CurrentChunk->ID<<" Chunk Lenght:"<<//std::dec<<m_CurrentChunk->length<<//std::endl;
    00853                                 Skip(m_CurrentChunk);
    00854                                 break;
    00855                         }
    00856                         chunk->bytesRead += m_CurrentChunk->bytesRead;
    00857                 }
    00858                 delete m_CurrentChunk;
    00859                 m_CurrentChunk = chunk;
    00860 UnGuard
    00861 }
    00862
    00863
    00864
    00865 void ExCModel3DS::ReadChunk(tChunk *chunk)
    00866 {
    00867 Guard(void ExCModel3DS::tChunk ReadChunk(tChunk *chunk))
    00869         chunk->bytesRead = fread(&chunk->ID, 1, 2, m_filePtr);
    00870         chunk->bytesRead += fread(&chunk->length, 1, 4, m_filePtr);
    00874 UnGuard
    00875 }
    00876
    00877 void ExCModel3DS::Skip(tChunk *chunk)
    00878 {
    00879 Guard(void ExCModel3DS::tChunk Skip(tChunk *chunk))
    00880         int buffer[50000] = {0};
    00882         chunk->bytesRead += fread(buffer, 1, chunk->length - chunk->bytesRead, m_filePtr);
    00883 UnGuard
    00884 }
    00885
    00886 void ExCModel3DS::ReadVertices(t3DObject *pObject,tChunk *chunk)
    00887 {
    00888 Guard(void ExCModel3DS::ReadVertices(t3DObject *pObject,tChunk *chunk))
    00889         int buffer[50000] = {0};
    00890         // Read in the number of vertices (int)
    00891         unsigned short vert;
    00892         chunk->bytesRead += fread(&vert, 1,sizeof(unsigned short), m_filePtr);
    00893         pObject->numOfVerts=vert;
    00895         float fl;
    00896         ExCVec3D vec;
    00897         for(int i=0;i<vert;i++)
    00898         {
    00899                 chunk->bytesRead += fread(&fl, 1,sizeof(float), m_filePtr);
    00900                 vec.SetX(fl);
    00901                 chunk->bytesRead += fread(&fl, 1,sizeof(float), m_filePtr);
    00902                 vec.SetY(fl);
    00903                 chunk->bytesRead += fread(&fl, 1,sizeof(float), m_filePtr);
    00904                 vec.SetZ(fl);
    00906                 pObject->Verts.push_back(vec);
    00907         }
    00908         Skip(chunk);
    00909 UnGuard
    00910 }
    00911
    00912 void ExCModel3DS::ReadFace(t3DObject *pObject,tChunk *chunk)
    00913 {
    00914 Guard(void ExCModel3DS::ReadFace(t3DObject *pObject,tChunk *chunk))
    00915         int buffer[50000] = {0};
    00916         // Read in the number of vertices (int)
    00917         tFace stFace;
    00918         unsigned short face,index;
    00919         chunk->bytesRead += fread(&face, 1,sizeof(unsigned short), m_filePtr);
    00920         pObject->numOfFaces=face;
    00922
    00923         // Go through all of the faces in this object
    00924         for(int i = 0; i <face; i++)
    00925         {
    00926                 // Next, we read in the A then B then C index for the face, but ignore the 4th value.
    00927                 // The fourth value is a visibility flag for 3D Studio Max, we don't care about this.
    00928                 for(int j = 0; j < 4; j++)
    00929                 {
    00930                         // Read the first vertice index for the current face
    00931                         chunk->bytesRead += fread(&index, 1, sizeof(unsigned short), m_filePtr);
    00932
    00933                         if(j < 3)
    00934                         {
    00935                                 // Store the index in our face structure.
    00936                                 //pObject->pFaces[i].vertIndex[j] = index;
    00937                                 stFace.vertIndex[j]=index;
    00938                         }
    00939                 }
    00941                 pObject->Faces.push_back(stFace);
    00942         }
    00943         char b=0;
    00944         std::string Material;
    00945         m_CurrentChunk = new tChunk;
    00946         while (chunk->bytesRead < chunk->length)
    00947         {
    00948                 ReadChunk(m_CurrentChunk);
    00949                 switch(m_CurrentChunk->ID)
    00950                 {
    00951                 case OBJECT_MATERIAL:
    00952                         //std::cout<<"                          Read object face OBJECT_MATERIAL"<<//std::endl;
    00953                         do
    00954                         {
    00955                                 m_CurrentChunk->bytesRead += fread(&b, 1, sizeof(char), m_filePtr);
    00956                                 if(b!=0)Material=Material+b;
    00957                         }while(b!=0);
    00959                         pObject->Material=Material;
    00960                         //std::cout<<"#"<<Material<<"#"<<//std::endl;
    00961                         ManagerTexture->Load(Material);
    00962                         Skip(m_CurrentChunk);
    00963                         break;
    00964                 case OBJECT_SMOOTH_GROUP:
    00965                         //std::cout<<"                          Read object face OBJECT_SMOOTH_GROUP"<<//std::endl;
    00966                         Skip(m_CurrentChunk);
    00967                         break;
    00968         default:
    00969                         //std::cout<<"                          Skip unused ,Chunk ID:"<<//std::hex<<m_CurrentChunk->ID<<" Chunk Lenght:"<<//std::dec<<m_CurrentChunk->length<<//std::endl;
    00970                         Skip(m_CurrentChunk);
    00971                         break;
    00972                 }
    00973                 chunk->bytesRead += m_CurrentChunk->bytesRead;
    00974         }
    00975         delete m_CurrentChunk;
    00976         m_CurrentChunk = chunk;
    00977
    00978
    00979
    00980 UnGuard
    00981 }
    00982
    00983 void ExCModel3DS::ReadUVCoordinates(t3DObject *pObject,tChunk *chunk)
    00984 {
    00985 Guard(void ExCModel3DS::ReadUVCoordinates(t3DObject *pObject,tChunk *chunk))
    00986         int buffer[50000] = {0};
    00987         // Read in the number of vertices (int)
    00988         unsigned short vert;
    00989         chunk->bytesRead += fread(&vert, 1,sizeof(unsigned short), m_filePtr);
    00990         pObject->numTexVertex=vert;
    00992         float fl;
    00993         ExCVec2D vec;
    00994         for(int i=0;i<vert;i++)
    00995         {
    00996                 chunk->bytesRead += fread(&fl, 1,sizeof(float), m_filePtr);
    00997                 vec.SetX(fl);
    00998                 chunk->bytesRead += fread(&fl, 1,sizeof(float), m_filePtr);
    00999                 vec.SetY(fl);
    01001                 pObject->TexVerts.push_back(vec);
    01002         }
    01003         Skip(chunk);
    01004 UnGuard
    01005 }
    01006
    01007 void ExCModel3DS::ReadObjectMaterial(t3DObject *pObject,tChunk *chunk)
    01008 {
    01009 Guard(void ExCModel3DS::ReadObjectMaterial(tChunk *chunk))
    01010         char b=0;
    01011         std::string Material;
    01012         do
    01013         {
    01014                 chunk->bytesRead += fread(&b, 1, sizeof(char), m_filePtr);
    01015                 Material=Material+b;
    01016         }while(b!=0);
    01017         //std::cout<<Material<<//std::endl;
    01018         Skip(chunk);
    01019 UnGuard
    01020 }