|
From: julien r. <jul...@us...> - 2004-11-07 19:44:00
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6312 Modified Files: boundingbox.cc boundingbox.h camera.cc camera.h md5instance.cc physicengine.cc physicnode.cc Log Message: fixe Index: boundingbox.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/boundingbox.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** boundingbox.h 7 Nov 2004 11:27:47 -0000 1.3 --- boundingbox.h 7 Nov 2004 19:43:48 -0000 1.4 *************** *** 28,31 **** --- 28,33 ---- Vector3 vBSCenter; float fBSRadius; + + void Rotate (const Quaternion& q); void Move (Vector3 vPos); Index: physicengine.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicengine.cc,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** physicengine.cc 7 Nov 2004 11:27:47 -0000 1.19 --- physicengine.cc 7 Nov 2004 19:43:49 -0000 1.20 *************** *** 141,149 **** //on a un objet qui doit subir les forces et les collisions ! if (!n->OnGround()) ! n->AddYAccel(-(*pGravity)); ! else if (n->GetYAccel() < 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) ! n->SetYAccel(0.0f); //std::cout << "OnGround : " << n->OnGround(); //std::cout << "Accel : \t" << n->GetAccel() << std::endl; --- 141,149 ---- //on a un objet qui doit subir les forces et les collisions ! 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; //std::cout << "OnGround : " << n->OnGround(); //std::cout << "Accel : \t" << n->GetAccel() << std::endl; *************** *** 151,155 **** //Engine::pEngine->pRenderer->drawDebugArrow(n->vPosition, n->vPosition+n->vAccel*5, red); //std::cout << n->GetVelocity() << std::endl; ! n->SetVelocity(n->GetVelocity()+n->GetAccel()*eTime); //mise a jour des volumes englobants n->CalculateBoundingVolume(); --- 151,155 ---- //Engine::pEngine->pRenderer->drawDebugArrow(n->vPosition, n->vPosition+n->vAccel*5, red); //std::cout << n->GetVelocity() << std::endl; ! n->SetVelocity(vVelocity); //mise a jour des volumes englobants n->CalculateBoundingVolume(); Index: camera.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/camera.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** camera.h 24 Oct 2004 13:36:59 -0000 1.2 --- camera.h 7 Nov 2004 19:43:48 -0000 1.3 *************** *** 37,40 **** --- 37,42 ---- void PreRender (float t) {} + void SetViewOffset(const Vector3& v) { vViewOffset = v; } + Vector3 GetViewOffset() { return vViewOffset; } bool bShift; *************** *** 51,54 **** --- 53,57 ---- protected: void _AngleToVectors (); + Vector3 vViewOffset; }; Index: physicnode.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicnode.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** physicnode.cc 7 Nov 2004 11:27:47 -0000 1.5 --- physicnode.cc 7 Nov 2004 19:43:49 -0000 1.6 *************** *** 26,32 **** n->SetPosition(vPosition); n->SetRotation(qRotation); ! pBBox->vMin = qRotation.Rotate(pBBox->vMin); ! pBBox->vMax = qRotation.Rotate(pBBox->vMax); ! pBBox->CalculatePlanes(); } } --- 26,30 ---- n->SetPosition(vPosition); n->SetRotation(qRotation); ! } } Index: camera.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/camera.cc,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** camera.cc 2 Nov 2004 15:32:15 -0000 1.8 --- camera.cc 7 Nov 2004 19:43:48 -0000 1.9 *************** *** 18,21 **** --- 18,22 ---- vRight.Null(); vUp.Null(); + vViewOffset.Null(); bShift = false; *************** *** 150,153 **** --- 151,155 ---- glMultMatrixf (matrix); //glRotatef (-a, axis.x, axis.y, axis.z); + glTranslatef(-vViewOffset.x, -vViewOffset.y, -vViewOffset.z); glTranslatef(-vPosition.x, -vPosition.y, -vPosition.z); frustum.Update(); Index: md5instance.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5instance.cc,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** md5instance.cc 6 Nov 2004 17:05:39 -0000 1.9 --- md5instance.cc 7 Nov 2004 19:43:48 -0000 1.10 *************** *** 140,146 **** _SkinMesh(); ! //Doit-on le faire ici ?? ! pBBox = pData->anim_GetBBox(iCurrentAnimation, iFrame); ! pBBox->qRotation = qRotation; } --- 140,145 ---- _SkinMesh(); ! //FIXME:Doit-on le faire ici ?? ! //pBBox = pData->anim_GetBBox(iCurrentAnimation, iFrame); } Index: boundingbox.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/boundingbox.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** boundingbox.cc 6 Nov 2004 17:05:39 -0000 1.2 --- boundingbox.cc 7 Nov 2004 19:43:48 -0000 1.3 *************** *** 20,23 **** --- 20,69 ---- } + void BoundingBox::Rotate(const Quaternion& q) + { + Vector3 vNewMin = q.Rotate(vMin); + Vector3 vNewMax = q.Rotate(vMax); + + Vector3 vMin2 (TG_INFINITY, TG_INFINITY, TG_INFINITY); + Vector3 vMax2 (0,0,0); + + if (vNewMin.x < vMin2.x) + vMin2.x = vNewMin.x; + if (vNewMax.x < vMin2.x) + vMin2.x = vNewMax.x; + + if (vNewMin.y < vMin2.y) + vMin2.y = vNewMin.y; + if (vNewMax.y < vMin2.y) + vMin2.y = vNewMax.y; + + if (vNewMin.z < vMin2.z) + vMin2.z = vNewMin.z; + if (vNewMax.z < vMin2.z) + vMin2.z = vNewMax.z; + + + if (vNewMin.x > vMax2.x) + vMax2.x = vNewMin.x; + if (vNewMax.x > vMax2.x) + vMax2.x = vNewMax.x; + + if (vNewMin.y > vMax2.y) + vMax2.y = vNewMin.y; + if (vNewMax.y > vMax2.y) + vMax2.y = vNewMax.y; + + if (vNewMin.z > vMax2.z) + vMax2.z = vNewMin.z; + if (vNewMax.z > vMax2.z) + vMax2.z = vNewMax.z; + + vMin = vMin2; + vMax = vMax2; + + CalculatePlanes(); + + } + void BoundingBox::Move (Vector3 vPos) { |