Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9090 Modified Files: AUTHORS Changelog Doxyfile LICENSE Makefile Makefile.Linux Makefile.OSX README TODO base.cc base.h boundingbox.cc boundingbox.h camera.cc camera.h command.cc command.h console.cc console.h cvarmanager.cc cvarmanager.h defs.h diskshape.cc diskshape.h dlinkednode.h edge.h emittershape.h engine.cc engine.h errbuffer.cc errbuffer.h event.h face.h font.h frustum.cc frustum.h function.cc function.h gldefs.cc gldefs.h glrenderer.cc glrenderer.h glrenderernv15.cc glrenderernv15.h guibutton.cc guibutton.h guicontainer.cc guicontainer.h guielement.h guimanager.cc guimanager.h guitext.h image2d.h logbuffer.cc logbuffer.h material.h matrice3.h md5instance.cc md5instance.h md5mesh10.cc md5mesh10.h mesh.cc mesh.h meshmanager.cc meshmanager.h particle.h particleemitter.cc particleemitter.h physiccallback.h physicengine.cc physicengine.h physicnode.cc physicnode.h plane.cc plane.h pointlight.h q3bsp.cc q3bsp.h quad.h quaternion.cc quaternion.h registry.cc registry.h renderer.cc renderer.h scenemanager.cc scenemanager.h scenenode.cc scenenode.h soundmanager.cc soundmanager.h texture.cc texture.h texturemanager.cc texturemanager.h tgendian.h tgglext.cc tgglext.h timer.cc timer.h util.cc util.h vbo.cc vbo.h vector3.cc vector3.h vertice.h video.cc video.h vshader.cc vshader.h Log Message: force commit Index: q3bsp.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/q3bsp.cc,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** q3bsp.cc 9 Nov 2004 18:19:04 -0000 1.10 --- q3bsp.cc 12 Nov 2004 12:11:36 -0000 1.11 *************** *** 803,807 **** bool Q3Bsp::IsVisible(int leaf) { ! int iCamLeaf = FindLeaf(pCamera->GetPosition()); int iCamCluster = pLeafs[iCamLeaf].cluster; int iTestCluster = pLeafs[leaf].cluster; --- 803,807 ---- bool Q3Bsp::IsVisible(int leaf) { ! int iCamLeaf = FindLeaf(pCamera->GetPosition()+pCamera->GetViewOffset()); int iCamCluster = pLeafs[iCamLeaf].cluster; int iTestCluster = pLeafs[leaf].cluster; *************** *** 1006,1010 **** memset (pVisibleFaces, 0, sizeof(bool)*numOfFaces); ! int iCamLeaf = FindLeaf(pCamera->GetPosition()); int iCamCluster = pLeafs[iCamLeaf].cluster; for (int i=0; i<numOfLeafs; i++) --- 1006,1010 ---- memset (pVisibleFaces, 0, sizeof(bool)*numOfFaces); ! int iCamLeaf = FindLeaf(pCamera->GetPosition()+pCamera->GetViewOffset()); int iCamCluster = pLeafs[iCamLeaf].cluster; for (int i=0; i<numOfLeafs; i++) Index: physicengine.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicengine.cc,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** physicengine.cc 9 Nov 2004 18:19:04 -0000 1.21 --- physicengine.cc 12 Nov 2004 12:11:36 -0000 1.22 *************** *** 113,117 **** #define BASE_HEIGHT 15 ! #define STEPSIZE 10 void PhysicEngine::Move (float eTime) { --- 113,117 ---- #define BASE_HEIGHT 15 ! #define STEPSIZE 20 void PhysicEngine::Move (float eTime) { *************** *** 143,147 **** Vector3 vVelocity = n->GetVelocity(); if (!n->OnGround()) ! vVelocity.y = -(*pGravity)*eTime; else if (vVelocity.y < 0) //si l'objet touche le sol, il faut ramener la gravité à zéro, sinon, l'objet va se retrouver avec une gravité négative très grande (ça l'empeche de sauter notamment) vVelocity.y = 0; --- 143,147 ---- Vector3 vVelocity = n->GetVelocity(); if (!n->OnGround()) ! vVelocity.y = -(*pGravity); else if (vVelocity.y < 0) //si l'objet touche le sol, il faut ramener la gravité à zéro, sinon, l'objet va se retrouver avec une gravité négative très grande (ça l'empeche de sauter notamment) vVelocity.y = 0; *************** *** 186,211 **** float updist = sqrt(distx+distz); ! /*if (updist > dist) //on passe l'obstacle { //std::cout << "time : " << eTime << "\t" << vUpNewPos << std::endl; n->SetPosition(vUpNewPos); ! if (vUpVelocity != n->GetVelocity() && n->GetPhysicCallBack() != NULL) { //std::cout << "callback" << std::endl; //ce ne sont pas les memes, donc il y a eu collision -> appelle de la callback n->GetPhysicCallBack()->Collide(NULL, Vector3(0,0,0), Vector3(0,0,0)); ! } } else //l'obstacle est trop haut ! {*/ //std::cout << "time : " << eTime << "\t" << vNewPos << std::endl; n->SetPosition(vNewPos); ! /* if (vVelocity != n->GetVelocity() && n->GetPhysicCallBack() != NULL) { //std::cout << "callback" << std::endl; //ce ne sont pas les memes, donc il y a eu collision -> appelle de la callback n->GetPhysicCallBack()->Collide(NULL, Vector3(0,0,0), Vector3(0,0,0)); ! } ! }*/ //Classification de la position --- 186,211 ---- float updist = sqrt(distx+distz); ! if (updist > dist) //on passe l'obstacle { //std::cout << "time : " << eTime << "\t" << vUpNewPos << std::endl; n->SetPosition(vUpNewPos); ! /*if (vUpVelocity != n->GetVelocity() && n->GetPhysicCallBack() != NULL) { //std::cout << "callback" << std::endl; //ce ne sont pas les memes, donc il y a eu collision -> appelle de la callback n->GetPhysicCallBack()->Collide(NULL, Vector3(0,0,0), Vector3(0,0,0)); ! }*/ } else //l'obstacle est trop haut ! { //std::cout << "time : " << eTime << "\t" << vNewPos << std::endl; n->SetPosition(vNewPos); ! /*if (vVelocity != n->GetVelocity() && n->GetPhysicCallBack() != NULL) { //std::cout << "callback" << std::endl; //ce ne sont pas les memes, donc il y a eu collision -> appelle de la callback n->GetPhysicCallBack()->Collide(NULL, Vector3(0,0,0), Vector3(0,0,0)); ! }*/ ! } //Classification de la position Index: md5mesh10.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5mesh10.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** md5mesh10.h 6 Nov 2004 17:05:39 -0000 1.5 --- md5mesh10.h 12 Nov 2004 12:11:36 -0000 1.6 *************** *** 51,54 **** --- 51,55 ---- inline int mesh_GetNumTris (int i) { return pMeshes[i].iNumTris; } inline unsigned int* mesh_GetIndexes(int i) { return pMeshes[i].pIndexes; } + inline Face* mesh_GetFace(int i, int j) { return &pMeshes[i].pTriangles[j]; } //Vertices informations inline int vert_GetWeightIndex(int i, int j) { return pMeshes[i].pVerts[j].iWeightIndex; } Index: mesh.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/mesh.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** mesh.h 26 Sep 2004 13:15:13 -0000 1.1.1.1 --- mesh.h 12 Nov 2004 12:11:36 -0000 1.2 *************** *** 71,75 **** virtual void DrawVisibleEdges () = 0; ! bool bCamera; float fScale; --- 71,75 ---- virtual void DrawVisibleEdges () = 0; ! bool bCamera; float fScale; Index: boundingbox.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/boundingbox.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** boundingbox.h 7 Nov 2004 19:43:48 -0000 1.4 --- boundingbox.h 12 Nov 2004 12:11:36 -0000 1.5 *************** *** 34,38 **** void CalculateVertices (); ! bool IsPointIn(Vector3 p); /** --- 34,38 ---- void CalculateVertices (); ! bool IsPointIn(Vector3 p); /** Index: boundingbox.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/boundingbox.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** boundingbox.cc 10 Nov 2004 21:02:04 -0000 1.5 --- boundingbox.cc 12 Nov 2004 12:11:36 -0000 1.6 *************** *** 84,88 **** //un plan pour chaque face ! //les normales sont justes. Si on recode cette fonction, il faut y faire gaffe... pPlanes[0].SetFromPoints(Vector3(va.x, vi.y, vi.z),vi, Vector3(va.x, va.y, vi.z)); pPlanes[1].SetFromPoints(va,Vector3(va.x, vi.y, va.z), Vector3(va.x, va.y, vi.z)); --- 84,88 ---- //un plan pour chaque face ! //les normales sont justes(elles pointent vers l'exterieur). Si on recode cette fonction, il faut y faire gaffe... pPlanes[0].SetFromPoints(Vector3(va.x, vi.y, vi.z),vi, Vector3(va.x, va.y, vi.z)); pPlanes[1].SetFromPoints(va,Vector3(va.x, vi.y, va.z), Vector3(va.x, va.y, vi.z)); *************** *** 137,150 **** } bool BoundingBox::TraceRay (Vector3 begin, Vector3 end, Vector3& colPoint, Vector3& colNormal) { ! /*bool col = false; for (int i=0; i<6; i++) { ! if (pPlanes[i].IntersectRay(begin,end,colPoint)) ! col = true; } ! return col;*/ ! return TraceSphereRay(begin, end, colPoint); } --- 137,159 ---- } + bool BoundingBox::TraceRay (Vector3 begin, Vector3 end, Vector3& colPoint, Vector3& colNormal) { ! return TraceSphereRay(begin, end, colPoint); ! /*int iB, iE; ! Vector3 cP; for (int i=0; i<6; i++) { ! iB = pPlanes[i].ClassifyPoint(begin); ! iE = pPlanes[i].ClassifyPoint(end); ! if ((iB == iE) && (iB == POINT_IN_FRONT_OF_PLANE)) ! return false; ! else if (iB == iE) ! continue; ! if (pPlanes[i].IntersectRay(begin, end, cP)) ! if ((begin-cP).Magnitude() < (begin-colPoint).Magnitude()) ! colPoint = cP; } ! return true;*/ } Index: md5instance.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5instance.cc,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** md5instance.cc 7 Nov 2004 19:43:48 -0000 1.10 --- md5instance.cc 12 Nov 2004 12:11:36 -0000 1.11 *************** *** 272,312 **** #if 0 ! void MD5Mesh::BuildBone (int frame, _MD5Bone* b) { ! //glMatrixMode (GL_MODELVIEW); ! glPushMatrix(); ! float translate[6]; ! _MD5Channel * chan; ! int lframe; ! for (int i =0; i < 6; i++) ! { ! chan = b->chan[i]; ! lframe = frame%chan->numkeys; ! translate[i] = chan->pKeys[lframe]; ! } ! //Inversion des coordonnes ! glTranslatef( translate[X],translate[Z],-translate[Y] ); ! glRotatef(translate[YAW] , 0,1,0 ); ! glRotatef(translate[PITCH], 0,0,-1 ); ! glRotatef(translate[ROLL] , 1,0,0 ); ! GLfloat matrix[16]; ! glGetFloatv( GL_MODELVIEW_MATRIX, matrix ); ! b->bindpos = Vector3 (matrix[12], matrix[13], matrix[14]); ! for(int i=0; i<3; i++) { ! for( int j=0; j<3; j++) { ! b->bindmat[3*i+j] = matrix[4*i+j]; ! } ! } ! for (int i = 0; i < b->children.size(); i++) ! { ! BuildBone(frame,b->children[i]); ! } ! glPopMatrix(); ! } #endif - } --- 272,374 ---- #if 0 ! bool MD5Instance::Trace (Vector3 Begin, Vector3 End, Vector3& colPoint, Vector3& colNormal) { ! /*Vector3 cP; ! float d1, d2; ! colPoint.x = colPoint.y = colPoint.z = TG_INFINITY; ! bool b = false; ! for (unsigned int i=0; i<numBones; i++) ! { ! //s'il y a collision ! if (pBones[i].BBox.TraceSphereRay(Begin, End, cP)) ! { ! d1 = (cP - Begin).Magnitude(); ! d2 = (colPoint - Begin).Magnitude(); ! if ( d1 < d2 ) ! { ! b = true; ! colPoint = cP; ! } ! } ! } ! return b;*/ ! if (/*pBBox->TraceRay(Begin, End, colPoint))*/pBBox->TraceSphereRay(Begin, End, colPoint)) ! return TriangleTrace(Begin, End, colPoint, colNormal); ! else ! return false; ! //return pBBox->TraceSphereRay(Begin, End, colPoint); ! } ! ! bool SameSide (const Vector3& p1, const Vector3& p2, const Vector3& a, const Vector3& b) ! { ! Vector3 cp1 ((b-a)%(p1-a)); ! Vector3 cp2 ((b-a)%(p2-a)); ! if (cp1*cp2 >= 0) ! return true; ! else ! return false; ! } ! bool PointInTriangle (const Vector3& p,const Vector3& a,const Vector3& b,const Vector3& c) ! { ! if (SameSide(p, a, b, c) && SameSide (p, b, a, c) && SameSide(p, c, a, b)) ! return true; ! else ! return false; ! } ! bool MD5Instance::TriangleTrace(const Vector3& Begin, const Vector3& End, Vector3& colPoint, Vector3& colNormal) ! { ! Plane p; ! colPoint.x = colPoint.y = colPoint.z = TG_INFINITY; ! Vector3 cP; ! float d1, d2; ! /* next variables are unused ! bool b = false; ! float dist, t; ! */ ! ! Vector3 points[3]; ! for (unsigned int j=0; j<iNumMeshes; j++) ! { ! for (unsigned int i=0; i<pData->mesh_GetNumTris(j); i++) ! { ! Face* f = pData->mesh_GetFace(j, i); ! points[0] = pVerticesListTab[j][f->pIndex[0]].vPosition+vPosition; ! points[1] = pVerticesListTab[j][f->pIndex[1]].vPosition+vPosition; ! points[2] = pVerticesListTab[j][f->pIndex[2]].vPosition+vPosition; ! p.SetFromPoints(points[0], points[1], points[2]); ! ! if (p.IntersectRay(Begin, End, cP)) ! { ! if (PointInTriangle(cP, points[0], points[1], points[2])) ! { ! d1 = (cP - Begin).Magnitude(); ! d2 = (colPoint - Begin).Magnitude(); ! if (d1 < d2) ! { ! colPoint = cP; ! colNormal = p.GetNormal(); ! } ! } ! //Engine::pConsole->Output("Collision"); ! } + /* + if (p.ClassifyPoint(Begin) != p.ClassifyPoint(End)) //le segment coupe le plan du triangle, collision possible + { + dist = p.GetDistance(Begin); //on cherche le point de collision avec le plan + t = (End - Begin).Magnitude()/dist; + tempColPoint = (End - Begin)*t; + + if (PointInTriangle(tempColPoint, pVerticesListTab[0][f.pIndex[0]].vPosition, pVerticesListTab[0][f.pIndex[1]].vPosition, pVerticesListTab[0][f.pIndex[2]].vPosition)) + //cP = tempColPoint; + Engine::pConsole->Output("Collision"); + }*/ + } + } + return true; + } #endif } Index: md5instance.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5instance.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** md5instance.h 2 Nov 2004 15:32:16 -0000 1.6 --- md5instance.h 12 Nov 2004 12:11:36 -0000 1.7 *************** *** 44,47 **** --- 44,51 ---- + //bool Trace (Vector3 Begin, Vector3 End, Vector3& colPoint, Vector3& colNormal); + //bool TriangleTrace(const Vector3& Begin, const Vector3& End, Vector3& colPoint, Vector3& colNormal); + + int GetVertexStride () { return 0; } void ComputeSilhouette (const Vector3& lightPos) {} |