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

# ExCModelMD2.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: ExCModelMD2.cpp,v 1.10 2002/11/24 11:59:01 data Exp $
    00021  *
    00022  */
    00023
    00024 #include "ExCModelMD2.h"
    00025 //---------------------------------------------------------------
    00026 ExCModelMD2::ExCModelMD2(void)
    00027 {
    00028 Guard(ExCModelMD2::ExCModelMD2(void))
    00029         m_CurrentFrames=2;
    00030         m_NextFrame=3;
    00031         m_InterpolationPourcentage=0.1f;
    00032         m_Interpolation=m_InterpolationPourcentage;
    00033         m_Transition=false;
    00034         m_Target.SetX(0.1f);
    00035         StartAction("IDLE");
    00036         m_speed=1;
    00037 UnGuard
    00038 }
    00039 /*
    00040 ExCModelMD2::ExCModelMD2(const ExCModelMD2& copy)
    00041 {
    00042 Guard(ExCModelMD2::ExCModelMD2(const ExCModelMD2& copy))
    00043         m_CurrentFrames=copy.m_CurrentFrames;
    00044         m_NextFrame=copy.m_NextFrame;
    00045         m_InterpolationPourcentage=copy.m_InterpolationPourcentage;
    00046         m_Interpolation=copy.m_Interpolation;
    00047         m_Transition=copy.m_Transition;
    00048         m_speed=copy.m_speed;
    00049
    00050         m_VecSkin=copy.m_VecSkin;
    00051         m_VecTexture=copy.m_VecTexture;
    00052         m_VecTriangle=copy.m_VecTriangle;
    00053         m_VecVertex=copy.m_VecVertex;
    00054 UnGuard
    00055 }*/
    00056
    00057 ExCModelMD2::~ExCModelMD2(void)
    00058 {
    00059 Guard(ExCModelMD2::~ExCModelMD2(void))
    00060 UnGuard
    00061 }
    00062
    00063 void ExCModelMD2::StartRun(void)
    00064 {
    00065 Guard(void ExCModelMD2::StartRun(void))
    00066         //m_CurrentFrames=40;
    00067         m_Transition=true;
    00068 UnGuard
    00069 }
    00070
    00071 void ExCModelMD2::StopRun(void)
    00072 {
    00073 Guard(void ExCModelMD2::StopRun(void))
    00074         m_CurrentFrames=1;
    00075         m_Transition=false;
    00076 UnGuard
    00077 }
    00078
    00079 void ExCModelMD2::Process(std::string Action)
    00080 {
    00081 Guard(void ExCModelMD2::Process(std::string Action))
    00082         //function must be repeat each time a frame of action is called
    00083         //std::cout<<"MD2 Process :"<<m_CurrentAction<<std::endl;
    00084         if(m_CurrentAction=="RUN")
    00085         {
    00086                 //m_Position=m_Position+((m_Target-m_Position)*m_speed);
    00087                 m_Position=m_Target*m_speed;
    00088         }
    00089         if(m_CurrentAction=="TURN_LEFT")
    00090         {
    00091                 m_AngleZ++;
    00092         }
    00093         if(m_CurrentAction=="TURN_RIGHT")
    00094         {
    00095                 m_AngleZ--;
    00096         }
    00097         if(m_CurrentAction=="LOOK_UP")
    00098         {
    00099                 m_AngleY++;
    00100         }
    00101         if(m_CurrentAction=="LOOK_DOWN")
    00102         {
    00103                 m_AngleY--;
    00104         }
    00105 UnGuard
    00106 }
    00107
    00108 void ExCModelMD2::StartAction(std::string        Action)
    00109 {
    00110 Guard(void ExCModelMD2::SStartAction(std::string         Action))
    00111         m_CurrentAction=Action;
    00112         if(m_CurrentAction=="RUN")
    00113         {
    00114                 m_KeyFrameStartAction=41;
    00115                 m_KeyFrameStopAction=46;
    00116         }
    00117         if(m_CurrentAction=="ATTACK")
    00118         {
    00119                 m_KeyFrameStartAction=47;
    00120                 m_KeyFrameStopAction=60;
    00121         }
    00122         if(m_CurrentAction=="CROUCH")
    00123         {
    00124                 m_KeyFrameStartAction=136;
    00125                 m_KeyFrameStopAction=154;
    00126         }
    00127         if(m_CurrentAction=="JUMP")
    00128         {
    00129                 m_KeyFrameStartAction=67;
    00130                 m_KeyFrameStopAction=72;
    00131         }
    00132         if(m_CurrentAction=="IDLE")
    00133         {
    00134                 m_KeyFrameStartAction=1;
    00135                 m_KeyFrameStopAction=39;
    00136         }
    00137         if(m_CurrentAction=="TEST")
    00138         {
    00139                 m_KeyFrameStartAction=113;
    00140                 m_KeyFrameStopAction=125;
    00141
    00142         }
    00143         if(m_CurrentAction=="TURN_LEFT")
    00144         {
    00145                 m_KeyFrameStartAction=1;
    00146                 m_KeyFrameStopAction=39;
    00147     }
    00148         if(m_CurrentAction=="TURN_RIGHT")
    00149         {
    00150                 m_KeyFrameStartAction=1;
    00151                 m_KeyFrameStopAction=39;
    00152         }
    00153         if(m_CurrentAction=="LOOK_UP")
    00154         {
    00155                 m_KeyFrameStartAction=1;
    00156                 m_KeyFrameStopAction=39;
    00157     }
    00158         if(m_CurrentAction=="LOOK_DOWN")
    00159         {
    00160                 m_KeyFrameStartAction=1;
    00161                 m_KeyFrameStopAction=39;
    00162         }
    00163         if(m_CurrentAction=="FULL")
    00164         {
    00165                 m_KeyFrameStartAction=1;
    00166                 m_KeyFrameStopAction=198;
    00167         }
    00168         m_Transition=true;
    00169         m_CurrentFrames=m_KeyFrameStartAction;
    00170 UnGuard
    00171 }
    00172
    00173 void ExCModelMD2::StopAction(void)
    00174 {
    00175 Guard(void ExCModelMD2::StopAction(void))
    00176         m_CurrentFrames=1;
    00177         m_Transition=false;
    00178 UnGuard
    00179 }
    00180
    00181 void ExCModelMD2::Draw(void)
    00182 {
    00183         Guard(void ExCModelMD2::Draw(void))
    00184                 ExCVec3D VecAB,VecBC,VecCA;
    00185         ExCVec2D VecTAB,VecTBC,VecTCA;
    00186         int FrameToDraw,FrameToInterpol;
    00187
    00188         glPushMatrix();
    00189         ExCModel::Draw();
    00190         glPushMatrix();
    00191         glEnable(GL_TEXTURE_2D);
    00192         glDisable(GL_LIGHTING);
    00193
    00194         if(m_Transition)
    00195         {
    00196                 m_Interpolation+=m_InterpolationPourcentage;
    00197                 if(m_Interpolation>1)//chexk if we go to next frame
    00198                 {
    00199                         m_Interpolation=m_InterpolationPourcentage;
    00200                         m_CurrentFrames++;
    00201                         m_NextFrame=m_CurrentFrames+1;
    00202                         if(m_NextFrame>m_KeyFrameStopAction)m_NextFrame=m_KeyFrameStartAction;
    00203                         if(m_CurrentFrames>m_KeyFrameStopAction)
    00204                         {
    00205                                 m_CurrentFrames=m_KeyFrameStartAction;
    00206                                 m_NextFrame=m_CurrentFrames+1;
    00207                         }
    00208                 }
    00209         }
    00210         FrameToDraw=m_numVertices*m_CurrentFrames;
    00211         FrameToInterpol=m_numVertices*m_NextFrame;
    00212         Process(m_CurrentAction);
    00213         ManagerTexture->SetCurrentObject(m_Skin);
    00214
    00215         glBegin(GL_TRIANGLES);
    00216         for(int i = 0; i < m_numTriangles; i++)
    00217         {
    00218                 //----------------
    00219                 //Texture coord
    00220                 //----------------
    00221                 VecTAB.SetX(m_VecTexture.at(m_VecTriangle.at(i).second.GetX()).GetX());
    00222                 VecTAB.SetY(m_VecTexture.at(m_VecTriangle.at(i).second.GetX()).GetY());
    00223
    00224                 VecTBC.SetX(m_VecTexture.at(m_VecTriangle.at(i).second.GetY()).GetX());
    00225                 VecTBC.SetY(m_VecTexture.at(m_VecTriangle.at(i).second.GetY()).GetY());
    00226
    00227                 VecTCA.SetX(m_VecTexture.at(m_VecTriangle.at(i).second.GetZ()).GetX());
    00228                 VecTCA.SetY(m_VecTexture.at(m_VecTriangle.at(i).second.GetZ()).GetY());
    00229                 //----------------
    00230                 //Vertex coord
    00231                 //----------------
    00232                 VecAB.SetX(m_VecVertex.at(m_VecTriangle.at(i).first.GetX()+FrameToDraw).GetX());
    00233                 VecAB.SetY(m_VecVertex.at(m_VecTriangle.at(i).first.GetX()+FrameToDraw).GetY());
    00234                 VecAB.SetZ(m_VecVertex.at(m_VecTriangle.at(i).first.GetX()+FrameToDraw).GetZ());
    00235
    00236                 VecBC.SetX(m_VecVertex.at(m_VecTriangle.at(i).first.GetY()+FrameToDraw).GetX());
    00237                 VecBC.SetY(m_VecVertex.at(m_VecTriangle.at(i).first.GetY()+FrameToDraw).GetY());
    00238                 VecBC.SetZ(m_VecVertex.at(m_VecTriangle.at(i).first.GetY()+FrameToDraw).GetZ());
    00239
    00240                 VecCA.SetX(m_VecVertex.at(m_VecTriangle.at(i).first.GetZ()+FrameToDraw).GetX());
    00241                 VecCA.SetY(m_VecVertex.at(m_VecTriangle.at(i).first.GetZ()+FrameToDraw).GetY());
    00242                 VecCA.SetZ(m_VecVertex.at(m_VecTriangle.at(i).first.GetZ()+FrameToDraw).GetZ());
    00243
    00244                 //--------------
    00245                 //interpolation
    00246                 //--------------
    00247                 if(m_Transition)
    00248                 {
    00249                         ExCVec3D VecABN,VecBCN,VecCAN;
    00250
    00251                         VecABN.SetX(m_VecVertex.at(m_VecTriangle.at(i).first.GetX()+FrameToInterpol).GetX());
    00252                         VecABN.SetY(m_VecVertex.at(m_VecTriangle.at(i).first.GetX()+FrameToInterpol).GetY());
    00253                         VecABN.SetZ(m_VecVertex.at(m_VecTriangle.at(i).first.GetX()+FrameToInterpol).GetZ());
    00254
    00255                         VecBCN.SetX(m_VecVertex.at(m_VecTriangle.at(i).first.GetY()+FrameToInterpol).GetX());
    00256                         VecBCN.SetY(m_VecVertex.at(m_VecTriangle.at(i).first.GetY()+FrameToInterpol).GetY());
    00257                         VecBCN.SetZ(m_VecVertex.at(m_VecTriangle.at(i).first.GetY()+FrameToInterpol).GetZ());
    00258
    00259                         VecCAN.SetX(m_VecVertex.at(m_VecTriangle.at(i).first.GetZ()+FrameToInterpol).GetX());
    00260                         VecCAN.SetY(m_VecVertex.at(m_VecTriangle.at(i).first.GetZ()+FrameToInterpol).GetY());
    00261                         VecCAN.SetZ(m_VecVertex.at(m_VecTriangle.at(i).first.GetZ()+FrameToInterpol).GetZ());
    00262
    00263                         VecAB=VecAB+((VecABN-VecAB)*m_Interpolation);
    00264                         VecBC=VecBC+((VecBCN-VecBC)*m_Interpolation);
    00265                         VecCA=VecCA+((VecCAN-VecCA)*m_Interpolation);
    00266                 }
    00267                 //--------------
    00268                 //Draw
    00269                 //--------------
    00270                 glColor3f(1,1,1);
    00271                 glTexCoord2f(VecTBC.GetX(),VecTBC.GetY());
    00272                 glVertex3f(VecBC.GetX(),VecBC.GetY(),VecBC.GetZ());
    00273
    00274                 glTexCoord2f(VecTAB.GetX(),VecTAB.GetY());
    00275                 glVertex3f(VecAB.GetX(),VecAB.GetY(),VecAB.GetZ());
    00276
    00277                 glTexCoord2f(VecTCA.GetX(),VecTCA.GetY());
    00278                 glVertex3f(VecCA.GetX(),VecCA.GetY(),VecCA.GetZ());
    00279         }
    00280         glEnd();
    00281         glDisable(GL_TEXTURE_2D);
    00282         glPopMatrix();
    00283         glPopMatrix();
    00284         UnGuard
    00285 }
    00286
    00287 void ExCModelMD2::DrawFrameFromFile(int NumFrame,int interpolation)
    00288 {
    00289 Guard(void ExCModelMD2::DrawFrameFromFile(int NumFrame,int interpolation))
    00290 /*      int i,j;
    00291         FILE *filePtr;                          // file pointer
    00292         int fileLen;                            // length of model file
    00293         char *buffer;                           // file buffer
    00294
    00295
    00296         frame_t *frame;                              // frame data
    00297         stIndex_t *stPtr;                       // texture data
    00298         mesh_t *bufIndexPtr;          // index variables
    00299
    00300         //-------------------------------------
    00301         //read vertex data
    00302         //-------------------------------------
    00303         ExCVec3D Vec3D;
    00304         frame = (frame_t*)&buffer[m_offsetFrames+ m_frameSize * NumFrame];
    00305         for (i = 0; i < m_numVertices; i++)
    00306         {
    00307                 Vec3D.SetX(frame->scale[0] * frame->fp[i].v[0] + frame->translate[0]);
    00308                 Vec3D.SetY(frame->scale[1] * frame->fp[i].v[1] + frame->translate[1]);
    00309                 Vec3D.SetZ(frame->scale[2] * frame->fp[i].v[2] + frame->translate[2]);
    00310                 Vec3D=Vec3D/10;
    00311                 m_VecVertex.push_back(Vec3D);
    00312         }
    00313         //-----------------------------------------------
    00314         //read triangles data
    00315         //-----------------------------------------------
    00316         fseek(filePtr, m_offsetTriangles, SEEK_SET);
    00317         short AB,BC,CA,TAB,TBC,TCA;
    00318         ExCVec3D VertexNum,TexturNum;
    00319         // point to triangle indexes in buffer
    00320         bufIndexPtr = (mesh_t*)&buffer[m_offsetTriangles];
    00321         // create a mesh (triangle) list
    00322         for (j = 0; j < m_numFrames; j++)
    00323         {
    00324                 // for all triangles in each frame
    00325                 for(i = 0; i < m_numTriangles; i++)
    00326                 {
    00327                         AB = bufIndexPtr[i].meshIndex[0];
    00328                         BC = bufIndexPtr[i].meshIndex[1];
    00329                         CA = bufIndexPtr[i].meshIndex[2];
    00330                         TAB = bufIndexPtr[i].stIndex[0];
    00331                         TBC = bufIndexPtr[i].stIndex[1];
    00332                         TCA = bufIndexPtr[i].stIndex[2];
    00333
    00334                         VertexNum.SetValue(AB,BC,CA);
    00335                         TexturNum.SetValue(TAB,TBC,TCA);
    00336                         std::pair<ExCVec3D,ExCVec3D> tmp(VertexNum,TexturNum);
    00337                         m_VecTriangle.push_back(tmp);
    00338                 }
    00339         }
    00340
    00341         //--------------------------------------------------------------------------------------------
    00342         //draw
    00343
    00344 */
    00345 UnGuard
    00346 }
    00347
    00348
    00349
    00350 bool ExCModelMD2::Load(std::string FileName)
    00351 {
    00352 Guard(bool ExCModelMD2::Load(std::string FileName))
    00353         int i,j;
    00354         FILE *filePtr;                          // file pointer
    00355     int fileLen;                            // length of model file
    00356     char *buffer;                           // file buffer
    00357
    00358     modelHeader_t *modelHeader;             // model header
    00359         frame_t *frame;                              // frame data
    00360         stIndex_t *stPtr;                       // texture data
    00361          mesh_t *bufIndexPtr;          // index variables
    00362         m_Skin=ExNihilo::ExtracValueFromSring(FileName,"../Data/Modeles/",".md2");
    00363         m_Skin=m_Skin+".pcx";
    00364         ManagerTexture->Load(m_Skin);
    00365
    00366
    00367     filePtr = fopen(FileName.data(), "rb");
    00368     if (filePtr == NULL)
    00369         {
    00370                 throw ExCExpFileNotFound();
    00371                 return false;
    00372         }
    00373
    00374
    00375          // find length of file
    00376      fseek(filePtr, 0, SEEK_END);
    00377      fileLen = ftell(filePtr);
    00378      fseek(filePtr, 0, SEEK_SET);
    00379
    00380      // read entire file into buffer
    00381      buffer = new char [fileLen+1];
    00382      fread(buffer, sizeof(char), fileLen, filePtr);
    00383
    00384          modelHeader = (modelHeader_t*)buffer;
    00385
    00386 /*       std::ofstream logscale;
    00387          std::ofstream logfp;
    00388          std::ofstream logtranslate;
    00389          std::ofstream logfile;
    00390          std::ofstream logHeader;
    00391          std::ofstream logTextureCoord;
    00392
    00393          logscale.open("logscale.txt",std::ios::out);
    00394          logfp.open("logfp.txt",std::ios::out);
    00395          logtranslate.open("logtranslate.txt",std::ios::out);
    00396          logfile.open("logfile.txt",std::ios::out);
    00397          logHeader.open("logHeader.txt",std::ios::out);
    00398          logTextureCoord.open("logTextureCoord.txt",std::ios::out);
    00399 */
    00400
    00401         m_magic=modelHeader->ident;
    00402         m_version=modelHeader->version;                                         // The version number of the file (Must be 8)
    00403         m_skinWidth=modelHeader->skinwidth;                                     // The skin width in pixels
    00404         m_skinHeight=modelHeader->skinheight;                           // The skin height in pixels
    00405         m_frameSize=modelHeader->framesize;                                     // The size in bytes the frames are
    00406         m_numSkins=modelHeader->numSkins;                                       // The number of skins associated with the model
    00407         m_numVertices=modelHeader->numXYZ;                              // The number of vertices (constant for each frame)
    00408         m_numTexCoords=modelHeader->numST;                      // The number of texture coordinates
    00409         m_numTriangles=modelHeader->numTris;                    // The number of faces (polygons)
    00410         m_numGlCommands=modelHeader->numGLcmds;                 // The number of gl commands
    00411         m_numFrames=modelHeader->numFrames;                                     // The number of animation frames
    00412         m_offsetSkins=modelHeader->offsetSkins;                         // The offset in the file for the skin data
    00413         m_offsetTexCoords=modelHeader->offsetST;                // The offset in the file for the texture data
    00414         m_offsetTriangles=modelHeader->offsetTris;              // The offset in the file for the face data
    00415         m_offsetFrames=modelHeader->offsetFrames;                       // The offset in the file for the frames data
    00416         m_offsetGlCommands=modelHeader->offsetGLcmds;   // The offset in the file for the gl commands data
    00417         m_offsetEnd=modelHeader->offsetEnd;                                     // The end of the file offset
    00418
    00419         /*logHeader<<"This is used to identify the file: "<<m_magic<<std::endl;
    00420         logHeader<<"The version number of the file (Musbe 8):"<<m_version<<std::endl;
    00421         logHeader<<"The skin width in pixels:"<<m_skinWidth<<std::endl;
    00422         logHeader<<"The skin heighin pixels:"<<m_skinHeight<<std::endl;
    00423         logHeader<<"The size in bytes the frames are:"<<m_frameSize<<std::endl;
    00424         logHeader<<"The number of skins associated with the model:"<<m_numSkins<<std::endl;
    00425         logHeader<<"The number of vertices (constan for each frame):"<<m_numVertices<<std::endl;
    00426         logHeader<<"The number of texture coordinates:"<<m_numTexCoords<<std::endl;
    00427         logHeader<<"The number of faces (polygons):"<<m_numTriangles<<std::endl;
    00428         logHeader<<"The number of gl commands:"<<m_numGlCommands<<std::endl;
    00429         logHeader<<"The number of animation frames:"<<m_numFrames<<std::endl;
    00430         logHeader<<"The offset in the file for the skin data:"<<m_offsetSkins<<std::endl;
    00431         logHeader<<"The offset in the file for the texture data:"<<m_offsetTexCoords<<std::endl;
    00432         logHeader<<"The offset in the file for the face data:"<<m_offsetTriangles<<std::endl;
    00433         logHeader<<"The offset in the file for the frames data:"<<m_offsetFrames<<std::endl;
    00434         logHeader<<"The offset in the file for the gl commands data:"<<m_offsetGlCommands<<std::endl;
    00435         logHeader<<"The end of the file offset:"<<m_offsetEnd<<std::endl;
    00436           */
    00437         //-----------------------------------------------
    00438         //read all skin
    00439         //-----------------------------------------------
    00440         char mybuff[65];
    00441         std::string BuffSkin;
    00442     fseek(filePtr, m_offsetSkins, SEEK_SET);
    00443         for(i = 0;i<m_numSkins;++i)
    00444         {
    00445                 fread(&mybuff,sizeof(char),64, filePtr);
    00446                 BuffSkin=mybuff;
    00447                 //std::cout<<BuffSkin<<std::endl;
    00448                 m_VecSkin.push_back(BuffSkin);
    00449         }
    00450         //-----------------------------------------------
    00451         //read vertex  data
    00452         //-----------------------------------------------
    00453          ExCVec3D Vec3D;
    00454          for (j = 0; j < m_numFrames; j++)
    00455      {
    00456           frame = (frame_t*)&buffer[m_offsetFrames+ m_frameSize * j];
    00457           for (i = 0; i < m_numVertices; i++)
    00458           {
    00459                                 Vec3D.SetX(frame->scale[0] * frame->fp[i].v[0] + frame->translate[0]);
    00460                                 Vec3D.SetY(frame->scale[1] * frame->fp[i].v[1] + frame->translate[1]);
    00461                                 Vec3D.SetZ(frame->scale[2] * frame->fp[i].v[2] + frame->translate[2]);
    00462                                 Vec3D=Vec3D/10;
    00463                                 m_VecVertex.push_back(Vec3D);
    00464
    00465                                 //logscale<<"X:"<<frame->scale[0]<<" Y:"<<frame->scale[1]<<" Z:"<<frame->scale[2]<<std::endl;
    00466                                 //logfp<<"X:"<<frame->fp[i].v[0]<<" Y:"<<frame->fp[i].v[1]<<" Z:"<<frame->fp[i].v[2]<<std::endl;
    00467                                 //logtranslate<<"X:"<<frame->translate[0]<<" Y:"<<frame->translate[1]<<" Z:"<<frame->translate[2]<<std::endl;
    00468                                 //logfile<<"vec :"<<i<<" "<<Vec3D<<std::endl;
    00469           }
    00470                   //logfile<<"------------------------------------------------------------------"<<std::endl;
    00471      }
    00472         //-----------------------------------------------
    00473         //read texture coord  data
    00474         //-----------------------------------------------
    00475          ExCVec2D Vec2D;
    00476          stPtr = (stIndex_t*)&buffer[m_offsetTexCoords];
    00477      for (i = 0; i < m_numTexCoords; i++)
    00478      {
    00479           Vec2D.SetX((float)stPtr[i].s / (float)m_skinWidth);
    00480           Vec2D.SetY((float)stPtr[i].t / (float)m_skinHeight);
    00481                   //logTextureCoord<<"vec :"<<Vec2D<<std::endl;
    00482                   m_VecTexture.push_back(Vec2D);
    00483      }
    00484
    00485         //-----------------------------------------------
    00486         //read triangles data
    00487         //-----------------------------------------------
    00488         fseek(filePtr, m_offsetTriangles, SEEK_SET);
    00489         short AB,BC,CA,TAB,TBC,TCA;
    00490         ExCVec3D VertexNum,TexturNum;
    00491 /*      std::ofstream logTri;
    00492         logTri.open("logTri.txt",std::ios::out);
    00493 */
    00494
    00495
    00496      // point to triangle indexes in buffer
    00497     bufIndexPtr = (mesh_t*)&buffer[modelHeader->offsetTris];
    00498         // create a mesh (triangle) list
    00499      for (j = 0; j < m_numFrames; j++)
    00500      {
    00501           // for all triangles in each frame
    00502           for(i = 0; i < m_numTriangles; i++)
    00503           {
    00504                AB = bufIndexPtr[i].meshIndex[0];
    00505                BC = bufIndexPtr[i].meshIndex[1];
    00506                CA = bufIndexPtr[i].meshIndex[2];
    00507                TAB = bufIndexPtr[i].stIndex[0];
    00508                TBC = bufIndexPtr[i].stIndex[1];
    00509                TCA = bufIndexPtr[i].stIndex[2];
    00510
    00511                         VertexNum.SetValue(AB,BC,CA);
    00512                         TexturNum.SetValue(TAB,TBC,TCA);
    00513                         std::pair<ExCVec3D,ExCVec3D> tmp(VertexNum,TexturNum);
    00514                         m_VecTriangle.push_back(tmp);
    00515                 //      logTri<<"AB:"<<AB<<" BC:"<<BC<<" CA:"<<CA<<std::endl;
    00516                 //      logTri<<"TAB:"<<TAB<<" TBC:"<<TBC<<" TCA:"<<TCA<<std::endl;
    00517           }
    00518      }
    00519
    00520          delete buffer;
    00521          return true;
    00522 UnGuard
    00523 }