Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6203 Modified Files: glrenderer.cc md2mesh.cc md5instance.cc md5instance.h md5mesh10.cc md5mesh10.h scenenode.cc texture.cc util.cc util.h Log Message: deverminage, calcul de bbox pour les modeles Index: util.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/util.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** util.h 26 Sep 2004 13:15:17 -0000 1.1.1.1 --- util.h 30 Sep 2004 09:23:16 -0000 1.2 *************** *** 30,33 **** --- 30,35 ---- static void QuaternionToMatrix33 (const Quaternion& q, float[9]); static void QuaternionToMatrix44 (const Quaternion& q, float[16]); + static void ChangeCoords(Vector3& v); + static void ChangeCoords(float& x, float&y, float& z); }; Index: md2mesh.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md2mesh.cc,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** md2mesh.cc 26 Sep 2004 13:15:12 -0000 1.1.1.1 --- md2mesh.cc 30 Sep 2004 09:23:16 -0000 1.2 *************** *** 5,10 **** namespace tg { - namespace scene - { /* MD2Mesh::MD2Mesh( ) : Mesh () --- 5,8 ---- *************** *** 304,307 **** }*/ - } //END scene } //END tg --- 302,304 ---- Index: md5instance.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5instance.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** md5instance.cc 28 Sep 2004 18:03:12 -0000 1.4 --- md5instance.cc 30 Sep 2004 09:23:16 -0000 1.5 *************** *** 12,15 **** --- 12,16 ---- pData = d; + pBBox = new BoundingBox (); iNumJoints = pData->GetNumJoints(); iNumBaseJoints = pData->GetNumBaseJoints(); *************** *** 76,81 **** --- 77,121 ---- _SkinMesh(); + _CalculateBBox (); + } + + MD5Instance::~MD5Instance () + { + delete pBBox; + } + + void MD5Instance::_CalculateBBox() + { + Vector3 vMin(0,0,0); + Vector3 vMax(0,0,0); + for (int i=0; i<pData->GetNumMeshes(); i++) + { + for (int j=0; j<pData->mesh_GetNumVerts(i); j++) + { + Vector3& vert = pVerticesListTab[i][j].vPosition; + if (vert.x > vMax.x) + vMax.x = vert.x; + if (vert.x < vMin.x) + vMin.x = vert.x; + + if (vert.y > vMax.y) + vMax.y = vert.y; + if (vert.y < vMin.y) + vMin.y = vert.y; + + if (vert.z > vMax.z) + vMax.z = vert.z; + if (vert.z < vMin.z) + vMin.z = vert.z; + + } + } + pBBox->vMin = vMin; + pBBox->vMax = vMax; + pBBox->Move (vPosition); } + + void MD5Instance::PreRender(float fTime) { Index: md5mesh10.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5mesh10.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** md5mesh10.h 28 Sep 2004 18:03:12 -0000 1.2 --- md5mesh10.h 30 Sep 2004 09:23:16 -0000 1.3 *************** *** 29,33 **** bool LoadMesh(char* str); bool LoadAnim(char* str); ! //Joint informations inline int GetNumJoints() { return iNumJoints; } --- 29,33 ---- bool LoadMesh(char* str); bool LoadAnim(char* str); ! //Joint informations inline int GetNumJoints() { return iNumJoints; } *************** *** 73,76 **** --- 73,77 ---- protected: + int iNumJoints; int iNumBaseJoints; *************** *** 78,81 **** --- 79,83 ---- int** pIndexes; + _MD5Joint* pJoints; Index: md5instance.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5instance.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** md5instance.h 27 Sep 2004 13:23:18 -0000 1.3 --- md5instance.h 30 Sep 2004 09:23:16 -0000 1.4 *************** *** 24,27 **** --- 24,28 ---- MD5Instance(MD5Mesh10*); + ~MD5Instance (); void SetAnimation (std::string name); *************** *** 50,53 **** --- 51,55 ---- void _BuildBone (int, Joint*,const Quaternion&, const Vector3&); void _SkinMesh (); + void _CalculateBBox (); MD5Mesh10* pData; Index: scenenode.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/scenenode.cc,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** scenenode.cc 26 Sep 2004 13:15:15 -0000 1.1.1.1 --- scenenode.cc 30 Sep 2004 09:23:16 -0000 1.2 *************** *** 44,52 **** { vPosition = v; } void SceneNode::CalculateBoundingVolume () { ! pBBox->Move(vPosition); } --- 44,53 ---- { vPosition = v; + pBBox->Move (v); } void SceneNode::CalculateBoundingVolume () { ! //pBBox->Move(vPosition); } Index: glrenderer.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/glrenderer.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** glrenderer.cc 27 Sep 2004 21:34:05 -0000 1.5 --- glrenderer.cc 30 Sep 2004 09:23:16 -0000 1.6 *************** *** 1840,1844 **** --- 1840,1846 ---- glBegin (GL_POINTS); for (int i=0; i<8; i++) + { glVertex3fv(&(b->pVertices[i].x)); + } glEnd(); Index: util.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/util.cc,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** util.cc 26 Sep 2004 13:15:17 -0000 1.1.1.1 --- util.cc 30 Sep 2004 09:23:16 -0000 1.2 *************** *** 10,13 **** --- 10,28 ---- } + void Util::ChangeCoords (Vector3& v) + { + float temp = v.y; + v.y = v.z; + v.z = -temp; + } + + void Util::ChangeCoords (float& x, float& y, float& z) + { + float temp = y; + y = z; + z = -temp; + } + + float Util::InvSqrt(float x) { Index: md5mesh10.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5mesh10.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** md5mesh10.cc 27 Sep 2004 14:45:59 -0000 1.2 --- md5mesh10.cc 30 Sep 2004 09:23:16 -0000 1.3 *************** *** 85,89 **** NEXT("(") pFD >> pJoints[i].vPosition.x >> pJoints[i].vPosition.y >> pJoints[i].vPosition.z; ! //ChangeCoords(pJoints[i].vPosition); --- 85,90 ---- NEXT("(") pFD >> pJoints[i].vPosition.x >> pJoints[i].vPosition.y >> pJoints[i].vPosition.z; ! ! Util::ChangeCoords(pJoints[i].vPosition); //ChangeCoords(pJoints[i].vPosition); *************** *** 91,94 **** --- 92,96 ---- NEXT("(") pFD >> q.x >> q.y >> q.z; + Util::ChangeCoords(q.x, q.y, q.z); q.ComputeR(); *************** *** 151,154 **** --- 153,157 ---- NEXT("(") pFD >> w.vWeights.x >> w.vWeights.y >> w.vWeights.z; + Util::ChangeCoords(w.vWeights); } } Index: texture.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/texture.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** texture.cc 28 Sep 2004 09:44:26 -0000 1.5 --- texture.cc 30 Sep 2004 09:23:16 -0000 1.6 *************** *** 13,18 **** namespace tg { - namespace gfx - { Texture::Texture() --- 13,16 ---- *************** *** 497,500 **** } - } //END gfx } //END tg --- 495,497 ---- |