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

# ExCModelEXM.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
    00021  *
    00022  */
    00023
    00024 #include "ExCModelEXM.h"
    00025
    00026 ExCModelEXM::ExCModelEXM(void)
    00027 {
    00028 Guard(ExCModelEXM::ExCModelEXM(void))
    00029         ExCModel::ExCModel();
    00030         SetName("ExCModelEXM");
    00031         SetType(typeid(this).name());
    00032         m_pFather=NULL;
    00033         m_VecChild=NULL;
    00034         m_CollisionGizmo=new ExCGizmoRectangle;
    00035         m_Lighting=false;
    00036 UnGuard
    00037 }
    00038
    00039 ExCModelEXM::~ExCModelEXM(void)
    00040 {
    00041 Guard(ExCModelEXM::~ExCModelEXM(void))
    00042 UnGuard
    00043 }
    00044
    00045 void ExCModelEXM::BuilGizmoBox(void)
    00046 {
    00047 Guard(void ExCModelEXM::BuilGizmoBox(void))
    00048
    00049 UnGuard
    00050 }
    00051
    00052
    00053
    00054 void ExCModelEXM::Draw(void)
    00055 {
    00056 Guard(void ExCModelEXM::Draw(void))
    00057         //----------------------------
    00058         //CREATE CURRENT VERTEX VECTOR
    00059         //----------------------------
    00060         BuildDrawVector();
    00061         //----------------------------
    00062         //DRAW MODEL
    00063         //----------------------------
    00064         /*if(!m_Lighting)*/glDisable(GL_LIGHTING);
    00065         glPushAttrib(GL_ALL_ATTRIB_BITS);
    00066         glPushMatrix();
    00067                 ExCModel::Draw();
    00068                 //--------------
    00069                 //Draw Model with array
    00070                 //--------------
    00071                 glRotatef(-90,1,0,0);//Align with axe
    00072                 glColor3f(1,1,1);
    00073                 glPushMatrix();
    00074                         //Texture
    00075                         for(unsigned int i=0;i<m_VecTextures.size();i++)
    00076                         {
    00077                                 ManagerTexture->SetTexture(i,m_VecTextures.at(i).data());
    00078                                 glTexCoordPointer(2,GL_FLOAT,0,TabTextures);
    00079                         }
    00080                         //Vertex
    00081                         glEnableClientState(GL_VERTEX_ARRAY);
    00082                         //glVertexPointer(3,GL_FLOAT,0,TabVertices);
    00083                         glDrawArrays( GL_TRIANGLES, 0 , m_numTriangles*3 );
    00084
    00085                         ManagerTexture->ResetMultitexture();
    00086                 glPopMatrix();
    00087         glPopAttrib();
    00088         glPopMatrix();
    00089         //glDisable(GL_TEXTURE_2D);
    00090
    00091         //delete TabCurrentVertices;
    00092 UnGuard
    00093 }
    00094
    00095 void ExCModelEXM::BuildDrawVector(void)
    00096 {
    00097 Guard(void ExCModelEXM::BuildDrawVector(void))
    00098         ExCVec3D VecAB,VecBC,VecCA;
    00099         TabVertices= new float[m_numTriangles*9];
    00100         int FrameToDraw=1;
    00101         //FrameToDraw=m_VecVertex.size()+10;
    00102
    00103         std::cout<<"plok m_VecTriangle "<<m_VecTriangle.size()<<std::endl;
    00104         std::cout<<"plok m_VecVertex "<<m_VecVertex.size()<<std::endl;
    00105         for(int i = 0; i < m_numTriangles; i++)
    00106         {
    00107                 //std::cout<<"plok gruik"<<std::endl;
    00108                 //----------------
    00109                 //Vertex coord
    00110                 //----------------
    00111                 VecAB.SetX(m_VecVertex.at(m_VecTriangle.at(i).first.GetX()+FrameToDraw).GetX());
    00112                 VecAB.SetY(m_VecVertex.at(m_VecTriangle.at(i).first.GetX()+FrameToDraw).GetY());
    00113                 VecAB.SetZ(m_VecVertex.at(m_VecTriangle.at(i).first.GetX()+FrameToDraw).GetZ());
    00114
    00115                 VecBC.SetX(m_VecVertex.at(m_VecTriangle.at(i).first.GetY()+FrameToDraw).GetX());
    00116                 VecBC.SetY(m_VecVertex.at(m_VecTriangle.at(i).first.GetY()+FrameToDraw).GetY());
    00117                 VecBC.SetZ(m_VecVertex.at(m_VecTriangle.at(i).first.GetY()+FrameToDraw).GetZ());
    00118
    00119                 VecCA.SetX(m_VecVertex.at(m_VecTriangle.at(i).first.GetZ()+FrameToDraw).GetX());
    00120                 VecCA.SetY(m_VecVertex.at(m_VecTriangle.at(i).first.GetZ()+FrameToDraw).GetY());
    00121                 VecCA.SetZ(m_VecVertex.at(m_VecTriangle.at(i).first.GetZ()+FrameToDraw).GetZ());
    00122                 //std::cout<<"plok"<<std::endl;
    00123                 //--------------
    00124                 //Build array with new vertex data
    00125                 //--------------
    00126                 TabVertices[0+i*9]=VecBC.GetX();
    00127                 TabVertices[1+i*9]=VecBC.GetY();
    00128                 TabVertices[2+i*9]=VecBC.GetZ();
    00129                 TabVertices[3+i*9]=VecAB.GetX();
    00130                 TabVertices[4+i*9]=VecAB.GetY();
    00131                 TabVertices[5+i*9]=VecAB.GetZ();
    00132                 TabVertices[6+i*9]=VecCA.GetX();
    00133                 TabVertices[7+i*9]=VecCA.GetY();
    00134                 TabVertices[8+i*9]=VecCA.GetZ();
    00135                 //std::cout<<"gruik"<<std::endl;
    00136         }
    00137 UnGuard
    00138 }
    00139
    00140 bool ExCModelEXM::Load(std::string FileName)
    00141 {
    00142 Guard(bool ExCModelEXM::Load(std::string FileName))
    00143         //std::cout<<"ExCModelEXM draw"<<std::endl;
    00144         return true;
    00145 UnGuard
    00146 }