You can subscribe to this list here.
| 2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(25) |
Oct
(64) |
Nov
(74) |
Dec
(22) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
(14) |
| 2015 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: julien r. <jul...@us...> - 2004-11-07 19:45:14
|
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6531 Modified Files: game.cc pawn.cc Log Message: fixe Index: game.cc =================================================================== RCS file: /cvsroot/epfl/tggame/game.cc,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** game.cc 6 Nov 2004 17:05:51 -0000 1.26 --- game.cc 7 Nov 2004 19:44:59 -0000 1.27 *************** *** 99,105 **** #endif Camera* cam = new Camera (0.025f,CAM_SPEED, Vector3 (0, 100,0)); ! //TODO: on devrait plutot se base sur la bounding box du model ! //cam->pBBox->vMin = Vector3(-10, -70, -10); ! //cam->pBBox->vMax = Vector3(10, 10, 10); //préchargement des meshes --- 99,103 ---- #endif Camera* cam = new Camera (0.025f,CAM_SPEED, Vector3 (0, 100,0)); ! cam->SetViewOffset(Vector3(0,70,0)); //préchargement des meshes *************** *** 110,115 **** pEngine->pMeshManager->LoadAnim("machinegun", "data/models/machinegun/fire4.md5anim"); ! pEngine->pMeshManager->Load("pinky", "data/models/zct/zct.md5mesh"); ! pEngine->pMeshManager->LoadAnim("pinky", "data/models/zct/zctidle.md5anim"); --- 108,113 ---- pEngine->pMeshManager->LoadAnim("machinegun", "data/models/machinegun/fire4.md5anim"); ! pEngine->pMeshManager->Load("pinky", "data/models/player/hazmat.md5mesh"); ! pEngine->pMeshManager->LoadAnim("pinky", "data/models/player/stand.md5anim"); *************** *** 132,136 **** //p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(20,80,20)); p->Attach (cam); ! p->SetPosition (Vector3(100,100,100)); p->SetMoveSpeed (CAM_SPEED); p->SetVisible(false); --- 130,134 ---- //p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(20,80,20)); p->Attach (cam); ! p->SetPosition (Vector3(100,80,100)); p->SetMoveSpeed (CAM_SPEED); p->SetVisible(false); *************** *** 145,150 **** p->SetMoveSpeed(CAM_SPEED); p->SetVelocity(Vector3(0,0,0)); ! //p->SetRotation(Quaternion(-90, Vector3(1,0,0))); ! //p->SetPosition(Vector3(-550,0,250)); //p->SetRotationVelocity(Quaternion(10,Vector3(0,1,1))); --- 143,148 ---- p->SetMoveSpeed(CAM_SPEED); p->SetVelocity(Vector3(0,0,0)); ! p->SetRotation(Quaternion(-90, Vector3(1,0,0))); ! p->SetPosition(Vector3(0,70,0)); //p->SetRotationVelocity(Quaternion(10,Vector3(0,1,1))); Index: pawn.cc =================================================================== RCS file: /cvsroot/epfl/tggame/pawn.cc,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** pawn.cc 6 Nov 2004 17:05:51 -0000 1.9 --- pawn.cc 7 Nov 2004 19:44:59 -0000 1.10 *************** *** 6,12 **** { pModel = Engine::pMeshManager->LoadInstance("pinky"); ! pModel->SetAnimation("zctidle"); pPhysic = new PhysicNode(pModel); ! pPhysic->SetClip(false); fMoveSpeed = 0.0f; } --- 6,14 ---- { pModel = Engine::pMeshManager->LoadInstance("pinky"); ! pModel->SetAnimation("stand"); pPhysic = new PhysicNode(pModel); ! pModel->GetBBox()->vMin.Set(-10,0,-10); ! pModel->GetBBox()->vMax.Set(10,80,10); ! //pPhysic->SetClip(false); fMoveSpeed = 0.0f; } |
|
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) { |
|
From: julien r. <jul...@us...> - 2004-11-07 11:27:59
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24195 Modified Files: boundingbox.h glrenderer.cc physicengine.cc physicnode.cc Removed Files: material.cc Log Message: fixe Index: boundingbox.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/boundingbox.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** boundingbox.h 6 Nov 2004 17:05:39 -0000 1.2 --- boundingbox.h 7 Nov 2004 11:27:47 -0000 1.3 *************** *** 27,31 **** Vector3 vWorldBSCenter; Vector3 vBSCenter; - Quaternion qRotation; float fBSRadius; --- 27,30 ---- Index: physicengine.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicengine.cc,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** physicengine.cc 6 Nov 2004 17:05:39 -0000 1.18 --- physicengine.cc 7 Nov 2004 11:27:47 -0000 1.19 *************** *** 15,18 **** --- 15,19 ---- //pCurrentNode = NULL; } + #define MAXBUMPS 5 *************** *** 22,29 **** --- 23,34 ---- int bumpcount = 0; //Vector3 origin = n->pBBox->vWorldOrigin; + std::vector<Vector3> pPlanes; + int iNumPlanes = 0; float time_left = eTime; trace.Fraction = 0.0f; + int i, j; + while ((trace.Fraction < (1.0f - EPSILON)) && (bumpcount < MAXBUMPS)) //a chaque fois qu'on rencontre un plan, on relance un trace avec comme origine le Endpoint sur le plan précédent et on ajuste la vitesse de notre objet. MAXBUMPS permet simplement d'éviter des boucles infinies *************** *** 33,37 **** if (trace.AllSolid) { ! vVelocity.Null(); return; } --- 38,43 ---- if (trace.AllSolid) { ! //vVelocity.Null(); ! vVelocity.y = 0; return; } *************** *** 40,44 **** origin = trace.EndPoint; } ! if (trace.Fraction > (1.0f - EPSILON)) { break; --- 46,50 ---- origin = trace.EndPoint; } ! if (trace.Fraction == 1) { break; *************** *** 46,50 **** time_left -= time_left*trace.Fraction; ! ClipVelocity (vVelocity, trace.CollisionNormal); bumpcount++; } --- 52,88 ---- time_left -= time_left*trace.Fraction; ! ! pPlanes.push_back(trace.CollisionNormal); ! iNumPlanes++; ! ! for (i=0; i<iNumPlanes; i++) ! { ! ClipVelocity (vVelocity, trace.CollisionNormal); ! for (j=0; j<iNumPlanes; j++) ! if (j != i) ! { ! if (vVelocity*pPlanes[j] < 0) ! break; ! } ! if (j==iNumPlanes) ! break; ! } ! ! if (i != iNumPlanes) ! { ! } ! else ! { ! if (iNumPlanes != 2) ! { ! vVelocity = origin; ! break; ! } ! Vector3 dir = pPlanes[0]%pPlanes[1]; ! float d = dir*vVelocity; ! vVelocity = dir/d; ! } ! ! bumpcount++; } *************** *** 53,63 **** void PhysicEngine::ClipVelocity (Vector3& vel, const Vector3 norm) { ! /* le produit scalaire entre la vitesse et la normale nous donne ! l'angle de collision multiplie par la norme de la vitesse et de la normale ! "change" est la projection de la normale de collision sur la vitesse (grace a l'angle ! constituant backoff) multiplie par la norme de la normale de collision(1) et de la vitesse, ! faisant ainsi rebondir d'exactement ce qu'il faut. ! Overbounce nous permet d'avoir un rebond un peu plus grand que necessaire. ! */ float backoff = vel*norm*fOverBounce; Vector3 change = norm*backoff; --- 91,101 ---- void PhysicEngine::ClipVelocity (Vector3& vel, const Vector3 norm) { ! // le produit scalaire entre la vitesse et la normale nous donne ! // l'angle de collision multiplie par la norme de la vitesse et de la normale ! // "change" est la projection de la normale de collision sur la vitesse (grace a l'angle ! // constituant backoff) multiplie par la norme de la normale de collision(1) et de la vitesse, ! // faisant ainsi rebondir d'exactement ce qu'il faut. ! // Overbounce nous permet d'avoir un rebond un peu plus grand que necessaire. ! float backoff = vel*norm*fOverBounce; Vector3 change = norm*backoff; *************** *** 73,77 **** //ugly hackpour que le bOnGround ne bug pas sur les monstres //-> on différenci la taille du joueur et des autres objets pour être sur le sol ! #define PLAYER_HEIGHT 80 #define BASE_HEIGHT 15 #define STEPSIZE 10 --- 111,115 ---- //ugly hackpour que le bOnGround ne bug pas sur les monstres //-> on différenci la taille du joueur et des autres objets pour être sur le sol ! #define BASE_HEIGHT 15 #define STEPSIZE 10 *************** *** 79,86 **** { PhysicNode* n; - /*Vector3 vVeloc1; - Vector3 vVeloc2; - Vector3 pos1 = n->GetPosition(); - Vector3 pos2 = n->GetPosition();*/ for (unsigned int i=0; i<pNodes.size(); i++) --- 117,120 ---- *************** *** 112,116 **** 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 << n << "\t" ;*/ //std::cout << "OnGround : " << n->OnGround(); //std::cout << "Accel : \t" << n->GetAccel() << std::endl; --- 146,149 ---- Index: glrenderer.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/glrenderer.cc,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** glrenderer.cc 6 Nov 2004 17:05:39 -0000 1.13 --- glrenderer.cc 7 Nov 2004 11:27:47 -0000 1.14 *************** *** 1851,1860 **** glLineWidth (1); - glPushMatrix (); - float matrix[16]; - b->qRotation.GetMatrix(matrix); - glMultMatrixf (matrix); - - glColor3f(0,1,0); glPointSize(5); --- 1851,1854 ---- *************** *** 1879,1883 **** glEnable(GL_CULL_FACE); //RenderBSphere (b->vWorldBSCenter, b->fBSRadius); - glPopMatrix (); } --- 1873,1876 ---- Index: physicnode.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicnode.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** physicnode.cc 6 Nov 2004 17:05:39 -0000 1.4 --- physicnode.cc 7 Nov 2004 11:27:47 -0000 1.5 *************** *** 26,29 **** --- 26,32 ---- n->SetPosition(vPosition); n->SetRotation(qRotation); + pBBox->vMin = qRotation.Rotate(pBBox->vMin); + pBBox->vMax = qRotation.Rotate(pBBox->vMax); + pBBox->CalculatePlanes(); } } --- material.cc DELETED --- |
|
From: julien r. <jul...@us...> - 2004-11-06 18:21:31
|
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24849 Modified Files: game.cc pawn.cc pawn.h Log Message: backup Index: pawn.h =================================================================== RCS file: /cvsroot/epfl/tggame/pawn.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** pawn.h 28 Oct 2004 21:20:33 -0000 1.8 --- pawn.h 6 Nov 2004 17:05:51 -0000 1.9 *************** *** 22,26 **** /** * Constructeur - * @param Camera* un pointeur sur l'éventuelle caméra attachée à ce pawn */ Pawn (); --- 22,25 ---- Index: game.cc =================================================================== RCS file: /cvsroot/epfl/tggame/game.cc,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** game.cc 2 Nov 2004 15:41:43 -0000 1.25 --- game.cc 6 Nov 2004 17:05:51 -0000 1.26 *************** *** 104,110 **** //préchargement des meshes ! pEngine->pMeshManager->Load("pinky", "data/models/guardian/guardian.md5mesh"); ! pEngine->pMeshManager->LoadAnim("pinky", "data/models/guardian/death.md5anim"); Pawn* p = new Pawn(); pSceneManager->SetCamera(cam); --- 104,127 ---- //préchargement des meshes ! pEngine->pMeshManager->Load("guardian", "data/models/guardian/guardian.md5mesh"); ! pEngine->pMeshManager->LoadAnim("guardian", "data/models/guardian/death.md5anim"); ! pEngine->pMeshManager->Load("machinegun", "data/models/machinegun/viewmachinegun.md5mesh"); ! pEngine->pMeshManager->LoadAnim("machinegun", "data/models/machinegun/idle.md5anim"); ! ! pEngine->pMeshManager->LoadAnim("machinegun", "data/models/machinegun/fire4.md5anim"); ! pEngine->pMeshManager->Load("pinky", "data/models/zct/zct.md5mesh"); ! pEngine->pMeshManager->LoadAnim("pinky", "data/models/zct/zctidle.md5anim"); ! + MD5Instance* pModel = Engine::pMeshManager->LoadInstance("machinegun"); + pModel->SetAnimation("idle"); + pModel->bCamera = true; + Quaternion q(-90, Vector3(1,0,0)); + q *= Quaternion(90, Vector3(0,1,0)); + pModel->SetRotation(q); + + pModel->SetPosition(Vector3(5,0,-5)); + pSceneManager->AddWorldObject(pModel); + Pawn* p = new Pawn(); pSceneManager->SetCamera(cam); *************** *** 113,121 **** pLocalController = new PlayerController(p); vControllers.push_back(pLocalController); ! p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(20,80,20)); p->Attach (cam); ! p->SetPosition (Vector3(100,80,100)); ! p->GetBBox()->vMin = Vector3(-10, -70, -10); ! p->GetBBox()->vMax = Vector3(10,10,10); p->SetMoveSpeed (CAM_SPEED); p->SetVisible(false); --- 130,136 ---- pLocalController = new PlayerController(p); vControllers.push_back(pLocalController); ! //p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(20,80,20)); p->Attach (cam); ! p->SetPosition (Vector3(100,100,100)); p->SetMoveSpeed (CAM_SPEED); p->SetVisible(false); *************** *** 130,135 **** p->SetMoveSpeed(CAM_SPEED); p->SetVelocity(Vector3(0,0,0)); ! p->SetRotation(Quaternion(-90, Vector3(1,0,0))); ! p->SetPosition(Vector3(-550,100,250)); //p->SetRotationVelocity(Quaternion(10,Vector3(0,1,1))); --- 145,150 ---- p->SetMoveSpeed(CAM_SPEED); p->SetVelocity(Vector3(0,0,0)); ! //p->SetRotation(Quaternion(-90, Vector3(1,0,0))); ! //p->SetPosition(Vector3(-550,0,250)); //p->SetRotationVelocity(Quaternion(10,Vector3(0,1,1))); Index: pawn.cc =================================================================== RCS file: /cvsroot/epfl/tggame/pawn.cc,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** pawn.cc 2 Nov 2004 15:41:43 -0000 1.8 --- pawn.cc 6 Nov 2004 17:05:51 -0000 1.9 *************** *** 5,12 **** Pawn::Pawn() : Actor () { - //pModel = new Model ("data/models/pinky/pinky.mdl", MDL_PLAYER); - //pCamera = c; pModel = Engine::pMeshManager->LoadInstance("pinky"); ! pModel->SetAnimation("death"); pPhysic = new PhysicNode(pModel); pPhysic->SetClip(false); --- 5,10 ---- Pawn::Pawn() : Actor () { pModel = Engine::pMeshManager->LoadInstance("pinky"); ! pModel->SetAnimation("zctidle"); pPhysic = new PhysicNode(pModel); pPhysic->SetClip(false); |
|
From: julien r. <jul...@us...> - 2004-11-06 18:19:55
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24841 Modified Files: boundingbox.cc boundingbox.h engine.cc glrenderer.cc material.h md5instance.cc md5mesh10.cc md5mesh10.h physicengine.cc physicnode.cc q3bsp.cc q3bsp.h scenemanager.cc Log Message: backup Index: boundingbox.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/boundingbox.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** boundingbox.h 26 Sep 2004 13:15:22 -0000 1.1.1.1 --- boundingbox.h 6 Nov 2004 17:05:39 -0000 1.2 *************** *** 4,7 **** --- 4,8 ---- #include "vector3.h" #include "plane.h" + #include "quaternion.h" namespace tg *************** *** 26,29 **** --- 27,31 ---- Vector3 vWorldBSCenter; Vector3 vBSCenter; + Quaternion qRotation; float fBSRadius; *************** *** 42,46 **** * Trace un rayon à travers la BBox */ ! bool TraceRay (Vector3 begin, Vector3 end, Vector3& colPoint); --- 44,48 ---- * Trace un rayon à travers la BBox */ ! bool TraceRay (Vector3 begin, Vector3 end, Vector3& colPoint, Vector3& colNormal); Index: physicengine.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicengine.cc,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** physicengine.cc 1 Nov 2004 08:57:10 -0000 1.17 --- physicengine.cc 6 Nov 2004 17:05:39 -0000 1.18 *************** *** 153,157 **** float updist = sqrt(distx+distz); ! if (updist > dist) //on passe l'obstacle { //std::cout << "time : " << eTime << "\t" << vUpNewPos << std::endl; --- 153,157 ---- float updist = sqrt(distx+distz); ! /*if (updist > dist) //on passe l'obstacle { //std::cout << "time : " << eTime << "\t" << vUpNewPos << std::endl; *************** *** 165,172 **** } 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; --- 165,172 ---- } 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; *************** *** 174,178 **** n->GetPhysicCallBack()->Collide(NULL, Vector3(0,0,0), Vector3(0,0,0)); } ! } //Classification de la position --- 174,178 ---- n->GetPhysicCallBack()->Collide(NULL, Vector3(0,0,0), Vector3(0,0,0)); } ! }*/ //Classification de la position *************** *** 180,184 **** n->GetBBox()->vMin, n->GetBBox()->vMax); //si on met le allsolid, ca foire les mouvements sur les y ! if (col.Fraction < 1.0f /*|| col.AllSolid*/) n->SetOnGround(true); else --- 180,184 ---- n->GetBBox()->vMin, n->GetBBox()->vMax); //si on met le allsolid, ca foire les mouvements sur les y ! if (col.Fraction < 1.0f || col.AllSolid) n->SetOnGround(true); else *************** *** 204,208 **** result.EndPoint = mapResult.EndPoint; result.Normal = mapResult.CollisionNormal; ! //on trace ensuite sur les objets (mObjects) Vector3 colPoint(0,0,0); Vector3 colNormal(0,0,0); --- 204,208 ---- result.EndPoint = mapResult.EndPoint; result.Normal = mapResult.CollisionNormal; ! //on trace sur les objets Vector3 colPoint(0,0,0); Vector3 colNormal(0,0,0); *************** *** 211,215 **** for (unsigned int i=0; i<pNodes.size(); i++) { ! if (pNodes[i]->Trace(Begin, End, colPoint, colNormal)) { d1 = (colPoint - Begin).Magnitude(); d2 = (result.EndPoint - Begin).Magnitude(); --- 211,215 ---- for (unsigned int i=0; i<pNodes.size(); i++) { ! if (pNodes[i]->GetBBox()->TraceRay(Begin, End, colPoint, colNormal)) { d1 = (colPoint - Begin).Magnitude(); d2 = (result.EndPoint - Begin).Magnitude(); *************** *** 221,243 **** } } - /* Mesh* m = pFirstObject; - if (m != NULL) - { - do - { - if (m->Trace(Begin, End, colPoint, colNormal)) - { - //on regarde si le nouveau point de collision est plus proche de la caméra que l'ancien point de collision - d1 = (colPoint - pCamera->GetPosition()).Magnitude(); - d2 = (result.EndPoint - pCamera->GetPosition()).Magnitude(); - if ( d1 < d2 ) - { - result.EndPoint = colPoint; - result.Normal = colNormal; - result.pNode = m; - } - } - } while((m=m->GetNext()) != NULL); - }*/ return result; --- 221,224 ---- Index: scenemanager.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/scenemanager.cc,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** scenemanager.cc 2 Nov 2004 15:32:16 -0000 1.12 --- scenemanager.cc 6 Nov 2004 17:05:39 -0000 1.13 *************** *** 96,103 **** ! //Vector3 Target = pCamera->GetForward(); ! Vector3 Target = Vector3::UNIT_X; ! Target = pCamera->GetForward()+Target*100000; ! CollisionResult myResult = pPhysicEngine->Trace(pCamera->GetForward(), Target); glPointSize(5.0f); --- 96,104 ---- ! Vector3 vTarget = pCamera->GetRotation().GetZAxis(); ! Vector3 vPosition = pCamera->GetPosition(); ! vTarget = vPosition - vTarget*10000; ! ! CollisionResult myResult = pPhysicEngine->Trace(vPosition, vTarget); glPointSize(5.0f); *************** *** 130,134 **** #endif #ifdef DEBUG ! //Engine::pRenderer->RenderBBox(m->GetBBox()); #endif } --- 131,135 ---- #endif #ifdef DEBUG ! Engine::pRenderer->RenderBBox(m->GetBBox()); #endif } Index: q3bsp.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/q3bsp.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** q3bsp.h 21 Oct 2004 21:18:28 -0000 1.3 --- q3bsp.h 6 Nov 2004 17:05:39 -0000 1.4 *************** *** 431,434 **** --- 431,436 ---- bool IsVisible (int leaf); + + /** * CheckRayMove Index: physicnode.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicnode.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** physicnode.cc 28 Oct 2004 21:10:16 -0000 1.3 --- physicnode.cc 6 Nov 2004 17:05:39 -0000 1.4 *************** *** 31,35 **** void PhysicNode::CalculateBoundingVolume () { ! } --- 31,35 ---- void PhysicNode::CalculateBoundingVolume () { ! pBBox = vNodes[0]->GetBBox(); } Index: engine.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/engine.cc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** engine.cc 31 Oct 2004 22:15:40 -0000 1.6 --- engine.cc 6 Nov 2004 17:05:39 -0000 1.7 *************** *** 196,200 **** while (!done) { - //TODO: Remove this ugly hack and code a real event manager :-P while(SDL_PollEvent(&event)) { --- 196,199 ---- Index: md5mesh10.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5mesh10.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** md5mesh10.h 2 Nov 2004 15:32:16 -0000 1.4 --- md5mesh10.h 6 Nov 2004 17:05:39 -0000 1.5 *************** *** 8,11 **** --- 8,12 ---- #include "quaternion.h" #include "material.h" + #include "boundingbox.h" namespace tg *************** *** 65,69 **** inline int anim_GetNumAnimatedComponents(int i) { return pAnimations[i].iNumAnimatedComponents; } inline float anim_GetFrameElement (int i, int j, int k) { return pAnimations[i].pFrames[j][k]; } ! inline int anim_joint_GetParent (int i, int j) { return pAnimations[i].pJointInfos[j].iParent; } inline int anim_joint_GetFlags (int i, int j) { return pAnimations[i].pJointInfos[j].iFlags; } --- 66,70 ---- inline int anim_GetNumAnimatedComponents(int i) { return pAnimations[i].iNumAnimatedComponents; } inline float anim_GetFrameElement (int i, int j, int k) { return pAnimations[i].pFrames[j][k]; } ! inline BoundingBox* anim_GetBBox(int i,int j) { return &pAnimations[i].pBBox[j]; } inline int anim_joint_GetParent (int i, int j) { return pAnimations[i].pJointInfos[j].iParent; } inline int anim_joint_GetFlags (int i, int j) { return pAnimations[i].pJointInfos[j].iFlags; } *************** *** 129,132 **** --- 130,135 ---- }; _MD5JointInfos* pJointInfos; //un tableau de iNumJoints + + BoundingBox* pBBox; //un tableau de [iNumFrames] BoundingBox, une pour chaque frame }; Index: q3bsp.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/q3bsp.cc,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** q3bsp.cc 21 Oct 2004 21:18:28 -0000 1.8 --- q3bsp.cc 6 Nov 2004 17:05:39 -0000 1.9 *************** *** 1542,1693 **** } - /*void Q3Bsp::Trace (Vector3 vStart, Vector3 vEnd, float* fFraction, Vector3* vTraceEnd, bool* bStartsOut, bool* bAllSolid) - { - (*bStartsOut) = true; - (*bAllSolid) = false; - (*fFraction) = 1.0f; - - vInputStart = vStart; - vInputEnd = vEnd; - - CheckNode (0, 0.0f, 1.0f, vStart, vEnd, bStartsOut, bAllSolid, fFraction); - if ((*fFraction) == 1.0f) - (*vTraceEnd) = vEnd; - else - (*vTraceEnd) = vStart + (*fFraction)*(vEnd-vStart); - } - - void Q3Bsp::CheckNode (int iNodeIndex, float fStartFraction, float fEndFraction, Vector3 vStart, Vector3 vEnd, bool* bStartsOut, bool* bAllSolid, float* fFraction) - { - if ((*fFraction) < fStartFraction) - return; - - if (iNodeIndex < 0) // c'est une leaf - { - BspLeaf* leaf = &pLeafs[~iNodeIndex]; - for (int i=0; i<leaf->numOfLeafBrushes; i++) - { - BspBrush* brush = &pBrushes[pLeafBrushes[leaf->leafBrush + i]]; - if (brush->brushSides > 0) //il manque une verification des contents flags des textures - CheckBrush(brush, bStartsOut, bAllSolid, fFraction); - } - return; - } - //sinon, c'est un noeud - - BspNode* node=&pNodes[iNodeIndex]; - BspPlane* plane=&pPlanes[node->plane]; - //on cherche les distances au plan des points de départ et d'arrivée - float startDist = ( vStart*plane->vNormal ) - plane->d; - float endDist = ( vEnd*plane->vNormal ) - plane->d; - - if ( startDist >= 0 && endDist >= 0) //les points sont devant le plan - CheckNode( node->front, fStartFraction, fEndFraction, vStart, vEnd, bStartsOut, bAllSolid, fFraction ); - else if (startDist < 0 && endDist < 0) //les points sont derriere le plan - CheckNode( node->back, fStartFraction, fEndFraction, vStart, vEnd, bStartsOut, bAllSolid, fFraction ); - else //la ligne passe a travers le plan - { - int side1, side2; - float f1, f2, fm; - Vector3 vMid; - float invDist = 1.0f / (startDist - endDist); - //on choisit la portion du segment dont on va s'occuper en premier - if (startDist < endDist) //le point de depart est derriere le plan - { - side1 = node->back; - side2 = node->front; - f1 = (startDist - EPSILON)*invDist; - f2 = (startDist + EPSILON)*invDist; - } - else if (endDist < startDist) //c'est le point d'arrive qui est derrier le plan - { - side1 = node->front; - side2 = node->back; - f1 = (startDist + EPSILON)*invDist; - f2 = (startDist - EPSILON)*invDist; - } - else - { - side1 = node->front; - side2 = node->back; - f1 = 1.0f; - f2 = 0.0f; - } - - - if ( f1 < 0.0f ) f1 = 0.0f; - else if ( f1 > 1.0f ) f1 = 1.0f; - if ( f2 < 0.0f ) f2 = 0.0f; - else if ( f2 > 1.0f ) f2 = 1.0f; - - //on calcul le point milieu du premier cote - fm = fStartFraction + f1*(fEndFraction - fStartFraction); - vMid = vStart + f1*(vEnd-vStart); - - CheckNode(side1, fStartFraction, fm, vStart, vMid, bStartsOut, bAllSolid, fFraction); - - //on calcul le point milieu du second cote - fm = fStartFraction + f2*(fEndFraction - fStartFraction); - vMid = vStart + f2*(vEnd-vStart); - - CheckNode(side2, fm, fEndFraction, vMid, vEnd, bStartsOut, bAllSolid, fFraction); - - } - } - - void Q3Bsp::CheckBrush (BspBrush* brush, bool* bStartsOut, bool* bAllSolid, float* fFraction) - { - float startFraction = -1.0f; - float endFraction = 1.0f; - bool startsOut = false; - bool endsOut = false; - - for (int i=0; i<brush->numOfBrushSides; i++) - { - BspBrushSide* brushSide = &pBrushSides[brush->brushSides + i]; - BspPlane* plane = &pPlanes[brushSide->plane]; - //calcul des distances au plan - float startDist = vInputStart*plane->vNormal - plane->d; - float endDist = vInputEnd*plane->vNormal - plane->d; - - if (startDist > 0 ) - startsOut = true; - if (endDist > 0 ) - endsOut = true; - - if (startsOut && endsOut) //le rayon n'est pas sur ce brush - return; - if (startDist <= 0 && endDist <= 0) //le rayon est derriere ce plan, il sera en collision avec d'autres plans du meme brush - continue; - - if (startDist > endDist) //le rayon entre dans le brush - { - float fraction = (startDist - EPSILON) / (startDist - endDist); - if (fraction > startFraction) - startFraction = fraction; - } - else //le rayon sort du brush - { - float fraction = (startDist + EPSILON) / (startDist - endDist); - if (fraction < endFraction) - endFraction = fraction; - } - } - - if (!startsOut) - { - (*bStartsOut) = false; - if (!endsOut) - (*bAllSolid) = true; - return; - } - - if (startFraction < endFraction) - if (startFraction > -1 && startFraction < (*fFraction)) - { - if (startFraction < 0) startFraction = 0; - (*fFraction = startFraction); - } - }*/ - }//END tg --- 1542,1544 ---- Index: material.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/material.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** material.h 26 Sep 2004 13:15:12 -0000 1.1.1.1 --- material.h 6 Nov 2004 17:05:39 -0000 1.2 *************** *** 11,15 **** { public: ! Material (); void SetFirstTexture (Texture* p) { pTex1 = p; } void SetSecondTexture (Texture* p) { pTex2 = p; } --- 11,15 ---- { public: ! Material () { pTex1 = pTex2 = pNormal = NULL; } void SetFirstTexture (Texture* p) { pTex1 = p; } void SetSecondTexture (Texture* p) { pTex2 = p; } Index: glrenderer.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/glrenderer.cc,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** glrenderer.cc 2 Nov 2004 15:32:15 -0000 1.12 --- glrenderer.cc 6 Nov 2004 17:05:39 -0000 1.13 *************** *** 1066,1093 **** glTranslatef(mesh->GetPosition().x, mesh->GetPosition().y, mesh->GetPosition().z); #ifdef DEBUG ! Vector3 fwd, rgt, up; ! //mesh->GetRotation().ToAngleVectors(fwd, rgt, up); ! //fwd = mesh->GetRotation().GetXAxis(); ! //rgt = mesh->GetRotation().GetZAxis(); ! //up = mesh->GetRotation().GetYAxis(); ! fwd = mesh->GetRotation().Rotate(Vector3::UNIT_X); ! rgt = mesh->GetRotation().Rotate(Vector3::UNIT_Z); ! up = mesh->GetRotation().Rotate(Vector3::UNIT_Y); ! fwd *= 10; ! rgt *= 10; ! up *= 10; ! glBegin (GL_LINES); ! glColor3f (1,0,0); ! glVertex3f (0,0,0); ! glVertex3fv (&fwd.x); ! ! glColor3f(0,0,1); ! glVertex3f (0,0,0); ! glVertex3fv (&rgt.x); ! ! glColor3f(0,1,0); ! glVertex3f (0,0,0); ! glVertex3fv (&up.x); ! glEnd (); #endif --- 1066,1095 ---- glTranslatef(mesh->GetPosition().x, mesh->GetPosition().y, mesh->GetPosition().z); #ifdef DEBUG ! if (!mesh->bCamera) { ! Vector3 fwd, rgt, up; ! //mesh->GetRotation().ToAngleVectors(fwd, rgt, up); ! //fwd = mesh->GetRotation().GetXAxis(); ! //rgt = mesh->GetRotation().GetZAxis(); ! //up = mesh->GetRotation().GetYAxis(); ! fwd = mesh->GetRotation().Rotate(Vector3::UNIT_X); ! rgt = mesh->GetRotation().Rotate(Vector3::UNIT_Z); ! up = mesh->GetRotation().Rotate(Vector3::UNIT_Y); ! fwd *= 10; ! rgt *= 10; ! up *= 10; ! glBegin (GL_LINES); ! glColor3f (1,0,0); ! glVertex3f (0,0,0); ! glVertex3fv (&fwd.x); ! ! glColor3f(0,0,1); ! glVertex3f (0,0,0); ! glVertex3fv (&rgt.x); ! ! glColor3f(0,1,0); ! glVertex3f (0,0,0); ! glVertex3fv (&up.x); ! glEnd (); ! } #endif *************** *** 1849,1852 **** --- 1851,1860 ---- glLineWidth (1); + glPushMatrix (); + float matrix[16]; + b->qRotation.GetMatrix(matrix); + glMultMatrixf (matrix); + + glColor3f(0,1,0); glPointSize(5); *************** *** 1871,1874 **** --- 1879,1883 ---- glEnable(GL_CULL_FACE); //RenderBSphere (b->vWorldBSCenter, b->fBSRadius); + glPopMatrix (); } Index: md5mesh10.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5mesh10.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** md5mesh10.cc 2 Nov 2004 15:32:16 -0000 1.5 --- md5mesh10.cc 6 Nov 2004 17:05:39 -0000 1.6 *************** *** 1 **** ! #include "md5mesh10.h" #include "quaternion.h" namespace tg { MD5Mesh10::MD5Mesh10 () { pAnimations.clear(); } MD5Mesh10::~ MD5Mesh10() { delete [] pJoints; for (int i=0; i<iNumMeshes; i++) { delete [] pMeshes[i].pVerts; delete [] pMeshes[i].pTriangles; delete [] pMeshes[i].pIndexes; delete [] pMeshes[i].pWeights; } delete [] pMeshes; for (unsigned int i=0; i<pAnimations.size(); i++) { for (int j=0; j<pAnimations[i].iNumJoints; j++) delete [] pAnimations[i].pBaseFrame[j]; delete [] pAnimations[i].pBaseFrame; delete [] pAnimations[i].pJointInfos; for (int j=0; j<pAnimations[i].iNumFrames; j++) delete [] pAnimations[i].pFrames[j]; delete [] pAnimations[i].pFrames; } pAnimations.clear(); } #define NEXT(str) while(buffer.find(str)==std::string::npos) \ pFD >> buffer; bool MD5Mesh10::LoadMesh(char* str) { std::ifstream pFD; std::string buffer; int version; std::cout << "[TGE] Chargement de " << str << std::endl; pFD.open(str, std::ios::in); if (pFD.fail()) { std::cerr << "[TGE] Erreur lors de l'ouverture de " << str << std::endl; return false; } pFD >> buffer; pFD >> version; if (version != 10) { std::cerr << "[TGE] Mauvaise version : " << version << std::endl; return false; } NEXT("numJoints") pFD >> iNumJoints; NEXT("numMeshes") pFD >> iNumMeshes; iNumBaseJoints = 0; pJoints = new _MD5Joint[iNumJoints]; for (int i=0; i<iNumJoints; i++) { NEXT("\"") pJoints[i].sName = buffer; //std::cout << pJoints[i].sName << std::endl; Quaternion q; //pFD >> pJoints[i].iNumber; pFD >> pJoints[i].iParent; if (pJoints[i].iParent < 0) iNumBaseJoints++; NEXT("(") pFD >> pJoints[i].vPosition.x >> pJoints[i].vPosition.y >> pJoints[i].vPosition.z; //Util::ChangeCoords(pJoints[i].vPosition); //ChangeCoords(pJoints[i].vPosition); NEXT(")") NEXT("(") pFD >> q.x >> q.y >> q.z; //Util::ChangeCoords(q.x, q.y, q.z); q.ComputeR(); pJoints[i].qOrientation = q; //Util::QuaternionToMatrix33(q,pJoints[i].mOrientation); } pMeshes = new _MD5Mesh[iNumMeshes]; for (int i=0; i<iNumMeshes; i++) { NEXT("shader") std::string sTmp; pFD >> sTmp; int iLastSlash = sTmp.find_last_of("/"); int iLastQuote = sTmp.find_last_of("\""); iLastSlash += 1; //on veut le caractere juste apres le dernier slash sTmp.erase(iLastQuote); pMeshes[i].sNormal = "data/textures/models/"+sTmp.substr(iLastSlash); pMeshes[i].sColor = pMeshes[i].sNormal+"_color.bmp"; pMeshes[i].sNormal += ".bmp"; //pMeshes[i].sNormal = "data/notexture.bmp"; //pMeshes[i].sColor = "data/notexture.bmp"; pMeshes[i].pMaterial = new Material (); Texture* tmpTex = new Texture (); tmpTex->LoadBMP((char*)pMeshes[i].sNormal.data(), TG_TEXTURE_2D); pMeshes[i].pMaterial->SetNormalTexture(tmpTex); tmpTex = new Texture(); tmpTex->LoadBMP((char*)pMeshes[i].sColor.data(), TG_TEXTURE_2D); pMeshes[i].pMaterial->SetFirstTexture(tmpTex); NEXT("numverts") pFD >> pMeshes[i].iNumVerts; pFD >> buffer; //sans ca, le NEXT("vert") ne va pas bouger car vert est deja dans numverts pMeshes[i].pVerts = new _MD5Vert[pMeshes[i].iNumVerts]; for (int j=0; j<pMeshes[i].iNumVerts; j++) { _MD5Vert& vert = pMeshes[i].pVerts[j]; NEXT("vert") NEXT("(") pFD >> vert.pTexCoords[0] >>vert.pTexCoords[1]; vert.pTexCoords[1] = 1 - vert.pTexCoords[1]; NEXT(")") pFD >> vert.iWeightIndex >> vert.iNumWeights; } NEXT("numtris") pFD >> pMeshes[i].iNumTris; pMeshes[i].pTriangles = new _MD5Triangle[pMeshes[i].iNumTris]; pMeshes[i].pIndexes = new unsigned int[pMeshes[i].iNumTris*3]; int iC = 0; pFD >> buffer; //sans ca, le NEXT("tri") ne va pas bouger car tri est deja dans numtris for (int j=0; j<pMeshes[i].iNumTris; j++) { _MD5Triangle& tri = pMeshes[i].pTriangles[j]; NEXT("tri") pFD >> buffer; pFD >> tri.pIndex[0] >> tri.pIndex[1] >> tri.pIndex[2]; pMeshes[i].pIndexes[iC] = pMeshes[i].pTriangles[j].pIndex[0]; iC++; pMeshes[i].pIndexes[iC] = pMeshes[i].pTriangles[j].pIndex[1]; iC++; pMeshes[i].pIndexes[iC] = pMeshes[i].pTriangles[j].pIndex[2]; iC++; } NEXT("numweights") pFD >> pMeshes[i].iNumWeights; pFD >> buffer; // sans ca, le NEXT("weight") foire pMeshes[i].pWeights = new _MD5Weight[pMeshes[i].iNumWeights]; for (int j=0; j<pMeshes[i].iNumWeights; j++) { _MD5Weight& w = pMeshes[i].pWeights[j]; NEXT("weight") pFD >> buffer; pFD >> w.iBoneIndex >> w.fBias; NEXT("(") pFD >> w.vWeights.x >> w.vWeights.y >> w.vWeights.z; //Util::ChangeCoords(w.vWeights); } } std::cout << "[TGE] Chargement de " << str << " termine" << std::endl; return true; } bool MD5Mesh10::LoadAnim(char* str) { _MD5Anim anim; //on garde juste le nom de l'animation std::string sTemp = std::string(str); int iLastSlash = sTemp.find_last_of("/"); int iLastPoint = sTemp.find_last_of("."); sTemp.erase(iLastPoint); anim.sName = sTemp.substr(iLastSlash+1); std::cout << "[TGE] anim name : " << anim.sName << std::endl; std::ifstream pFD; std::string buffer; int version; std::cout << "[TGE] Chargement de " << str << std::endl; pFD.open(str, std::ios::in); if (pFD.fail()) { std::cerr << "[TGE] Erreur lors de l'ouverture de " << str << std::endl; return false; } pFD >> buffer; pFD >> version; if (version != 10) { std::cerr << "[TGE] Mauvaise version : " << version << std::endl; return false; } NEXT("numFrames") pFD >> anim.iNumFrames; NEXT("numJoints") pFD >> anim.iNumJoints; NEXT("frameRate") pFD >> anim.iFrameRate; NEXT("numAnimatedComponents") pFD >> anim.iNumAnimatedComponents; anim.pFrames = new float*[anim.iNumFrames]; for (int i=0; i<anim.iNumFrames; i++) anim.pFrames[i] = new float[anim.iNumAnimatedComponents]; anim.pJointInfos = new _MD5Anim::_MD5JointInfos[anim.iNumJoints]; anim.pBaseFrame = new float*[anim.iNumJoints]; //FIXME: a priori, il n'y a pas de md5mesh ou la hierarchie de l'anim est different du md5mesh. Ceci dit, on peut peut-etre utiliser ca pour demembrer ou autre NEXT("hierarchy") for (int i=0; i<anim.iNumJoints; i++) { NEXT("\"") buffer = ""; pFD >> anim.pJointInfos[i].iParent; pFD >> anim.pJointInfos[i].iFlags; pFD >> anim.pJointInfos[i].iStartIndex; } //chargement de baseframe NEXT("baseframe") for (int i=0; i<anim.iNumJoints; i++) { anim.pBaseFrame[i] = new float[6]; NEXT("(") pFD >> anim.pBaseFrame[i][0]; pFD >> anim.pBaseFrame[i][1]; pFD >> anim.pBaseFrame[i][2]; NEXT(")") NEXT("(") pFD >> anim.pBaseFrame[i][3]; pFD >> anim.pBaseFrame[i][4]; pFD >> anim.pBaseFrame[i][5]; NEXT(")") } //chargement des frames for (int i=0; i<anim.iNumFrames; i++) { NEXT("frame") NEXT("{") for (int j=0; j<anim.iNumAnimatedComponents; j++) pFD >> anim.pFrames[i][j]; NEXT("}") } pAnimations.push_back(anim); std::cout << "[TGE] Chargement de " << str << " termine" << std::endl; return true; } int MD5Mesh10::GetAnimIndex(const std::string& name) { int size = pAnimations.size(); for (int i=0; i<size; i++) { if (pAnimations[i].sName == name) return i; } return -1; } } \ No newline at end of file --- 1,300 ---- ! #include "md5mesh10.h" ! #include "quaternion.h" ! ! namespace tg ! { ! ! MD5Mesh10::MD5Mesh10 () ! { ! pAnimations.clear(); ! } ! ! MD5Mesh10::~ MD5Mesh10() ! { ! delete [] pJoints; ! for (int i=0; i<iNumMeshes; i++) ! { ! delete [] pMeshes[i].pVerts; ! delete [] pMeshes[i].pTriangles; ! delete [] pMeshes[i].pIndexes; ! delete [] pMeshes[i].pWeights; ! } ! delete [] pMeshes; ! for (unsigned int i=0; i<pAnimations.size(); i++) ! { ! for (int j=0; j<pAnimations[i].iNumJoints; j++) ! delete [] pAnimations[i].pBaseFrame[j]; ! delete [] pAnimations[i].pBaseFrame; ! delete [] pAnimations[i].pJointInfos; ! ! for (int j=0; j<pAnimations[i].iNumFrames; j++) ! delete [] pAnimations[i].pFrames[j]; ! delete [] pAnimations[i].pFrames; ! ! } ! pAnimations.clear(); ! } ! ! #define NEXT(str) while(buffer.find(str)==std::string::npos) \ ! pFD >> buffer; ! ! bool MD5Mesh10::LoadMesh(char* str) ! { ! std::ifstream pFD; ! std::string buffer; ! int version; ! ! std::cout << "[TGE] Chargement de " << str << std::endl; ! ! pFD.open(str, std::ios::in); ! ! if (pFD.fail()) ! { ! std::cerr << "[TGE] Erreur lors de l'ouverture de " << str << std::endl; ! return false; ! } ! ! pFD >> buffer; ! pFD >> version; ! ! if (version != 10) ! { ! std::cerr << "[TGE] Mauvaise version : " << version << std::endl; ! return false; ! } ! ! NEXT("numJoints") ! pFD >> iNumJoints; ! ! NEXT("numMeshes") ! pFD >> iNumMeshes; ! ! iNumBaseJoints = 0; ! pJoints = new _MD5Joint[iNumJoints]; ! ! for (int i=0; i<iNumJoints; i++) ! { ! NEXT("\"") ! pJoints[i].sName = buffer; ! //std::cout << pJoints[i].sName << std::endl; ! Quaternion q; ! //pFD >> pJoints[i].iNumber; ! pFD >> pJoints[i].iParent; ! if (pJoints[i].iParent < 0) ! iNumBaseJoints++; ! NEXT("(") ! pFD >> pJoints[i].vPosition.x >> pJoints[i].vPosition.y >> pJoints[i].vPosition.z; ! ! //Util::ChangeCoords(pJoints[i].vPosition); ! //ChangeCoords(pJoints[i].vPosition); ! ! NEXT(")") ! NEXT("(") ! pFD >> q.x >> q.y >> q.z; ! //Util::ChangeCoords(q.x, q.y, q.z); ! ! q.ComputeR(); ! ! pJoints[i].qOrientation = q; ! //Util::QuaternionToMatrix33(q,pJoints[i].mOrientation); ! } ! pMeshes = new _MD5Mesh[iNumMeshes]; ! for (int i=0; i<iNumMeshes; i++) ! { ! NEXT("shader") ! std::string sTmp; ! pFD >> sTmp; ! int iLastSlash = sTmp.find_last_of("/"); ! int iLastQuote = sTmp.find_last_of("\""); ! iLastSlash += 1; //on veut le caractere juste apres le dernier slash ! sTmp.erase(iLastQuote); ! pMeshes[i].sNormal = "data/textures/models/"+sTmp.substr(iLastSlash); ! pMeshes[i].sColor = pMeshes[i].sNormal+"_color.bmp"; ! pMeshes[i].sNormal += ".bmp"; ! //pMeshes[i].sNormal = "data/notexture.bmp"; ! //pMeshes[i].sColor = "data/notexture.bmp"; ! ! pMeshes[i].pMaterial = new Material (); ! Texture* tmpTex = new Texture (); ! tmpTex->LoadBMP((char*)pMeshes[i].sNormal.data(), TG_TEXTURE_2D); ! pMeshes[i].pMaterial->SetNormalTexture(tmpTex); ! tmpTex = new Texture(); ! tmpTex->LoadBMP((char*)pMeshes[i].sColor.data(), TG_TEXTURE_2D); ! pMeshes[i].pMaterial->SetFirstTexture(tmpTex); ! ! ! NEXT("numverts") ! pFD >> pMeshes[i].iNumVerts; ! pFD >> buffer; //sans ca, le NEXT("vert") ne va pas bouger car vert est deja dans numverts ! ! pMeshes[i].pVerts = new _MD5Vert[pMeshes[i].iNumVerts]; ! for (int j=0; j<pMeshes[i].iNumVerts; j++) ! { ! _MD5Vert& vert = pMeshes[i].pVerts[j]; ! NEXT("vert") ! NEXT("(") ! pFD >> vert.pTexCoords[0] >>vert.pTexCoords[1]; ! vert.pTexCoords[1] = 1 - vert.pTexCoords[1]; ! NEXT(")") ! pFD >> vert.iWeightIndex >> vert.iNumWeights; ! ! } ! NEXT("numtris") ! pFD >> pMeshes[i].iNumTris; ! ! pMeshes[i].pTriangles = new _MD5Triangle[pMeshes[i].iNumTris]; ! pMeshes[i].pIndexes = new unsigned int[pMeshes[i].iNumTris*3]; ! int iC = 0; ! pFD >> buffer; //sans ca, le NEXT("tri") ne va pas bouger car tri est deja dans numtris ! for (int j=0; j<pMeshes[i].iNumTris; j++) ! { ! _MD5Triangle& tri = pMeshes[i].pTriangles[j]; ! NEXT("tri") ! pFD >> buffer; ! pFD >> tri.pIndex[0] >> tri.pIndex[1] >> tri.pIndex[2]; ! ! pMeshes[i].pIndexes[iC] = pMeshes[i].pTriangles[j].pIndex[0]; ! iC++; ! pMeshes[i].pIndexes[iC] = pMeshes[i].pTriangles[j].pIndex[1]; ! iC++; ! pMeshes[i].pIndexes[iC] = pMeshes[i].pTriangles[j].pIndex[2]; ! iC++; ! } ! ! NEXT("numweights") ! pFD >> pMeshes[i].iNumWeights; ! pFD >> buffer; // sans ca, le NEXT("weight") foire ! pMeshes[i].pWeights = new _MD5Weight[pMeshes[i].iNumWeights]; ! for (int j=0; j<pMeshes[i].iNumWeights; j++) ! { ! _MD5Weight& w = pMeshes[i].pWeights[j]; ! NEXT("weight") ! pFD >> buffer; ! pFD >> w.iBoneIndex >> w.fBias; ! NEXT("(") ! pFD >> w.vWeights.x >> w.vWeights.y >> w.vWeights.z; ! //Util::ChangeCoords(w.vWeights); ! } ! } ! ! std::cout << "[TGE] Chargement de " << str << " termine" << std::endl; ! return true; ! ! } ! ! bool MD5Mesh10::LoadAnim(char* str) ! { ! _MD5Anim anim; ! //on garde juste le nom de l'animation ! std::string sTemp = std::string(str); ! int iLastSlash = sTemp.find_last_of("/"); ! int iLastPoint = sTemp.find_last_of("."); ! sTemp.erase(iLastPoint); ! anim.sName = sTemp.substr(iLastSlash+1); ! std::cout << "[TGE] anim name : " << anim.sName << std::endl; ! ! std::ifstream pFD; ! std::string buffer; ! int version; ! ! std::cout << "[TGE] Chargement de " << str << std::endl; ! ! pFD.open(str, std::ios::in); ! ! if (pFD.fail()) ! { ! std::cerr << "[TGE] Erreur lors de l'ouverture de " << str << std::endl; ! return false; ! } ! ! pFD >> buffer; ! pFD >> version; ! ! if (version != 10) ! { ! std::cerr << "[TGE] Mauvaise version : " << version << std::endl; ! return false; ! } ! ! NEXT("numFrames") ! pFD >> anim.iNumFrames; ! NEXT("numJoints") ! pFD >> anim.iNumJoints; ! NEXT("frameRate") ! pFD >> anim.iFrameRate; ! NEXT("numAnimatedComponents") ! pFD >> anim.iNumAnimatedComponents; ! ! anim.pFrames = new float*[anim.iNumFrames]; ! for (int i=0; i<anim.iNumFrames; i++) ! anim.pFrames[i] = new float[anim.iNumAnimatedComponents]; ! ! anim.pJointInfos = new _MD5Anim::_MD5JointInfos[anim.iNumJoints]; ! ! anim.pBaseFrame = new float*[anim.iNumJoints]; ! ! //FIXME: a priori, il n'y a pas de md5mesh ou la hierarchie de l'anim est different du md5mesh. Ceci dit, on peut peut-etre utiliser ca pour demembrer ou autre ! NEXT("hierarchy") ! for (int i=0; i<anim.iNumJoints; i++) ! { ! NEXT("\"") ! buffer = ""; ! pFD >> anim.pJointInfos[i].iParent; ! pFD >> anim.pJointInfos[i].iFlags; ! pFD >> anim.pJointInfos[i].iStartIndex; ! } ! ! anim.pBBox = new BoundingBox[anim.iNumFrames]; ! NEXT("bounds") ! for (int i=0; i<anim.iNumFrames; i++) ! { ! NEXT("(") ! pFD >> anim.pBBox[i].vMin.x >> anim.pBBox[i].vMin.y >> anim.pBBox[i].vMin.z; ! NEXT(")") ! NEXT("(") ! pFD >> anim.pBBox[i].vMax.x >> anim.pBBox[i].vMax.y >> anim.pBBox[i].vMax.z; ! NEXT(")") ! ! } ! ! //chargement de baseframe ! NEXT("baseframe") ! for (int i=0; i<anim.iNumJoints; i++) ! { ! anim.pBaseFrame[i] = new float[6]; ! NEXT("(") ! pFD >> anim.pBaseFrame[i][0]; ! pFD >> anim.pBaseFrame[i][1]; ! pFD >> anim.pBaseFrame[i][2]; ! NEXT(")") ! NEXT("(") ! pFD >> anim.pBaseFrame[i][3]; ! pFD >> anim.pBaseFrame[i][4]; ! pFD >> anim.pBaseFrame[i][5]; ! NEXT(")") ! } ! //chargement des frames ! for (int i=0; i<anim.iNumFrames; i++) ! { ! NEXT("frame") ! NEXT("{") ! for (int j=0; j<anim.iNumAnimatedComponents; j++) ! pFD >> anim.pFrames[i][j]; ! NEXT("}") ! } ! pAnimations.push_back(anim); ! std::cout << "[TGE] Chargement de " << str << " termine" << std::endl; ! return true; ! } ! ! int MD5Mesh10::GetAnimIndex(const std::string& name) ! { ! int size = pAnimations.size(); ! for (int i=0; i<size; i++) { ! if (pAnimations[i].sName == name) ! return i; ! } ! return -1; ! } ! ! } Index: md5instance.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5instance.cc,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** md5instance.cc 2 Nov 2004 16:30:54 -0000 1.8 --- md5instance.cc 6 Nov 2004 17:05:39 -0000 1.9 *************** *** 139,142 **** --- 139,146 ---- } _SkinMesh(); + + //Doit-on le faire ici ?? + pBBox = pData->anim_GetBBox(iCurrentAnimation, iFrame); + pBBox->qRotation = qRotation; } Index: boundingbox.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/boundingbox.cc,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** boundingbox.cc 26 Sep 2004 13:15:22 -0000 1.1.1.1 --- boundingbox.cc 6 Nov 2004 17:05:39 -0000 1.2 *************** *** 93,97 **** } ! bool BoundingBox::TraceRay (Vector3 begin, Vector3 end, Vector3& colPoint) { float startFraction = -1.0f; --- 93,97 ---- } ! bool BoundingBox::TraceRay (Vector3 begin, Vector3 end, Vector3& colPoint, Vector3& colNormal) { float startFraction = -1.0f; *************** *** 139,160 **** } return false; - - /*bool b_inside=true; //le point de depart est dedans - bool e_inside=true; //le point d'arrive est dedans - - for (unsigned int i=0; i<6; i++) - { - int b = pPlanes[i].ClassifyPoint(begin); - int e = pPlanes[i].ClassifyPoint(end); - if (b != POINT_BEHIND_PLANE) //si le point n'est pas derriere l'un des plans, il est en dehors de la boite - b_inside = false; - if (e != POINT_BEHIND_PLANE) - e_inside = false; - - } - - if (!b_inside && !e_inside) - return false; - return true;*/ } --- 139,142 ---- |
|
From: julien r. <jul...@us...> - 2004-11-02 16:31:57
|
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5691 Modified Files: Makefile Makefile.Linux Log Message: Index: Makefile =================================================================== RCS file: /cvsroot/epfl/tggame/Makefile,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Makefile 2 Nov 2004 15:41:43 -0000 1.8 --- Makefile 2 Nov 2004 16:31:40 -0000 1.9 *************** *** 14,18 **** linuxDebug: ! make -f Makefile.Linux "CFLAGS = -ggdb -DDEBUG -DTGLINUX -pg" osx: --- 14,18 ---- linuxDebug: ! make -f Makefile.Linux "CFLAGS = -ggdb -DDEBUG -DTGLINUX" osx: Index: Makefile.Linux =================================================================== RCS file: /cvsroot/epfl/tggame/Makefile.Linux,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Makefile.Linux 10 Oct 2004 20:54:47 -0000 1.4 --- Makefile.Linux 2 Nov 2004 16:31:40 -0000 1.5 *************** *** 13,17 **** all: $(OBJS) ! g++ -o tg $(INCLUDEPATH) $(LINKPATH) $(LIBS) $(OBJS) clean: --- 13,17 ---- all: $(OBJS) ! g++ -o tg $(INCLUDEPATH) $(LINKPATH) $(LIBS) $(OBJS) clean: |
|
From: julien r. <jul...@us...> - 2004-11-02 16:31:05
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5486 Modified Files: Makefile.Linux md5instance.cc quaternion.cc quaternion.h Log Message: MD5 Animation optimization Index: Makefile.Linux =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/Makefile.Linux,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Makefile.Linux 2 Nov 2004 15:32:15 -0000 1.4 --- Makefile.Linux 2 Nov 2004 16:30:54 -0000 1.5 *************** *** 1,4 **** ## TG Engine Makefile - # Ajoutez -DTGHIGHDEF pour construire la version haute resolution (stencil shadows, dot3 bump) ## --- 1,3 ---- Index: quaternion.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/quaternion.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** quaternion.cc 2 Nov 2004 15:32:16 -0000 1.3 --- quaternion.cc 2 Nov 2004 16:30:54 -0000 1.4 *************** *** 247,250 **** --- 247,252 ---- } + const Quaternion Quaternion::UNIT(1,0,0,0); + } //END tg Index: quaternion.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/quaternion.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** quaternion.h 2 Nov 2004 15:32:16 -0000 1.4 --- quaternion.h 2 Nov 2004 16:30:54 -0000 1.5 *************** *** 105,109 **** */ void SetRotation (float, float, float, float); ! }; --- 105,110 ---- */ void SetRotation (float, float, float, float); ! ! static const Quaternion UNIT; }; Index: md5instance.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5instance.cc,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** md5instance.cc 2 Nov 2004 15:32:15 -0000 1.7 --- md5instance.cc 2 Nov 2004 16:30:54 -0000 1.8 *************** *** 135,141 **** //glPushMatrix(); //glLoadIdentity(); ! Quaternion q; ! Vector3 v(0,0,0); ! _BuildBone(iFrame, pBaseJoints[i], q, v); //glPopMatrix(); } --- 135,139 ---- //glPushMatrix(); //glLoadIdentity(); ! _BuildBone(iFrame, pBaseJoints[i], Quaternion::UNIT, Vector3::ZERO); //glPopMatrix(); } |
|
From: julien r. <jul...@us...> - 2004-11-02 15:41:53
|
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27438 Modified Files: Makefile aicontroller.cc game.cc pawn.cc Log Message: md5 animation Index: Makefile =================================================================== RCS file: /cvsroot/epfl/tggame/Makefile,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Makefile 10 Oct 2004 20:54:47 -0000 1.7 --- Makefile 2 Nov 2004 15:41:43 -0000 1.8 *************** *** 11,15 **** linux: ! make -f Makefile.Linux linuxDebug: --- 11,15 ---- linux: ! make -f Makefile.Linux "CFLAGS = -O3 -DTGLINUX" linuxDebug: Index: game.cc =================================================================== RCS file: /cvsroot/epfl/tggame/game.cc,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** game.cc 1 Nov 2004 18:01:47 -0000 1.24 --- game.cc 2 Nov 2004 15:41:43 -0000 1.25 *************** *** 104,108 **** //préchargement des meshes ! pEngine->pMeshManager->Load("pinky", "data/models/pinky/pinky.md5mesh"); Pawn* p = new Pawn(); --- 104,109 ---- //préchargement des meshes ! pEngine->pMeshManager->Load("pinky", "data/models/guardian/guardian.md5mesh"); ! pEngine->pMeshManager->LoadAnim("pinky", "data/models/guardian/death.md5anim"); Pawn* p = new Pawn(); *************** *** 129,133 **** p->SetMoveSpeed(CAM_SPEED); p->SetVelocity(Vector3(0,0,0)); ! p->SetPosition(Vector3(50,70,0)); //p->SetRotationVelocity(Quaternion(10,Vector3(0,1,1))); --- 130,135 ---- p->SetMoveSpeed(CAM_SPEED); p->SetVelocity(Vector3(0,0,0)); ! p->SetRotation(Quaternion(-90, Vector3(1,0,0))); ! p->SetPosition(Vector3(-550,100,250)); //p->SetRotationVelocity(Quaternion(10,Vector3(0,1,1))); Index: aicontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/aicontroller.cc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** aicontroller.cc 31 Oct 2004 11:40:44 -0000 1.6 --- aicontroller.cc 2 Nov 2004 15:41:43 -0000 1.7 *************** *** 40,44 **** //pPawn->SetRotation(Quaternion(rot++, Vector3::UNIT_Y)); //rot=rot%360; ! bDir[STRAFELEFT]=1; } --- 40,44 ---- //pPawn->SetRotation(Quaternion(rot++, Vector3::UNIT_Y)); //rot=rot%360; ! //bDir[STRAFELEFT]=1; } Index: pawn.cc =================================================================== RCS file: /cvsroot/epfl/tggame/pawn.cc,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** pawn.cc 1 Nov 2004 18:01:47 -0000 1.7 --- pawn.cc 2 Nov 2004 15:41:43 -0000 1.8 *************** *** 8,12 **** --- 8,14 ---- //pCamera = c; pModel = Engine::pMeshManager->LoadInstance("pinky"); + pModel->SetAnimation("death"); pPhysic = new PhysicNode(pModel); + pPhysic->SetClip(false); fMoveSpeed = 0.0f; } |
|
From: julien r. <jul...@us...> - 2004-11-02 15:32:28
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25269 Modified Files: Makefile Makefile.Linux Makefile.OSX camera.cc glrenderer.cc md5instance.cc md5instance.h md5mesh10.cc md5mesh10.h quaternion.cc quaternion.h scenemanager.cc Log Message: animations md5 Index: quaternion.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/quaternion.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** quaternion.h 28 Oct 2004 21:10:16 -0000 1.3 --- quaternion.h 2 Nov 2004 15:32:16 -0000 1.4 *************** *** 25,29 **** Quaternion operator + (const Quaternion& q); Quaternion operator - (const Quaternion& q); ! Quaternion operator * (Quaternion q); Quaternion operator / (Quaternion q); Quaternion operator += (const Quaternion& q); --- 25,29 ---- Quaternion operator + (const Quaternion& q); Quaternion operator - (const Quaternion& q); ! Quaternion operator * (Quaternion q) const; Quaternion operator / (Quaternion q); Quaternion operator += (const Quaternion& q); Index: quaternion.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/quaternion.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** quaternion.cc 28 Oct 2004 21:10:16 -0000 1.2 --- quaternion.cc 2 Nov 2004 15:32:16 -0000 1.3 *************** *** 24,28 **** } ! Quaternion Quaternion::operator * (Quaternion q) { return Quaternion (r*q.r - x*q.x - y*q.y - z*q.z, --- 24,28 ---- } ! Quaternion Quaternion::operator * (Quaternion q) const { return Quaternion (r*q.r - x*q.x - y*q.y - z*q.z, Index: camera.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/camera.cc,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** camera.cc 30 Oct 2004 17:43:27 -0000 1.7 --- camera.cc 2 Nov 2004 15:32:15 -0000 1.8 *************** *** 142,147 **** //glRotatef(vEuler.x, 1.0f, 0.0f, 0.0f); //glRotatef(vEuler.y, 0.0f, 1.0f, 0.0f); ! Vector3 axis = qRotation.GetRotationAxis (); ! float a = RADTODEG*qRotation.GetRotationAngle (); //std::cout << "camera : " << qRotation << std::endl; float matrix[16]; --- 142,147 ---- //glRotatef(vEuler.x, 1.0f, 0.0f, 0.0f); //glRotatef(vEuler.y, 0.0f, 1.0f, 0.0f); ! //Vector3 axis = qRotation.GetRotationAxis (); ! //float a = RADTODEG*qRotation.GetRotationAngle (); //std::cout << "camera : " << qRotation << std::endl; float matrix[16]; Index: scenemanager.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/scenemanager.cc,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** scenemanager.cc 28 Oct 2004 21:10:16 -0000 1.11 --- scenemanager.cc 2 Nov 2004 15:32:16 -0000 1.12 *************** *** 186,190 **** } while((p=p->GetNext()) != NULL); } - //TODO: enlever ca #ifdef DEBUG Engine::pRenderer->Render (); --- 186,189 ---- Index: md5mesh10.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5mesh10.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** md5mesh10.h 30 Sep 2004 09:23:16 -0000 1.3 --- md5mesh10.h 2 Nov 2004 15:32:16 -0000 1.4 *************** *** 7,10 **** --- 7,11 ---- #include "base.h" #include "quaternion.h" + #include "material.h" namespace tg *************** *** 30,33 **** --- 31,40 ---- bool LoadAnim(char* str); + //Material + inline Material* GetMaterial (int imesh) { return pMeshes[imesh].pMaterial; } + + //Animations informations + int GetAnimIndex(const std::string& name); + //Joint informations inline int GetNumJoints() { return iNumJoints; } *************** *** 149,152 **** --- 156,163 ---- unsigned int* pIndexes; + + Material* pMaterial; + std::string sColor; + std::string sNormal; }; Index: glrenderer.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/glrenderer.cc,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** glrenderer.cc 28 Oct 2004 21:10:16 -0000 1.11 --- glrenderer.cc 2 Nov 2004 15:32:15 -0000 1.12 *************** *** 1106,1111 **** (*_glClientActiveTextureARB) (GL_TEXTURE0); glEnable (GL_TEXTURE_2D); - if (mesh->GetMaterial() && mesh->GetMaterial()->HasPrimary()) - glBindTexture (GL_TEXTURE_2D, mesh->GetMaterial()->GetFirstTexture()->iId); glEnableClientState(GL_TEXTURE_COORD_ARRAY); --- 1106,1109 ---- *************** *** 1127,1130 **** --- 1125,1129 ---- if (mesh->GetMaterial(j) && mesh->GetMaterial(j)->HasPrimary()) glBindTexture (GL_TEXTURE_2D, mesh->GetMaterial(j)->GetFirstTexture()->iId); + glVertexPointer(3, GL_FLOAT, sizeof(Vertice) , &pVerts[0].vPosition); glTexCoordPointer(2, GL_FLOAT, sizeof(Vertice), &pVerts[0].s); *************** *** 1132,1135 **** --- 1131,1135 ---- glDrawElements(GL_TRIANGLES, mesh->GetTrianglesCount(j)*3, GL_UNSIGNED_INT, pIndexes); + /*glBegin (GL_TRIANGLES); for (unsigned int i=0; i<mesh->GetTrianglesCount(j)*3; i++) Index: Makefile =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/Makefile,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Makefile 1 Nov 2004 08:57:10 -0000 1.12 --- Makefile 2 Nov 2004 15:32:15 -0000 1.13 *************** *** 11,15 **** linux: ! make -f Makefile.Linux --- 11,15 ---- linux: ! make -f Makefile.Linux "CFLAGS = -O3 -DTGLINUX" Index: Makefile.Linux =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/Makefile.Linux,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Makefile.Linux 27 Sep 2004 21:34:05 -0000 1.3 --- Makefile.Linux 2 Nov 2004 15:32:15 -0000 1.4 *************** *** 13,17 **** all : $(OBJS) ! gcc -shared -o out/libtgengine.so $(OBJS) clean : --- 13,17 ---- all : $(OBJS) ! $(CC) -shared -o out/libtgengine.so $(OBJS) clean : Index: md5instance.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5instance.cc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** md5instance.cc 28 Oct 2004 21:10:16 -0000 1.6 --- md5instance.cc 2 Nov 2004 15:32:15 -0000 1.7 *************** *** 153,156 **** --- 153,160 ---- { pVerticesListTab[i][j].vPosition.Null(); + //assignation des texcoords. + //FIXME: On pourrait éviter ça et ne le faire qu'une seule fois nan ? + pVerticesListTab[i][j].s = pData->vert_GetTexCoords(i,j)[0]; + pVerticesListTab[i][j].t = pData->vert_GetTexCoords(i,j)[1]; for (int k=0; k<pData->vert_GetNumWeights(i, j); k++) *************** *** 250,254 **** pJoint->vPosition = q.Rotate(animatedPosition); pJoint->vPosition += v; ! pJoint->qOrientation = animatedOrientation*q; } --- 254,258 ---- pJoint->vPosition = q.Rotate(animatedPosition); pJoint->vPosition += v; ! pJoint->qOrientation = q*animatedOrientation; } *************** *** 261,264 **** --- 265,273 ---- //glPopMatrix (); } + void MD5Instance::SetAnimation (const std::string& name) + { + iCurrentAnimation = pData->GetAnimIndex(name); + } + #if 0 void MD5Mesh::BuildBone (int frame, _MD5Bone* b) Index: Makefile.OSX =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/Makefile.OSX,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Makefile.OSX 16 Oct 2004 14:01:34 -0000 1.7 --- Makefile.OSX 2 Nov 2004 15:32:15 -0000 1.8 *************** *** 14,18 **** all : $(OBJS) ! g++ -dynamiclib $(LIBS) -o out/libtgengine.dylib $(OBJS) clean : --- 14,18 ---- all : $(OBJS) ! $(CC) -dynamiclib $(LIBS) -o out/libtgengine.dylib $(OBJS) clean : Index: md5instance.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5instance.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** md5instance.h 28 Oct 2004 21:10:16 -0000 1.5 --- md5instance.h 2 Nov 2004 15:32:16 -0000 1.6 *************** *** 26,36 **** ~MD5Instance (); ! void SetAnimation (std::string name); void PreRender (float); unsigned int GetMeshesCount () { return iNumMeshes; } unsigned int GetTrianglesCount (int imesh=0) { return pData->mesh_GetNumTris(imesh); } - Material* GetMaterial (int imesh=0) { return NULL; } Vertice* GetVertexList (int imesh=0) { return pVerticesListTab[imesh]; } unsigned int GetVerticesCount(int imesh=0) { return pData->mesh_GetNumVerts(imesh); } --- 26,36 ---- ~MD5Instance (); ! void SetAnimation (const std::string& name); void PreRender (float); + inline Material* GetMaterial (int imesh) { return pData->GetMaterial(imesh); } unsigned int GetMeshesCount () { return iNumMeshes; } unsigned int GetTrianglesCount (int imesh=0) { return pData->mesh_GetNumTris(imesh); } Vertice* GetVertexList (int imesh=0) { return pVerticesListTab[imesh]; } unsigned int GetVerticesCount(int imesh=0) { return pData->mesh_GetNumVerts(imesh); } Index: md5mesh10.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5mesh10.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** md5mesh10.cc 21 Oct 2004 21:18:28 -0000 1.4 --- md5mesh10.cc 2 Nov 2004 15:32:16 -0000 1.5 *************** *** 1,250 **** ! #include "md5mesh10.h" ! #include "quaternion.h" ! ! namespace tg ! { ! ! MD5Mesh10::MD5Mesh10 () ! { ! pAnimations.clear(); ! } ! ! MD5Mesh10::~ MD5Mesh10() ! { ! delete [] pJoints; ! for (int i=0; i<iNumMeshes; i++) ! { ! delete [] pMeshes[i].pVerts; ! delete [] pMeshes[i].pTriangles; ! delete [] pMeshes[i].pIndexes; ! delete [] pMeshes[i].pWeights; ! } ! delete [] pMeshes; ! for (unsigned int i=0; i<pAnimations.size(); i++) ! { ! for (int j=0; j<pAnimations[i].iNumJoints; j++) ! delete [] pAnimations[i].pBaseFrame[j]; ! delete [] pAnimations[i].pBaseFrame; ! delete [] pAnimations[i].pJointInfos; ! ! for (int j=0; j<pAnimations[i].iNumFrames; j++) ! delete [] pAnimations[i].pFrames[j]; ! delete [] pAnimations[i].pFrames; ! ! } ! pAnimations.clear(); ! } ! ! #define NEXT(str) while(buffer.find(str)==std::string::npos) \ ! pFD >> buffer; ! ! bool MD5Mesh10::LoadMesh(char* str) ! { ! std::ifstream pFD; ! std::string buffer; ! int version; ! ! std::cout << "[TGE] Chargement de " << str << std::endl; ! ! pFD.open(str, std::ios::in); ! ! if (pFD.fail()) ! { ! std::cerr << "[TGE] Erreur lors de l'ouverture de " << str << std::endl; ! return false; ! } ! ! pFD >> buffer; ! pFD >> version; ! ! if (version != 10) ! { ! std::cerr << "[TGE] Mauvaise version : " << version << std::endl; ! return false; ! } ! ! NEXT("numJoints") ! pFD >> iNumJoints; ! ! NEXT("numMeshes") ! pFD >> iNumMeshes; ! ! iNumBaseJoints = 0; ! pJoints = new _MD5Joint[iNumJoints]; ! ! for (int i=0; i<iNumJoints; i++) ! { ! NEXT("\"") ! pJoints[i].sName = buffer; ! //std::cout << pJoints[i].sName << std::endl; ! Quaternion q; ! //pFD >> pJoints[i].iNumber; ! pFD >> pJoints[i].iParent; ! if (pJoints[i].iParent < 0) ! iNumBaseJoints++; ! NEXT("(") ! pFD >> pJoints[i].vPosition.x >> pJoints[i].vPosition.y >> pJoints[i].vPosition.z; ! ! Util::ChangeCoords(pJoints[i].vPosition); ! //ChangeCoords(pJoints[i].vPosition); ! ! NEXT(")") ! NEXT("(") ! pFD >> q.x >> q.y >> q.z; ! Util::ChangeCoords(q.x, q.y, q.z); ! ! q.ComputeR(); ! ! pJoints[i].qOrientation = q; ! //Util::QuaternionToMatrix33(q,pJoints[i].mOrientation); ! } ! pMeshes = new _MD5Mesh[iNumMeshes]; ! for (int i=0; i<iNumMeshes; i++) ! { ! NEXT("numverts") ! pFD >> pMeshes[i].iNumVerts; ! pFD >> buffer; //sans ca, le NEXT("vert") ne va pas bouger car vert est deja dans numverts ! ! pMeshes[i].pVerts = new _MD5Vert[pMeshes[i].iNumVerts]; ! for (int j=0; j<pMeshes[i].iNumVerts; j++) ! { ! _MD5Vert& vert = pMeshes[i].pVerts[j]; ! NEXT("vert") ! NEXT("(") ! pFD >> vert.pTexCoords[0] >>vert.pTexCoords[1]; ! NEXT(")") ! pFD >> vert.iWeightIndex >> vert.iNumWeights; ! ! } ! NEXT("numtris") ! pFD >> pMeshes[i].iNumTris; ! ! pMeshes[i].pTriangles = new _MD5Triangle[pMeshes[i].iNumTris]; ! pMeshes[i].pIndexes = new unsigned int[pMeshes[i].iNumTris*3]; ! int iC = 0; ! pFD >> buffer; //sans ca, le NEXT("tri") ne va pas bouger car tri est deja dans numtris ! for (int j=0; j<pMeshes[i].iNumTris; j++) ! { ! _MD5Triangle& tri = pMeshes[i].pTriangles[j]; ! NEXT("tri") ! pFD >> buffer; ! pFD >> tri.pIndex[0] >> tri.pIndex[1] >> tri.pIndex[2]; ! ! pMeshes[i].pIndexes[iC] = pMeshes[i].pTriangles[j].pIndex[0]; ! iC++; ! pMeshes[i].pIndexes[iC] = pMeshes[i].pTriangles[j].pIndex[1]; ! iC++; ! pMeshes[i].pIndexes[iC] = pMeshes[i].pTriangles[j].pIndex[2]; ! iC++; ! } ! ! NEXT("numweights") ! pFD >> pMeshes[i].iNumWeights; ! pFD >> buffer; // sans ca, le NEXT("weight") foire ! pMeshes[i].pWeights = new _MD5Weight[pMeshes[i].iNumWeights]; ! for (int j=0; j<pMeshes[i].iNumWeights; j++) ! { ! _MD5Weight& w = pMeshes[i].pWeights[j]; ! NEXT("weight") ! pFD >> buffer; ! pFD >> w.iBoneIndex >> w.fBias; ! NEXT("(") ! pFD >> w.vWeights.x >> w.vWeights.y >> w.vWeights.z; ! Util::ChangeCoords(w.vWeights); ! } ! } ! ! std::cout << "[TGE] Chargement de " << str << " termine" << std::endl; ! return true; ! ! } ! ! bool MD5Mesh10::LoadAnim(char* str) ! { ! _MD5Anim anim; ! anim.sName = std::string(str); ! //std::string animname(str); ! //_MD5Anim& anim = mAnimations[animname]; ! ! std::ifstream pFD; ! std::string buffer; ! int version; ! ! std::cout << "Chargement de " << str << std::endl; ! ! pFD.open(str, std::ios::in); ! ! if (pFD.fail()) ! { ! std::cerr << "[TGE] Erreur lors de l'ouverture de " << str << std::endl; ! return false; ! } ! ! pFD >> buffer; ! pFD >> version; ! ! if (version != 10) ! { ! std::cerr << "[TGE] Mauvaise version : " << version << std::endl; ! return false; ! } ! ! NEXT("numFrames") ! pFD >> anim.iNumFrames; ! NEXT("numJoints") ! pFD >> anim.iNumJoints; ! NEXT("frameRate") ! pFD >> anim.iFrameRate; ! NEXT("numAnimatedComponents") ! pFD >> anim.iNumAnimatedComponents; ! ! anim.pFrames = new float*[anim.iNumFrames]; ! for (int i=0; i<anim.iNumFrames; i++) ! anim.pFrames[i] = new float[anim.iNumAnimatedComponents]; ! ! anim.pJointInfos = new _MD5Anim::_MD5JointInfos[anim.iNumJoints]; ! ! anim.pBaseFrame = new float*[anim.iNumJoints]; ! ! //FIXME: a priori, il n'y a pas de md5mesh ou la hierarchie de l'anim est different du md5mesh. Ceci dit, on peut peut-etre utiliser ca pour demembrer ou autre ! NEXT("hierarchy") ! for (int i=0; i<anim.iNumJoints; i++) ! { ! NEXT("\"") ! buffer = ""; ! pFD >> anim.pJointInfos[i].iParent; ! pFD >> anim.pJointInfos[i].iFlags; ! pFD >> anim.pJointInfos[i].iStartIndex; ! } ! ! //chargement de baseframe ! NEXT("baseframe") ! for (int i=0; i<anim.iNumJoints; i++) ! { ! anim.pBaseFrame[i] = new float[6]; ! NEXT("(") ! pFD >> anim.pBaseFrame[i][0]; ! pFD >> anim.pBaseFrame[i][1]; ! pFD >> anim.pBaseFrame[i][2]; ! NEXT(")") ! NEXT("(") ! pFD >> anim.pBaseFrame[i][3]; ! pFD >> anim.pBaseFrame[i][4]; ! pFD >> anim.pBaseFrame[i][5]; ! NEXT(")") ! } ! //chargement des frames ! for (int i=0; i<anim.iNumFrames; i++) ! { ! NEXT("frame") ! NEXT("{") ! for (int j=0; j<anim.iNumAnimatedComponents; j++) ! pFD >> anim.pFrames[i][j]; ! NEXT("}") ! } ! pAnimations.push_back(anim); ! std::cout << "Chargement de " << str << " termine" << std::endl; ! return true; ! } ! ! } --- 1 ---- ! #include "md5mesh10.h" #include "quaternion.h" namespace tg { MD5Mesh10::MD5Mesh10 () { pAnimations.clear(); } MD5Mesh10::~ MD5Mesh10() { delete [] pJoints; for (int i=0; i<iNumMeshes; i++) { delete [] pMeshes[i].pVerts; delete [] pMeshes[i].pTriangles; delete [] pMeshes[i].pIndexes; delete [] pMeshes[i].pWeights; } delete [] pMeshes; for (unsigned int i=0; i<pAnimations.size(); i++) { for (int j=0; j<pAnimations[i].iNumJoints; j++) delete [] pAnimations[i].pBaseFrame[j]; delete [] pAnimations[i].pBaseFrame; delete [] pAnimations[i].pJointInfos; for (int j=0; j<pAnimations[i].iNumFrames; j++) delete [] pAnimations[i].pFrames[j]; delete [] pAnimations[i].pFrames; } pAnimations.clear(); } #define NEXT(str) while(buffer.find(str)==std::string::npos) \ pFD >> buffer; bool MD5Mesh10::LoadMesh(char* str) { std::ifstream pFD; std::string buffer; int version; std::cout << "[TGE] Chargement de " << str << std::endl; pFD.open(str, std::ios::in); if (pFD.fail()) { std::cerr << "[TGE] Erreur lors de l'ouverture de " << str << std::endl; return false; } pFD >> buffer; pFD >> version; if (version != 10) { std::cerr << "[TGE] Mauvaise version : " << version << std::endl; return false; } NEXT("numJoints") pFD >> iNumJoints; NEXT("numMeshes") pFD >> iNumMeshes; iNumBaseJoints = 0; pJoints = new _MD5Joint[iNumJoints]; for (int i=0; i<iNumJoints; i++) { NEXT("\"") pJoints[i].sName = buffer; //std::cout << pJoints[i].sName << std::endl; Quaternion q; //pFD >> pJoints[i].iNumber; pFD >> pJoints[i].iParent; if (pJoints[i].iParent < 0) iNumBaseJoints++; NEXT("(") pFD >> pJoints[i].vPosition.x >> pJoints[i].vPosition.y >> pJoints[i].vPosition.z; //Util::ChangeCoords(pJoints[i].vPosition); //ChangeCoords(pJoints[i].vPosition); NEXT(")") NEXT("(") pFD >> q.x >> q.y >> q.z; //Util::ChangeCoords(q.x, q.y, q.z); q.ComputeR(); pJoints[i].qOrientation = q; //Util::QuaternionToMatrix33(q,pJoints[i].mOrientation); } pMeshes = new _MD5Mesh[iNumMeshes]; for (int i=0; i<iNumMeshes; i++) { NEXT("shader") std::string sTmp; pFD >> sTmp; int iLastSlash = sTmp.find_last_of("/"); int iLastQuote = sTmp.find_last_of("\""); iLastSlash += 1; //on veut le caractere juste apres le dernier slash sTmp.erase(iLastQuote); pMeshes[i].sNormal = "data/textures/models/"+sTmp.substr(iLastSlash); pMeshes[i].sColor = pMeshes[i].sNormal+"_color.bmp"; pMeshes[i].sNormal += ".bmp"; //pMeshes[i].sNormal = "data/notexture.bmp"; //pMeshes[i].sColor = "data/notexture.bmp"; pMeshes[i].pMaterial = new Material (); Texture* tmpTex = new Texture (); tmpTex->LoadBMP((char*)pMeshes[i].sNormal.data(), TG_TEXTURE_2D); pMeshes[i].pMaterial->SetNormalTexture(tmpTex); tmpTex = new Texture(); tmpTex->LoadBMP((char*)pMeshes[i].sColor.data(), TG_TEXTURE_2D); pMeshes[i].pMaterial->SetFirstTexture(tmpTex); NEXT("numverts") pFD >> pMeshes[i].iNumVerts; pFD >> buffer; //sans ca, le NEXT("vert") ne va pas bouger car vert est deja dans numverts pMeshes[i].pVerts = new _MD5Vert[pMeshes[i].iNumVerts]; for (int j=0; j<pMeshes[i].iNumVerts; j++) { _MD5Vert& vert = pMeshes[i].pVerts[j]; NEXT("vert") NEXT("(") pFD >> vert.pTexCoords[0] >>vert.pTexCoords[1]; vert.pTexCoords[1] = 1 - vert.pTexCoords[1]; NEXT(")") pFD >> vert.iWeightIndex >> vert.iNumWeights; } NEXT("numtris") pFD >> pMeshes[i].iNumTris; pMeshes[i].pTriangles = new _MD5Triangle[pMeshes[i].iNumTris]; pMeshes[i].pIndexes = new unsigned int[pMeshes[i].iNumTris*3]; int iC = 0; pFD >> buffer; //sans ca, le NEXT("tri") ne va pas bouger car tri est deja dans numtris for (int j=0; j<pMeshes[i].iNumTris; j++) { _MD5Triangle& tri = pMeshes[i].pTriangles[j]; NEXT("tri") pFD >> buffer; pFD >> tri.pIndex[0] >> tri.pIndex[1] >> tri.pIndex[2]; pMeshes[i].pIndexes[iC] = pMeshes[i].pTriangles[j].pIndex[0]; iC++; pMeshes[i].pIndexes[iC] = pMeshes[i].pTriangles[j].pIndex[1]; iC++; pMeshes[i].pIndexes[iC] = pMeshes[i].pTriangles[j].pIndex[2]; iC++; } NEXT("numweights") pFD >> pMeshes[i].iNumWeights; pFD >> buffer; // sans ca, le NEXT("weight") foire pMeshes[i].pWeights = new _MD5Weight[pMeshes[i].iNumWeights]; for (int j=0; j<pMeshes[i].iNumWeights; j++) { _MD5Weight& w = pMeshes[i].pWeights[j]; NEXT("weight") pFD >> buffer; pFD >> w.iBoneIndex >> w.fBias; NEXT("(") pFD >> w.vWeights.x >> w.vWeights.y >> w.vWeights.z; //Util::ChangeCoords(w.vWeights); } } std::cout << "[TGE] Chargement de " << str << " termine" << std::endl; return true; } bool MD5Mesh10::LoadAnim(char* str) { _MD5Anim anim; //on garde juste le nom de l'animation std::string sTemp = std::string(str); int iLastSlash = sTemp.find_last_of("/"); int iLastPoint = sTemp.find_last_of("."); sTemp.erase(iLastPoint); anim.sName = sTemp.substr(iLastSlash+1); std::cout << "[TGE] anim name : " << anim.sName << std::endl; std::ifstream pFD; std::string buffer; int version; std::cout << "[TGE] Chargement de " << str << std::endl; pFD.open(str, std::ios::in); if (pFD.fail()) { std::cerr << "[TGE] Erreur lors de l'ouverture de " << str << std::endl; return false; } pFD >> buffer; pFD >> version; if (version != 10) { std::cerr << "[TGE] Mauvaise version : " << version << std::endl; return false; } NEXT("numFrames") pFD >> anim.iNumFrames; NEXT("numJoints") pFD >> anim.iNumJoints; NEXT("frameRate") pFD >> anim.iFrameRate; NEXT("numAnimatedComponents") pFD >> anim.iNumAnimatedComponents; anim.pFrames = new float*[anim.iNumFrames]; for (int i=0; i<anim.iNumFrames; i++) anim.pFrames[i] = new float[anim.iNumAnimatedComponents]; anim.pJointInfos = new _MD5Anim::_MD5JointInfos[anim.iNumJoints]; anim.pBaseFrame = new float*[anim.iNumJoints]; //FIXME: a priori, il n'y a pas de md5mesh ou la hierarchie de l'anim est different du md5mesh. Ceci dit, on peut peut-etre utiliser ca pour demembrer ou autre NEXT("hierarchy") for (int i=0; i<anim.iNumJoints; i++) { NEXT("\"") buffer = ""; pFD >> anim.pJointInfos[i].iParent; pFD >> anim.pJointInfos[i].iFlags; pFD >> anim.pJointInfos[i].iStartIndex; } //chargement de baseframe NEXT("baseframe") for (int i=0; i<anim.iNumJoints; i++) { anim.pBaseFrame[i] = new float[6]; NEXT("(") pFD >> anim.pBaseFrame[i][0]; pFD >> anim.pBaseFrame[i][1]; pFD >> anim.pBaseFrame[i][2]; NEXT(")") NEXT("(") pFD >> anim.pBaseFrame[i][3]; pFD >> anim.pBaseFrame[i][4]; pFD >> anim.pBaseFrame[i][5]; NEXT(")") } //chargement des frames for (int i=0; i<anim.iNumFrames; i++) { NEXT("frame") NEXT("{") for (int j=0; j<anim.iNumAnimatedComponents; j++) pFD >> anim.pFrames[i][j]; NEXT("}") } pAnimations.push_back(anim); std::cout << "[TGE] Chargement de " << str << " termine" << std::endl; return true; } int MD5Mesh10::GetAnimIndex(const std::string& name) { int size = pAnimations.size(); for (int i=0; i<size; i++) { if (pAnimations[i].sName == name) return i; } return -1; } } \ No newline at end of file |
|
From: julien r. <jul...@us...> - 2004-11-01 18:01:57
|
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13710 Modified Files: game.cc pawn.cc Log Message: chargement des meshes Index: game.cc =================================================================== RCS file: /cvsroot/epfl/tggame/game.cc,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** game.cc 31 Oct 2004 11:40:44 -0000 1.23 --- game.cc 1 Nov 2004 18:01:47 -0000 1.24 *************** *** 102,106 **** //cam->pBBox->vMin = Vector3(-10, -70, -10); //cam->pBBox->vMax = Vector3(10, 10, 10); ! Pawn* p = new Pawn(); pSceneManager->SetCamera(cam); --- 102,109 ---- //cam->pBBox->vMin = Vector3(-10, -70, -10); //cam->pBBox->vMax = Vector3(10, 10, 10); ! ! //préchargement des meshes ! pEngine->pMeshManager->Load("pinky", "data/models/pinky/pinky.md5mesh"); ! Pawn* p = new Pawn(); pSceneManager->SetCamera(cam); *************** *** 117,127 **** p->SetVisible(false); //p->GetCamera()->SetPhysicCallBack(pLocalController); - - MD5Instance* pMD5 = Engine::pMeshManager->Load("data/models/cube/cube.md5mesh"); - pSceneManager->AddWorldObject (pMD5); - pMD5->SetPosition(Vector3(0,50,0)); - PhysicNode* pNode = new PhysicNode(pMD5); - pPhysicEngine->AddNode(pNode); - pNode->SetPosition (Vector3(100,50,0)); //création d'un ennemi --- 120,123 ---- Index: pawn.cc =================================================================== RCS file: /cvsroot/epfl/tggame/pawn.cc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pawn.cc 25 Oct 2004 20:04:14 -0000 1.6 --- pawn.cc 1 Nov 2004 18:01:47 -0000 1.7 *************** *** 7,11 **** //pModel = new Model ("data/models/pinky/pinky.mdl", MDL_PLAYER); //pCamera = c; ! pModel = Engine::pMeshManager->Load("data/models/pinky/pinky.md5mesh"); pPhysic = new PhysicNode(pModel); fMoveSpeed = 0.0f; --- 7,11 ---- //pModel = new Model ("data/models/pinky/pinky.mdl", MDL_PLAYER); //pCamera = c; ! pModel = Engine::pMeshManager->LoadInstance("pinky"); pPhysic = new PhysicNode(pModel); fMoveSpeed = 0.0f; |
|
From: julien r. <jul...@us...> - 2004-11-01 17:57:10
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13098 Modified Files: base.h meshmanager.cc meshmanager.h Log Message: chargement des meshes Index: meshmanager.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/meshmanager.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** meshmanager.cc 21 Oct 2004 21:21:00 -0000 1.1 --- meshmanager.cc 1 Nov 2004 17:57:01 -0000 1.2 *************** *** 17,30 **** } ! MD5Instance* MeshManager::Load (const std::string& name) { MeshesList::iterator i = mMeshes.begin (); ! if((i=mMeshes.find(name)) == mMeshes.end()) //on doit charger le mesh { MD5Mesh10* m = new MD5Mesh10 (); ! if (m->LoadMesh((char*)name.data())) mMeshes[name] = m; else mMeshes[name] = mMeshes["nomesh"]; } --- 17,54 ---- } ! void MeshManager::Load (const std::string& name, const std::string& path) { MeshesList::iterator i = mMeshes.begin (); ! if ((i=mMeshes.find(name)) == mMeshes.end()) { MD5Mesh10* m = new MD5Mesh10 (); ! if (m->LoadMesh((char*)path.data())) mMeshes[name] = m; else mMeshes[name] = mMeshes["nomesh"]; + } + } + + void MeshManager::LoadAnim (const std::string& name, const std::string& path) + { + MeshesList::iterator i = mMeshes.begin (); + if ((i=mMeshes.find(name)) != mMeshes.end()) //si le mesh a été chargé + { + MD5Mesh10* m = mMeshes[name]; + m->LoadAnim((char*)path.data()); + } + } + + MD5Instance* MeshManager::LoadInstance (const std::string& name) + { + MeshesList::iterator i = mMeshes.begin (); + if((i=mMeshes.find(name)) == mMeshes.end()) //mesh non chargé + { + mMeshes[name] = mMeshes["nomesh"]; + /*MD5Mesh10* m = new MD5Mesh10 (); + if (m->LoadMesh((char*)name.data())) + mMeshes[name] = m; + else + mMeshes[name] = mMeshes["nomesh"];*/ } Index: meshmanager.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/meshmanager.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** meshmanager.h 21 Oct 2004 21:21:00 -0000 1.1 --- meshmanager.h 1 Nov 2004 17:57:01 -0000 1.2 *************** *** 12,16 **** MeshManager (); ~MeshManager (); ! MD5Instance* Load (const std::string& name); protected: typedef std::map<std::string, MD5Mesh10*> MeshesList; --- 12,19 ---- MeshManager (); ~MeshManager (); ! void Load (const std::string& name, const std::string& path); ! void LoadAnim (const std::string& name, const std::string& path); ! ! MD5Instance* LoadInstance (const std::string& name); protected: typedef std::map<std::string, MD5Mesh10*> MeshesList; Index: base.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/base.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** base.h 21 Oct 2004 21:18:28 -0000 1.2 --- base.h 1 Nov 2004 17:57:00 -0000 1.3 *************** *** 3,7 **** #include <iostream> ! #include <stdarg.h> //vsnprintf & cie namespace tg --- 3,7 ---- #include <iostream> ! #include <stdarg.h> //vsnprintf et compagnie namespace tg |
|
From: Yohann C. <pl...@us...> - 2004-11-01 08:57:34
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3681 Modified Files: Makefile physicengine.cc soundmanager.cc Log Message: qq lignes commentees.... Index: physicengine.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicengine.cc,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** physicengine.cc 31 Oct 2004 22:15:40 -0000 1.16 --- physicengine.cc 1 Nov 2004 08:57:10 -0000 1.17 *************** *** 9,13 **** //pNodes.clear(); fOverBounce = 1.00f; ! Engine::pVarManager->AddVar("gravity", 800); pGravity = &Engine::pVarManager->GetVar("gravity")->floatValue; --- 9,13 ---- //pNodes.clear(); fOverBounce = 1.00f; ! Engine::pVarManager->AddVar("gravity", 800); pGravity = &Engine::pVarManager->GetVar("gravity")->floatValue; *************** *** 22,34 **** int bumpcount = 0; //Vector3 origin = n->pBBox->vWorldOrigin; ! float time_left = eTime; trace.Fraction = 0.0f; ! ! while ((trace.Fraction < (1.0f - EPSILON)) && (bumpcount < MAXBUMPS)) //a chaque fois qu'on rencontre un plan, on relance un trace avec comme origine le Endpoint sur le plan précédent et on ajuste la vitesse de notre objet. MAXBUMPS permet simplement d'éviter des boucles infinies { trace = pLevel->CheckRayMove(origin, origin+vVelocity*time_left, n->GetBBox()->vMin, n->GetBBox()->vMax); ! if (trace.AllSolid) { --- 22,34 ---- int bumpcount = 0; //Vector3 origin = n->pBBox->vWorldOrigin; ! float time_left = eTime; trace.Fraction = 0.0f; ! ! while ((trace.Fraction < (1.0f - EPSILON)) && (bumpcount < MAXBUMPS)) //a chaque fois qu'on rencontre un plan, on relance un trace avec comme origine le Endpoint sur le plan précédent et on ajuste la vitesse de notre objet. MAXBUMPS permet simplement d'éviter des boucles infinies { trace = pLevel->CheckRayMove(origin, origin+vVelocity*time_left, n->GetBBox()->vMin, n->GetBBox()->vMax); ! if (trace.AllSolid) { *************** *** 44,48 **** break; } ! time_left -= time_left*trace.Fraction; ClipVelocity (vVelocity, trace.CollisionNormal); --- 44,48 ---- break; } ! time_left -= time_left*trace.Fraction; ClipVelocity (vVelocity, trace.CollisionNormal); *************** *** 83,87 **** Vector3 pos1 = n->GetPosition(); Vector3 pos2 = n->GetPosition();*/ ! for (unsigned int i=0; i<pNodes.size(); i++) { --- 83,87 ---- Vector3 pos1 = n->GetPosition(); Vector3 pos2 = n->GetPosition();*/ ! for (unsigned int i=0; i<pNodes.size(); i++) { *************** *** 94,98 **** veloc.y = 0; n->SetVelocity(veloc); ! n->SetPosition(n->GetPosition()+n->GetVelocity()*eTime); //n->SetRotation(n->GetRotation()+n->GetRotationVelocity()*eTime); --- 94,98 ---- veloc.y = 0; n->SetVelocity(veloc); ! n->SetPosition(n->GetPosition()+n->GetVelocity()*eTime); //n->SetRotation(n->GetRotation()+n->GetRotationVelocity()*eTime); *************** *** 100,105 **** q.Normalize(); n->SetRotation(n->GetRotation()*q); ! ! n->UpdatePosition(); continue; --- 100,105 ---- q.Normalize(); n->SetRotation(n->GetRotation()*q); ! ! n->UpdatePosition(); continue; *************** *** 107,118 **** //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 << n << "\t" ;*/ ! std::cout << "OnGround : " << n->OnGround(); ! std::cout << "Accel : \t" << n->GetAccel() << std::endl; //int red[]={1,0,0}; //Engine::pEngine->pRenderer->drawDebugArrow(n->vPosition, n->vPosition+n->vAccel*5, red); --- 107,118 ---- //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 << n << "\t" ;*/ ! //std::cout << "OnGround : " << n->OnGround(); ! //std::cout << "Accel : \t" << n->GetAccel() << std::endl; //int red[]={1,0,0}; //Engine::pEngine->pRenderer->drawDebugArrow(n->vPosition, n->vPosition+n->vAccel*5, red); *************** *** 122,131 **** n->CalculateBoundingVolume(); //on test les collisions avec le monde ! if (pLevel) { ! //on essaie de faire monter les petits obstacles sur les y (escaliers, rebords) au joueur. Pour cela, on test si lorsqu'on monte //le joueur de STEPSIZE, il arrive à avancer plus sur les x et les z (mais _pas_ les y) ! ////TODO: lorsqu'on monte les escaliers, ça se fait par petit saut (normal, on ajoute 10 a la position en un coup. //Il faudrait faire ça de manière à ce qu'on ait l'impression de glisser sur les escaliers Vector3 vVelocity = n->GetVelocity(); --- 122,131 ---- n->CalculateBoundingVolume(); //on test les collisions avec le monde ! if (pLevel) { ! //on essaie de faire monter les petits obstacles sur les y (escaliers, rebords) au joueur. Pour cela, on test si lorsqu'on monte //le joueur de STEPSIZE, il arrive à avancer plus sur les x et les z (mais _pas_ les y) ! ////TODO: lorsqu'on monte les escaliers, ça se fait par petit saut (normal, on ajoute 10 a la position en un coup. //Il faudrait faire ça de manière à ce qu'on ait l'impression de glisser sur les escaliers Vector3 vVelocity = n->GetVelocity(); *************** *** 144,148 **** distz *= distz; float dist = sqrt(distx+distz); ! StepSlideMove (n, eTime, vUpVelocity, vUpPos); vUpNewPos += vUpVelocity*eTime; --- 144,148 ---- distz *= distz; float dist = sqrt(distx+distz); ! StepSlideMove (n, eTime, vUpVelocity, vUpPos); vUpNewPos += vUpVelocity*eTime; *************** *** 152,156 **** distz *= distz; float updist = sqrt(distx+distz); ! if (updist > dist) //on passe l'obstacle { --- 152,156 ---- distz *= distz; float updist = sqrt(distx+distz); ! if (updist > dist) //on passe l'obstacle { *************** *** 162,166 **** //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 --- 162,166 ---- //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 *************** *** 173,181 **** //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 ! BspCollisionResult col = pLevel->CheckRayMove(n->GetPosition(), n->GetPosition()+Vector3::NEGATIVE_UNIT_Y*BASE_HEIGHT, n->GetBBox()->vMin, n->GetBBox()->vMax); //si on met le allsolid, ca foire les mouvements sur les y --- 173,181 ---- //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 ! BspCollisionResult col = pLevel->CheckRayMove(n->GetPosition(), n->GetPosition()+Vector3::NEGATIVE_UNIT_Y*BASE_HEIGHT, n->GetBBox()->vMin, n->GetBBox()->vMax); //si on met le allsolid, ca foire les mouvements sur les y *************** *** 188,193 **** q.Normalize(); n->SetRotation(n->GetRotation()*q); ! ! n->UpdatePosition(); } } --- 188,193 ---- q.Normalize(); n->SetRotation(n->GetRotation()*q); ! ! n->UpdatePosition(); } } *************** *** 200,205 **** CollisionResult result; result.pNode = NULL; ! ! BspCollisionResult mapResult = pLevel->CheckRayMove(Begin, End, TRACE_RAY, 0); result.EndPoint = mapResult.EndPoint; result.Normal = mapResult.CollisionNormal; --- 200,205 ---- CollisionResult result; result.pNode = NULL; ! ! BspCollisionResult mapResult = pLevel->CheckRayMove(Begin, End, TRACE_RAY, 0); result.EndPoint = mapResult.EndPoint; result.Normal = mapResult.CollisionNormal; *************** *** 240,244 **** } while((m=m->GetNext()) != NULL); }*/ ! return result; } --- 240,244 ---- } while((m=m->GetNext()) != NULL); }*/ ! return result; } Index: Makefile =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/Makefile,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Makefile 22 Oct 2004 19:39:04 -0000 1.11 --- Makefile 1 Nov 2004 08:57:10 -0000 1.12 *************** *** 6,9 **** --- 6,10 ---- clean: + rm -Rf out/* rm -f *.o rm -f *~ Index: soundmanager.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/soundmanager.cc,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** soundmanager.cc 30 Oct 2004 08:38:27 -0000 1.14 --- soundmanager.cc 1 Nov 2004 08:57:10 -0000 1.15 *************** *** 21,27 **** cout << "[OpenAL] Starting SoundManager" << endl; #endif ! Init(); ! LoopThread = SDL_CreateThread(SoundManager::MainLoop,NULL); } --- 21,27 ---- cout << "[OpenAL] Starting SoundManager" << endl; #endif [...980 lines suppressed...] ! case ALC_INVALID_CONTEXT: ! return string("ALC_INVALID_CONTEXT"); ! break; ! case ALC_INVALID_ENUM: ! return string("ALC_INVALID_ENUM"); ! break; ! case ALC_INVALID_VALUE: ! return string("ALC_INVALID_VALUE"); ! break; ! case ALC_OUT_OF_MEMORY: ! return string("ALC_OUT_OF_MEMORY"); ! break; ! ! default: return string("UNKNOW_ALC_ERROR"); break; |
|
From: julien r. <jul...@us...> - 2004-10-31 22:15:49
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2603 Modified Files: engine.cc physicengine.cc Log Message: ... Index: physicengine.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicengine.cc,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** physicengine.cc 31 Oct 2004 11:39:49 -0000 1.15 --- physicengine.cc 31 Oct 2004 22:15:40 -0000 1.16 *************** *** 74,78 **** //-> on différenci la taille du joueur et des autres objets pour être sur le sol #define PLAYER_HEIGHT 80 ! #define BASE_HEIGHT 5 #define STEPSIZE 10 void PhysicEngine::Move (float eTime) --- 74,78 ---- //-> on différenci la taille du joueur et des autres objets pour être sur le sol #define PLAYER_HEIGHT 80 ! #define BASE_HEIGHT 15 #define STEPSIZE 10 void PhysicEngine::Move (float eTime) *************** *** 90,94 **** if (!n->Clip()) { ! //ugly hack pour éviter de tomber quand on tappe noclip le jeu étant deja lancé (on se choppe l'accel négative de la frame précédente en fait... Vector3 veloc = n->GetVelocity(); veloc.y = 0; --- 90,94 ---- if (!n->Clip()) { ! //ugly hack pour éviter de tomber quand on tappe -clip le jeu étant deja lancé (on se choppe l'accel négative de la frame précédente en fait... Vector3 veloc = n->GetVelocity(); veloc.y = 0; *************** *** 112,118 **** 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 << n << "\t" ; ! std::cout << n->bOnGround; ! std::cout << "\t" << n->vAccel << std::endl;*/ //int red[]={1,0,0}; //Engine::pEngine->pRenderer->drawDebugArrow(n->vPosition, n->vPosition+n->vAccel*5, red); --- 112,118 ---- 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 << n << "\t" ;*/ ! std::cout << "OnGround : " << n->OnGround(); ! std::cout << "Accel : \t" << n->GetAccel() << std::endl; //int red[]={1,0,0}; //Engine::pEngine->pRenderer->drawDebugArrow(n->vPosition, n->vPosition+n->vAccel*5, red); *************** *** 177,184 **** //Classification de la position - //FIXME:on fait une differenciation entre le joueur et les autres scenenode. il ne faudrait pas! - /*if (n->bIsCamera && pLevel->CheckRayMove(n->GetPosition(), n->GetPosition()+Vector3::NEGATIVE_UNIT_Y*PLAYER_HEIGHT, TRACE_RAY, 0).Fraction < 1.0f) - n->SetOnGround(true); - else*/ BspCollisionResult col = pLevel->CheckRayMove(n->GetPosition(), n->GetPosition()+Vector3::NEGATIVE_UNIT_Y*BASE_HEIGHT, n->GetBBox()->vMin, n->GetBBox()->vMax); --- 177,180 ---- *************** *** 189,198 **** n->SetOnGround(false); - //n->SetRotation(n->GetRotation()+n->GetRotationVelocity()*eTime); - /*n->SetRotation(n->GetRotation()*n->GetRotationVelocity()*eTime);*/ - /*static float angle =0 ; - angle+=1; - angle=0; - Quaternion q(angle, Vector3(0,0,0));*/ Quaternion q = n->GetRotationVelocity()*eTime; q.Normalize(); --- 185,188 ---- Index: engine.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/engine.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** engine.cc 21 Oct 2004 21:18:28 -0000 1.5 --- engine.cc 31 Oct 2004 22:15:40 -0000 1.6 *************** *** 28,32 **** } ! pLog = new LogBuffer ("log.txt", true); std::cout.rdbuf (pLog); pErr = new ErrBuffer ("err.txt", true); --- 28,32 ---- } ! pLog = new LogBuffer ("log.txt", false); std::cout.rdbuf (pLog); pErr = new ErrBuffer ("err.txt", true); |
|
From: Luis C. <ce...@us...> - 2004-10-31 17:44:56
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9397 Modified Files: AUTHORS Log Message: Petite correction Index: AUTHORS =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/AUTHORS,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AUTHORS 15 Oct 2004 22:29:53 -0000 1.4 --- AUTHORS 31 Oct 2004 17:44:47 -0000 1.5 *************** *** 15,17 **** Network Developement : ! Luis Fernando "cerel" Alonsoz Couso : luis.couso *chez* epfl.ch --- 15,17 ---- Network Developement : ! Luis Fernando "cerel" Couso Alonso : luis.couso *chez* epfl.ch |
|
From: julien r. <jul...@us...> - 2004-10-31 11:40:55
|
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20572 Modified Files: aicontroller.cc aicontroller.h game.cc playercontroller.cc playercontroller.h Log Message: deplacements Index: game.cc =================================================================== RCS file: /cvsroot/epfl/tggame/game.cc,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** game.cc 31 Oct 2004 11:03:06 -0000 1.22 --- game.cc 31 Oct 2004 11:40:44 -0000 1.23 *************** *** 135,139 **** p->SetPosition(Vector3(50,70,0)); ! p->SetRotationVelocity(Quaternion(10,Vector3(0,1,1))); //p->SetRotation(Quaternion(90,Vector3(0,1,0))); //p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(0,30,0)); --- 135,139 ---- p->SetPosition(Vector3(50,70,0)); ! //p->SetRotationVelocity(Quaternion(10,Vector3(0,1,1))); //p->SetRotation(Quaternion(90,Vector3(0,1,0))); //p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(0,30,0)); Index: aicontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/aicontroller.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** aicontroller.cc 31 Oct 2004 11:03:06 -0000 1.5 --- aicontroller.cc 31 Oct 2004 11:40:44 -0000 1.6 *************** *** 11,14 **** --- 11,19 ---- int rot=0; + int AIController::FORWARD = 3; + int AIController::BACKWARD = 2; + int AIController::STRAFELEFT = 0; + int AIController::STRAFERIGHT = 1; + void AIController::Think (float eTime) { *************** *** 33,39 **** #endif ! pPawn->SetRotation(Quaternion(rot++, Vector3::UNIT_Y)); ! rot=rot%360; ! bDir[0]=1; } --- 38,44 ---- #endif ! //pPawn->SetRotation(Quaternion(rot++, Vector3::UNIT_Y)); ! //rot=rot%360; ! bDir[STRAFELEFT]=1; } Index: aicontroller.h =================================================================== RCS file: /cvsroot/epfl/tggame/aicontroller.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** aicontroller.h 28 Oct 2004 21:20:33 -0000 1.3 --- aicontroller.h 31 Oct 2004 11:40:44 -0000 1.4 *************** *** 7,10 **** --- 7,14 ---- class AIController : public Controller { + static int FORWARD; + static int BACKWARD; + static int STRAFELEFT; + static int STRAFERIGHT; public: AIController (Pawn* p) : Controller(p) {} Index: playercontroller.h =================================================================== RCS file: /cvsroot/epfl/tggame/playercontroller.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** playercontroller.h 25 Oct 2004 20:04:14 -0000 1.4 --- playercontroller.h 31 Oct 2004 11:40:44 -0000 1.5 *************** *** 13,17 **** CLIP=1 }; ! public: PlayerController (Pawn*); --- 13,21 ---- CLIP=1 }; ! ! static int FORWARD; ! static int BACKWARD; ! static int STRAFELEFT; ! static int STRAFERIGHT; public: PlayerController (Pawn*); Index: playercontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/playercontroller.cc,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** playercontroller.cc 30 Oct 2004 17:46:47 -0000 1.10 --- playercontroller.cc 31 Oct 2004 11:40:44 -0000 1.11 *************** *** 5,8 **** --- 5,13 ---- using namespace tg; + int PlayerController::FORWARD = 0; + int PlayerController::BACKWARD = 1; + int PlayerController::STRAFELEFT = 2; + int PlayerController::STRAFERIGHT = 3; + PlayerController::PlayerController(Pawn* p) : Controller (p) { *************** *** 55,74 **** case TGKEY_w: //iForward += 1; ! bDir[0] = true; SoundManager::pSoundManager->PlaySound("step"); break; case TGKEY_s: //iForward -= 1; ! bDir[1] = true; SoundManager::pSoundManager->PlaySound("step"); break; case TGKEY_a: //iStrafe -= 1; ! bDir[2] = true; SoundManager::pSoundManager->PlaySound("step"); break; case TGKEY_d: //iStrafe += 1; ! bDir[3] = true; SoundManager::pSoundManager->PlaySound("step"); break; --- 60,79 ---- case TGKEY_w: //iForward += 1; ! bDir[FORWARD] = true; SoundManager::pSoundManager->PlaySound("step"); break; case TGKEY_s: //iForward -= 1; ! bDir[BACKWARD] = true; SoundManager::pSoundManager->PlaySound("step"); break; case TGKEY_a: //iStrafe -= 1; ! bDir[STRAFELEFT] = true; SoundManager::pSoundManager->PlaySound("step"); break; case TGKEY_d: //iStrafe += 1; ! bDir[STRAFERIGHT] = true; SoundManager::pSoundManager->PlaySound("step"); break; *************** *** 88,107 **** { case TGKEY_w: ! bDir[0] = false; SoundManager::pSoundManager->StopSound("step"); break; case TGKEY_s: //iForward = 0; ! bDir[1] = false; SoundManager::pSoundManager->StopSound("step"); break; case TGKEY_a: ! bDir[2] = false; SoundManager::pSoundManager->StopSound("step"); break; case TGKEY_d: //iStrafe = 0; ! bDir[3] = false; SoundManager::pSoundManager->StopSound("step"); break; --- 93,112 ---- { case TGKEY_w: ! bDir[FORWARD] = false; SoundManager::pSoundManager->StopSound("step"); break; case TGKEY_s: //iForward = 0; ! bDir[BACKWARD] = false; SoundManager::pSoundManager->StopSound("step"); break; case TGKEY_a: ! bDir[STRAFELEFT] = false; SoundManager::pSoundManager->StopSound("step"); break; case TGKEY_d: //iStrafe = 0; ! bDir[STRAFERIGHT] = false; SoundManager::pSoundManager->StopSound("step"); break; |
|
From: julien r. <jul...@us...> - 2004-10-31 11:40:00
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20369 Modified Files: physicengine.cc Log Message: ^^ Index: physicengine.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicengine.cc,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** physicengine.cc 28 Oct 2004 21:10:16 -0000 1.14 --- physicengine.cc 31 Oct 2004 11:39:49 -0000 1.15 *************** *** 97,101 **** n->SetPosition(n->GetPosition()+n->GetVelocity()*eTime); //n->SetRotation(n->GetRotation()+n->GetRotationVelocity()*eTime); ! n->SetRotation(n->GetRotation()*n->GetRotationVelocity()*eTime); n->UpdatePosition(); --- 97,104 ---- n->SetPosition(n->GetPosition()+n->GetVelocity()*eTime); //n->SetRotation(n->GetRotation()+n->GetRotationVelocity()*eTime); ! Quaternion q = n->GetRotationVelocity()*eTime; ! q.Normalize(); ! n->SetRotation(n->GetRotation()*q); ! n->UpdatePosition(); |
|
From: Yohann C. <pl...@us...> - 2004-10-31 11:03:23
|
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14697 Modified Files: aicontroller.cc game.cc Log Message: pinky tourne en rond.... piloté par l'AI.... Index: game.cc =================================================================== RCS file: /cvsroot/epfl/tggame/game.cc,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** game.cc 28 Oct 2004 21:20:33 -0000 1.21 --- game.cc 31 Oct 2004 11:03:06 -0000 1.22 *************** *** 135,140 **** p->SetPosition(Vector3(50,70,0)); ! p->SetRotationVelocity(Quaternion(0.5,Vector3(0,1,1))); ! p->SetRotation(Quaternion(90,Vector3(0,1,0))); //p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(0,30,0)); //p->GetModel()->SetPhysicCallBack(c); --- 135,140 ---- p->SetPosition(Vector3(50,70,0)); ! p->SetRotationVelocity(Quaternion(10,Vector3(0,1,1))); ! //p->SetRotation(Quaternion(90,Vector3(0,1,0))); //p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(0,30,0)); //p->GetModel()->SetPhysicCallBack(c); Index: aicontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/aicontroller.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** aicontroller.cc 21 Oct 2004 21:29:14 -0000 1.4 --- aicontroller.cc 31 Oct 2004 11:03:06 -0000 1.5 *************** *** 1,2 **** --- 1,4 ---- + #define AI_DEBUG 0 + #include "aicontroller.h" #include "game.h" *************** *** 7,18 **** bool initialised = false; ! void AIController::Think (float eTime) { ! if (!initialised) // A mettre ailleurs... mais je ne vais pas hacker tggame.. je laisse ca aux experts ;) AIController::Initialize(); ! // Vector3 pos = pPawn->GetPosition(); // position du perso AI Vector3 vPos = Game::pSelf->GetSceneManager()->GetCamera()->GetPosition(); // position de la camera --- 9,20 ---- bool initialised = false; ! int rot=0; void AIController::Think (float eTime) { ! /* if (!initialised) // A mettre ailleurs... mais je ne vais pas hacker tggame.. je laisse ca aux experts ;) AIController::Initialize(); ! */ // Vector3 pos = pPawn->GetPosition(); // position du perso AI Vector3 vPos = Game::pSelf->GetSceneManager()->GetCamera()->GetPosition(); // position de la camera *************** *** 20,34 **** Vector3 vCentre = Game::pSelf->GetSceneManager()->Trace(vPos, vPos + ( Vector3::UNIT_Z*(-1000000) ) ).EndPoint; float fVarX = vCentre.x - vPos.x; float fVarZ = vCentre.z - vPos.z; float fDist = sqrt(fVarX*fVarX + fVarZ*fVarZ); ! /* std::cout << "EndPoint Z: " << vCentre.z ! << " Position : " << vPos ! << " Distance : " << abs(fVarZ) << std::endl;*/ } void AIController::Collide (SceneNode* other, const Vector3& vPoint, const Vector3& vCollisionNormal) { - // std::cout << "aicontroller" << std::endl; // fYaw=rand()%360; // std::cout << vPoint << std::endl; --- 22,43 ---- Vector3 vCentre = Game::pSelf->GetSceneManager()->Trace(vPos, vPos + ( Vector3::UNIT_Z*(-1000000) ) ).EndPoint; + float fVarX = vCentre.x - vPos.x; float fVarZ = vCentre.z - vPos.z; float fDist = sqrt(fVarX*fVarX + fVarZ*fVarZ); ! ! #if AI_DEBUG >= 5 ! std::cout << "[AI] EndPoint Z: " << vCentre.z ! << " Position : " << vPos ! << " Distance : " << abs(fVarZ) << std::endl; ! #endif ! ! pPawn->SetRotation(Quaternion(rot++, Vector3::UNIT_Y)); ! rot=rot%360; ! bDir[0]=1; } void AIController::Collide (SceneNode* other, const Vector3& vPoint, const Vector3& vCollisionNormal) { // fYaw=rand()%360; // std::cout << vPoint << std::endl; *************** *** 37,43 **** void AIController::Initialize() { ! std::cout << "\n\n---[AI]--- C'est parti pour l'IA" << std::endl; initialised=true; ! // srand( (unsigned)time( NULL ) ); } --- 46,54 ---- void AIController::Initialize() { ! #if AI_DEBUG >= 1 ! std::cout << "[AI] C'est parti pour l'IA" << std::endl; ! #endif initialised=true; ! srand( (unsigned)time( NULL ) ); } |
|
From: julien r. <jul...@us...> - 2004-10-30 17:46:56
|
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22708 Modified Files: controller.cc playercontroller.cc Log Message: camera quaternion devermine Index: playercontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/playercontroller.cc,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** playercontroller.cc 28 Oct 2004 21:20:33 -0000 1.9 --- playercontroller.cc 30 Oct 2004 17:46:47 -0000 1.10 *************** *** 26,41 **** //Vector3 mRot(0,0,0); ! //Quaternion roty (((float)mX-middleX)*6*fSensivity, 0,1,0); ! //Quaternion rotx (((float)mY-middleY)*6*fSensivity, 1,0,0); ! ry += ((float)mX-middleX)*6*fSensivity; ! rx += ((float)mY-middleY)*6*fSensivity; Game::pSelf->GetEngine()->WarpMouse(middleX,middleY); ! //pPawn->SetRotation(pPawn->GetRotation()+mRot); ! //pPawn->SetRotation(pPawn->GetRotation()*roty*rotx); ! Quaternion q; ! q.FromEuler(rx, ry, 0); q.Normalize(); pPawn->SetRotation(q); } --- 26,42 ---- //Vector3 mRot(0,0,0); ! ry -= ((float)mX-middleX)*6*fSensivity; ! rx -= ((float)mY-middleY)*6*fSensivity; Game::pSelf->GetEngine()->WarpMouse(middleX,middleY); ! Quaternion qY = Quaternion(ry, Vector3(0,1,0)); ! Quaternion qX = Quaternion(rx, Vector3(1,0,0)); ! Quaternion q = qY*qX; q.Normalize(); + + /*Quaternion q; + q.FromEuler(rx, ry, 0); + q.Normalize();*/ pPawn->SetRotation(q); } Index: controller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/controller.cc,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** controller.cc 28 Oct 2004 21:20:33 -0000 1.7 --- controller.cc 30 Oct 2004 17:46:47 -0000 1.8 *************** *** 22,25 **** --- 22,26 ---- //Vector3 rot = pPawn->GetRotation(); Quaternion rot = pPawn->GetRotation(); + //std::cout << rot << std::endl; vLastVel.Null(); *************** *** 49,59 **** z = rot.GetZAxis(); if (bDir[0]) ! vLastVel = vVelocity += x*fSpeed; if (bDir[1]) - vLastVel = vVelocity -= x*fSpeed; - if (bDir[2]) vLastVel = vVelocity += z*fSpeed; if (bDir[3]) ! vLastVel = vVelocity -= z*fSpeed; pPawn->SetVelocity(pPawn->GetVelocity()+vVelocity); --- 50,60 ---- z = rot.GetZAxis(); if (bDir[0]) ! vLastVel = vVelocity -= z*fSpeed; if (bDir[1]) vLastVel = vVelocity += z*fSpeed; + if (bDir[2]) + vLastVel = vVelocity -= x*fSpeed; if (bDir[3]) ! vLastVel = vVelocity += x*fSpeed; pPawn->SetVelocity(pPawn->GetVelocity()+vVelocity); |
|
From: julien r. <jul...@us...> - 2004-10-30 17:43:49
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22035 Modified Files: camera.cc Log Message: quaternion camera bug Index: camera.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/camera.cc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** camera.cc 28 Oct 2004 21:10:16 -0000 1.6 --- camera.cc 30 Oct 2004 17:43:27 -0000 1.7 *************** *** 25,29 **** void Camera::Update (float time) { ! if (Engine::pConsole->GetState()) //si la console est ouverte, on desactive la souris return; --- 25,29 ---- void Camera::Update (float time) { ! /*if (Engine::pConsole->GetState()) //si la console est ouverte, on desactive la souris return; *************** *** 36,44 **** //On se fout du temps pour ce qui est des mouvements de souris... ! vRot.y += ((float)mX-middleX)*fSensivity/**time*/*6; ! vRot.x += ((float)mY-middleY)*fSensivity/*time*/*6; //SDL_WarpMouse (middleX, middleY); ! Engine::pEngine->WarpMouse(middleX, middleY); /* float factor; --- 36,44 ---- //On se fout du temps pour ce qui est des mouvements de souris... ! vRot.y += ((float)mX-middleX)*fSensivity*6; ! vRot.x += ((float)mY-middleY)*fSensivity*6; //SDL_WarpMouse (middleX, middleY); ! Engine::pEngine->WarpMouse(middleX, middleY);*/ /* float factor; *************** *** 97,103 **** //vRot.ToAngleVectors(vForward, vRight, vUp); ! vForward = qRotation.GetXAxis (); ! vRight = qRotation.GetZAxis (); ! vUp = qRotation.GetYAxis (); //_AngleToVectors (); } --- 97,103 ---- //vRot.ToAngleVectors(vForward, vRight, vUp); ! //vForward = qRotation.GetXAxis (); ! //vRight = qRotation.GetZAxis (); ! //vUp = qRotation.GetYAxis (); //_AngleToVectors (); } *************** *** 142,148 **** //glRotatef(vEuler.x, 1.0f, 0.0f, 0.0f); //glRotatef(vEuler.y, 0.0f, 1.0f, 0.0f); float matrix[16]; ! qRotation.GetMatrix(matrix); glMultMatrixf (matrix); glTranslatef(-vPosition.x, -vPosition.y, -vPosition.z); frustum.Update(); --- 142,153 ---- //glRotatef(vEuler.x, 1.0f, 0.0f, 0.0f); //glRotatef(vEuler.y, 0.0f, 1.0f, 0.0f); + Vector3 axis = qRotation.GetRotationAxis (); + float a = RADTODEG*qRotation.GetRotationAngle (); + //std::cout << "camera : " << qRotation << std::endl; float matrix[16]; ! Quaternion qconj = qRotation.Conjugate(); ! qconj.GetMatrix(matrix); glMultMatrixf (matrix); + //glRotatef (-a, axis.x, axis.y, axis.z); glTranslatef(-vPosition.x, -vPosition.y, -vPosition.z); frustum.Update(); |
|
From: Seb <whi...@us...> - 2004-10-30 08:38:38
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12772 Modified Files: soundmanager.cc Log Message: Modif du formatage des log et err: OpenAL:: -> [OpenAL] Index: soundmanager.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/soundmanager.cc,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** soundmanager.cc 22 Oct 2004 20:31:08 -0000 1.13 --- soundmanager.cc 30 Oct 2004 08:38:27 -0000 1.14 *************** *** 19,23 **** { #ifdef SOUND_DEBUG ! cout << "OpenAL:: Starting SoundManager" << endl; #endif --- 19,23 ---- { #ifdef SOUND_DEBUG ! cout << "[OpenAL] Starting SoundManager" << endl; #endif *************** *** 31,35 **** { #ifdef SOUND_DEBUG ! cout << "OpenAL:: Ending SoundManager" << endl; #endif --- 31,35 ---- { #ifdef SOUND_DEBUG ! cout << "[OpenAL] Ending SoundManager" << endl; #endif *************** *** 42,46 **** { #ifdef SOUND_DEBUG ! cout << "OpenAL:: Initializing SoundManager" << endl; #endif --- 42,46 ---- { #ifdef SOUND_DEBUG ! cout << "[OpenAL] Initializing SoundManager" << endl; #endif *************** *** 48,52 **** { #ifdef SOUND_DEBUG ! cout << "OpenAL:: Little Endian detected..." << endl; #endif --- 48,52 ---- { #ifdef SOUND_DEBUG ! cout << "[OpenAL] Little Endian detected..." << endl; #endif *************** *** 56,60 **** { #ifdef SOUND_DEBUG ! cout << "OpenAL:: Big Endian detected..." << endl; #endif --- 56,60 ---- { #ifdef SOUND_DEBUG ! cout << "[OpenAL] Big Endian detected..." << endl; #endif *************** *** 65,69 **** #ifdef SOUND_DEBUG ! cout << "OpenAL:: Loading Lib: Version = " << (char*)alGetString(AL_VERSION) << flush; cout << " | Renderer = " << (char*)alGetString(AL_RENDERER) << flush; cout << " | Vendor = " << (char*)alGetString(AL_VENDOR) << endl; --- 65,69 ---- #ifdef SOUND_DEBUG ! cout << "[OpenAL] Loading Lib: Version = " << (char*)alGetString(AL_VERSION) << flush; cout << " | Renderer = " << (char*)alGetString(AL_RENDERER) << flush; cout << " | Vendor = " << (char*)alGetString(AL_VENDOR) << endl; *************** *** 89,94 **** if(!*check) pSoundManager->DisableSoundManager(); ! else ! pSoundManager->EnableSoundManager(); SDL_Delay(80); --- 89,94 ---- if(!*check) pSoundManager->DisableSoundManager(); ! //else ! //pSoundManager->EnableSoundManager(); SDL_Delay(80); *************** *** 115,119 **** { #ifdef SOUND_DEBUG ! //cout << "OpenAL:: SetListenerPosition (" << x << "," << y << "," << z << ")" << endl; #endif --- 115,119 ---- { #ifdef SOUND_DEBUG ! //cout << "[OpenAL] SetListenerPosition (" << x << "," << y << "," << z << ")" << endl; #endif *************** *** 126,130 **** { #ifdef SOUND_DEBUG ! //cout << "OpenAL:: SetListenerOrientation" << endl; #endif --- 126,130 ---- { #ifdef SOUND_DEBUG ! //cout << "[OpenAL] SetListenerOrientation" << endl; #endif *************** *** 145,149 **** { #ifdef SOUND_DEBUG ! //cout << "OpenAL:: UpdateListener" << endl; #endif --- 145,149 ---- { #ifdef SOUND_DEBUG ! //cout << "[OpenAL] UpdateListener" << endl; #endif *************** *** 166,170 **** { #ifdef SOUND_DEBUG ! cout << "OpenAL:: AddSound: " << name << endl; #endif --- 166,170 ---- { #ifdef SOUND_DEBUG ! cout << "[OpenAL] AddSound: " << name << endl; #endif *************** *** 191,195 **** else { ! cerr << "OpenAL:: Cannot find " << name << " for reading..." << endl; } --- 191,195 ---- else { ! cerr << "[OpenAL] Cannot find " << name << " for reading..." << endl; } *************** *** 217,221 **** #ifdef SOUND_DEBUG ! cout << "OpenAL:: LoadWavALBuffer: " << path << endl; #endif --- 217,221 ---- #ifdef SOUND_DEBUG ! cout << "[OpenAL] LoadWavALBuffer: " << path << endl; #endif *************** *** 267,271 **** #ifdef SOUND_DEBUG ! cout << "OpenAL:: GetLoadedWavALBuffer: " << path << endl; #endif --- 267,271 ---- #ifdef SOUND_DEBUG ! cout << "[OpenAL] GetLoadedWavALBuffer: " << path << endl; #endif *************** *** 303,307 **** #ifdef SOUND_DEBUG ! cout << "OpenAL:: LoadWavALSample: " << name << endl; #endif --- 303,307 ---- #ifdef SOUND_DEBUG ! cout << "[OpenAL] LoadWavALSample: " << name << endl; #endif *************** *** 344,348 **** #ifdef SOUND_DEBUG ! cout << "OpenAL:: LoadOggALBuffer: " << path << endl; #endif --- 344,348 ---- #ifdef SOUND_DEBUG ! cout << "[OpenAL] LoadOggALBuffer: " << path << endl; #endif *************** *** 377,381 **** #ifdef SOUND_DEBUG ! cout << "OpenAL:: GetLoadedOggALBuffer: " << path << endl; #endif --- 377,381 ---- #ifdef SOUND_DEBUG ! cout << "[OpenAL] GetLoadedOggALBuffer: " << path << endl; #endif *************** *** 413,417 **** #ifdef SOUND_DEBUG ! cout << "OpenAL:: LoadOggALSample: " << name << endl; #endif --- 413,417 ---- #ifdef SOUND_DEBUG ! cout << "[OpenAL] LoadOggALSample: " << name << endl; #endif *************** *** 457,461 **** if (ov_open(f, &oggFile, NULL, 0) != 0) { ! cerr << "OpenAL:: Error opening " << fileName << " for decoding..." << endl; exit(-1); } --- 457,461 ---- if (ov_open(f, &oggFile, NULL, 0) != 0) { ! cerr << "[OpenAL] Error opening " << fileName << " for decoding..." << endl; exit(-1); } *************** *** 484,488 **** { ov_clear(&oggFile); ! cerr << "OpenAL:: Error decoding " << fileName << "..." << endl; exit(-1); } --- 484,488 ---- { ov_clear(&oggFile); ! cerr << "[OpenAL] Error decoding " << fileName << "..." << endl; exit(-1); } *************** *** 506,510 **** { #ifdef SOUND_DEBUG ! cout << "OpenAL:: SetSoundProperties: " << name << "(" << x << "," << y << "," << z << ")" << endl; #endif --- 506,510 ---- { #ifdef SOUND_DEBUG ! cout << "[OpenAL] SetSoundProperties: " << name << "(" << x << "," << y << "," << z << ")" << endl; #endif *************** *** 521,525 **** { #ifdef SOUND_DEBUG ! cout << "OpenAL:: SetSoundVolume: " << name << "(" << x << ")" << endl; #endif --- 521,525 ---- { #ifdef SOUND_DEBUG ! cout << "[OpenAL] SetSoundVolume: " << name << "(" << x << ")" << endl; #endif *************** *** 534,538 **** { #ifdef SOUND_DEBUG ! cout << "OpenAL:: PlaySound: " << name << endl; #endif --- 534,538 ---- { #ifdef SOUND_DEBUG ! cout << "[OpenAL] PlaySound: " << name << endl; #endif *************** *** 547,551 **** { #ifdef SOUND_DEBUG ! cout << "OpenAL:: StopSound: " << name << endl; #endif --- 547,551 ---- { #ifdef SOUND_DEBUG ! cout << "[OpenAL] StopSound: " << name << endl; #endif *************** *** 562,566 **** { #ifdef SOUND_DEBUG ! cout << "OpenAL:: SoundStatus: " << name << endl; #endif --- 562,566 ---- { #ifdef SOUND_DEBUG ! cout << "[OpenAL] SoundStatus: " << name << endl; #endif *************** *** 596,600 **** else { ! cerr << "OpenAL:: Sound " << name << " not loaded..." << endl; return AL_FALSE; } --- 596,602 ---- else { ! #ifdef SOUND_DEBUG ! cerr << "[OpenAL] Sound " << name << " not loaded..." << endl; ! #endif return AL_FALSE; } *************** *** 613,617 **** #ifdef SOUND_DEBUG ! cout << "OpenAL:: KillALData" << endl; #endif --- 615,619 ---- #ifdef SOUND_DEBUG ! cout << "[OpenAL] KillALData" << endl; #endif *************** *** 634,638 **** if (file.fail()) { ! cerr << "OpenAL:: Cannot parse SoundFile: " << filename << endl; return; } --- 636,640 ---- if (file.fail()) { ! cerr << "[OpenAL] Cannot parse SoundFile: " << filename << endl; return; } |
|
From: julien r. <jul...@us...> - 2004-10-28 21:20:46
|
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1491 Modified Files: aicontroller.h config.cfg controller.cc controller.h game.cc pawn.h playercontroller.cc Log Message: quaternions Index: config.cfg =================================================================== RCS file: /cvsroot/epfl/tggame/config.cfg,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** config.cfg 25 Oct 2004 20:04:14 -0000 1.7 --- config.cfg 28 Oct 2004 21:20:33 -0000 1.8 *************** *** 5,7 **** -set lightpos.y 0 -set bump 0 - -clip --- 5,6 ---- Index: game.cc =================================================================== RCS file: /cvsroot/epfl/tggame/game.cc,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** game.cc 25 Oct 2004 20:04:14 -0000 1.20 --- game.cc 28 Oct 2004 21:20:33 -0000 1.21 *************** *** 124,128 **** pPhysicEngine->AddNode(pNode); pNode->SetPosition (Vector3(100,50,0)); - //pNode->SetYRot (45); //création d'un ennemi --- 124,127 ---- *************** *** 135,139 **** p->SetVelocity(Vector3(0,0,0)); p->SetPosition(Vector3(50,70,0)); ! p->SetRotationVelocity(Vector3(10,0,10)); //p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(0,30,0)); //p->GetModel()->SetPhysicCallBack(c); --- 134,140 ---- p->SetVelocity(Vector3(0,0,0)); p->SetPosition(Vector3(50,70,0)); ! ! p->SetRotationVelocity(Quaternion(0.5,Vector3(0,1,1))); ! p->SetRotation(Quaternion(90,Vector3(0,1,0))); //p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(0,30,0)); //p->GetModel()->SetPhysicCallBack(c); Index: pawn.h =================================================================== RCS file: /cvsroot/epfl/tggame/pawn.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** pawn.h 25 Oct 2004 20:04:14 -0000 1.7 --- pawn.h 28 Oct 2004 21:20:33 -0000 1.8 *************** *** 39,47 **** inline Vector3 GetPosition () { return pPhysic->GetPosition(); } ! inline Vector3 GetRotation () { return pPhysic->GetRotation(); } ! inline void SetRotation (const Vector3& v) { pPhysic->SetRotation(v); } ! inline void SetRotationVelocity (const Vector3& q) { pPhysic->SetRotationVelocity(q); } inline float GetMoveSpeed () { return fMoveSpeed; } --- 39,47 ---- inline Vector3 GetPosition () { return pPhysic->GetPosition(); } ! inline Quaternion GetRotation () { return pPhysic->GetRotation(); } ! inline void SetRotation (const Quaternion& q) { pPhysic->SetRotation(q); } ! inline void SetRotationVelocity (const Quaternion& q) { pPhysic->SetRotationVelocity(q); } inline float GetMoveSpeed () { return fMoveSpeed; } Index: controller.h =================================================================== RCS file: /cvsroot/epfl/tggame/controller.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** controller.h 24 Oct 2004 14:53:58 -0000 1.6 --- controller.h 28 Oct 2004 21:20:33 -0000 1.7 *************** *** 17,20 **** --- 17,21 ---- public: Controller (Pawn*); + virtual ~Controller () {} virtual void Think (float) = 0; Index: aicontroller.h =================================================================== RCS file: /cvsroot/epfl/tggame/aicontroller.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** aicontroller.h 14 Oct 2004 13:21:06 -0000 1.2 --- aicontroller.h 28 Oct 2004 21:20:33 -0000 1.3 *************** *** 9,12 **** --- 9,14 ---- public: AIController (Pawn* p) : Controller(p) {} + virtual ~AIController() {} + void Think (float); void Collide (SceneNode* other, const Vector3& vPoint, const Vector3& vCollisionNormal); Index: playercontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/playercontroller.cc,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** playercontroller.cc 25 Oct 2004 20:04:14 -0000 1.8 --- playercontroller.cc 28 Oct 2004 21:20:33 -0000 1.9 *************** *** 13,16 **** --- 13,19 ---- { float fSensivity = 0.02; + static float ry = 0; + static float rx = 0; + int mX, mY; int middleX, middleY; *************** *** 18,29 **** middleX = 320; middleY = 240; ! Vector3 mRot(0,0,0); ! mRot.y += ((float)mX-middleX)*6*fSensivity; ! mRot.x += ((float)mY-middleY)*6*fSensivity; Game::pSelf->GetEngine()->WarpMouse(middleX,middleY); ! pPawn->SetRotation(pPawn->GetRotation()+mRot); } --- 21,42 ---- middleX = 320; middleY = 240; + //si la souris reste au milieu, on a pas besoin de tourner + if ((mX == middleX) && (mY == middleY)) + return; ! //Vector3 mRot(0,0,0); ! //Quaternion roty (((float)mX-middleX)*6*fSensivity, 0,1,0); ! //Quaternion rotx (((float)mY-middleY)*6*fSensivity, 1,0,0); ! ry += ((float)mX-middleX)*6*fSensivity; ! rx += ((float)mY-middleY)*6*fSensivity; Game::pSelf->GetEngine()->WarpMouse(middleX,middleY); ! //pPawn->SetRotation(pPawn->GetRotation()+mRot); ! //pPawn->SetRotation(pPawn->GetRotation()*roty*rotx); ! Quaternion q; ! q.FromEuler(rx, ry, 0); ! q.Normalize(); ! pPawn->SetRotation(q); } Index: controller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/controller.cc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** controller.cc 24 Oct 2004 14:53:58 -0000 1.6 --- controller.cc 28 Oct 2004 21:20:33 -0000 1.7 *************** *** 20,28 **** //on garde la vitesse sur les y, elle est gérée par le moteur physique pPawn->SetVelocity(pPawn->GetVelocity()-vLastVel); ! Vector3 rot = pPawn->GetRotation(); ! vLastVel.Null(); ! if (bDir[0]) { vLastVel.x = vVelocity.x += sinf(rot.y*DEGTORAD)*fSpeed; vLastVel.z = vVelocity.z -= cosf(rot.y*DEGTORAD)*fSpeed; --- 20,28 ---- //on garde la vitesse sur les y, elle est gérée par le moteur physique pPawn->SetVelocity(pPawn->GetVelocity()-vLastVel); ! //Vector3 rot = pPawn->GetRotation(); ! Quaternion rot = pPawn->GetRotation(); vLastVel.Null(); ! /*if (bDir[0]) { vLastVel.x = vVelocity.x += sinf(rot.y*DEGTORAD)*fSpeed; vLastVel.z = vVelocity.z -= cosf(rot.y*DEGTORAD)*fSpeed; *************** *** 42,46 **** vLastVel.x = vVelocity.x += cosf(rot.y*DEGTORAD)*fSpeed; vLastVel.z = vVelocity.z += sinf(rot.y*DEGTORAD)*fSpeed; ! } pPawn->SetVelocity(pPawn->GetVelocity()+vVelocity); --- 42,60 ---- vLastVel.x = vVelocity.x += cosf(rot.y*DEGTORAD)*fSpeed; vLastVel.z = vVelocity.z += sinf(rot.y*DEGTORAD)*fSpeed; ! }*/ ! Vector3 x, z; ! //x = rot.Rotate(Vector3::UNIT_X); ! //z = rot.Rotate(Vector3::UNIT_Z); ! x = rot.GetXAxis(); ! z = rot.GetZAxis(); ! if (bDir[0]) ! vLastVel = vVelocity += x*fSpeed; ! if (bDir[1]) ! vLastVel = vVelocity -= x*fSpeed; ! if (bDir[2]) ! vLastVel = vVelocity += z*fSpeed; ! if (bDir[3]) ! vLastVel = vVelocity -= z*fSpeed; ! pPawn->SetVelocity(pPawn->GetVelocity()+vVelocity); |
|
From: julien r. <jul...@us...> - 2004-10-28 21:10:32
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31280 Modified Files: camera.cc glrenderer.cc md5instance.cc md5instance.h physicengine.cc physicnode.cc physicnode.h quaternion.cc quaternion.h scenemanager.cc scenenode.cc scenenode.h Log Message: rotation utilisent des quaternions Index: physicengine.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicengine.cc,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** physicengine.cc 24 Oct 2004 16:56:20 -0000 1.13 --- physicengine.cc 28 Oct 2004 21:10:16 -0000 1.14 *************** *** 96,100 **** n->SetPosition(n->GetPosition()+n->GetVelocity()*eTime); ! n->SetRotation(n->GetRotation()+n->GetRotationVelocity()*eTime); n->UpdatePosition(); --- 96,101 ---- n->SetPosition(n->GetPosition()+n->GetVelocity()*eTime); ! //n->SetRotation(n->GetRotation()+n->GetRotationVelocity()*eTime); ! n->SetRotation(n->GetRotation()*n->GetRotationVelocity()*eTime); n->UpdatePosition(); *************** *** 185,190 **** n->SetOnGround(false); ! n->SetRotation(n->GetRotation()+n->GetRotationVelocity()*eTime); ! n->UpdatePosition(); } --- 186,199 ---- n->SetOnGround(false); ! //n->SetRotation(n->GetRotation()+n->GetRotationVelocity()*eTime); ! /*n->SetRotation(n->GetRotation()*n->GetRotationVelocity()*eTime);*/ ! /*static float angle =0 ; ! angle+=1; ! angle=0; ! Quaternion q(angle, Vector3(0,0,0));*/ ! Quaternion q = n->GetRotationVelocity()*eTime; ! q.Normalize(); ! n->SetRotation(n->GetRotation()*q); ! n->UpdatePosition(); } Index: scenemanager.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/scenemanager.cc,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** scenemanager.cc 24 Oct 2004 16:56:20 -0000 1.10 --- scenemanager.cc 28 Oct 2004 21:10:16 -0000 1.11 *************** *** 59,62 **** --- 59,90 ---- pCamera->Update (frameInterval); pCamera->Look (); + + glPushMatrix(); + + Quaternion q = pCamera->GetRotation(); + Vector3 fwd, rgt, up; + fwd = q.GetXAxis(); + rgt = q.GetZAxis(); + up = q.GetYAxis(); + + fwd *= 10; + rgt *= 10; + up *= 10; + //glTranslatef(-13,-10,-20); + glDisable (GL_TEXTURE_2D); + glBegin (GL_LINES); + glColor3f (1,0,0); + glVertex3f (0,0,0); + glVertex3fv (&fwd.x); + + glColor3f(0,0,1); + glVertex3f (0,0,0); + glVertex3fv (&rgt.x); + + glColor3f(0,1,0); + glVertex3f (0,0,0); + glVertex3fv (&up.x); + glEnd (); + glPopMatrix (); //Engine::pRenderer->RenderBBox(pCamera->pBBox); } Index: quaternion.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/quaternion.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** quaternion.h 24 Oct 2004 13:36:59 -0000 1.2 --- quaternion.h 28 Oct 2004 21:10:16 -0000 1.3 *************** *** 18,22 **** public: inline Quaternion () : r(1), x(0), y(0), z(0) {} //par defaut, on met le quaternion identite ! inline Quaternion (float f, float i, float j, float k) { SetRotation(f,i,j,k); } inline Quaternion (const Quaternion& q) : r(q.r), x(q.x), y(q.y), z(q.z) {} inline Quaternion (float f, Vector3 v) { SetRotation(f, v);} --- 18,22 ---- public: inline Quaternion () : r(1), x(0), y(0), z(0) {} //par defaut, on met le quaternion identite ! inline Quaternion (float f, float i, float j, float k) : r(f), x(i), y(j), z(k) {} inline Quaternion (const Quaternion& q) : r(q.r), x(q.x), y(q.y), z(q.z) {} inline Quaternion (float f, Vector3 v) { SetRotation(f, v);} *************** *** 39,42 **** --- 39,46 ---- float Magnitude (); + Vector3 GetXAxis() const; + Vector3 GetYAxis() const; + Vector3 GetZAxis() const; + /** * Trouve la valeure de R, utilise par les mesh au format md5 *************** *** 45,65 **** /** - * Utilise par le md5 lorsque des valeurs de quaternions semblent s'inverser - */ - /*inline void CheckCoSom () { float c = - - - float cosom = q1[0] * q2[0] + q1[1] * q2[1] + q1[2] * q2[2] + q1[3] * q2[3]; - if (cosom < 0.0f) - { - q2[0] = -q2[0]; - q2[1] = -q2[1]; - q2[2] = -q2[2]; - q2[3] = -q2[3]; - } */ - /** * Normalise le quaternion */ void Normalize (); Quaternion Inverse (); --- 49,57 ---- /** * Normalise le quaternion */ void Normalize (); + + void GetMatrix (float*) const; Quaternion Inverse (); *************** *** 77,80 **** --- 69,74 ---- */ float GetRotationAngle (); + + void FromEuler (float, float, float); /** Index: physicnode.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicnode.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** physicnode.cc 24 Oct 2004 13:36:59 -0000 1.2 --- physicnode.cc 28 Oct 2004 21:10:16 -0000 1.3 *************** *** 14,19 **** vPosition.Null(); vAccel.Null(); ! vEuler.Null(); ! vEulerVelocity.Null(); } --- 14,20 ---- vPosition.Null(); vAccel.Null(); ! ! //vEuler.Null(); ! //vEulerVelocity.Null(); } *************** *** 24,28 **** n = vNodes[i]; n->SetPosition(vPosition); ! n->SetRotation(vEuler); } } --- 25,29 ---- n = vNodes[i]; n->SetPosition(vPosition); ! n->SetRotation(qRotation); } } Index: physicnode.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicnode.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** physicnode.h 24 Oct 2004 13:36:59 -0000 1.2 --- physicnode.h 28 Oct 2004 21:10:16 -0000 1.3 *************** *** 6,9 **** --- 6,10 ---- #include "boundingbox.h" #include "scenenode.h" + #include "quaternion.h" *************** *** 86,90 **** /* Rotation */ ! inline Vector3 GetRotation () { return vEuler; } inline void SetRotation (const Vector3& v) { vEuler = v; } inline void AddRotation (const Vector3& v) { vEuler += v; } --- 87,93 ---- /* Rotation */ ! inline Quaternion GetRotation () { return qRotation; } ! inline void SetRotation (const Quaternion& q) { qRotation = q; } ! /*inline Vector3 GetRotation () { return vEuler; } inline void SetRotation (const Vector3& v) { vEuler = v; } inline void AddRotation (const Vector3& v) { vEuler += v; } *************** *** 97,104 **** inline void AddXRot (float f) { vEuler.x += f; } inline void AddYRot (float f) { vEuler.y += f; } ! inline void AddZRot (float f) { vEuler.z += f; } /* Vitesse de rotation */ ! inline Vector3 GetRotationVelocity () { return vEulerVelocity; } inline void SetRotationVelocity (const Vector3& v) { vEulerVelocity = v; } inline void AddRotVelocity (const Vector3& v) { vEulerVelocity += v; } --- 100,109 ---- inline void AddXRot (float f) { vEuler.x += f; } inline void AddYRot (float f) { vEuler.y += f; } ! inline void AddZRot (float f) { vEuler.z += f; }*/ /* Vitesse de rotation */ ! inline Quaternion GetRotationVelocity () { return qRotationVelocity; } ! inline void SetRotationVelocity (const Quaternion& q) { qRotationVelocity = q; } ! /*inline Vector3 GetRotationVelocity () { return vEulerVelocity; } inline void SetRotationVelocity (const Vector3& v) { vEulerVelocity = v; } inline void AddRotVelocity (const Vector3& v) { vEulerVelocity += v; } *************** *** 111,115 **** inline void AddXRotVelocity (float f) { vEulerVelocity.x += f; } inline void AddYRotVelocity (float f) { vEulerVelocity.y += f; } ! inline void AddZRotVelocity (float f) { vEulerVelocity.z += f; } void UpdatePosition (); --- 116,120 ---- inline void AddXRotVelocity (float f) { vEulerVelocity.x += f; } inline void AddYRotVelocity (float f) { vEulerVelocity.y += f; } ! inline void AddZRotVelocity (float f) { vEulerVelocity.z += f; }*/ void UpdatePosition (); *************** *** 122,127 **** Vector3 vAccel; Vector3 vVelocity; ! Vector3 vEuler; ! Vector3 vEulerVelocity; Vector3 vPosition; BoundingBox* pBBox; --- 127,134 ---- Vector3 vAccel; Vector3 vVelocity; ! //Vector3 vEuler; ! //Vector3 vEulerVelocity; ! Quaternion qRotation; ! Quaternion qRotationVelocity; Vector3 vPosition; BoundingBox* pBBox; Index: scenenode.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/scenenode.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** scenenode.h 24 Oct 2004 16:56:20 -0000 1.6 --- scenenode.h 28 Oct 2004 21:10:16 -0000 1.7 *************** *** 38,42 **** /* Rotation */ ! Vector3 GetRotation () { return vEuler; } virtual void SetRotation (const Vector3& v) { vEuler = v; } inline float GetXRot () { return vEuler.x; } --- 38,44 ---- /* Rotation */ ! inline Quaternion GetRotation () { return qRotation; } ! inline void SetRotation (const Quaternion& q) { qRotation=q; } ! /*Vector3 GetRotation () { return vEuler; } virtual void SetRotation (const Vector3& v) { vEuler = v; } inline float GetXRot () { return vEuler.x; } *************** *** 48,52 **** inline void AddXRot (float f) { vEuler.x += f; } inline void AddYRot (float f) { vEuler.y += f; } ! inline void AddZRot (float f) { vEuler.z += f; } /* Autres */ --- 50,54 ---- inline void AddXRot (float f) { vEuler.x += f; } inline void AddYRot (float f) { vEuler.y += f; } ! inline void AddZRot (float f) { vEuler.z += f; }*/ /* Autres */ *************** *** 63,67 **** //PhysicCallBack* pPhysicCallBack; bool bRender; ! Vector3 vEuler; Vector3 vPosition; --- 65,70 ---- //PhysicCallBack* pPhysicCallBack; bool bRender; ! //Vector3 vEuler; ! Quaternion qRotation; Vector3 vPosition; Index: quaternion.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/quaternion.cc,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** quaternion.cc 26 Sep 2004 13:15:23 -0000 1.1.1.1 --- quaternion.cc 28 Oct 2004 21:10:16 -0000 1.2 *************** *** 78,81 **** --- 78,138 ---- } + Vector3 Quaternion::GetXAxis () const + { + //float tx = 2*x; + float ty = 2*y; + float tz = 2*z; + float twy = ty*r; + float twz = tz*r; + float txy = ty*x; + float txz = tz*x; + float tyy = ty*y; + float tzz = tz*z; + + return Vector3 (1.0f-(tyy+tzz), txy+twz, txz-twy); + } + + Vector3 Quaternion::GetYAxis () const + { + float tx = 2*x; + float ty = 2*y; + float tz = 2*z; + float twx = tx*r; + float twz = tz*r; + float txx = tx*x; + float txy = ty*x; + float tyz = tz*y; + float tzz = tz*z; + + return Vector3(txy-twz, 1.0f-(txx+tzz), tyz+twx); + } + + Vector3 Quaternion::GetZAxis () const + { + float tx = 2*x; + float ty = 2*y; + float tz = 2*z; + float twx = tx*r; + float twy = ty*r; + float txx = tx*x; + float txz = tz*x; + float tyy = ty*y; + float tyz = tz*y; + + return Vector3(txz+twy, tyz-twx, 1.0f-(txx+tyy)); + } + + void Quaternion::FromEuler(float x, float y, float z) + { + Quaternion qx (x, Vector3(1,0,0)); + Quaternion qy (y, Vector3(0,1,0)); + Quaternion qz (z, Vector3(0,0,1)); + Quaternion qt; + + qt = qx*qy; + *this = qt*qz; + } + + float Quaternion::Norm() { *************** *** 114,120 **** Vector3 Quaternion::Rotate (const Vector3& v) const { //nVidia SDK // trouve dans Ogre3d ! Vector3 uv, uuv; Vector3 qvec(x,y,z); uv = qvec%v; --- 171,184 ---- Vector3 Quaternion::Rotate (const Vector3& v) const { + Quaternion vec(0, v.x, v.y, v.z); + Quaternion q = *this; + Quaternion qinv = q.Conjugate(); + + Quaternion vec2 = q*vec*qinv; + + return Vector3 (vec2.x, vec2.y, vec2.z); //nVidia SDK // trouve dans Ogre3d ! /*Vector3 uv, uuv; Vector3 qvec(x,y,z); uv = qvec%v; *************** *** 122,134 **** uv *= (2.0f*r); uuv *= 2.0f; ! return v + uv + uuv; ! /* Quaternion qv(0, v.x, v.y, v.z); Quaternion qm = (*this)*qv*(this->Inverse()); return Vector3 (qm.x, qm.y, qm.z);*/ } void Quaternion::SetRotation (float a,const Vector3& tv) { Vector3 tmp = tv.Normalize (); float sin_a = sinf (a/2); float cos_a = cosf (a/2); --- 186,222 ---- uv *= (2.0f*r); uuv *= 2.0f; ! return v + uv + uuv;*/ ! /*Quaternion qv(0, v.x, v.y, v.z); Quaternion qm = (*this)*qv*(this->Inverse()); return Vector3 (qm.x, qm.y, qm.z);*/ } + void Quaternion::GetMatrix(float* m) const + { + m[0] = 1.0f - 2.0f * (y * y + z * z); + m[1] = 2.0f * (x * y + z * r); + m[2] = 2.0f * (x * z - y * r); + m[3] = 0.0f; + + m[4] = 2.0f * (x * y - z * r); + m[5] = 1.0f - 2.0f * (x * x + z * z); + m[6] = 2.0f * (z * y + x * r); + m[7] = 0.0f; + + m[8] = 2.0f * (x * z + y * r); + m[9] = 2.0f * (y * z - x * r); + m[10] = 1.0f - 2.0f * (x * x + y * y); + m[11] = 0.0f; + + m[12] = 0; + m[13] = 0; + m[14] = 0; + m[15] = 1.0f; + } + void Quaternion::SetRotation (float a,const Vector3& tv) { Vector3 tmp = tv.Normalize (); + a *= DEGTORAD; float sin_a = sinf (a/2); float cos_a = cosf (a/2); *************** *** 137,141 **** z = tmp.z*sin_a; r = cos_a; - this->Normalize(); } --- 225,228 ---- Index: md5instance.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5instance.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** md5instance.h 30 Sep 2004 09:23:16 -0000 1.4 --- md5instance.h 28 Oct 2004 21:10:16 -0000 1.5 *************** *** 49,53 **** void DrawVisibleEdges () {} protected: ! void _BuildBone (int, Joint*,const Quaternion&, const Vector3&); void _SkinMesh (); void _CalculateBBox (); --- 49,53 ---- void DrawVisibleEdges () {} protected: ! void _BuildBone (int, Joint*, const Quaternion&, const Vector3&); void _SkinMesh (); void _CalculateBBox (); Index: scenenode.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/scenenode.cc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** scenenode.cc 24 Oct 2004 16:56:20 -0000 1.6 --- scenenode.cc 28 Oct 2004 21:10:16 -0000 1.7 *************** *** 6,14 **** { vPosition.Null(); - // vVelocity.Null(); - // vAccel.Null(); pBBox = new BoundingBox (); ! vEuler.Null(); // bNoClip = false; --- 6,12 ---- { vPosition.Null(); pBBox = new BoundingBox (); ! //vEuler.Null(); // bNoClip = false; *************** *** 24,32 **** vPosition = p; - // vVelocity.Null(); - // vAccel.Null(); pBBox = new BoundingBox (); ! vEuler.Null(); // bNoClip = false; --- 22,28 ---- vPosition = p; pBBox = new BoundingBox (); ! //vEuler.Null(); // bNoClip = false; Index: glrenderer.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/glrenderer.cc,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** glrenderer.cc 24 Oct 2004 14:51:54 -0000 1.10 --- glrenderer.cc 28 Oct 2004 21:10:16 -0000 1.11 *************** *** 776,782 **** void GLRenderer::_RotateNode (SceneNode* s) { ! glRotatef(s->GetRotation().x, 1, 0, 0); glRotatef(s->GetRotation().y, 0, 1, 0); ! glRotatef(s->GetRotation().z, 0, 0, 1); /*Vector3 axis = s->GetRotation().GetRotationAxis(); glRotatef(s->GetRotation().GetRotationAngle(),axis.x, axis.y, axis.z);*/ --- 776,785 ---- void GLRenderer::_RotateNode (SceneNode* s) { ! float matrix[16]; ! s->GetRotation().GetMatrix(matrix); ! glMultMatrixf (matrix); ! /*glRotatef(s->GetRotation().x, 1, 0, 0); glRotatef(s->GetRotation().y, 0, 1, 0); ! glRotatef(s->GetRotation().z, 0, 0, 1);*/ /*Vector3 axis = s->GetRotation().GetRotationAxis(); glRotatef(s->GetRotation().GetRotationAngle(),axis.x, axis.y, axis.z);*/ *************** *** 1062,1069 **** glTranslatef(mesh->GetPosition().x, mesh->GetPosition().y, mesh->GetPosition().z); - #ifdef DEBUG Vector3 fwd, rgt, up; ! mesh->GetRotation().ToAngleVectors(fwd, rgt, up); fwd *= 10; rgt *= 10; --- 1065,1077 ---- glTranslatef(mesh->GetPosition().x, mesh->GetPosition().y, mesh->GetPosition().z); #ifdef DEBUG Vector3 fwd, rgt, up; ! //mesh->GetRotation().ToAngleVectors(fwd, rgt, up); ! //fwd = mesh->GetRotation().GetXAxis(); ! //rgt = mesh->GetRotation().GetZAxis(); ! //up = mesh->GetRotation().GetYAxis(); ! fwd = mesh->GetRotation().Rotate(Vector3::UNIT_X); ! rgt = mesh->GetRotation().Rotate(Vector3::UNIT_Z); ! up = mesh->GetRotation().Rotate(Vector3::UNIT_Y); fwd *= 10; rgt *= 10; *************** *** 1086,1105 **** _RotateNode(mesh); - glLineWidth(3.0f); - glBegin (GL_LINES); - glColor3f(1,0,0); - glVertex3f (0,0,0); - glVertex3f (10,0,0); - - glColor3f(0,0,1); - glVertex3f(0,0,0); - glVertex3f(0,0,10); - - glColor3f(0,1,0); - glVertex3f(0,0,0); - glVertex3f(0,10,0); - glEnd (); - glLineWidth(1.0f); - glScalef(mesh->fScale, mesh->fScale, mesh->fScale); --- 1094,1097 ---- Index: camera.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/camera.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** camera.cc 24 Oct 2004 14:51:54 -0000 1.5 --- camera.cc 28 Oct 2004 21:10:16 -0000 1.6 *************** *** 96,100 **** }*/ ! vRot.ToAngleVectors(vForward, vRight, vUp); //_AngleToVectors (); } --- 96,103 ---- }*/ ! //vRot.ToAngleVectors(vForward, vRight, vUp); ! vForward = qRotation.GetXAxis (); ! vRight = qRotation.GetZAxis (); ! vUp = qRotation.GetYAxis (); //_AngleToVectors (); } *************** *** 136,141 **** { glMatrixMode (GL_MODELVIEW); ! glRotatef(vEuler.x, 1.0f, 0.0f, 0.0f); ! glRotatef(vEuler.y, 0.0f, 1.0f, 0.0f); glTranslatef(-vPosition.x, -vPosition.y, -vPosition.z); frustum.Update(); --- 139,148 ---- { glMatrixMode (GL_MODELVIEW); ! //glRotatef (vEuler.z, 1.0f, 0.0f, 1.0f); ! //glRotatef(vEuler.x, 1.0f, 0.0f, 0.0f); ! //glRotatef(vEuler.y, 0.0f, 1.0f, 0.0f); ! float matrix[16]; ! qRotation.GetMatrix(matrix); ! glMultMatrixf (matrix); 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.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** md5instance.cc 30 Sep 2004 09:23:16 -0000 1.5 --- md5instance.cc 28 Oct 2004 21:10:16 -0000 1.6 *************** *** 168,172 **** } ! void MD5Instance::_BuildBone (int iFrame, Joint* pJoint, const Quaternion& q, const Vector3& v) { /*pJoint->vPosition.x = pData->anim_joint_GetBaseFrameElement(iCurrentAnimation, pJoint->iNumber, 0) + v.x; --- 168,172 ---- } ! void MD5Instance::_BuildBone (int iFrame, Joint* pJoint,const Quaternion& q, const Vector3& v) { /*pJoint->vPosition.x = pData->anim_joint_GetBaseFrameElement(iCurrentAnimation, pJoint->iNumber, 0) + v.x; |
|
From: julien r. <jul...@us...> - 2004-10-25 20:04:34
|
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14520 Modified Files: config.cfg game.cc game.h pawn.cc pawn.h playercontroller.cc playercontroller.h tg.cc Log Message: Index: config.cfg =================================================================== RCS file: /cvsroot/epfl/tggame/config.cfg,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** config.cfg 21 Oct 2004 21:29:15 -0000 1.6 --- config.cfg 25 Oct 2004 20:04:14 -0000 1.7 *************** *** 5,6 **** --- 5,7 ---- -set lightpos.y 0 -set bump 0 + -clip Index: game.cc =================================================================== RCS file: /cvsroot/epfl/tggame/game.cc,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** game.cc 24 Oct 2004 14:53:58 -0000 1.19 --- game.cc 25 Oct 2004 20:04:14 -0000 1.20 *************** *** 5,8 **** --- 5,9 ---- Game::Game (int argc, char** argv) { + pSelf = this; //Initialisation de base pTimer = new Timer (); *************** *** 114,117 **** --- 115,119 ---- p->GetBBox()->vMax = Vector3(10,10,10); p->SetMoveSpeed (CAM_SPEED); + p->SetVisible(false); //p->GetCamera()->SetPhysicCallBack(pLocalController); *************** *** 133,137 **** p->SetVelocity(Vector3(0,0,0)); p->SetPosition(Vector3(50,70,0)); ! p->SetRotationVelocity(Vector3(10,10,0)); //p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(0,30,0)); //p->GetModel()->SetPhysicCallBack(c); --- 135,139 ---- p->SetVelocity(Vector3(0,0,0)); p->SetPosition(Vector3(50,70,0)); ! p->SetRotationVelocity(Vector3(10,0,10)); //p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(0,30,0)); //p->GetModel()->SetPhysicCallBack(c); Index: pawn.cc =================================================================== RCS file: /cvsroot/epfl/tggame/pawn.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pawn.cc 24 Oct 2004 14:53:58 -0000 1.5 --- pawn.cc 25 Oct 2004 20:04:14 -0000 1.6 *************** *** 9,13 **** pModel = Engine::pMeshManager->Load("data/models/pinky/pinky.md5mesh"); pPhysic = new PhysicNode(pModel); - pPhysic->SetClip(true); fMoveSpeed = 0.0f; } --- 9,12 ---- Index: pawn.h =================================================================== RCS file: /cvsroot/epfl/tggame/pawn.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pawn.h 24 Oct 2004 14:53:58 -0000 1.6 --- pawn.h 25 Oct 2004 20:04:14 -0000 1.7 *************** *** 52,55 **** --- 52,60 ---- void Add(PhysicEngine* p) {p->AddNode(pPhysic); } void Add(SceneManager* s) {s->AddWorldObject(pModel); } + + inline void SetClip(bool b) { pPhysic->SetClip(b); } + inline bool GetClip () { return pPhysic->Clip(); } + + inline void SetVisible (bool b) { pModel->SetRender(b); } //Model* GetModel () { return pModel; } Index: playercontroller.h =================================================================== RCS file: /cvsroot/epfl/tggame/playercontroller.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** playercontroller.h 10 Oct 2004 20:54:47 -0000 1.3 --- playercontroller.h 25 Oct 2004 20:04:14 -0000 1.4 *************** *** 8,13 **** using namespace tg; ! class PlayerController : public Controller { public: PlayerController (Pawn*); --- 8,17 ---- using namespace tg; ! class PlayerController : public Controller, public Function { + enum { + CLIP=1 + }; + public: PlayerController (Pawn*); *************** *** 15,18 **** --- 19,29 ---- void EventHandler (tgEvent& e); void Collide(SceneNode* other, const Vector3& vPoint, const Vector3& vCollisionNormal); + + void Exec (const std::string& s, int arg) { + switch(arg) { + case CLIP: pPawn->SetClip(pPawn->GetClip() ? false:true); break; + default: break; + } + } }; Index: playercontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/playercontroller.cc,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** playercontroller.cc 24 Oct 2004 14:53:58 -0000 1.7 --- playercontroller.cc 25 Oct 2004 20:04:14 -0000 1.8 *************** *** 7,11 **** PlayerController::PlayerController(Pawn* p) : Controller (p) { ! } --- 7,11 ---- PlayerController::PlayerController(Pawn* p) : Controller (p) { ! Game::pSelf->GetConsole()->Register("clip", this, CLIP); } Index: tg.cc =================================================================== RCS file: /cvsroot/epfl/tggame/tg.cc,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** tg.cc 23 Sep 2004 22:57:24 -0000 1.1.1.1 --- tg.cc 25 Oct 2004 20:04:14 -0000 1.2 *************** *** 4,8 **** { Game* pGame = new Game(argc, argv); - pGame->pSelf = pGame; pGame->MainLoop (); }; --- 4,7 ---- Index: game.h =================================================================== RCS file: /cvsroot/epfl/tggame/game.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** game.h 24 Oct 2004 14:53:58 -0000 1.7 --- game.h 25 Oct 2004 20:04:14 -0000 1.8 *************** *** 56,59 **** --- 56,60 ---- inline World* GetWorld () { return pWorld; } inline Engine* GetEngine () { return pEngine; } + inline Console* GetConsole () { return pConsole; } /** |
|
From: julien r. <jul...@us...> - 2004-10-24 16:56:29
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22509 Modified Files: physicengine.cc scenemanager.cc scenenode.cc scenenode.h Log Message: Index: scenenode.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/scenenode.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** scenenode.cc 21 Oct 2004 21:18:28 -0000 1.5 --- scenenode.cc 24 Oct 2004 16:56:20 -0000 1.6 *************** *** 16,19 **** --- 16,20 ---- // bOnGround = false; bIsCamera = false; + bRender = true; // pPhysicCallBack = NULL; } *************** *** 33,36 **** --- 34,38 ---- // bOnGround = false; bIsCamera = false; + bRender = true; // pPhysicCallBack = NULL; } Index: physicengine.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicengine.cc,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** physicengine.cc 24 Oct 2004 13:36:59 -0000 1.12 --- physicengine.cc 24 Oct 2004 16:56:20 -0000 1.13 *************** *** 26,30 **** trace.Fraction = 0.0f; ! while ((trace.Fraction < (1.0f - EPSILON)) || (bumpcount < MAXBUMPS)) //a chaque fois qu'on rencontre un plan, on relance un trace avec comme origine le Endpoint sur le plan précédent et on ajuste la vitesse de notre objet. MAXBUMPS permet simplement d'éviter des boucles infinies { --- 26,30 ---- trace.Fraction = 0.0f; ! while ((trace.Fraction < (1.0f - EPSILON)) && (bumpcount < MAXBUMPS)) //a chaque fois qu'on rencontre un plan, on relance un trace avec comme origine le Endpoint sur le plan précédent et on ajuste la vitesse de notre objet. MAXBUMPS permet simplement d'éviter des boucles infinies { *************** *** 47,51 **** time_left -= time_left*trace.Fraction; ClipVelocity (vVelocity, trace.CollisionNormal); ! } } --- 47,51 ---- time_left -= time_left*trace.Fraction; ClipVelocity (vVelocity, trace.CollisionNormal); ! bumpcount++; } } *************** *** 90,93 **** --- 90,98 ---- if (!n->Clip()) { + //ugly hack pour éviter de tomber quand on tappe noclip le jeu étant deja lancé (on se choppe l'accel négative de la frame précédente en fait... + Vector3 veloc = n->GetVelocity(); + veloc.y = 0; + n->SetVelocity(veloc); + n->SetPosition(n->GetPosition()+n->GetVelocity()*eTime); n->SetRotation(n->GetRotation()+n->GetRotationVelocity()*eTime); Index: scenemanager.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/scenemanager.cc,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** scenemanager.cc 24 Oct 2004 13:36:59 -0000 1.9 --- scenemanager.cc 24 Oct 2004 16:56:20 -0000 1.10 *************** *** 89,97 **** { do ! { m->PreRender(frameInterval); m->GetBBox()->CalculatePlanes(); m->iLeaf = pLevel->FindLeaf(m->GetPosition()); ! if ((pLevel->IsVisible(m->iLeaf) || m->bCamera)) { --- 89,97 ---- { do ! { m->PreRender(frameInterval); m->GetBBox()->CalculatePlanes(); m->iLeaf = pLevel->FindLeaf(m->GetPosition()); ! if (m->GetRender() && ((pLevel->IsVisible(m->iLeaf) || m->bCamera))) { *************** *** 109,113 **** } ! m = pFirstObject; if (m != NULL) --- 109,113 ---- } ! /* m = pFirstObject; if (m != NULL) *************** *** 115,119 **** do { ! if (pLevel->IsVisible(m->iLeaf)) { Engine::pRenderer->RenderMeshShadow(m); --- 115,119 ---- do { ! if (m->GetRender() && pLevel->IsVisible(m->iLeaf)) { Engine::pRenderer->RenderMeshShadow(m); *************** *** 121,125 **** } while((m=m->GetNext()) != NULL); Engine::pRenderer->EndShadow(); ! } PointLight* pl = pFirstPointLight; --- 121,125 ---- } while((m=m->GetNext()) != NULL); Engine::pRenderer->EndShadow(); ! }*/ PointLight* pl = pFirstPointLight; Index: scenenode.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/scenenode.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** scenenode.h 24 Oct 2004 13:36:59 -0000 1.5 --- scenenode.h 24 Oct 2004 16:56:20 -0000 1.6 *************** *** 30,33 **** --- 30,36 ---- inline BoundingBox* GetBBox () { return pBBox; } + inline void SetRender(bool b) { bRender = b; } + inline bool GetRender () { return bRender; } + /* Position */ virtual void SetPosition (Vector3 v); *************** *** 59,63 **** protected: //PhysicCallBack* pPhysicCallBack; ! Vector3 vEuler; Vector3 vPosition; --- 62,66 ---- protected: //PhysicCallBack* pPhysicCallBack; ! bool bRender; Vector3 vEuler; Vector3 vPosition; |
|
From: julien r. <jul...@us...> - 2004-10-24 14:54:08
|
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23304 Modified Files: controller.cc controller.h game.cc game.h pawn.cc pawn.h playercontroller.cc Log Message: pas mal de suppression de bugs concernant les mouvements Index: game.cc =================================================================== RCS file: /cvsroot/epfl/tggame/game.cc,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** game.cc 22 Oct 2004 20:30:22 -0000 1.18 --- game.cc 24 Oct 2004 14:53:58 -0000 1.19 *************** *** 122,127 **** pPhysicEngine->AddNode(pNode); pNode->SetPosition (Vector3(100,50,0)); ! //pNode->SetYRot (45); ! //création d'un ennemi --- 122,126 ---- pPhysicEngine->AddNode(pNode); pNode->SetPosition (Vector3(100,50,0)); ! //pNode->SetYRot (45); //création d'un ennemi *************** *** 133,138 **** p->SetMoveSpeed(CAM_SPEED); p->SetVelocity(Vector3(0,0,0)); ! p->SetPosition(Vector3(0,10,0)); ! p->SetRotVelocity(Vector3(0,20,0)); //p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(0,30,0)); //p->GetModel()->SetPhysicCallBack(c); --- 132,137 ---- p->SetMoveSpeed(CAM_SPEED); p->SetVelocity(Vector3(0,0,0)); ! p->SetPosition(Vector3(50,70,0)); ! p->SetRotationVelocity(Vector3(10,10,0)); //p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(0,30,0)); //p->GetModel()->SetPhysicCallBack(c); Index: pawn.h =================================================================== RCS file: /cvsroot/epfl/tggame/pawn.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pawn.h 21 Oct 2004 21:29:15 -0000 1.5 --- pawn.h 24 Oct 2004 14:53:58 -0000 1.6 *************** *** 39,43 **** inline Vector3 GetPosition () { return pPhysic->GetPosition(); } ! inline void SetRotVelocity (const Vector3& v) { pPhysic->SetRotVelocity(v); } inline float GetMoveSpeed () { return fMoveSpeed; } --- 39,47 ---- inline Vector3 GetPosition () { return pPhysic->GetPosition(); } ! inline Vector3 GetRotation () { return pPhysic->GetRotation(); } ! ! inline void SetRotation (const Vector3& v) { pPhysic->SetRotation(v); } ! ! inline void SetRotationVelocity (const Vector3& q) { pPhysic->SetRotationVelocity(q); } inline float GetMoveSpeed () { return fMoveSpeed; } Index: pawn.cc =================================================================== RCS file: /cvsroot/epfl/tggame/pawn.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pawn.cc 21 Oct 2004 21:29:15 -0000 1.4 --- pawn.cc 24 Oct 2004 14:53:58 -0000 1.5 *************** *** 9,13 **** pModel = Engine::pMeshManager->Load("data/models/pinky/pinky.md5mesh"); pPhysic = new PhysicNode(pModel); ! pPhysic->SetClip(false); fMoveSpeed = 0.0f; } --- 9,13 ---- pModel = Engine::pMeshManager->Load("data/models/pinky/pinky.md5mesh"); pPhysic = new PhysicNode(pModel); ! pPhysic->SetClip(true); fMoveSpeed = 0.0f; } Index: controller.h =================================================================== RCS file: /cvsroot/epfl/tggame/controller.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** controller.h 21 Oct 2004 21:29:15 -0000 1.5 --- controller.h 24 Oct 2004 14:53:58 -0000 1.6 *************** *** 28,32 **** Pawn* pPawn; bool bDir[4]; ! bool bLastDir[4]; //pour les mouvements //int iForward; --- 28,33 ---- Pawn* pPawn; bool bDir[4]; ! ! Vector3 vLastVel; //pour les mouvements //int iForward; Index: playercontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/playercontroller.cc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** playercontroller.cc 21 Oct 2004 21:29:15 -0000 1.6 --- playercontroller.cc 24 Oct 2004 14:53:58 -0000 1.7 *************** *** 12,16 **** --- 12,29 ---- void PlayerController::Think (float eTime) { + float fSensivity = 0.02; + int mX, mY; + int middleX, middleY; + Game::pSelf->GetEngine()->GetMouseState(&mX,&mY); + middleX = 320; + middleY = 240; + Vector3 mRot(0,0,0); + mRot.y += ((float)mX-middleX)*6*fSensivity; + mRot.x += ((float)mY-middleY)*6*fSensivity; + + Game::pSelf->GetEngine()->WarpMouse(middleX,middleY); + + pPawn->SetRotation(pPawn->GetRotation()+mRot); } Index: game.h =================================================================== RCS file: /cvsroot/epfl/tggame/game.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** game.h 10 Oct 2004 21:18:41 -0000 1.6 --- game.h 24 Oct 2004 14:53:58 -0000 1.7 *************** *** 55,58 **** --- 55,59 ---- inline SceneManager* GetSceneManager () { return pSceneManager; } inline World* GetWorld () { return pWorld; } + inline Engine* GetEngine () { return pEngine; } /** Index: controller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/controller.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** controller.cc 21 Oct 2004 21:29:15 -0000 1.5 --- controller.cc 24 Oct 2004 14:53:58 -0000 1.6 *************** *** 8,12 **** for (int i=0; i<4; i++) { bDir[i] = false; - bLastDir[i] = false; } } --- 8,11 ---- *************** *** 20,57 **** float factor = 1.0f; //on garde la vitesse sur les y, elle est gérée par le moteur physique ! ! /*if (iForward >= 1) ! vVelocity.x += fSpeed; ! else if (iForward <= -1) ! vVelocity.x -= fSpeed; ! if (iStrafe >= 1) ! vVelocity.z += fSpeed; ! else if (iStrafe <= 1) ! vVelocity.z -= fSpeed;*/ ! ! if (bDir[0] && !bLastDir[0]) ! vVelocity.z -= fSpeed; ! else if (!bDir[0] && bLastDir[0]) ! vVelocity.z += fSpeed; ! if (bDir[1] && !bLastDir[1]) ! vVelocity.z += fSpeed; ! else if (!bDir[1] && bLastDir[1]) ! vVelocity.z -= fSpeed; ! if (bDir[2] && !bLastDir[2]) ! vVelocity.x -= fSpeed; ! else if (!bDir[2] && bLastDir[2]) ! vVelocity.x += fSpeed; ! if (bDir[3] && !bLastDir[3]) ! vVelocity.x += fSpeed; ! else if (!bDir[3] && bLastDir[3]) ! vVelocity.x -= fSpeed; ! for (int i=0; i<4; i++) ! bLastDir[i] = bDir[i]; ! ! //pPawn->GetModel()->SetAcceleration(vAccel); pPawn->SetVelocity(pPawn->GetVelocity()+vVelocity); --- 19,46 ---- float factor = 1.0f; //on garde la vitesse sur les y, elle est gérée par le moteur physique ! pPawn->SetVelocity(pPawn->GetVelocity()-vLastVel); ! Vector3 rot = pPawn->GetRotation(); ! vLastVel.Null(); ! if (bDir[0]) { ! vLastVel.x = vVelocity.x += sinf(rot.y*DEGTORAD)*fSpeed; ! vLastVel.z = vVelocity.z -= cosf(rot.y*DEGTORAD)*fSpeed; ! } ! if (bDir[1]) { ! vLastVel.x = vVelocity.x -= sinf(rot.y*DEGTORAD)*fSpeed; ! vLastVel.z = vVelocity.z += cosf(rot.y*DEGTORAD)*fSpeed; ! } ! if (bDir[2]) { ! vLastVel.x = vVelocity.x -= cosf(rot.y*DEGTORAD)*fSpeed; ! vLastVel.z = vVelocity.z -= sinf(rot.y*DEGTORAD)*fSpeed; ! } ! ! if (bDir[3]) { ! vLastVel.x = vVelocity.x += cosf(rot.y*DEGTORAD)*fSpeed; ! vLastVel.z = vVelocity.z += sinf(rot.y*DEGTORAD)*fSpeed; ! } pPawn->SetVelocity(pPawn->GetVelocity()+vVelocity); |