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-17 22:43:18
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13960 Modified Files: boundingbox.cc decalmanager.cc decalmanager.h physiccallback.h physicengine.cc physicengine.h physicnode.cc physicnode.h q3bsp.cc q3bsp.h scenemanager.cc scenemanager.h texture.cc Log Message: JPEG texture pour les map Index: physicengine.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicengine.cc,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** physicengine.cc 15 Nov 2004 21:35:21 -0000 1.24 --- physicengine.cc 17 Nov 2004 22:43:06 -0000 1.25 *************** *** 20,24 **** void PhysicEngine::StepSlideMove(PhysicNode* n, float eTime, Vector3& vVelocity, Vector3 origin) { ! BspCollisionResult trace; int bumpcount = 0; //Vector3 origin = n->pBBox->vWorldOrigin; --- 20,25 ---- void PhysicEngine::StepSlideMove(PhysicNode* n, float eTime, Vector3& vVelocity, Vector3 origin) { ! //BspCollisionResult trace; ! CollisionResult trace; int bumpcount = 0; //Vector3 origin = n->pBBox->vWorldOrigin; *************** *** 34,38 **** //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); //on trace avec une sphere, les mouvements sembles plus 'lisses' //trace = pLevel->CheckRayMove(origin+n->GetBBox()->vBSCenter, origin+n->GetBBox()->vBSCenter+vVelocity*time_left, TRACE_SPHERE, n->GetBBox()->fBSRadius); --- 35,40 ---- //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); ! trace = Trace(origin, origin+vVelocity*time_left, n->GetBBox()->vMin, n->GetBBox()->vMax, n); //on trace avec une sphere, les mouvements sembles plus 'lisses' //trace = pLevel->CheckRayMove(origin+n->GetBBox()->vBSCenter, origin+n->GetBBox()->vBSCenter+vVelocity*time_left, TRACE_SPHERE, n->GetBBox()->fBSRadius); *************** *** 54,63 **** 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) --- 56,65 ---- time_left -= time_left*trace.Fraction; ! pPlanes.push_back(trace.Normal); iNumPlanes++; for (i=0; i<iNumPlanes; i++) { ! ClipVelocity (vVelocity, trace.Normal); for (j=0; j<iNumPlanes; j++) if (j != i) *************** *** 137,147 **** //on verifie que ca ne nous fasse pas rentrer dans le plafond ! BspCollisionResult trace = pLevel->CheckRayMove(vUpPos, vNewPos, n->GetBBox()->vMin, n->GetBBox()->vMax); if (trace.AllSolid) vUpNewPos = trace.EndPoint; if (updist > dist) //on passe l'obstacle { ! n->SetPosition(/*Vector3(vNewPos.x, vUpNewPos.y, vNewPos.z)*/vUpNewPos); } else //l'obstacle est trop haut --- 139,153 ---- //on verifie que ca ne nous fasse pas rentrer dans le plafond ! //BspCollisionResult trace = pLevel->CheckRayMove(vUpPos, vNewPos, n->GetBBox()->vMin, n->GetBBox()->vMax); ! CollisionResult trace = Trace(vUpPos, vNewPos, n->GetBBox()->vMin, n->GetBBox()->vMax, n); if (trace.AllSolid) vUpNewPos = trace.EndPoint; + //appel de la callback pour les collisions avec la map. Ca permet aux objets style rockets de savoir s'ils doivent exploser + if (trace.Fraction < 1.0f) + n->GetPhysicCallBack()->Collide(trace.pNode, trace.EndPoint, trace.Normal); if (updist > dist) //on passe l'obstacle { ! n->SetPosition(vUpNewPos); } else //l'obstacle est trop haut *************** *** 151,155 **** //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 if (col.Fraction < 1.0f || col.AllSolid) --- 157,162 ---- //Classification de la position ! //BspCollisionResult col = pLevel->CheckRayMove(n->GetPosition(), n->GetPosition()+Vector3::NEGATIVE_UNIT_Y*BASE_HEIGHT, n->GetBBox()->vMin, n->GetBBox()->vMax); ! CollisionResult col = Trace(n->GetPosition(), n->GetPosition()+Vector3::NEGATIVE_UNIT_Y*BASE_HEIGHT, n->GetBBox()->vMin, n->GetBBox()->vMax, n); //si on met le allsolid, ca foire les mouvements sur les y if (col.Fraction < 1.0f || col.AllSolid) *************** *** 223,235 **** //TODO: Les objets doivent être classés par leaf et cela doit etre utilise pour le trace (il faudrait extraire l'arbre BSP de la map et l'envoyer au moteur physique, qui s'occuperait d'y rajouter les objets & Co) ! CollisionResult PhysicEngine::Trace (Vector3 Begin, Vector3 End, PhysicNode* edict) { //on choppe le resultat du trace sur la map CollisionResult result; result.pNode = NULL; ! ! BspCollisionResult mapResult = pLevel->CheckRayMove(Begin, End, TRACE_RAY, 0); result.EndPoint = mapResult.EndPoint; result.Normal = mapResult.CollisionNormal; //on trace sur les objets Vector3 colPoint(0,0,0); --- 230,245 ---- //TODO: Les objets doivent être classés par leaf et cela doit etre utilise pour le trace (il faudrait extraire l'arbre BSP de la map et l'envoyer au moteur physique, qui s'occuperait d'y rajouter les objets & Co) ! CollisionResult PhysicEngine::Trace (Vector3 Begin, Vector3 End, Vector3 vMin, Vector3 vMax, PhysicNode* edict) { //on choppe le resultat du trace sur la map CollisionResult result; result.pNode = NULL; ! ! BspCollisionResult mapResult = pLevel->CheckRayMove(Begin, End, vMin, vMax); ! result.EndPoint = mapResult.EndPoint; result.Normal = mapResult.CollisionNormal; + result.Fraction = mapResult.Fraction; + result.AllSolid = mapResult.AllSolid; //on trace sur les objets Vector3 colPoint(0,0,0); *************** *** 250,253 **** --- 260,265 ---- result.Normal = colNormal; result.pNode = pNodes[i]; + //result.Fraction = (End-Begin).Magnitude()/(colPoint-Begin).Magnitude(); + //result.AllSolid = false; } } Index: scenemanager.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/scenemanager.cc,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** scenemanager.cc 13 Nov 2004 23:35:40 -0000 1.17 --- scenemanager.cc 17 Nov 2004 22:43:06 -0000 1.18 *************** *** 116,137 **** } - (*_glActiveTextureARB)(GL_TEXTURE0); - glDisable (GL_TEXTURE_2D); - (*_glActiveTextureARB)(GL_TEXTURE1); - glDisable (GL_TEXTURE_2D); - for (int i=0; i<pDebugSpheres.size (); i++) - { - DebugSphere* s = pDebugSpheres[i]; - glPushMatrix(); - glColor3f(s->pColors[0], s->pColors[1], s->pColors[2]); - glTranslatef(s->vPosition.x, s->vPosition.y, s->vPosition.z); - gluSphere(s->q, s->fD, 10, 10); - glPopMatrix(); - } - (*_glActiveTextureARB)(GL_TEXTURE0); - glEnable (GL_TEXTURE_2D); - (*_glActiveTextureARB)(GL_TEXTURE1); - glEnable (GL_TEXTURE_2D); - Mesh* m = pFirstObject; --- 116,119 ---- *************** *** 175,178 **** --- 157,178 ---- pDecalManager->Render(frameInterval); + (*_glActiveTextureARB)(GL_TEXTURE0); + glDisable (GL_TEXTURE_2D); + (*_glActiveTextureARB)(GL_TEXTURE1); + glDisable (GL_TEXTURE_2D); + for (int i=0; i<pDebugSpheres.size (); i++) + { + DebugSphere* s = pDebugSpheres[i]; + glPushMatrix(); + glColor3f(s->pColors[0], s->pColors[1], s->pColors[2]); + glTranslatef(s->vPosition.x, s->vPosition.y, s->vPosition.z); + gluSphere(s->q, s->fD, 10, 10); + glPopMatrix(); + } + (*_glActiveTextureARB)(GL_TEXTURE0); + glEnable (GL_TEXTURE_2D); + (*_glActiveTextureARB)(GL_TEXTURE1); + glEnable (GL_TEXTURE_2D); + PointLight* pl = pFirstPointLight; Index: q3bsp.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/q3bsp.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** q3bsp.h 12 Nov 2004 12:11:36 -0000 1.5 --- q3bsp.h 17 Nov 2004 22:43:06 -0000 1.6 *************** *** 265,268 **** --- 265,275 ---- }; + struct BspShader + { + char strName[64]; //le nom du shader + int brush; //le brush qui génère cet effet + int unknown; // toujours 5, sauf q3dm8 qui en a un à -1 + }; + //END STRUCT TextureManager* pTexManager; *************** *** 281,284 **** --- 288,292 ---- int numOfMeshIndices; int numOfEntities; + int numOfShaders; int numOfLeafBrushes; *************** *** 302,305 **** --- 310,314 ---- int *pLeafBrushes; BspBrush *pBrushes; + BspShader* pShaders; bool* pVisibleFaces; int* pMeshIndices; Index: physicnode.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicnode.cc,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** physicnode.cc 15 Nov 2004 21:35:21 -0000 1.8 --- physicnode.cc 17 Nov 2004 22:43:06 -0000 1.9 *************** *** 19,22 **** --- 19,27 ---- } + PhysicNode::~PhysicNode() + { + vNodes.clear(); + } + void PhysicNode::UpdatePosition () { Index: physicengine.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicengine.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** physicengine.h 15 Nov 2004 21:35:21 -0000 1.7 --- physicengine.h 17 Nov 2004 22:43:06 -0000 1.8 *************** *** 15,18 **** --- 15,20 ---- Vector3 EndPoint; Vector3 Normal; + float Fraction; + bool AllSolid; //le node qui a ete touche. NULL si c'est la carte qui est touche ou si rien n'est touche PhysicNode* pNode; *************** *** 49,53 **** * @param PhysicNode le physicnode qui demande le trace -> le trace n'est pas bloqué par ce physicnode */ ! CollisionResult Trace(Vector3 Begin, Vector3 End, PhysicNode* edict=NULL); protected: void _TryToStep (PhysicNode*, float); --- 51,55 ---- * @param PhysicNode le physicnode qui demande le trace -> le trace n'est pas bloqué par ce physicnode */ ! CollisionResult Trace(Vector3 Begin, Vector3 End, Vector3 vMin=Vector3(0,0,0), Vector3 vMax=Vector3(0,0,0), PhysicNode* edict=NULL); protected: void _TryToStep (PhysicNode*, float); Index: scenemanager.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/scenemanager.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** scenemanager.h 13 Nov 2004 23:35:40 -0000 1.7 --- scenemanager.h 17 Nov 2004 22:43:06 -0000 1.8 *************** *** 19,23 **** struct DebugSphere { ! DebugSphere () { vPosition.Null(); fD = 10.0f; pColors[0] = pColors[1] = pColors[2] = pColors[3] = 1.0f; q = gluNewQuadric();} ~DebugSphere () { gluDeleteQuadric(q); } GLUquadric* q; --- 19,23 ---- struct DebugSphere { ! DebugSphere () { vPosition.Null(); fD = 5.0f; pColors[0] = pColors[1] = pColors[2] = pColors[3] = 1.0f; q = gluNewQuadric();} ~DebugSphere () { gluDeleteQuadric(q); } GLUquadric* q; Index: texture.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/texture.cc,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** texture.cc 13 Nov 2004 23:35:40 -0000 1.10 --- texture.cc 17 Nov 2004 22:43:06 -0000 1.11 *************** *** 446,450 **** bool Texture::LoadJPG (char* image, texType type) { ! std::cout << "chargement de "<<image<<std::endl; SDL_Surface* texture; --- 446,450 ---- bool Texture::LoadJPG (char* image, texType type) { ! std::cout << "[TGE] Chargement de "<<image<<std::endl; SDL_Surface* texture; *************** *** 452,456 **** --- 452,459 ---- if (texture == NULL) + { + std::cerr << "[TGE] Impossible de charger le fichier " << image << std::endl; return false; + } FlipAroundX (texture->w, texture->h, (unsigned char*)texture->pixels); Index: decalmanager.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/decalmanager.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** decalmanager.h 13 Nov 2004 23:37:55 -0000 1.1 --- decalmanager.h 17 Nov 2004 22:43:06 -0000 1.2 *************** *** 8,11 **** --- 8,13 ---- #include "q3bsp.h" + #define NUM_MAX_DECALS 50 + namespace tg { *************** *** 15,19 **** public: DecalManager (); ! ~DecalManager () {} void AddDecal (Vector3 vPos, Vector3 vNorm, float sX, float sY, Texture* pTex, float t); void AddDecal (Decal* d); --- 17,21 ---- public: DecalManager (); ! ~DecalManager (); void AddDecal (Vector3 vPos, Vector3 vNorm, float sX, float sY, Texture* pTex, float t); void AddDecal (Decal* d); *************** *** 23,33 **** protected: ! void _ProcessTimedDecal (Decal* d, float t); ! void _RemoveDecal (Decal* d); Q3Bsp* pLevel; ! Decal* pFirstDecal; ! Decal* pCurrentDecal; --- 25,38 ---- protected: ! /*void _ProcessTimedDecal (Decal* d, float t); ! void _RemoveDecal (Decal* d);*/ ! ! Decal** pDecals; ! int iCurrentIndex; Q3Bsp* pLevel; ! /*Decal* pFirstDecal; ! Decal* pCurrentDecal;*/ Index: decalmanager.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/decalmanager.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** decalmanager.cc 13 Nov 2004 23:37:55 -0000 1.1 --- decalmanager.cc 17 Nov 2004 22:43:06 -0000 1.2 *************** *** 7,12 **** DecalManager::DecalManager () { ! pCurrentDecal = NULL; ! pFirstDecal = NULL; } --- 7,23 ---- DecalManager::DecalManager () { ! //pCurrentDecal = NULL; ! //pFirstDecal = NULL; ! pDecals = new Decal*[NUM_MAX_DECALS]; ! for (int i=0; i<NUM_MAX_DECALS; i++) ! pDecals[i] = NULL; ! iCurrentIndex = 0; ! } ! ! DecalManager::~DecalManager () ! { ! for (int i=0; i<NUM_MAX_DECALS; i++) ! if (pDecals[i] != NULL) ! delete pDecals[i]; } *************** *** 19,23 **** void DecalManager::AddDecal (Decal* d) { ! if (pFirstDecal) //le premier noeud existe { pCurrentDecal->SetNext(d); --- 30,41 ---- void DecalManager::AddDecal (Decal* d) { ! if ( iCurrentIndex >= NUM_MAX_DECALS ) //on doit supprimer le premier decal ! { ! delete pDecals[0]; ! iCurrentIndex = 0; ! } ! pDecals[iCurrentIndex] = d; ! iCurrentIndex++; ! /*if (pFirstDecal) //le premier noeud existe { pCurrentDecal->SetNext(d); *************** *** 32,41 **** pFirstDecal = d; pCurrentDecal = d; ! } } void DecalManager::Render (float eTime) { ! Decal* d = pFirstDecal; if (d != NULL) { --- 50,70 ---- pFirstDecal = d; pCurrentDecal = d; ! }*/ } void DecalManager::Render (float eTime) { ! glDepthMask(GL_FALSE); ! for (int i=0; i<NUM_MAX_DECALS; i++) ! { ! if (pDecals[i] == NULL) ! continue; ! if (pLevel->IsVisible(pLevel->FindLeaf(pDecals[i]->vPosition))) ! { ! Engine::pRenderer->RenderDecal(pDecals[i]); ! } ! } ! glDepthMask(GL_TRUE); ! /*Decal* d = pFirstDecal; if (d != NULL) { *************** *** 50,56 **** } while((d=d->GetNext()) != NULL); glDepthMask(GL_TRUE); ! } } ! void DecalManager::_ProcessTimedDecal(Decal* d, float t) { --- 79,85 ---- } while((d=d->GetNext()) != NULL); glDepthMask(GL_TRUE); ! }*/ } ! /* void DecalManager::_ProcessTimedDecal(Decal* d, float t) { *************** *** 95,99 **** } } ! } } --- 124,128 ---- } } ! }*/ } Index: q3bsp.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/q3bsp.cc,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** q3bsp.cc 15 Nov 2004 21:35:21 -0000 1.13 --- q3bsp.cc 17 Nov 2004 22:43:06 -0000 1.14 *************** *** 237,240 **** --- 237,243 ---- numOfMeshIndices = lumps[kMeshVerts].length / sizeof(int); pMeshIndices = new int[numOfMeshIndices]; + //allocation memoire pour les effets + numOfShaders = lumps[kShaders].length / sizeof(BspShader); + pShaders = new BspShader[numOfShaders]; #ifdef DEBUG *************** *** 250,253 **** --- 253,257 ---- std::cout << "[TGE] nombre de brushsides:\t" << numOfBrushSides << std::endl; std::cout << "[TGE] nombre de meshindices:\t" << numOfMeshIndices << std::endl; + std::cout << "[TGE] nombre de shaders:\t" << numOfShaders << std::endl; #endif *************** *** 458,461 **** --- 462,474 ---- delete [] pLightMapsInfos; + //chargement des shaders + pFD.seekg(lumps[kShaders].offset); + pFD.read((char*)pShaders, sizeof(BspShader)*numOfShaders); + for (int i=0; i<numOfShaders; i++) + { + SWAPLONG(pShaders[i].brush); + SWAPLONG(pShaders[i].unknown); + } + //chargement des nodes pFD.seekg(lumps[kNodes].offset); *************** *** 601,605 **** { pFD.read(&buffer, sizeof(char)); ! if (buffer == '{') { //std::cout << "---nouvelle---" << std::endl; --- 614,619 ---- { pFD.read(&buffer, sizeof(char)); ! //std::cout << buffer ; ! /*if (buffer == '{') { //std::cout << "---nouvelle---" << std::endl; *************** *** 628,635 **** state=ENTITY_NAME; prop_value = name; ! //std::cout << "nom : " << prop_name << ",valeure : " << prop_value << std::endl; pEntities[eCount].mProperties[prop_name]=prop_value; } ! } } } --- 642,649 ---- state=ENTITY_NAME; prop_value = name; ! std::cout << "nom : " << prop_name << ",valeure : " << prop_value << std::endl; pEntities[eCount].mProperties[prop_name]=prop_value; } ! }*/ } } *************** *** 690,697 **** //std::string tex("textures/gothic_block/blocks15"); //strcat (pTexturesInfos[i].strName, ".bmp"); ! pMaterials[i].SetFirstTexture(pTexManager->LoadTexture(/*pTexturesInfos[i].strName*/("data/"+tex+".bmp").data(), TG_TEXTURE_2D)); ! pMaterials[i].SetNormalTexture(pTexManager->LoadTexture(("data/"+tex+"_local.bmp").data(), TG_TEXTURE_2D)); } - pSpotLight.SetFirstTexture(pTexManager->LoadTexture("spot.bmp", TG_TEXTURE_2D)); } --- 704,710 ---- //std::string tex("textures/gothic_block/blocks15"); //strcat (pTexturesInfos[i].strName, ".bmp"); ! pMaterials[i].SetFirstTexture(pTexManager->LoadTexture(/*pTexturesInfos[i].strName*/("data/"+tex+".jpg").data(), TG_TEXTURE_2D)); ! //pMaterials[i].SetNormalTexture(pTexManager->LoadTexture(("data/"+tex+"_local.jpg").data(), TG_TEXTURE_2D)); } } *************** *** 706,710 **** // Bind the texture to the texture arrays index and init the texture glBindTexture(GL_TEXTURE_2D, pLightMaps[i]); ! ChangeGamma((unsigned char*)pLightMapsInfos[i].imageBits, 128*128*3, 1); //ChangeContrast((unsigned char*)pLightMapsInfos[i].imageBits, 128*128*3, 3); // Build Mipmaps (builds different versions of the picture for distances - looks better) --- 719,723 ---- // Bind the texture to the texture arrays index and init the texture glBindTexture(GL_TEXTURE_2D, pLightMaps[i]); ! ChangeGamma((unsigned char*)pLightMapsInfos[i].imageBits, 128*128*3, 2); //ChangeContrast((unsigned char*)pLightMapsInfos[i].imageBits, 128*128*3, 3); // Build Mipmaps (builds different versions of the picture for distances - looks better) Index: boundingbox.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/boundingbox.cc,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** boundingbox.cc 15 Nov 2004 21:35:21 -0000 1.7 --- boundingbox.cc 17 Nov 2004 22:43:06 -0000 1.8 *************** *** 208,214 **** Vector3 akPoint[2]; float extents[3]; ! extents[0] = (vMax.x-vMin.x); ! extents[1] = (vMax.y-vMin.y); ! extents[2] = (vMax.z-vMin.z); bool bIntersects = MgcFindIntersection(kOrigin,kDirection,extents, fT0,fT1); --- 208,217 ---- Vector3 akPoint[2]; float extents[3]; ! //extents[0] = (vMax.x-vMin.x); ! //extents[1] = (vMax.y-vMin.y); ! //extents[2] = (vMax.z-vMin.z); ! extents[0] = -vMin.x > vMax.x ? -vMin.x : vMax.x; ! extents[1] = -vMin.y > vMax.y ? -vMin.y : vMax.y; ! extents[2] = -vMin.z > vMax.z ? -vMin.z : vMax.z; bool bIntersects = MgcFindIntersection(kOrigin,kDirection,extents, fT0,fT1); Index: physicnode.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicnode.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** physicnode.h 15 Nov 2004 21:35:21 -0000 1.6 --- physicnode.h 17 Nov 2004 22:43:06 -0000 1.7 *************** *** 29,32 **** --- 29,34 ---- bool TraceRay(Vector3 begin, Vector3 end, Vector3& colPoint, Vector3& colNormal); + SceneNode* GetSceneNode (int i = 0) { return vNodes[i]; } + /** * Retourne un pointeur sur la classe servant de callback en cas de collision Index: physiccallback.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physiccallback.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** physiccallback.h 12 Nov 2004 12:11:36 -0000 1.2 --- physiccallback.h 17 Nov 2004 22:43:06 -0000 1.3 *************** *** 10,19 **** */ ! class SceneNode; class PhysicCallBack { public: ! virtual void Collide (SceneNode* other,const Vector3& vPoint, const Vector3& vCollisionNormal) = 0; }; --- 10,19 ---- */ ! class PhysicNode; class PhysicCallBack { public: ! virtual void Collide (PhysicNode* other,const Vector3& vPoint, const Vector3& vCollisionNormal) = 0; }; |
|
From: Yohann C. <pl...@us...> - 2004-11-17 21:48:33
|
Update of /cvsroot/epfl/tgtools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv836 Added Files: jpgbmp Log Message: conversion des jpg et tga en bmp --- NEW FILE: jpgbmp --- #!/bin/bash function explore() { TERMWIDTH=$COLUMNS file=`echo $1 | sed -e "s/\/$//"` let as=$(echo $file | wc -c) let fillsize=$(( ($TERMWIDTH - $as) /2 )) fill="" while [ "$fillsize" -gt "0" ] do fill="${fill} " let fillsize=${fillsize}-1 done line="" let fillsize=$TERMWIDTH while [ "$fillsize" -gt "0" ] do line="${line}=" let fillsize=${fillsize}-1 done echo $line echo "$fill$file" echo $line for FICHIER in $file/* do if test -d $FICHIER then explore $FICHIER fi done for ENTREE in $file/*.jpg do if [ -e ./$ENTREE ]; then affiche=" --- `basename $ENTREE`" SORTIE=$(echo $ENTREE | sed -e s/jpg/bmp/) if [ ! -e $SORTIE ]; then convert $ENTREE $SORTIE if [ -e $SORTIE ]; then result="[OK]" else result="[FAILED]" fi else result="[PASS]" fi let affichesize=$(echo $affiche | wc -c) let resultsize=$(echo $result | wc -c) let fillsize=${TERMWIDTH}-${affichesize}-${resultsize}-3 fill="" while [ "$fillsize" -gt "0" ] do fill="${fill} " let fillsize=${fillsize}-1 done echo "$affiche$fill$result" fi done for ENTREE in $file/*.tga do if [ -e ./$ENTREE ]; then affiche=" --- `basename $ENTREE`" SORTIE=$(echo $ENTREE | sed -e s/tga/bmp/) if [ ! -e $SORTIE ]; then convert $ENTREE $SORTIE if [ -e $SORTIE ]; then result="[OK]" else result="[FAILED]" fi else result="[PASS]" fi let affichesize=$(echo $affiche | wc -c) let resultsize=$(echo $result | wc -c) let fillsize=${TERMWIDTH}-${affichesize}-${resultsize}-3 fill="" while [ "$fillsize" -gt "0" ] do fill="${fill} " let fillsize=${fillsize}-1 done echo "$affiche$fill$result" fi done } explore $1 |
|
From: julien r. <jul...@us...> - 2004-11-15 21:42:03
|
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2271 Modified Files: game.cc playercontroller.cc playercontroller.h Log Message: physic Index: game.cc =================================================================== RCS file: /cvsroot/epfl/tggame/game.cc,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** game.cc 13 Nov 2004 23:38:08 -0000 1.31 --- game.cc 15 Nov 2004 21:41:52 -0000 1.32 *************** *** 29,33 **** std::string mapname = "data/maps/"; if (argc < 2) ! mapname += "test1.bsp"; else mapname += argv[1]; --- 29,33 ---- std::string mapname = "data/maps/"; if (argc < 2) ! mapname += "test.bsp"; else mapname += argv[1]; Index: playercontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/playercontroller.cc,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** playercontroller.cc 14 Nov 2004 13:34:44 -0000 1.17 --- playercontroller.cc 15 Nov 2004 21:41:52 -0000 1.18 *************** *** 13,18 **** { Game::pSelf->GetConsole()->Register("clip", this, CLIP); ! /*pSphere = new DebugSphere (); ! Game::pSelf->GetSceneManager()->AddDebugSphere(pSphere);*/ pWeapon = new Weapon (); bFire = false; --- 13,18 ---- { Game::pSelf->GetConsole()->Register("clip", this, CLIP); ! pSphere = new DebugSphere (); ! Game::pSelf->GetSceneManager()->AddDebugSphere(pSphere); pWeapon = new Weapon (); bFire = false; *************** *** 29,38 **** pWeapon->Fire (vPosition, vTarget, pPawn); ! /* vTarget = vPosition - vTarget*1000000; CollisionResult cR = Game::pSelf->Trace(vPosition, vTarget, pPawn); pSphere->vPosition = cR.EndPoint; ! if (cR.pNode == NULL) //on a touche la map Game::pSelf->GetSceneManager()->GetDecalManager()->AddDecal(cR.EndPoint, cR.Normal, 1.0f, 1.0f, Engine::pTextureManager->LoadTexture("data/textures/decals/mgun.bmp", TG_TEXTURE_2D), 10.0f); --- 29,38 ---- pWeapon->Fire (vPosition, vTarget, pPawn); ! vTarget = vPosition - vTarget*1000000; CollisionResult cR = Game::pSelf->Trace(vPosition, vTarget, pPawn); pSphere->vPosition = cR.EndPoint; ! /* if (cR.pNode == NULL) //on a touche la map Game::pSelf->GetSceneManager()->GetDecalManager()->AddDecal(cR.EndPoint, cR.Normal, 1.0f, 1.0f, Engine::pTextureManager->LoadTexture("data/textures/decals/mgun.bmp", TG_TEXTURE_2D), 10.0f); Index: playercontroller.h =================================================================== RCS file: /cvsroot/epfl/tggame/playercontroller.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** playercontroller.h 13 Nov 2004 23:38:08 -0000 1.8 --- playercontroller.h 15 Nov 2004 21:41:52 -0000 1.9 *************** *** 22,26 **** Weapon* pWeapon; bool bFire; ! //DebugSphere* pSphere; public: PlayerController (Pawn*); --- 22,26 ---- Weapon* pWeapon; bool bFire; ! DebugSphere* pSphere; public: PlayerController (Pawn*); |
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv963 Modified Files: boundingbox.cc glrenderer.cc md5instance.cc md5instance.h physicengine.cc physicengine.h physicnode.cc physicnode.h q3bsp.cc vector3.h Log Message: physic fixes Index: physicengine.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicengine.cc,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** physicengine.cc 13 Nov 2004 23:35:40 -0000 1.23 --- physicengine.cc 15 Nov 2004 21:35:21 -0000 1.24 *************** *** 16,20 **** } ! #define MAXBUMPS 5 void PhysicEngine::StepSlideMove(PhysicNode* n, float eTime, Vector3& vVelocity, Vector3 origin) --- 16,20 ---- } ! #define MAXBUMPS 10 void PhysicEngine::StepSlideMove(PhysicNode* n, float eTime, Vector3& vVelocity, Vector3 origin) *************** *** 35,42 **** { trace = pLevel->CheckRayMove(origin, origin+vVelocity*time_left, n->GetBBox()->vMin, n->GetBBox()->vMax); if (trace.AllSolid) { - //vVelocity.Null(); vVelocity.y = 0; return; --- 35,43 ---- { trace = pLevel->CheckRayMove(origin, origin+vVelocity*time_left, n->GetBBox()->vMin, n->GetBBox()->vMax); + //on trace avec une sphere, les mouvements sembles plus 'lisses' + //trace = pLevel->CheckRayMove(origin+n->GetBBox()->vBSCenter, origin+n->GetBBox()->vBSCenter+vVelocity*time_left, TRACE_SPHERE, n->GetBBox()->fBSRadius); if (trace.AllSolid) { vVelocity.y = 0; return; *************** *** 101,105 **** Vector3 change = norm*backoff; vel -= change; ! //return (vel - change); } --- 102,160 ---- Vector3 change = norm*backoff; vel -= change; ! } ! ! #define BASE_HEIGHT 5 ! #define STEPSIZE 20 ! ! void PhysicEngine::_TryToStep (PhysicNode* n, float eTime) ! { ! //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(); ! Vector3 vUpVelocity = n->GetVelocity(); ! Vector3 vPos = n->GetPosition(); ! Vector3 vNewPos = vPos; ! Vector3 vUpPos = n->GetPosition() + (Vector3::UNIT_Y*STEPSIZE); ! Vector3 vUpNewPos = vUpPos; ! float distx, distz; ! ! StepSlideMove (n, eTime, vVelocity, vPos); ! vNewPos += vVelocity*eTime; ! distx = (vNewPos.x - vPos.x); ! distx *= distx; ! distz = (vNewPos.z - vPos.z); ! distz *= distz; ! float dist = sqrt(distx+distz); ! ! StepSlideMove (n, eTime, vUpVelocity, vUpPos); ! vUpNewPos += vUpVelocity*eTime; ! distx = (vUpNewPos.x - vUpPos.x); ! distx *= distx; ! distz = (vUpNewPos.z - vUpPos.z); ! distz *= distz; ! float updist = sqrt(distx+distz); ! ! //on verifie que ca ne nous fasse pas rentrer dans le plafond ! BspCollisionResult trace = pLevel->CheckRayMove(vUpPos, vNewPos, n->GetBBox()->vMin, n->GetBBox()->vMax); ! if (trace.AllSolid) ! vUpNewPos = trace.EndPoint; ! ! if (updist > dist) //on passe l'obstacle ! { ! n->SetPosition(/*Vector3(vNewPos.x, vUpNewPos.y, vNewPos.z)*/vUpNewPos); ! } ! else //l'obstacle est trop haut ! { ! n->SetPosition(vNewPos); ! } ! ! //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 ! if (col.Fraction < 1.0f || col.AllSolid) ! n->SetOnGround(true); ! else ! n->SetOnGround(false); } *************** *** 112,117 **** //-> on différenci la taille du joueur et des autres objets pour être sur le sol - #define BASE_HEIGHT 15 - #define STEPSIZE 20*1/0.01 void PhysicEngine::Move (float eTime) { --- 167,170 ---- *************** *** 157,225 **** 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(); ! Vector3 vUpVelocity = n->GetVelocity(); ! Vector3 vPos = n->GetPosition(); ! Vector3 vNewPos = vPos; ! Vector3 vUpPos = n->GetPosition() + (Vector3::UNIT_Y*STEPSIZE*eTime); ! Vector3 vUpNewPos = vUpPos; ! float distx, distz; ! ! StepSlideMove (n, eTime, vVelocity, vPos); ! vNewPos += vVelocity*eTime; ! distx = (vNewPos.x - vPos.x); ! distx *= distx; ! distz = (vNewPos.z - vPos.z); ! distz *= distz; ! float dist = sqrt(distx+distz); ! ! StepSlideMove (n, eTime, vUpVelocity, vUpPos); ! vUpNewPos += vUpVelocity*eTime; ! distx = (vUpNewPos.x - vUpPos.x); ! distx *= distx; ! distz = (vUpNewPos.z - vUpPos.z); ! distz *= distz; ! float updist = sqrt(distx+distz); ! ! if (updist > dist) //on passe l'obstacle ! { ! //std::cout << "time : " << eTime << "\t" << vUpNewPos << std::endl; ! n->SetPosition(vUpNewPos); ! /*if (vUpVelocity != n->GetVelocity() && n->GetPhysicCallBack() != NULL) ! { ! //std::cout << "callback" << std::endl; ! //ce ne sont pas les memes, donc il y a eu collision -> appelle de la callback ! n->GetPhysicCallBack()->Collide(NULL, Vector3(0,0,0), Vector3(0,0,0)); ! }*/ ! } ! else //l'obstacle est trop haut ! { ! //std::cout << "time : " << eTime << "\t" << vNewPos << std::endl; ! n->SetPosition(vNewPos); ! /*if (vVelocity != n->GetVelocity() && n->GetPhysicCallBack() != NULL) ! { ! //std::cout << "callback" << std::endl; ! //ce ne sont pas les memes, donc il y a eu collision -> appelle de la callback ! n->GetPhysicCallBack()->Collide(NULL, Vector3(0,0,0), Vector3(0,0,0)); ! }*/ ! } ! ! //Classification de la position ! 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 ! if (col.Fraction < 1.0f || col.AllSolid) ! n->SetOnGround(true); ! else ! n->SetOnGround(false); ! Quaternion q = n->GetRotationVelocity()*eTime; q.Normalize(); n->SetRotation(n->GetRotation()*q); ! n->UpdatePosition(); } } --- 210,221 ---- if (pLevel) { ! _TryToStep(n, eTime); ! Quaternion q = n->GetRotationVelocity()*eTime; q.Normalize(); n->SetRotation(n->GetRotation()*q); ! n->UpdatePosition(); + } } *************** *** 246,250 **** continue; ! if (pNodes[i]->GetBBox()->TraceRay(Begin, End, colPoint, colNormal)) { result.pNode = pNodes[i]; d1 = (colPoint - Begin).Magnitude(); --- 242,246 ---- continue; ! if (pNodes[i]->TraceRay(Begin, End, colPoint, colNormal)) { result.pNode = pNodes[i]; d1 = (colPoint - Begin).Magnitude(); Index: physicnode.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicnode.cc,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** physicnode.cc 12 Nov 2004 12:11:36 -0000 1.7 --- physicnode.cc 15 Nov 2004 21:35:21 -0000 1.8 *************** *** 34,37 **** --- 34,46 ---- pBBox = vNodes[0]->GetBBox(); } + + bool PhysicNode::TraceRay(Vector3 begin, Vector3 end, Vector3& colPoint, Vector3& colNormal) + { + /*if (pBBox->TraceRay(begin, end, colPoint, colNormal)) + return vNodes[0]->Trace(begin, end, colPoint, colNormal); + else + return false;*/ + return pBBox->TraceRay(begin, end, colPoint, colNormal); + } } Index: physicengine.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicengine.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** physicengine.h 12 Nov 2004 12:11:36 -0000 1.6 --- physicengine.h 15 Nov 2004 21:35:21 -0000 1.7 *************** *** 51,54 **** --- 51,56 ---- CollisionResult Trace(Vector3 Begin, Vector3 End, PhysicNode* edict=NULL); protected: + void _TryToStep (PhysicNode*, float); + std::vector<PhysicNode*> pNodes; Q3Bsp* pLevel; Index: physicnode.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicnode.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** physicnode.h 12 Nov 2004 12:11:36 -0000 1.5 --- physicnode.h 15 Nov 2004 21:35:21 -0000 1.6 *************** *** 27,30 **** --- 27,32 ---- inline BoundingBox* GetBBox () { return pBBox; } + bool TraceRay(Vector3 begin, Vector3 end, Vector3& colPoint, Vector3& colNormal); + /** * Retourne un pointeur sur la classe servant de callback en cas de collision Index: q3bsp.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/q3bsp.cc,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** q3bsp.cc 13 Nov 2004 23:35:40 -0000 1.12 --- q3bsp.cc 15 Nov 2004 21:35:21 -0000 1.13 *************** *** 1236,1242 **** // If the brush has sides (is a convex volume) and is SOLID then check it out! ! /*TODO or FIXME: ! C'est vraiment bizarre.. Le nombre de brush SOLID est très réduit, certainement pour des questions d'optimisation... A voir s'il faut l'activer ou non ...*/ ! if ( brush->numOfBrushSides > 0 && pContents[brush->textureID] & 1/*&& (pTextures[brush->textureID].contents & 1)*/) { CheckTouchBrush( brush, traceType,radius ); --- 1236,1241 ---- // If the brush has sides (is a convex volume) and is SOLID then check it out! ! /*C'est vraiment bizarre.. Le nombre de brush SOLID est très réduit, certainement pour des questions d'optimisation... A voir s'il faut l'activer ou non ...*/ ! if ( brush->numOfBrushSides > 0 && pContents[brush->textureID] & 1) { CheckTouchBrush( brush, traceType,radius ); *************** *** 1253,1264 **** BspNode *node = &pNodes[nodeIndex]; BspPlane *plane = &pPlanes[node->plane]; ! /*float startDistance = plane->vNormal.x * Start.x + ! plane->vNormal.y * Start.y + ! plane->vNormal.z * Start.z - ! plane->d; ! float endDistance = plane->vNormal.x * End.x + ! plane->vNormal.y * End.y + ! plane->vNormal.z * End.z - ! plane->d;*/ float startDistance = plane->vNormal*Start - plane->d; float endDistance = plane->vNormal*End - plane->d; --- 1252,1256 ---- BspNode *node = &pNodes[nodeIndex]; BspPlane *plane = &pPlanes[node->plane]; ! float startDistance = plane->vNormal*Start - plane->d; float endDistance = plane->vNormal*End - plane->d; *************** *** 1284,1288 **** { CheckMoveByNode( node->front, startFraction, endFraction, Start, End, traceType,radius ); ! //return; } // If both points are in behind the plane (the negative side) pass the ray to the back --- 1276,1280 ---- { CheckMoveByNode( node->front, startFraction, endFraction, Start, End, traceType,radius ); ! return; } // If both points are in behind the plane (the negative side) pass the ray to the back *************** *** 1292,1296 **** { CheckMoveByNode( node->back, startFraction, endFraction, Start, End, traceType,radius ); ! //return; } --- 1284,1288 ---- { CheckMoveByNode( node->back, startFraction, endFraction, Start, End, traceType,radius ); ! return; } *************** *** 1310,1314 **** side2 = node->front; float inverseDistance = 1.0f / (startDistance - endDistance); // optimization ! fraction1 = (startDistance - EPSILON - offset) * inverseDistance; // compute fraction for the start-middle fraction2 = (startDistance + EPSILON + offset) * inverseDistance; // compute fraction for the middle-end } --- 1302,1306 ---- side2 = node->front; float inverseDistance = 1.0f / (startDistance - endDistance); // optimization ! fraction1 = (startDistance + EPSILON - offset) * inverseDistance; // compute fraction for the start-middle fraction2 = (startDistance + EPSILON + offset) * inverseDistance; // compute fraction for the middle-end } Index: md5instance.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5instance.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** md5instance.h 12 Nov 2004 12:11:36 -0000 1.7 --- md5instance.h 15 Nov 2004 21:35:21 -0000 1.8 *************** *** 44,49 **** ! //bool Trace (Vector3 Begin, Vector3 End, Vector3& colPoint, Vector3& colNormal); ! //bool TriangleTrace(const Vector3& Begin, const Vector3& End, Vector3& colPoint, Vector3& colNormal); --- 44,49 ---- ! /*bool Trace (Vector3 Begin, Vector3 End, Vector3& colPoint, Vector3& colNormal); ! bool TriangleTrace(Vector3 Begin, Vector3 End, Vector3& colPoint, Vector3& colNormal);*/ Index: glrenderer.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/glrenderer.cc,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** glrenderer.cc 13 Nov 2004 23:35:39 -0000 1.19 --- glrenderer.cc 15 Nov 2004 21:35:21 -0000 1.20 *************** *** 1997,2003 **** } glEnd (); //BSphere ! glPushMatrix(); Vector3 vb = b->vWorldOrigin + b->vBSCenter; glTranslatef(vb.x, vb.y, vb.z); --- 1997,2004 ---- } glEnd (); + //BSphere ! /*glPushMatrix(); Vector3 vb = b->vWorldOrigin + b->vBSCenter; glTranslatef(vb.x, vb.y, vb.z); *************** *** 2005,2014 **** gluSphere(pQ, b->fBSRadius, 10, 10); gluDeleteQuadric(pQ); ! glPopMatrix(); if (!bWireFrame) glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); glEnable(GL_CULL_FACE); ! //RenderBSphere (b->vWorldBSCenter, b->fBSRadius); } --- 2006,2031 ---- gluSphere(pQ, b->fBSRadius, 10, 10); gluDeleteQuadric(pQ); ! glPopMatrix();*/ if (!bWireFrame) glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); glEnable(GL_CULL_FACE); ! ! glColor3f(0,1,0); ! glLineWidth(3.0f); ! glBegin (GL_LINES); ! for (int i=0; i<6; i++) ! { ! Vector3 norm = b->pPlanes[i].vNormal; ! Vector3 v1 = b->pPlanes[i].v[0]+b->pPlanes[i].v[1]+b->pPlanes[i].v[2]; ! v1 /= 3; ! Vector3 v2 = v1+norm*10; ! glVertex3fv (&v1.x); ! glVertex3fv (&v2.x); ! } ! glEnd (); ! glLineWidth(1.0f); ! ! glColor3f(1,1,1); } Index: vector3.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/vector3.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** vector3.h 13 Nov 2004 23:35:40 -0000 1.5 --- vector3.h 15 Nov 2004 21:35:21 -0000 1.6 *************** *** 42,46 **** } ! inline float& operator [] (int n) { switch (n) { case 0: return x; case 1: return y; case 2: return z;}} inline bool operator != (const Vector3& v) { return (v.x==x&&v.y==y&&v.z==z); } --- 42,46 ---- } ! inline float& operator [] (int n) { switch (n) { case 0: return x; case 1: return y; case 2: return z; default: return x;}} inline bool operator != (const Vector3& v) { return (v.x==x&&v.y==y&&v.z==z); } Index: md5instance.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5instance.cc,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** md5instance.cc 12 Nov 2004 12:11:36 -0000 1.11 --- md5instance.cc 15 Nov 2004 21:35:21 -0000 1.12 *************** *** 293,301 **** } return b;*/ ! if (/*pBBox->TraceRay(Begin, End, colPoint))*/pBBox->TraceSphereRay(Begin, End, colPoint)) ! return TriangleTrace(Begin, End, colPoint, colNormal); ! else ! return false; ! //return pBBox->TraceSphereRay(Begin, End, colPoint); } --- 293,297 ---- } return b;*/ ! return TriangleTrace(Begin, End, colPoint, colNormal); } *************** *** 318,327 **** } ! bool MD5Instance::TriangleTrace(const Vector3& Begin, const Vector3& End, Vector3& colPoint, Vector3& colNormal) { Plane p; colPoint.x = colPoint.y = colPoint.z = TG_INFINITY; Vector3 cP; float d1, d2; /* next variables are unused --- 314,326 ---- } ! bool MD5Instance::TriangleTrace(Vector3 Begin, Vector3 End, Vector3& colPoint, Vector3& colNormal) { + Quaternion q(-90, Vector3(1,0,0)); Plane p; + Vector3 cPBack = colPoint; colPoint.x = colPoint.y = colPoint.z = TG_INFINITY; Vector3 cP; float d1, d2; + bool bCollide = false; /* next variables are unused *************** *** 339,342 **** --- 338,344 ---- points[1] = pVerticesListTab[j][f->pIndex[1]].vPosition+vPosition; points[2] = pVerticesListTab[j][f->pIndex[2]].vPosition+vPosition; + points[0] = q.Rotate(points[0]); + points[1] = q.Rotate(points[1]); + points[2] = q.Rotate(points[2]); p.SetFromPoints(points[0], points[1], points[2]); *************** *** 351,354 **** --- 353,357 ---- colPoint = cP; colNormal = p.GetNormal(); + bCollide = true; } } *************** *** 369,373 **** } } ! return true; } #endif --- 372,378 ---- } } ! if (!bCollide) ! colPoint = cPBack; ! return bCollide; } #endif Index: boundingbox.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/boundingbox.cc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** boundingbox.cc 12 Nov 2004 12:11:36 -0000 1.6 --- boundingbox.cc 15 Nov 2004 21:35:21 -0000 1.7 *************** *** 137,144 **** } bool BoundingBox::TraceRay (Vector3 begin, Vector3 end, Vector3& colPoint, Vector3& colNormal) { ! return TraceSphereRay(begin, end, colPoint); /*int iB, iE; Vector3 cP; --- 137,189 ---- } + bool Clip (float fDenom, float fNumer, float& rfT0, + float& rfT1) + { + // Return value is 'true' if line segment intersects the current test + // plane. Otherwise 'false' is returned in which case the line segment + // is entirely clipped. + + if ( fDenom > 0.0 ) + { + if ( fNumer > fDenom*rfT1 ) + return false; + if ( fNumer > fDenom*rfT0 ) + rfT0 = fNumer/fDenom; + return true; + } + else if ( fDenom < 0.0 ) + { + if ( fNumer > fDenom*rfT0 ) + return false; + if ( fNumer > fDenom*rfT1 ) + rfT1 = fNumer/fDenom; + return true; + } + else + { + return fNumer <= 0.0; + } + } + //---------------------------------------------------------------------------- + bool MgcFindIntersection (const Vector3& rkOrigin, + const Vector3& rkDirection, const float afExtent[3], float& rfT0, + float& rfT1) + { + float fSaveT0 = rfT0, fSaveT1 = rfT1; + + bool bNotEntirelyClipped = + Clip(+rkDirection.x,-rkOrigin.x-afExtent[0],rfT0,rfT1) && + Clip(-rkDirection.x,+rkOrigin.x-afExtent[0],rfT0,rfT1) && + Clip(+rkDirection.y,-rkOrigin.y-afExtent[1],rfT0,rfT1) && + Clip(-rkDirection.y,+rkOrigin.y-afExtent[1],rfT0,rfT1) && + Clip(+rkDirection.z,-rkOrigin.z-afExtent[2],rfT0,rfT1) && + Clip(-rkDirection.z,+rkOrigin.z-afExtent[2],rfT0,rfT1); + + return bNotEntirelyClipped && ( rfT0 != fSaveT0 || rfT1 != fSaveT1 ); + } bool BoundingBox::TraceRay (Vector3 begin, Vector3 end, Vector3& colPoint, Vector3& colNormal) { ! //return TraceSphereRay(begin, end, colPoint); /*int iB, iE; Vector3 cP; *************** *** 149,153 **** if ((iB == iE) && (iB == POINT_IN_FRONT_OF_PLANE)) return false; ! else if (iB == iE) continue; if (pPlanes[i].IntersectRay(begin, end, cP)) --- 194,198 ---- if ((iB == iE) && (iB == POINT_IN_FRONT_OF_PLANE)) return false; ! if (iB == iE) continue; if (pPlanes[i].IntersectRay(begin, end, cP)) *************** *** 156,159 **** --- 201,267 ---- } return true;*/ + Vector3 kOrigin = begin - vWorldOrigin; + Vector3 kDirection = end - begin; + + float fT0 = 0.0, fT1 = 1.0; + int riQuantity; + Vector3 akPoint[2]; + float extents[3]; + extents[0] = (vMax.x-vMin.x); + extents[1] = (vMax.y-vMin.y); + extents[2] = (vMax.z-vMin.z); + bool bIntersects = MgcFindIntersection(kOrigin,kDirection,extents, + fT0,fT1); + + if ( bIntersects ) + { + if ( fT0 > 0.0 ) + { + if ( fT1 < 1.0 ) + { + riQuantity = 2; + akPoint[0] = kOrigin + fT0*kDirection; + akPoint[1] = kOrigin + fT1*kDirection; + } + else + { + riQuantity = 1; + akPoint[0] = kOrigin + fT0*kDirection; + } + } + else // fT0 == 0.0 + { + if ( fT1 < 1.0 ) + { + riQuantity = 1; + akPoint[0] = kOrigin + fT1*kDirection; + } + else // fT1 == 1.0 + { + // segment entirely in box + riQuantity = 0; + } + } + } + else + { + riQuantity = 0; + } + + if (riQuantity == 2) + { + float dist1 = (kOrigin - akPoint[0]).Magnitude(); + float dist2 = (kOrigin - akPoint[1]).Magnitude(); + + if (dist1 > dist2) + colPoint = akPoint[1]; + else + colPoint = akPoint[0]; + } + else if (riQuantity == 1) + colPoint = akPoint[0]; + colPoint += vWorldOrigin; + //std::cout << colPoint << std::endl; + return bIntersects; } |
|
From: Seb <whi...@us...> - 2004-11-14 13:34:53
|
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27317 Modified Files: playercontroller.cc weapon.cc weapon.h Log Message: Un effet de style plus une nouvelle fonction pour changer l'animation de l'arme en cours :-) Index: playercontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/playercontroller.cc,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** playercontroller.cc 14 Nov 2004 13:07:17 -0000 1.16 --- playercontroller.cc 14 Nov 2004 13:34:44 -0000 1.17 *************** *** 88,95 **** --- 88,97 ---- { bFire = true; + pWeapon->Animation("fire4"); } else if (e.type == evMouseButtonUp) { bFire = false; + pWeapon->Animation("idle"); } Index: weapon.cc =================================================================== RCS file: /cvsroot/epfl/tggame/weapon.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** weapon.cc 14 Nov 2004 13:07:17 -0000 1.2 --- weapon.cc 14 Nov 2004 13:34:44 -0000 1.3 *************** *** 46,50 **** --- 46,54 ---- SoundManager::pSoundManager->PlaySound("gun"); + } + void Weapon::Animation(string name) + { + pModel->SetAnimation(name); } Index: weapon.h =================================================================== RCS file: /cvsroot/epfl/tggame/weapon.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** weapon.h 13 Nov 2004 23:38:08 -0000 1.1 --- weapon.h 14 Nov 2004 13:34:44 -0000 1.2 *************** *** 17,20 **** --- 17,23 ---- void Fire (const Vector3& vPosition, const Vector3& vTarget, Pawn* p); void Think (float eTime); + + void Animation(std::string name); + protected: MD5Instance* pModel; |
|
From: Seb <whi...@us...> - 2004-11-14 13:07:29
|
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21765 Modified Files: playercontroller.cc weapon.cc Log Message: Bruit de tir pour l'arme Index: playercontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/playercontroller.cc,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** playercontroller.cc 13 Nov 2004 23:38:08 -0000 1.15 --- playercontroller.cc 14 Nov 2004 13:07:17 -0000 1.16 *************** *** 28,31 **** --- 28,32 ---- Vector3 vPosition = pPawn->GetPosition()+vViewOffset; pWeapon->Fire (vPosition, vTarget, pPawn); + /* vTarget = vPosition - vTarget*1000000; *************** *** 118,125 **** SoundManager::pSoundManager->PlaySound("step"); break; - case TGKEY_SPACE: - SoundManager::pSoundManager->PlaySound("gun"); - break; - case TGKEY_RIGHT: pPawn->SetPosition(Game::pSelf->GetWorld()->GetRandomStartPosition()+Vector3(20,80,20)); --- 119,122 ---- Index: weapon.cc =================================================================== RCS file: /cvsroot/epfl/tggame/weapon.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** weapon.cc 13 Nov 2004 23:38:08 -0000 1.1 --- weapon.cc 14 Nov 2004 13:07:17 -0000 1.2 *************** *** 1,4 **** --- 1,5 ---- #include "weapon.h" #include "game.h" + #include <soundmanager.h> Weapon::Weapon () *************** *** 44,48 **** cR.pNode->GetPhysicCallBack()->Collide(NULL, cR.EndPoint, cR.Normal); ! } --- 45,49 ---- cR.pNode->GetPhysicCallBack()->Collide(NULL, cR.EndPoint, cR.Normal); ! SoundManager::pSoundManager->PlaySound("gun"); } |
|
From: julien r. <jul...@us...> - 2004-11-13 23:38:18
|
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv920 Modified Files: game.cc game.h playercontroller.cc playercontroller.h Added Files: weapon.cc weapon.h Log Message: decals + classe weapon Index: game.cc =================================================================== RCS file: /cvsroot/epfl/tggame/game.cc,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** game.cc 12 Nov 2004 12:13:17 -0000 1.30 --- game.cc 13 Nov 2004 23:38:08 -0000 1.31 *************** *** 112,121 **** //creation de l'arme ! MD5Instance* pModel = Engine::pMeshManager->LoadInstance("machinegun"); pModel->SetAnimation("idle"); pModel->bCamera = true; pModel->SetRotation(Quaternion(90, Vector3(0,0,1))); pModel->SetPosition(Vector3(5,0,-5)); ! pSceneManager->AddWorldObject(pModel); //creation du joueur --- 112,121 ---- //creation de l'arme ! /*MD5Instance* pModel = Engine::pMeshManager->LoadInstance("machinegun"); pModel->SetAnimation("idle"); pModel->bCamera = true; pModel->SetRotation(Quaternion(90, Vector3(0,0,1))); pModel->SetPosition(Vector3(5,0,-5)); ! pSceneManager->AddWorldObject(pModel);*/ //creation du joueur Index: playercontroller.h =================================================================== RCS file: /cvsroot/epfl/tggame/playercontroller.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** playercontroller.h 12 Nov 2004 12:13:17 -0000 1.7 --- playercontroller.h 13 Nov 2004 23:38:08 -0000 1.8 *************** *** 5,8 **** --- 5,9 ---- #include "controller.h" + #include "weapon.h" using namespace tg; *************** *** 19,23 **** static int STRAFERIGHT; ! DebugSphere* pSphere; public: PlayerController (Pawn*); --- 20,26 ---- static int STRAFERIGHT; ! Weapon* pWeapon; ! bool bFire; ! //DebugSphere* pSphere; public: PlayerController (Pawn*); Index: playercontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/playercontroller.cc,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** playercontroller.cc 12 Nov 2004 12:13:17 -0000 1.14 --- playercontroller.cc 13 Nov 2004 23:38:08 -0000 1.15 *************** *** 13,33 **** { Game::pSelf->GetConsole()->Register("clip", this, CLIP); ! pSphere = new DebugSphere (); ! Game::pSelf->GetSceneManager()->AddDebugSphere(pSphere); } void PlayerController::Think (float eTime) { //Test des tirs { Vector3 vTarget = pPawn->GetRotation().GetZAxis(); Vector3 vPosition = pPawn->GetPosition()+vViewOffset; ! vTarget = vPosition - vTarget*1000000; CollisionResult cR = Game::pSelf->Trace(vPosition, vTarget, pPawn); pSphere->vPosition = cR.EndPoint; if (cR.pNode != NULL && cR.pNode->GetPhysicCallBack() != NULL) ! cR.pNode->GetPhysicCallBack()->Collide(NULL, cR.EndPoint, cR.Normal); } --- 13,41 ---- { Game::pSelf->GetConsole()->Register("clip", this, CLIP); ! /*pSphere = new DebugSphere (); ! Game::pSelf->GetSceneManager()->AddDebugSphere(pSphere);*/ ! pWeapon = new Weapon (); ! bFire = false; } void PlayerController::Think (float eTime) { + pWeapon->Think(eTime); //Test des tirs + if (bFire) { Vector3 vTarget = pPawn->GetRotation().GetZAxis(); Vector3 vPosition = pPawn->GetPosition()+vViewOffset; ! pWeapon->Fire (vPosition, vTarget, pPawn); ! /* vTarget = vPosition - vTarget*1000000; CollisionResult cR = Game::pSelf->Trace(vPosition, vTarget, pPawn); pSphere->vPosition = cR.EndPoint; + if (cR.pNode == NULL) //on a touche la map + Game::pSelf->GetSceneManager()->GetDecalManager()->AddDecal(cR.EndPoint, cR.Normal, 1.0f, 1.0f, Engine::pTextureManager->LoadTexture("data/textures/decals/mgun.bmp", TG_TEXTURE_2D), 10.0f); + if (cR.pNode != NULL && cR.pNode->GetPhysicCallBack() != NULL) ! cR.pNode->GetPhysicCallBack()->Collide(NULL, cR.EndPoint, cR.Normal);*/ } *************** *** 75,78 **** --- 83,97 ---- void PlayerController::EventHandler (tgEvent& e) { + //souris + if (e.type == evMouseButtonDown) + { + bFire = true; + } + else if (e.type == evMouseButtonUp) + { + bFire = false; + } + + //clavier if (e.type == evKeyDown) { Index: game.h =================================================================== RCS file: /cvsroot/epfl/tggame/game.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** game.h 12 Nov 2004 12:13:17 -0000 1.10 --- game.h 13 Nov 2004 23:38:08 -0000 1.11 *************** *** 60,63 **** --- 60,64 ---- inline PhysicEngine* GetPhysicEngine () { return pPhysicEngine; } inline Console* GetConsole () { return pConsole; } + inline Timer* GetTimer() { return pTimer; } /** --- NEW FILE: weapon.h --- #ifndef _TGWEAPON_H #define _TGWEAPON_H #include "pawn.h" #include "controller.h" #include <vector3.h> #include <md5instance.h> using namespace tg; class Weapon { public: Weapon (); ~Weapon (); void Fire (const Vector3& vPosition, const Vector3& vTarget, Pawn* p); void Think (float eTime); protected: MD5Instance* pModel; float fCoolDown; float fFireRate; }; #endif --- NEW FILE: weapon.cc --- #include "weapon.h" #include "game.h" Weapon::Weapon () { pModel = Engine::pMeshManager->LoadInstance("machinegun"); pModel->SetAnimation("idle"); pModel->bCamera = true; pModel->SetRotation(Quaternion(90, Vector3(0,0,1))); pModel->SetPosition(Vector3(5,0,-5)); Game::pSelf->GetSceneManager()->AddWorldObject(pModel); fFireRate = 0.1f; fCoolDown = fFireRate; } Weapon::~Weapon () { Game::pSelf->GetSceneManager()->RemoveWorldObject(pModel); delete pModel; } void Weapon::Think (float eTime) { if (fCoolDown > 0) fCoolDown -= eTime; else fCoolDown = 0.0f; } void Weapon::Fire (const Vector3& vPosition, const Vector3& vTarget, Pawn* p) { if (fCoolDown > 0.0f) return; fCoolDown = fFireRate; Vector3 target = vPosition - vTarget*10000; CollisionResult cR = Game::pSelf->Trace(vPosition, target, p); if (cR.pNode == NULL) //on a touche la map Game::pSelf->GetSceneManager()->GetDecalManager()->AddDecal(cR.EndPoint, cR.Normal, 1.0f, 1.0f, Engine::pTextureManager->LoadTexture("data/textures/decals/mgun.bmp", TG_TEXTURE_2D), 10.0f); if (cR.pNode != NULL && cR.pNode->GetPhysicCallBack() != NULL) //on a touche un objet cR.pNode->GetPhysicCallBack()->Collide(NULL, cR.EndPoint, cR.Normal); } |
|
From: julien r. <jul...@us...> - 2004-11-13 23:38:05
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv907 Added Files: decal.h decalmanager.cc decalmanager.h Log Message: decals --- NEW FILE: decalmanager.h --- #ifndef _TGDECALMANAGER_H #define _TGDECALMANAGER_H #include "vector3.h" #include "material.h" #include "dlinkednode.h" #include "decal.h" #include "q3bsp.h" namespace tg { class DecalManager { public: DecalManager (); ~DecalManager () {} void AddDecal (Vector3 vPos, Vector3 vNorm, float sX, float sY, Texture* pTex, float t); void AddDecal (Decal* d); void Render (float eTime); void SetLevel(Q3Bsp* l) { pLevel = l; } protected: void _ProcessTimedDecal (Decal* d, float t); void _RemoveDecal (Decal* d); Q3Bsp* pLevel; Decal* pFirstDecal; Decal* pCurrentDecal; }; } #endif --- NEW FILE: decalmanager.cc --- #include "decalmanager.h" #include "engine.h" namespace tg { DecalManager::DecalManager () { pCurrentDecal = NULL; pFirstDecal = NULL; } void DecalManager::AddDecal (Vector3 vPos, Vector3 vNorm, float sX, float sY, Texture* pTex, float t) { Decal* d = new Decal (vPos, vNorm, sX, sY, pTex, t); AddDecal(d); } void DecalManager::AddDecal (Decal* d) { if (pFirstDecal) //le premier noeud existe { pCurrentDecal->SetNext(d); d->SetPrev(pCurrentDecal); d->SetNext(NULL); pCurrentDecal = d; } else { d->SetPrev(NULL); d->SetNext(NULL); pFirstDecal = d; pCurrentDecal = d; } } void DecalManager::Render (float eTime) { Decal* d = pFirstDecal; if (d != NULL) { glDepthMask(GL_FALSE); do { if (pLevel->IsVisible(pLevel->FindLeaf(d->vPosition))) { Engine::pRenderer->RenderDecal(d); } //_ProcessTimedDecal(d, eTime); } while((d=d->GetNext()) != NULL); glDepthMask(GL_TRUE); } } void DecalManager::_ProcessTimedDecal(Decal* d, float t) { if (d->fTime == -1) //l'objet ne tient pas compte du temps return; d->fTime -= t; if (d->fTime <= 0) //l'objet est arrive en fin de vie { _RemoveDecal(d); delete d; } } void DecalManager::_RemoveDecal(Decal* d) { if (d->GetNext() == NULL) //l'objet est le dernier de la liste { if (d->GetPrev() != NULL) //mais il a un predecesseur { pCurrentDecal = d->GetPrev(); pCurrentDecal->SetNext(NULL); } //sinon, il est seul dans la liste else { pFirstDecal = NULL; pCurrentDecal = NULL; } } else //il n'est pas le dernier { if (d->GetPrev() != NULL) //il a un predecesseur { d->GetPrev()->SetNext(d->GetNext()); d->GetNext()->SetPrev(d->GetPrev()); } else //il est le premier de la liste { pFirstDecal = d->GetNext(); pFirstDecal->SetPrev(NULL); } } } } --- NEW FILE: decal.h --- #ifndef _TGDECAL_H #define _TGDECAL_H #include "texture.h" #include "vector3.h" namespace tg { struct Decal { inline Decal (Vector3 v, Vector3 n, float x, float y, Texture* m, float t) { _TG_INIT_DLINKEDNODE(NULL,NULL) vPosition = v; vNormal = n; fSizeX = x; fSizeY = y; fTime = t; pTexture = m; } virtual ~Decal () {} Vector3 vPosition; Vector3 vNormal; float fSizeX; float fSizeY; float fTime; Texture* pTexture; _TG_DLINKEDNODE(Decal) }; } #endif |
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv443 Modified Files: engine.cc engine.h glrenderer.cc glrenderer.h physicengine.cc q3bsp.cc scenemanager.cc scenemanager.h texture.cc vector3.h Log Message: decal Index: physicengine.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicengine.cc,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** physicengine.cc 12 Nov 2004 12:11:36 -0000 1.22 --- physicengine.cc 13 Nov 2004 23:35:40 -0000 1.23 *************** *** 113,121 **** #define BASE_HEIGHT 15 ! #define STEPSIZE 20 void PhysicEngine::Move (float eTime) { PhysicNode* n; - for (unsigned int i=0; i<pNodes.size(); i++) { --- 113,120 ---- #define BASE_HEIGHT 15 ! #define STEPSIZE 20*1/0.01 void PhysicEngine::Move (float eTime) { PhysicNode* n; for (unsigned int i=0; i<pNodes.size(); i++) { *************** *** 166,170 **** Vector3 vPos = n->GetPosition(); Vector3 vNewPos = vPos; ! Vector3 vUpPos = n->GetPosition() + (Vector3::UNIT_Y*STEPSIZE); Vector3 vUpNewPos = vUpPos; float distx, distz; --- 165,169 ---- Vector3 vPos = n->GetPosition(); Vector3 vNewPos = vPos; ! Vector3 vUpPos = n->GetPosition() + (Vector3::UNIT_Y*STEPSIZE*eTime); Vector3 vUpNewPos = vUpPos; float distx, distz; Index: engine.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/engine.cc,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** engine.cc 12 Nov 2004 12:11:36 -0000 1.9 --- engine.cc 13 Nov 2004 23:35:39 -0000 1.10 *************** *** 11,14 **** --- 11,15 ---- Endian* Engine::pEndian = NULL; MeshManager* Engine::pMeshManager = new MeshManager (); + TextureManager* Engine::pTextureManager = NULL; #ifdef TGVIDEO Video* Engine::pVideo = NULL; *************** *** 98,101 **** --- 99,105 ---- //il faut initialiser l'affichage avant de faire des glGetString (_ChooseRenderer), sinon, opengl est tout perdu SDL_SetVideoMode(800, 600, vidInfo->vfmt->BitsPerPixel, videoFlags); + + pTextureManager = new TextureManager (); + _ChooseRenderer(); //"reelle" initialisation de l'affichage Index: scenemanager.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/scenemanager.cc,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** scenemanager.cc 12 Nov 2004 12:11:36 -0000 1.16 --- scenemanager.cc 13 Nov 2004 23:35:40 -0000 1.17 *************** *** 18,21 **** --- 18,23 ---- pCurrentPointLight = NULL; + pDecalManager = new DecalManager (); + Engine::pVarManager->AddVar("bump", 1); iBump = &Engine::pVarManager->GetVar("bump")->intValue; *************** *** 171,174 **** --- 173,179 ---- }*/ + pDecalManager->Render(frameInterval); + + PointLight* pl = pFirstPointLight; int count = 0; Index: q3bsp.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/q3bsp.cc,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** q3bsp.cc 12 Nov 2004 12:11:36 -0000 1.11 --- q3bsp.cc 13 Nov 2004 23:35:40 -0000 1.12 *************** *** 139,144 **** Q3Bsp::Q3Bsp () { ! pTexManager = new TextureManager (); ! //pTexManager = Engine::pTextureManager; def = 3; --- 139,144 ---- Q3Bsp::Q3Bsp () { ! //pTexManager = new TextureManager (); ! pTexManager = Engine::pTextureManager; def = 3; *************** *** 1434,1438 **** { endFraction = fraction; ! CandidateToHitNormal = plane->vNormal; } } --- 1434,1438 ---- { endFraction = fraction; ! //CandidateToHitNormal = plane->vNormal; } } Index: engine.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/engine.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** engine.h 12 Nov 2004 12:11:36 -0000 1.7 --- engine.h 13 Nov 2004 23:35:39 -0000 1.8 *************** *** 70,73 **** --- 70,75 ---- static Endian* pEndian; static MeshManager* pMeshManager; + static TextureManager* pTextureManager; + #ifdef TGVIDEO static Video* pVideo; *************** *** 75,79 **** #endif - //static TextureManager* pTextureManager; --- 77,80 ---- Index: glrenderer.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/glrenderer.cc,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** glrenderer.cc 12 Nov 2004 12:11:36 -0000 1.18 --- glrenderer.cc 13 Nov 2004 23:35:39 -0000 1.19 *************** *** 36,39 **** --- 36,155 ---- + void ProjectPointOnPlane (Vector3& dst, Vector3 p, Vector3 normal){ + float d, invDenom; + invDenom = 1.0 / (normal*normal); + d = (normal*p) * invDenom; + dst = p-d*(normal*invDenom); + } + + void PerpendicularVector (Vector3& dst, Vector3 src){ + int i, pos = 0; + float val, min = 1.0; + Vector3 tmp; + // Find the smallest magnitude axially aligned vector + for (i = 0; i < 3; i++){ + val = fabs(src[i]); + if (val < min){ + min = val; + pos = i; + } + } + tmp[pos] = 1.0; + // Project the point onto the plane defined by src + ProjectPointOnPlane(dst, tmp, src); + // Normalize the result + dst = dst.Normalize(); + } + + + void GLRenderer::RenderDecal (Decal* d) + { + Vector3 axis[3]; + axis[0] = d->vNormal.Normalize (); + PerpendicularVector(axis[1], axis[0]); + //RotatePointAroundVector(axis[2], axis[0], axis[1], orientation); + //CrossProduct(axis[0], axis[2], axis[1]); + axis[2] = axis[0]%axis[1]; + + + Vector3 horiz=0.5*axis[1]*10; + Vector3 vert=0.5*axis[2]*10; + (*_glActiveTextureARB)(GL_TEXTURE0); + glEnable (GL_TEXTURE_2D); + glBindTexture (GL_TEXTURE_2D, d->pTexture->iId); + glColor3f(1,1,1); + glDisable(GL_CULL_FACE); + glEnable(GL_BLEND); + glBlendFunc( GL_SRC_ALPHA, GL_ONE ); + + glPushMatrix (); + glTranslatef(d->vPosition.x, d->vPosition.y, d->vPosition.z); + glTranslatef(axis[0].x, axis[0].y, axis[0].z); + glBegin(GL_QUADS); + (*_glMultiTexCoord2fARB)(GL_TEXTURE0,0,0); glVertex3f(horiz.x+vert.x, horiz.y+vert.y, horiz.z+vert.z); + (*_glMultiTexCoord2fARB)(GL_TEXTURE0,1,0); glVertex3f(horiz.x-vert.x, horiz.y-vert.y, horiz.z-vert.z); + (*_glMultiTexCoord2fARB)(GL_TEXTURE0,1,1); glVertex3f(-horiz.x-vert.x, -horiz.y-vert.y, -horiz.z-vert.z); + (*_glMultiTexCoord2fARB)(GL_TEXTURE0,0,1); glVertex3f(-horiz.x+vert.x, -horiz.y+vert.y,-horiz.z+vert.z); + glEnd(); + glPopMatrix (); + glEnable (GL_CULL_FACE); + glDisable(GL_BLEND); + /*Vector3 p1(0,0,0); + Vector3 vec1, vec2; + d->vNormal = d->vNormal.Normalize (); + if (d->vNormal.z > EPSILON || d->vNormal.z < -EPSILON) + p1.z = (d->vNormal*d->vPosition)/d->vNormal.z; + else if (d->vNormal.x > EPSILON || d->vNormal.x < -EPSILON) + p1.x = (d->vNormal*d->vPosition)/d->vNormal.x; + else if (d->vNormal.y > EPSILON || d->vNormal.y < -EPSILON) + p1.y = (d->vNormal*d->vPosition)/d->vNormal.y; + + vec1 = p1-d->vPosition; + vec1 = vec1.Normalize (); + vec2 = vec1 % d->vNormal; + vec2 = vec2.Normalize (); + + + Vector3 horiz=0.5*vec1*10; + Vector3 vert=0.5*vec2*10; + + glDisable (GL_CULL_FACE); + glPushMatrix (); + glTranslatef(d->vPosition.x, d->vPosition.y, d->vPosition.z); + glBegin(GL_QUADS); + glTexCoord2f(0,0); glVertex3f(horiz.x+vert.x, horiz.y+vert.y, horiz.z+vert.z); + glTexCoord2f(1,0); glVertex3f(horiz.x-vert.x, horiz.y-vert.y, horiz.z-vert.z); + glTexCoord2f(1,1); glVertex3f(-horiz.x-vert.x, -horiz.y-vert.y, -horiz.z-vert.z); + glTexCoord2f(0,1); glVertex3f(-horiz.x+vert.x, -horiz.y+vert.y,-horiz.z+vert.z); + glEnd(); + glPopMatrix (); + glEnable (GL_CULL_FACE); + + + Vector3 di = d->vPosition + d->vNormal.Normalize()*5; + Vector3 di2 = d->vPosition + vec1.Normalize()*5; + Vector3 di3 = d->vPosition + vec2.Normalize()*5; + glColor3f(1,0,0); + glLineWidth (2.0f); + glBegin (GL_LINES); + glVertex3fv(&d->vPosition.x); + glVertex3fv(&di.x); + glVertex3fv(&d->vPosition.x); + glVertex3fv(&di2.x); + glVertex3fv(&d->vPosition.x); + glVertex3fv(&di3.x); + glEnd (); + glLineWidth (1.0f); + glColor3f(1,1,1);*/ + + /* glPointSize(10.0f); + glColor3f(1,0,0); + glBegin (GL_POINTS); + glVertex3fv(&d->vPosition.x); + glEnd (); + glPointSize(1.0f); + glColor3f(1,1,1);*/ + } + void GLRenderer::Initialize () { Index: glrenderer.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/glrenderer.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** glrenderer.h 12 Nov 2004 12:11:36 -0000 1.4 --- glrenderer.h 13 Nov 2004 23:35:40 -0000 1.5 *************** *** 11,14 **** --- 11,15 ---- #include "pointlight.h" #include "tgglext.h" + #include "decal.h" namespace tg *************** *** 57,60 **** --- 58,62 ---- virtual void RenderMesh (Mesh*, PointLight*); virtual void RenderMeshShadow (Mesh*); + virtual void RenderDecal (Decal*); virtual void EndShadow (); virtual void RenderParticles (ParticleEmitter*); Index: vector3.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/vector3.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** vector3.h 12 Nov 2004 12:11:36 -0000 1.4 --- vector3.h 13 Nov 2004 23:35:40 -0000 1.5 *************** *** 42,46 **** } ! inline float operator [] (int n) { switch (n) { case 0: return x; case 1: return y; case 2: return z;}} inline bool operator != (const Vector3& v) { return (v.x==x&&v.y==y&&v.z==z); } --- 42,46 ---- } ! inline float& operator [] (int n) { switch (n) { case 0: return x; case 1: return y; case 2: return z;}} inline bool operator != (const Vector3& v) { return (v.x==x&&v.y==y&&v.z==z); } Index: texture.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/texture.cc,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** texture.cc 12 Nov 2004 12:11:36 -0000 1.9 --- texture.cc 13 Nov 2004 23:35:40 -0000 1.10 *************** *** 32,37 **** if (strstr(image, ".bmp") != NULL) return LoadBMP (image, type); - if (strstr(image, ".tga") != NULL) #ifdef TGSDL_IMAGE return LoadTGA (image, type); if (strstr(image, ".png") != NULL) --- 32,37 ---- if (strstr(image, ".bmp") != NULL) return LoadBMP (image, type); #ifdef TGSDL_IMAGE + if (strstr(image, ".tga") != NULL) return LoadTGA (image, type); if (strstr(image, ".png") != NULL) Index: scenemanager.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/scenemanager.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** scenemanager.h 12 Nov 2004 12:11:36 -0000 1.6 --- scenemanager.h 13 Nov 2004 23:35:40 -0000 1.7 *************** *** 12,17 **** #include "dlinkednode.h" #include "pointlight.h" ! #include <string> ! #include <map> namespace tg --- 12,16 ---- #include "dlinkednode.h" #include "pointlight.h" ! #include "decalmanager.h" namespace tg *************** *** 60,64 **** void AddTimedParticleEmitter (ParticleEmitter* p,float time); ! void SetLevel(Q3Bsp* p) { pLevel = p; if(pPhysicEngine) pPhysicEngine->SetLevel(p);} //void SetLevel(D3Map* d) { pD3Level = d; } --- 59,65 ---- void AddTimedParticleEmitter (ParticleEmitter* p,float time); ! void SetLevel(Q3Bsp* p) { pLevel = p; if(pPhysicEngine) pPhysicEngine->SetLevel(p); pDecalManager->SetLevel(p);} ! ! DecalManager* GetDecalManager () { return pDecalManager; } //void SetLevel(D3Map* d) { pD3Level = d; } *************** *** 71,74 **** --- 72,77 ---- void _RenderLight (PointLight*); + DecalManager* pDecalManager; + std::vector<DebugSphere*> pDebugSpheres; |
|
From: Seb <whi...@us...> - 2004-11-12 15:59:21
|
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30772 Modified Files: Makefile.OSX Log Message: Capture video (OSX) Index: Makefile.OSX =================================================================== RCS file: /cvsroot/epfl/tggame/Makefile.OSX,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Makefile.OSX 12 Nov 2004 15:39:22 -0000 1.6 --- Makefile.OSX 12 Nov 2004 15:59:09 -0000 1.7 *************** *** 1,4 **** # TG Makefile ! CFLAGS = -O3 -DDEBUG -DTGOSX -DTGVIDEO INCLUDEPATH = -I/sw/include/SDL -I./ -I../tgengine-0.1 LINKPATH = -L../tgengine-0.1/out --- 1,4 ---- # TG Makefile ! CFLAGS = -O3 -DDEBUG -DTGOSX INCLUDEPATH = -I/sw/include/SDL -I./ -I../tgengine-0.1 LINKPATH = -L../tgengine-0.1/out |
|
From: Seb <whi...@us...> - 2004-11-12 15:40:13
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25738 Modified Files: Makefile Makefile.OSX Log Message: Capture video pour OSX :-) Index: Makefile =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/Makefile,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Makefile 12 Nov 2004 12:11:36 -0000 1.15 --- Makefile 12 Nov 2004 15:40:03 -0000 1.16 *************** *** 13,17 **** make -f Makefile.Linux "CFLAGS = -O3 -DTGLINUX" - linuxDebug: make -f Makefile.Linux "CFLAGS = -ggdb -DDEBUG -DTGLINUX" --- 13,16 ---- *************** *** 25,27 **** --- 24,29 ---- osxDebug: make -f Makefile.OSX "CFLAGS = -ggdb -DDEBUG -DTGOSX" + + osxVideo: + make -f Makefile.OSX "CFLAGS = -DTGOSX -DDEBUG -DTGVIDEO -I/sw/include/ffmpeg/" Index: Makefile.OSX =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/Makefile.OSX,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Makefile.OSX 12 Nov 2004 13:50:43 -0000 1.11 --- Makefile.OSX 12 Nov 2004 15:40:03 -0000 1.12 *************** *** 1,4 **** ## TG Engine Makefile - # Ajoutez -DTGHIGHDEF pour construire la version haute resolution (stencil shadows, dot3 bump) ## --- 1,3 ---- *************** *** 6,13 **** OBJSRC = $(wildcard *.cc) OBJS = $(addsuffix .${OBJ_EXT}, $(basename $(OBJSRC))) ! LIBS = -lvorbis -lvorbisfile -framework OpenAL `sdl-config --libs` -lSDL_image ! ## -lavcodec ! CFLAGS = -DTGOSX -O3 -DDEBUG -DSOUND_DEBUG ! ## -DTGVIDEO -I../ffmpeg-0.4.8/libavcodec CC = g++ --- 5,10 ---- OBJSRC = $(wildcard *.cc) OBJS = $(addsuffix .${OBJ_EXT}, $(basename $(OBJSRC))) ! LIBS = -lvorbis -lvorbisfile -framework OpenAL `sdl-config --libs` -lSDL_image -lavcodec ! CFLAGS = -DTGOSX -O3 -DDEBUG -DSOUND_DEBUG CC = g++ |
|
From: Seb <whi...@us...> - 2004-11-12 15:39:31
|
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25613 Modified Files: Makefile Makefile.OSX Added Files: Makefile.OSXVideo Log Message: Capture video pour OSX :-) --- NEW FILE: Makefile.OSXVideo --- # TG Makefile CFLAGS = -O3 -DDEBUG -DTGOSX -DTGVIDEO INCLUDEPATH = -I/sw/include/SDL -I/sw/include/ffmpeg -I./ -I../tgengine-0.1 LINKPATH = -L../tgengine-0.1/out LIBS = `sdl-config --libs` -framework OpenAL -lSDL_image -ltgengine -ljpeg -lm -lavcodec OBJ_EXT = o OBJSRC = $(wildcard *.cc) OBJS = $(addsuffix .${OBJ_EXT}, $(basename $(OBJSRC))) CC = g++ .cc.${OBJ_EXT}: $(CC) -c $(CFLAGS) -Wall $(INCLUDEPATH) $< -o $@ all: $(OBJS) g++ -o tg -Xlinker -bind_at_load $(INCLUDEPATH) $(LINKPATH) $(LIBS) $(OBJS) clean: rm -f tg rm -f *.o rm -f *~ Index: Makefile =================================================================== RCS file: /cvsroot/epfl/tggame/Makefile,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Makefile 12 Nov 2004 12:13:17 -0000 1.11 --- Makefile 12 Nov 2004 15:39:21 -0000 1.12 *************** *** 24,26 **** --- 24,29 ---- osxDebug: make -f Makefile.OSX "CFLAGS = -ggdb -DDEBUG -DTGOSX -pg" + + osxVideo: + make -f Makefile.OSXVideo Index: Makefile.OSX =================================================================== RCS file: /cvsroot/epfl/tggame/Makefile.OSX,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Makefile.OSX 12 Nov 2004 12:13:17 -0000 1.5 --- Makefile.OSX 12 Nov 2004 15:39:22 -0000 1.6 *************** *** 1,4 **** # TG Makefile ! CFLAGS = -O3 -DTGOSX INCLUDEPATH = -I/sw/include/SDL -I./ -I../tgengine-0.1 LINKPATH = -L../tgengine-0.1/out --- 1,4 ---- # TG Makefile ! CFLAGS = -O3 -DDEBUG -DTGOSX -DTGVIDEO INCLUDEPATH = -I/sw/include/SDL -I./ -I../tgengine-0.1 LINKPATH = -L../tgengine-0.1/out |
|
From: Seb <whi...@us...> - 2004-11-12 13:50:54
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32364 Modified Files: Makefile.OSX Log Message: Makefile OSX Index: Makefile.OSX =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/Makefile.OSX,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Makefile.OSX 12 Nov 2004 12:11:36 -0000 1.10 --- Makefile.OSX 12 Nov 2004 13:50:43 -0000 1.11 *************** *** 6,11 **** OBJSRC = $(wildcard *.cc) OBJS = $(addsuffix .${OBJ_EXT}, $(basename $(OBJSRC))) ! LIBS = -lvorbis -lvorbisfile -framework OpenAL `sdl-config --libs` -lSDL_image ! CFLAGS = -DTGOSX -O3 -DDEBUG -DSOUND_DEBUG -DTGVIDEO -I../ffmpeg-0.4.8/libavcodec/ CC = g++ --- 6,13 ---- OBJSRC = $(wildcard *.cc) OBJS = $(addsuffix .${OBJ_EXT}, $(basename $(OBJSRC))) ! LIBS = -lvorbis -lvorbisfile -framework OpenAL `sdl-config --libs` -lSDL_image ! ## -lavcodec ! CFLAGS = -DTGOSX -O3 -DDEBUG -DSOUND_DEBUG ! ## -DTGVIDEO -I../ffmpeg-0.4.8/libavcodec CC = g++ |
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9682 Modified Files: Makefile Makefile.Linux Makefile.LinuxVideo Makefile.OSX actor.h aicontroller.cc aicontroller.h config.cfg controller.cc controller.h dox_config game.cc game.h gamedefs.h model.cc model.h pawn.cc pawn.h playercontroller.cc playercontroller.h tg.cc world.cc world.h Log Message: force commit Index: config.cfg =================================================================== RCS file: /cvsroot/epfl/tggame/config.cfg,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** config.cfg 28 Oct 2004 21:20:33 -0000 1.8 --- config.cfg 12 Nov 2004 12:13:17 -0000 1.9 *************** *** 5,6 **** --- 5,7 ---- -set lightpos.y 0 -set bump 0 + -set gravity 1000 Index: world.h =================================================================== RCS file: /cvsroot/epfl/tggame/world.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** world.h 21 Oct 2004 21:29:15 -0000 1.4 --- world.h 12 Nov 2004 12:13:17 -0000 1.5 *************** *** 23,26 **** --- 23,29 ---- */ World (char*); + + int GetNumStartPositions (); + Vector3 GetStartPosition (int i); /** * ChangeMap : Change de map Index: world.cc =================================================================== RCS file: /cvsroot/epfl/tggame/world.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** world.cc 1 Oct 2004 21:31:06 -0000 1.3 --- world.cc 12 Nov 2004 12:13:17 -0000 1.4 *************** *** 14,17 **** --- 14,27 ---- } + int World::GetNumStartPositions () + { + return pMap->GetNumStartPoints(); + } + + Vector3 World::GetStartPosition (int i) + { + return pStartPoints[i]; + } + void World::_Load (char* mapName) { Index: game.cc =================================================================== RCS file: /cvsroot/epfl/tggame/game.cc,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** game.cc 10 Nov 2004 21:02:19 -0000 1.29 --- game.cc 12 Nov 2004 12:13:17 -0000 1.30 *************** *** 118,122 **** pModel->SetPosition(Vector3(5,0,-5)); pSceneManager->AddWorldObject(pModel); ! //creation du joueur Pawn* p = new Pawn(); --- 118,122 ---- pModel->SetPosition(Vector3(5,0,-5)); pSceneManager->AddWorldObject(pModel); ! //creation du joueur Pawn* p = new Pawn(); *************** *** 137,150 **** //création d'un ennemi ! p = new Pawn(); ! vPawns.push_back(p); ! this->AddPawn(p); ! Controller* c = new AIController(p); ! vControllers.push_back(c); ! p->SetMoveSpeed(CAM_SPEED); ! p->SetVelocity(Vector3(0,0,0)); ! //p->SetRotation(Quaternion(-90, Vector3(1,0,0))); ! p->SetPosition(Vector3(0,70,0)); ! c->SetViewOffset(Vector3(0,70,0)); //p->SetRotationVelocity(Quaternion(10,Vector3(0,1,1))); --- 137,153 ---- //création d'un ennemi ! //for (int i=0; i<pWorld->GetNumStartPositions(); i++) ! //{ ! p = new Pawn(); ! vPawns.push_back(p); ! this->AddPawn(p); ! Controller* c = new AIController(p); ! vControllers.push_back(c); ! p->SetMoveSpeed(CAM_SPEED); ! p->SetVelocity(Vector3(0,0,0)); ! //p->SetRotation(Quaternion(-90, Vector3(1,0,0))); ! p->SetPosition(pWorld->GetStartPosition(0)); ! c->SetViewOffset(Vector3(0,70,0)); ! //} //p->SetRotationVelocity(Quaternion(10,Vector3(0,1,1))); Index: controller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/controller.cc,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** controller.cc 9 Nov 2004 18:19:03 -0000 1.9 --- controller.cc 12 Nov 2004 12:13:17 -0000 1.10 *************** *** 27,49 **** 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; - }*/ Vector3 x, z; //x = rot.Rotate(Vector3::UNIT_X); --- 27,30 ---- *************** *** 51,54 **** --- 32,38 ---- x = rot.GetXAxis(); z = rot.GetZAxis(); + //le joueur ne peut pas choisir de se déplacer sur les y (vertical) + x.y = 0; + z.y = 0; if (bDir[0]) vLastVel = vVelocity -= z*fSpeed; Index: playercontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/playercontroller.cc,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** playercontroller.cc 10 Nov 2004 21:02:19 -0000 1.13 --- playercontroller.cc 12 Nov 2004 12:13:17 -0000 1.14 *************** *** 23,27 **** Vector3 vTarget = pPawn->GetRotation().GetZAxis(); Vector3 vPosition = pPawn->GetPosition()+vViewOffset; ! vTarget = vPosition - vTarget*1000; CollisionResult cR = Game::pSelf->Trace(vPosition, vTarget, pPawn); --- 23,27 ---- Vector3 vTarget = pPawn->GetRotation().GetZAxis(); Vector3 vPosition = pPawn->GetPosition()+vViewOffset; ! vTarget = vPosition - vTarget*1000000; CollisionResult cR = Game::pSelf->Trace(vPosition, vTarget, pPawn); |
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9090 Modified Files: AUTHORS Changelog Doxyfile LICENSE Makefile Makefile.Linux Makefile.OSX README TODO base.cc base.h boundingbox.cc boundingbox.h camera.cc camera.h command.cc command.h console.cc console.h cvarmanager.cc cvarmanager.h defs.h diskshape.cc diskshape.h dlinkednode.h edge.h emittershape.h engine.cc engine.h errbuffer.cc errbuffer.h event.h face.h font.h frustum.cc frustum.h function.cc function.h gldefs.cc gldefs.h glrenderer.cc glrenderer.h glrenderernv15.cc glrenderernv15.h guibutton.cc guibutton.h guicontainer.cc guicontainer.h guielement.h guimanager.cc guimanager.h guitext.h image2d.h logbuffer.cc logbuffer.h material.h matrice3.h md5instance.cc md5instance.h md5mesh10.cc md5mesh10.h mesh.cc mesh.h meshmanager.cc meshmanager.h particle.h particleemitter.cc particleemitter.h physiccallback.h physicengine.cc physicengine.h physicnode.cc physicnode.h plane.cc plane.h pointlight.h q3bsp.cc q3bsp.h quad.h quaternion.cc quaternion.h registry.cc registry.h renderer.cc renderer.h scenemanager.cc scenemanager.h scenenode.cc scenenode.h soundmanager.cc soundmanager.h texture.cc texture.h texturemanager.cc texturemanager.h tgendian.h tgglext.cc tgglext.h timer.cc timer.h util.cc util.h vbo.cc vbo.h vector3.cc vector3.h vertice.h video.cc video.h vshader.cc vshader.h Log Message: force commit Index: q3bsp.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/q3bsp.cc,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** q3bsp.cc 9 Nov 2004 18:19:04 -0000 1.10 --- q3bsp.cc 12 Nov 2004 12:11:36 -0000 1.11 *************** *** 803,807 **** bool Q3Bsp::IsVisible(int leaf) { ! int iCamLeaf = FindLeaf(pCamera->GetPosition()); int iCamCluster = pLeafs[iCamLeaf].cluster; int iTestCluster = pLeafs[leaf].cluster; --- 803,807 ---- bool Q3Bsp::IsVisible(int leaf) { ! int iCamLeaf = FindLeaf(pCamera->GetPosition()+pCamera->GetViewOffset()); int iCamCluster = pLeafs[iCamLeaf].cluster; int iTestCluster = pLeafs[leaf].cluster; *************** *** 1006,1010 **** memset (pVisibleFaces, 0, sizeof(bool)*numOfFaces); ! int iCamLeaf = FindLeaf(pCamera->GetPosition()); int iCamCluster = pLeafs[iCamLeaf].cluster; for (int i=0; i<numOfLeafs; i++) --- 1006,1010 ---- memset (pVisibleFaces, 0, sizeof(bool)*numOfFaces); ! int iCamLeaf = FindLeaf(pCamera->GetPosition()+pCamera->GetViewOffset()); int iCamCluster = pLeafs[iCamLeaf].cluster; for (int i=0; i<numOfLeafs; i++) Index: physicengine.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicengine.cc,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** physicengine.cc 9 Nov 2004 18:19:04 -0000 1.21 --- physicengine.cc 12 Nov 2004 12:11:36 -0000 1.22 *************** *** 113,117 **** #define BASE_HEIGHT 15 ! #define STEPSIZE 10 void PhysicEngine::Move (float eTime) { --- 113,117 ---- #define BASE_HEIGHT 15 ! #define STEPSIZE 20 void PhysicEngine::Move (float eTime) { *************** *** 143,147 **** Vector3 vVelocity = n->GetVelocity(); if (!n->OnGround()) ! vVelocity.y = -(*pGravity)*eTime; else if (vVelocity.y < 0) //si l'objet touche le sol, il faut ramener la gravité à zéro, sinon, l'objet va se retrouver avec une gravité négative très grande (ça l'empeche de sauter notamment) vVelocity.y = 0; --- 143,147 ---- Vector3 vVelocity = n->GetVelocity(); if (!n->OnGround()) ! vVelocity.y = -(*pGravity); else if (vVelocity.y < 0) //si l'objet touche le sol, il faut ramener la gravité à zéro, sinon, l'objet va se retrouver avec une gravité négative très grande (ça l'empeche de sauter notamment) vVelocity.y = 0; *************** *** 186,211 **** float updist = sqrt(distx+distz); ! /*if (updist > dist) //on passe l'obstacle { //std::cout << "time : " << eTime << "\t" << vUpNewPos << std::endl; n->SetPosition(vUpNewPos); ! if (vUpVelocity != n->GetVelocity() && n->GetPhysicCallBack() != NULL) { //std::cout << "callback" << std::endl; //ce ne sont pas les memes, donc il y a eu collision -> appelle de la callback n->GetPhysicCallBack()->Collide(NULL, Vector3(0,0,0), Vector3(0,0,0)); ! } } else //l'obstacle est trop haut ! {*/ //std::cout << "time : " << eTime << "\t" << vNewPos << std::endl; n->SetPosition(vNewPos); ! /* if (vVelocity != n->GetVelocity() && n->GetPhysicCallBack() != NULL) { //std::cout << "callback" << std::endl; //ce ne sont pas les memes, donc il y a eu collision -> appelle de la callback n->GetPhysicCallBack()->Collide(NULL, Vector3(0,0,0), Vector3(0,0,0)); ! } ! }*/ //Classification de la position --- 186,211 ---- float updist = sqrt(distx+distz); ! if (updist > dist) //on passe l'obstacle { //std::cout << "time : " << eTime << "\t" << vUpNewPos << std::endl; n->SetPosition(vUpNewPos); ! /*if (vUpVelocity != n->GetVelocity() && n->GetPhysicCallBack() != NULL) { //std::cout << "callback" << std::endl; //ce ne sont pas les memes, donc il y a eu collision -> appelle de la callback n->GetPhysicCallBack()->Collide(NULL, Vector3(0,0,0), Vector3(0,0,0)); ! }*/ } else //l'obstacle est trop haut ! { //std::cout << "time : " << eTime << "\t" << vNewPos << std::endl; n->SetPosition(vNewPos); ! /*if (vVelocity != n->GetVelocity() && n->GetPhysicCallBack() != NULL) { //std::cout << "callback" << std::endl; //ce ne sont pas les memes, donc il y a eu collision -> appelle de la callback n->GetPhysicCallBack()->Collide(NULL, Vector3(0,0,0), Vector3(0,0,0)); ! }*/ ! } //Classification de la position Index: md5mesh10.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5mesh10.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** md5mesh10.h 6 Nov 2004 17:05:39 -0000 1.5 --- md5mesh10.h 12 Nov 2004 12:11:36 -0000 1.6 *************** *** 51,54 **** --- 51,55 ---- inline int mesh_GetNumTris (int i) { return pMeshes[i].iNumTris; } inline unsigned int* mesh_GetIndexes(int i) { return pMeshes[i].pIndexes; } + inline Face* mesh_GetFace(int i, int j) { return &pMeshes[i].pTriangles[j]; } //Vertices informations inline int vert_GetWeightIndex(int i, int j) { return pMeshes[i].pVerts[j].iWeightIndex; } Index: mesh.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/mesh.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** mesh.h 26 Sep 2004 13:15:13 -0000 1.1.1.1 --- mesh.h 12 Nov 2004 12:11:36 -0000 1.2 *************** *** 71,75 **** virtual void DrawVisibleEdges () = 0; ! bool bCamera; float fScale; --- 71,75 ---- virtual void DrawVisibleEdges () = 0; ! bool bCamera; float fScale; Index: boundingbox.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/boundingbox.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** boundingbox.h 7 Nov 2004 19:43:48 -0000 1.4 --- boundingbox.h 12 Nov 2004 12:11:36 -0000 1.5 *************** *** 34,38 **** void CalculateVertices (); ! bool IsPointIn(Vector3 p); /** --- 34,38 ---- void CalculateVertices (); ! bool IsPointIn(Vector3 p); /** Index: boundingbox.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/boundingbox.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** boundingbox.cc 10 Nov 2004 21:02:04 -0000 1.5 --- boundingbox.cc 12 Nov 2004 12:11:36 -0000 1.6 *************** *** 84,88 **** //un plan pour chaque face ! //les normales sont justes. Si on recode cette fonction, il faut y faire gaffe... pPlanes[0].SetFromPoints(Vector3(va.x, vi.y, vi.z),vi, Vector3(va.x, va.y, vi.z)); pPlanes[1].SetFromPoints(va,Vector3(va.x, vi.y, va.z), Vector3(va.x, va.y, vi.z)); --- 84,88 ---- //un plan pour chaque face ! //les normales sont justes(elles pointent vers l'exterieur). Si on recode cette fonction, il faut y faire gaffe... pPlanes[0].SetFromPoints(Vector3(va.x, vi.y, vi.z),vi, Vector3(va.x, va.y, vi.z)); pPlanes[1].SetFromPoints(va,Vector3(va.x, vi.y, va.z), Vector3(va.x, va.y, vi.z)); *************** *** 137,150 **** } bool BoundingBox::TraceRay (Vector3 begin, Vector3 end, Vector3& colPoint, Vector3& colNormal) { ! /*bool col = false; for (int i=0; i<6; i++) { ! if (pPlanes[i].IntersectRay(begin,end,colPoint)) ! col = true; } ! return col;*/ ! return TraceSphereRay(begin, end, colPoint); } --- 137,159 ---- } + bool BoundingBox::TraceRay (Vector3 begin, Vector3 end, Vector3& colPoint, Vector3& colNormal) { ! return TraceSphereRay(begin, end, colPoint); ! /*int iB, iE; ! Vector3 cP; for (int i=0; i<6; i++) { ! iB = pPlanes[i].ClassifyPoint(begin); ! iE = pPlanes[i].ClassifyPoint(end); ! if ((iB == iE) && (iB == POINT_IN_FRONT_OF_PLANE)) ! return false; ! else if (iB == iE) ! continue; ! if (pPlanes[i].IntersectRay(begin, end, cP)) ! if ((begin-cP).Magnitude() < (begin-colPoint).Magnitude()) ! colPoint = cP; } ! return true;*/ } Index: md5instance.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5instance.cc,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** md5instance.cc 7 Nov 2004 19:43:48 -0000 1.10 --- md5instance.cc 12 Nov 2004 12:11:36 -0000 1.11 *************** *** 272,312 **** #if 0 ! void MD5Mesh::BuildBone (int frame, _MD5Bone* b) { ! //glMatrixMode (GL_MODELVIEW); ! glPushMatrix(); ! float translate[6]; ! _MD5Channel * chan; ! int lframe; ! for (int i =0; i < 6; i++) ! { ! chan = b->chan[i]; ! lframe = frame%chan->numkeys; ! translate[i] = chan->pKeys[lframe]; ! } ! //Inversion des coordonnes ! glTranslatef( translate[X],translate[Z],-translate[Y] ); ! glRotatef(translate[YAW] , 0,1,0 ); ! glRotatef(translate[PITCH], 0,0,-1 ); ! glRotatef(translate[ROLL] , 1,0,0 ); ! GLfloat matrix[16]; ! glGetFloatv( GL_MODELVIEW_MATRIX, matrix ); ! b->bindpos = Vector3 (matrix[12], matrix[13], matrix[14]); ! for(int i=0; i<3; i++) { ! for( int j=0; j<3; j++) { ! b->bindmat[3*i+j] = matrix[4*i+j]; ! } ! } ! for (int i = 0; i < b->children.size(); i++) ! { ! BuildBone(frame,b->children[i]); ! } ! glPopMatrix(); ! } #endif - } --- 272,374 ---- #if 0 ! bool MD5Instance::Trace (Vector3 Begin, Vector3 End, Vector3& colPoint, Vector3& colNormal) { ! /*Vector3 cP; ! float d1, d2; ! colPoint.x = colPoint.y = colPoint.z = TG_INFINITY; ! bool b = false; ! for (unsigned int i=0; i<numBones; i++) ! { ! //s'il y a collision ! if (pBones[i].BBox.TraceSphereRay(Begin, End, cP)) ! { ! d1 = (cP - Begin).Magnitude(); ! d2 = (colPoint - Begin).Magnitude(); ! if ( d1 < d2 ) ! { ! b = true; ! colPoint = cP; ! } ! } ! } ! return b;*/ ! if (/*pBBox->TraceRay(Begin, End, colPoint))*/pBBox->TraceSphereRay(Begin, End, colPoint)) ! return TriangleTrace(Begin, End, colPoint, colNormal); ! else ! return false; ! //return pBBox->TraceSphereRay(Begin, End, colPoint); ! } ! ! bool SameSide (const Vector3& p1, const Vector3& p2, const Vector3& a, const Vector3& b) ! { ! Vector3 cp1 ((b-a)%(p1-a)); ! Vector3 cp2 ((b-a)%(p2-a)); ! if (cp1*cp2 >= 0) ! return true; ! else ! return false; ! } ! bool PointInTriangle (const Vector3& p,const Vector3& a,const Vector3& b,const Vector3& c) ! { ! if (SameSide(p, a, b, c) && SameSide (p, b, a, c) && SameSide(p, c, a, b)) ! return true; ! else ! return false; ! } ! bool MD5Instance::TriangleTrace(const Vector3& Begin, const Vector3& End, Vector3& colPoint, Vector3& colNormal) ! { ! Plane p; ! colPoint.x = colPoint.y = colPoint.z = TG_INFINITY; ! Vector3 cP; ! float d1, d2; ! /* next variables are unused ! bool b = false; ! float dist, t; ! */ ! ! Vector3 points[3]; ! for (unsigned int j=0; j<iNumMeshes; j++) ! { ! for (unsigned int i=0; i<pData->mesh_GetNumTris(j); i++) ! { ! Face* f = pData->mesh_GetFace(j, i); ! points[0] = pVerticesListTab[j][f->pIndex[0]].vPosition+vPosition; ! points[1] = pVerticesListTab[j][f->pIndex[1]].vPosition+vPosition; ! points[2] = pVerticesListTab[j][f->pIndex[2]].vPosition+vPosition; ! p.SetFromPoints(points[0], points[1], points[2]); ! ! if (p.IntersectRay(Begin, End, cP)) ! { ! if (PointInTriangle(cP, points[0], points[1], points[2])) ! { ! d1 = (cP - Begin).Magnitude(); ! d2 = (colPoint - Begin).Magnitude(); ! if (d1 < d2) ! { ! colPoint = cP; ! colNormal = p.GetNormal(); ! } ! } ! //Engine::pConsole->Output("Collision"); ! } + /* + if (p.ClassifyPoint(Begin) != p.ClassifyPoint(End)) //le segment coupe le plan du triangle, collision possible + { + dist = p.GetDistance(Begin); //on cherche le point de collision avec le plan + t = (End - Begin).Magnitude()/dist; + tempColPoint = (End - Begin)*t; + + if (PointInTriangle(tempColPoint, pVerticesListTab[0][f.pIndex[0]].vPosition, pVerticesListTab[0][f.pIndex[1]].vPosition, pVerticesListTab[0][f.pIndex[2]].vPosition)) + //cP = tempColPoint; + Engine::pConsole->Output("Collision"); + }*/ + } + } + return true; + } #endif } Index: md5instance.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5instance.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** md5instance.h 2 Nov 2004 15:32:16 -0000 1.6 --- md5instance.h 12 Nov 2004 12:11:36 -0000 1.7 *************** *** 44,47 **** --- 44,51 ---- + //bool Trace (Vector3 Begin, Vector3 End, Vector3& colPoint, Vector3& colNormal); + //bool TriangleTrace(const Vector3& Begin, const Vector3& End, Vector3& colPoint, Vector3& colNormal); + + int GetVertexStride () { return 0; } void ComputeSilhouette (const Vector3& lightPos) {} |
|
From: Seb <whi...@us...> - 2004-11-11 19:35:52
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26515 Modified Files: video.h Log Message: Portage OSX pour la capture video Index: video.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/video.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** video.h 11 Nov 2004 19:20:45 -0000 1.2 --- video.h 11 Nov 2004 19:35:43 -0000 1.3 *************** *** 24,28 **** #ifdef TGOSX ! #include <malloc/malloc.h> #else #include <malloc.h> --- 24,28 ---- #ifdef TGOSX ! #include <stdlib.h> #else #include <malloc.h> |
|
From: Seb <whi...@us...> - 2004-11-11 19:20:56
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23252 Modified Files: Makefile.OSX video.h Log Message: Portage OSX pour la capture video (pas encore fonctionnel) Index: video.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/video.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** video.h 11 Nov 2004 10:39:33 -0000 1.1 --- video.h 11 Nov 2004 19:20:45 -0000 1.2 *************** *** 22,26 **** --- 22,32 ---- #include <stdio.h> + + #ifdef TGOSX + #include <malloc/malloc.h> + #else #include <malloc.h> + #endif + #include <avcodec.h> Index: Makefile.OSX =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/Makefile.OSX,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Makefile.OSX 2 Nov 2004 15:32:15 -0000 1.8 --- Makefile.OSX 11 Nov 2004 19:20:45 -0000 1.9 *************** *** 7,11 **** OBJS = $(addsuffix .${OBJ_EXT}, $(basename $(OBJSRC))) LIBS = -lvorbis -lvorbisfile -framework OpenAL `sdl-config --libs` -lSDL_image ! CFLAGS = -DTGOSX -O3 -DDEBUG -DSOUND_DEBUG CC = g++ --- 7,11 ---- OBJS = $(addsuffix .${OBJ_EXT}, $(basename $(OBJSRC))) LIBS = -lvorbis -lvorbisfile -framework OpenAL `sdl-config --libs` -lSDL_image ! CFLAGS = -DTGOSX -O3 -DDEBUG -DSOUND_DEBUG -DTGVIDEO -I../ffmpeg-0.4.8/libavcodec/ CC = g++ |
|
From: julien r. <jul...@us...> - 2004-11-11 10:39:52
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1911 Added Files: video.cc video.h Log Message: capture video --- NEW FILE: video.cc --- /* Video * * Copyright (C) 2003-2004, Alexander Zaprjagaev <fr...@fr...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifdef TGVIDEO #include <stdio.h> #include "video.h" namespace tg { Video::Video(const char *name,int width,int height,int bitrate) { avcodec_init(); avcodec_register_all(); codec = avcodec_find_encoder(CODEC_ID_MPEG2VIDEO); c = avcodec_alloc_context(); c->bit_rate = bitrate; c->width = width; c->height = height; c->frame_rate = 25; c->frame_rate_base= 1; c->gop_size = 10; c->max_b_frames = 1; avcodec_open(c,codec); picture = avcodec_alloc_frame(); yuv = avcodec_alloc_frame(); int size = avpicture_get_size(PIX_FMT_YUV420P,width,height); yuv_data = (uint8_t*)malloc(size); avpicture_fill((AVPicture*)yuv,yuv_data,PIX_FMT_YUV420P,width,height); outbuf_size = 1024 * 1024; outbuf = (uint8_t*)malloc(outbuf_size); file = fopen(name,"wb"); } Video::~Video() { char buf[4] = { 0x00, 0x00, 0x01, 0xb7 }; fwrite(buf,1,4,file); fclose(file); avcodec_close(c); free(c); free(yuv); free(yuv_data); free(picture); } /* */ void Video::save(unsigned char *data,int flip) { if(flip) { for(int y = 0; y < c->height / 2; y++) { unsigned char *l0 = &data[c->width * y * 3]; unsigned char *l1 = &data[c->width * (c->height - y - 1) * 3]; for(int x = 0; x < c->width * 3; x++) { unsigned char l = *l0; *l0++ = *l1; *l1++ = l; } } } avpicture_fill((AVPicture*)picture,(uint8_t*)data,PIX_FMT_RGB24,c->width,c->height); img_convert((AVPicture*)yuv,PIX_FMT_YUV420P,(AVPicture*)picture,PIX_FMT_RGB24,c->width,c->height); int out_size = avcodec_encode_video(c,outbuf,outbuf_size,yuv); fwrite(outbuf,1,out_size,file); } } #endif --- NEW FILE: video.h --- /* Video * * Copyright (C) 2003-2004, Alexander Zaprjagaev <fr...@fr...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifdef TGVIDEO #ifndef __VIDEO_H__ #define __VIDEO_H__ #include <stdio.h> #include <malloc.h> #include <avcodec.h> namespace tg { class Video { public: Video(const char *name,int width,int height,int bitrate); ~Video(); void save(unsigned char *data,int flip = 0); protected: AVCodec *codec; AVCodecContext *c; AVFrame *picture; AVFrame *yuv; uint8_t *yuv_data; int outbuf_size; uint8_t *outbuf; FILE *file; }; #endif /* __VIDEO_H__ */ } #endif |
|
From: julien r. <jul...@us...> - 2004-11-11 10:36:44
|
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1283 Added Files: Makefile.LinuxVideo Log Message: Capture video --- NEW FILE: Makefile.LinuxVideo --- # TG Makefile CFLAGS = -O3 -DTGLINUX -DTGVIDEO -DDEBUG INCLUDEPATH = -I/usr/include/SDL -I./ -I../tgengine-0.1 -I/root/ffmpeg-0.4.8/libavcodec/ LINKPATH = -L../tgengine-0.1/out -L/opt/ffmpeg/lib LIBS = -lGL -lSDL -lGLU -ltgengine -ljpeg -lm -lSDL_image -lvorbis -lvorbisfile -lopenal -lavcodec OBJ_EXT = o OBJSRC = $(wildcard *.cc) OBJS = $(addsuffix .${OBJ_EXT}, $(basename $(OBJSRC))) CC = g++ .cc.${OBJ_EXT}: $(CC) -c $(CFLAGS) -Wall $(INCLUDEPATH) $< -o $@ all: $(OBJS) g++ -o tg $(INCLUDEPATH) $(LINKPATH) $(LIBS) $(OBJS) clean: rm -f tg rm -f *.o rm -f *~ |
|
From: julien r. <jul...@us...> - 2004-11-11 10:34:16
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv686 Modified Files: AUTHORS Makefile engine.cc engine.h glrenderer.cc scenemanager.cc Log Message: capture video Index: scenemanager.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/scenemanager.cc,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** scenemanager.cc 9 Nov 2004 18:19:04 -0000 1.14 --- scenemanager.cc 11 Nov 2004 10:34:01 -0000 1.15 *************** *** 223,227 **** glColor3f(p->pColors[0]*0.4, p->pColors[1]*0.4, p->pColors[2]*0.4); ! Vector3 v = p->vPosition-pCamera->GetForward()*rad; glVertex3fv(&v.x); glColor3f(0,0,0); --- 223,228 ---- glColor3f(p->pColors[0]*0.4, p->pColors[1]*0.4, p->pColors[2]*0.4); ! //Vector3 v = p->vPosition-pCamera->GetForward()*rad; ! Vector3 v = p->vPosition-pCamera->GetRotation().GetXAxis()*rad; glVertex3fv(&v.x); glColor3f(0,0,0); Index: Makefile =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/Makefile,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Makefile 2 Nov 2004 15:32:15 -0000 1.13 --- Makefile 11 Nov 2004 10:34:01 -0000 1.14 *************** *** 17,20 **** --- 17,23 ---- make -f Makefile.Linux "CFLAGS = -ggdb -DDEBUG -DTGLINUX" + linuxVideo: + make -f Makefile.Linux "CFLAGS = -DTGLINUX -DDEBUG -DTGVIDEO -I/root/ffmpeg-0.4.8/libavcodec/" + osx: make -f Makefile.OSX Index: engine.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/engine.cc,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** engine.cc 6 Nov 2004 17:05:39 -0000 1.7 --- engine.cc 11 Nov 2004 10:34:01 -0000 1.8 *************** *** 11,14 **** --- 11,18 ---- Endian* Engine::pEndian = NULL; MeshManager* Engine::pMeshManager = new MeshManager (); + #ifdef TGVIDEO + Video* Engine::pVideo = NULL; + unsigned char* Engine::pVideoBuffer = NULL; + #endif Engine::Engine (Timer* t) *************** *** 97,100 **** --- 101,109 ---- //"reelle" initialisation de l'affichage ResizeScreen(800, 600, false, true); + + #ifdef TGVIDEO + pVideo = new Video("video.mpg",800,600,16000000); + pVideoBuffer = new unsigned char[800 * 600 * 4]; + #endif Index: engine.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/engine.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** engine.h 24 Oct 2004 14:51:54 -0000 1.5 --- engine.h 11 Nov 2004 10:34:01 -0000 1.6 *************** *** 40,43 **** --- 40,47 ---- #include "meshmanager.h" + #ifdef TGVIDEO + #include "video.h" + #endif + namespace tg { *************** *** 66,69 **** --- 70,77 ---- static Endian* pEndian; static MeshManager* pMeshManager; + #ifdef TGVIDEO + static Video* pVideo; + static unsigned char* pVideoBuffer; + #endif //static TextureManager* pTextureManager; Index: AUTHORS =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/AUTHORS,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** AUTHORS 31 Oct 2004 17:44:47 -0000 1.5 --- AUTHORS 11 Nov 2004 10:34:01 -0000 1.6 *************** *** 16,17 **** --- 16,28 ---- Network Developement : Luis Fernando "cerel" Couso Alonso : luis.couso *chez* epfl.ch + + Code repris dans d'autres applications: + video.h & video.cc de Engine_0.2, Alexander Zaprjagaev <fr...@fr...> (GPL) + Quake II, pour certaines fonction de détection des collisions (GPL) + Le tutorial "Quake 3 BSP Collision Detection" de Nathan Ostgard ( http://www.devmaster.net/articles/quake3collision/ ) + et beaucoup d'autres, ayant notamment servi d'inspiration: + Ogre3D, + CrystalSpace, + les articles de nehe.gamedev.net, + les articles de www.gametutorials.com, + Index: glrenderer.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/glrenderer.cc,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** glrenderer.cc 10 Nov 2004 21:02:04 -0000 1.16 --- glrenderer.cc 11 Nov 2004 10:34:01 -0000 1.17 *************** *** 436,439 **** --- 436,448 ---- void GLRenderer::PostRender () { + #ifdef TGVIDEO + static float count = 0; + count += Engine::pEngine->GetTimer()->GetFPS(); + if(count > 1.0 / 25.0) { + glReadPixels(0,0,800,600,GL_RGB,GL_UNSIGNED_BYTE,Engine::pVideoBuffer); + Engine::pVideo->save(Engine::pVideoBuffer,true); + count -= 1.0 / 25.0; + } + #endif glFlush(); SDL_GL_SwapBuffers(); |
|
From: julien r. <jul...@us...> - 2004-11-11 10:34:15
|
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv701 Modified Files: Makefile Log Message: capture video Index: Makefile =================================================================== RCS file: /cvsroot/epfl/tggame/Makefile,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Makefile 2 Nov 2004 16:31:40 -0000 1.9 --- Makefile 11 Nov 2004 10:34:01 -0000 1.10 *************** *** 16,19 **** --- 16,22 ---- make -f Makefile.Linux "CFLAGS = -ggdb -DDEBUG -DTGLINUX" + linuxVideo: + make -f Makefile.LinuxVideo + osx: make -f Makefile.OSX |
|
From: julien r. <jul...@us...> - 2004-11-10 21:02:34
|
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28541 Modified Files: aicontroller.cc game.cc playercontroller.cc Log Message: fixe dans les collisions Index: game.cc =================================================================== RCS file: /cvsroot/epfl/tggame/game.cc,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** game.cc 9 Nov 2004 18:19:03 -0000 1.28 --- game.cc 10 Nov 2004 21:02:19 -0000 1.29 *************** *** 115,121 **** 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); --- 115,119 ---- pModel->SetAnimation("idle"); pModel->bCamera = true; ! pModel->SetRotation(Quaternion(90, Vector3(0,0,1))); pModel->SetPosition(Vector3(5,0,-5)); pSceneManager->AddWorldObject(pModel); *************** *** 129,133 **** vControllers.push_back(pLocalController); cam->SetViewOffset(Vector3(0,70,0)); ! pLocalController->SetViewOffset(Vector3(0,70,0)); //p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(20,80,20)); --- 127,131 ---- vControllers.push_back(pLocalController); cam->SetViewOffset(Vector3(0,70,0)); ! pLocalController->SetViewOffset(Vector3(0,60,0)); //p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(20,80,20)); *************** *** 146,150 **** p->SetMoveSpeed(CAM_SPEED); p->SetVelocity(Vector3(0,0,0)); ! p->SetRotation(Quaternion(-90, Vector3(1,0,0))); p->SetPosition(Vector3(0,70,0)); c->SetViewOffset(Vector3(0,70,0)); --- 144,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)); c->SetViewOffset(Vector3(0,70,0)); Index: playercontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/playercontroller.cc,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** playercontroller.cc 9 Nov 2004 18:19:03 -0000 1.12 --- playercontroller.cc 10 Nov 2004 21:02:19 -0000 1.13 *************** *** 70,74 **** void PlayerController::Collide (SceneNode* other, const Vector3& vPoint, const Vector3& vCollisionNormal) { ! std::cerr << "playercontroller" << std::endl; } --- 70,74 ---- void PlayerController::Collide (SceneNode* other, const Vector3& vPoint, const Vector3& vCollisionNormal) { ! //std::cerr << "playercontroller" << std::endl; } Index: aicontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/aicontroller.cc,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** aicontroller.cc 9 Nov 2004 18:19:02 -0000 1.8 --- aicontroller.cc 10 Nov 2004 21:02:17 -0000 1.9 *************** *** 19,22 **** --- 19,23 ---- { pSphere = new DebugSphere (); + Game::pSelf->GetSceneManager()->AddDebugSphere(pSphere); } *************** *** 31,35 **** CollisionResult cR = Game::pSelf->Trace(vPosition, vTarget, pPawn); pSphere->vPosition = cR.EndPoint; ! std::cout << cR.EndPoint << std::endl; if (cR.pNode != NULL && cR.pNode->GetPhysicCallBack() != NULL) --- 32,36 ---- CollisionResult cR = Game::pSelf->Trace(vPosition, vTarget, pPawn); pSphere->vPosition = cR.EndPoint; ! //std::cout << cR.EndPoint << std::endl; if (cR.pNode != NULL && cR.pNode->GetPhysicCallBack() != NULL) |
|
From: julien r. <jul...@us...> - 2004-11-10 21:02:24
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28528 Modified Files: boundingbox.cc glrenderer.cc Log Message: fixe dans les collisions Index: glrenderer.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/glrenderer.cc,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** glrenderer.cc 9 Nov 2004 18:19:04 -0000 1.15 --- glrenderer.cc 10 Nov 2004 21:02:04 -0000 1.16 *************** *** 1070,1079 **** 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; --- 1070,1079 ---- 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; *************** *** 1095,1099 **** } #endif ! _RotateNode(mesh); --- 1095,1100 ---- } #endif ! //les axes sont inverses dans les trucs ID ! glRotatef(-90, 1, 0, 0); _RotateNode(mesh); *************** *** 1872,1876 **** glEnd (); ! glPushMatrix(); Vector3 vb = b->vWorldOrigin + b->vBSCenter; --- 1873,1877 ---- glEnd (); ! //BSphere glPushMatrix(); Vector3 vb = b->vWorldOrigin + b->vBSCenter; Index: boundingbox.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/boundingbox.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** boundingbox.cc 9 Nov 2004 18:19:04 -0000 1.4 --- boundingbox.cc 10 Nov 2004 21:02:04 -0000 1.5 *************** *** 122,129 **** bool BoundingBox::TraceSphereRay (Vector3 begin, Vector3 end, Vector3& colPoint) ! { ! ! //calcul de l'intersection ! Vector3 D = end.Normalize(); Vector3 EO = (vWorldOrigin+vBSCenter) - begin; float v = EO*D; --- 122,127 ---- bool BoundingBox::TraceSphereRay (Vector3 begin, Vector3 end, Vector3& colPoint) ! { ! Vector3 D = (end-begin).Normalize(); Vector3 EO = (vWorldOrigin+vBSCenter) - begin; float v = EO*D; |
|
From: julien r. <jul...@us...> - 2004-11-09 18:19:34
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27910 Modified Files: boundingbox.cc glrenderer.cc physicengine.cc physicengine.h physicnode.h q3bsp.cc scenemanager.cc scenemanager.h Log Message: collisions Index: physicengine.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicengine.cc,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** physicengine.cc 7 Nov 2004 19:43:49 -0000 1.20 --- physicengine.cc 9 Nov 2004 18:19:04 -0000 1.21 *************** *** 228,232 **** //TODO: Les objets doivent être classés par leaf et cela doit etre utilise pour le trace (il faudrait extraire l'arbre BSP de la map et l'envoyer au moteur physique, qui s'occuperait d'y rajouter les objets & Co) ! CollisionResult PhysicEngine::Trace (Vector3 Begin, Vector3 End) { //on choppe le resultat du trace sur la map --- 228,232 ---- //TODO: Les objets doivent être classés par leaf et cela doit etre utilise pour le trace (il faudrait extraire l'arbre BSP de la map et l'envoyer au moteur physique, qui s'occuperait d'y rajouter les objets & Co) ! CollisionResult PhysicEngine::Trace (Vector3 Begin, Vector3 End, PhysicNode* edict) { //on choppe le resultat du trace sur la map *************** *** 244,248 **** --- 244,252 ---- for (unsigned int i=0; i<pNodes.size(); i++) { + if (edict == pNodes[i]) //on ne considere pas le node qui a appele le trace + continue; + if (pNodes[i]->GetBBox()->TraceRay(Begin, End, colPoint, colNormal)) { + result.pNode = pNodes[i]; d1 = (colPoint - Begin).Magnitude(); d2 = (result.EndPoint - Begin).Magnitude(); Index: scenemanager.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/scenemanager.cc,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** scenemanager.cc 6 Nov 2004 17:05:39 -0000 1.13 --- scenemanager.cc 9 Nov 2004 18:19:04 -0000 1.14 *************** *** 96,100 **** ! Vector3 vTarget = pCamera->GetRotation().GetZAxis(); Vector3 vPosition = pCamera->GetPosition(); vTarget = vPosition - vTarget*10000; --- 96,100 ---- ! /*Vector3 vTarget = pCamera->GetRotation().GetZAxis(); Vector3 vPosition = pCamera->GetPosition(); vTarget = vPosition - vTarget*10000; *************** *** 111,116 **** --- 111,135 ---- GLUquadric* pquad = gluNewQuadric(); gluSphere( pquad, 10,10,10); + glPopMatrix();*/ + } + + (*_glActiveTextureARB)(GL_TEXTURE0); + glDisable (GL_TEXTURE_2D); + (*_glActiveTextureARB)(GL_TEXTURE1); + glDisable (GL_TEXTURE_2D); + for (int i=0; i<pDebugSpheres.size (); i++) + { + DebugSphere* s = pDebugSpheres[i]; + glPushMatrix(); + glColor3f(s->pColors[0], s->pColors[1], s->pColors[2]); + glTranslatef(s->vPosition.x, s->vPosition.y, s->vPosition.z); + gluSphere(s->q, s->fD, 10, 10); glPopMatrix(); } + (*_glActiveTextureARB)(GL_TEXTURE0); + glEnable (GL_TEXTURE_2D); + (*_glActiveTextureARB)(GL_TEXTURE1); + glEnable (GL_TEXTURE_2D); + Mesh* m = pFirstObject; Index: physicengine.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicengine.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** physicengine.h 21 Oct 2004 21:18:28 -0000 1.4 --- physicengine.h 9 Nov 2004 18:19:04 -0000 1.5 *************** *** 43,47 **** void UpdatePosition (); ! CollisionResult Trace(Vector3 Begin, Vector3 End); protected: std::vector<PhysicNode*> pNodes; --- 43,53 ---- void UpdatePosition (); ! /* ! * Lance un rayon a travers la map et les modeles et renvoie des informations de collision ! * @param Vector3 le point de debut du rayon ! * @param Vector3 le point de fin du rayon ! * @param PhysicNode le physicnode qui demande le trace -> le trace n'est pas bloqué par ce physicnode ! */ ! CollisionResult Trace(Vector3 Begin, Vector3 End, PhysicNode* edict=NULL); protected: std::vector<PhysicNode*> pNodes; Index: scenemanager.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/scenemanager.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** scenemanager.h 21 Oct 2004 21:18:28 -0000 1.4 --- scenemanager.h 9 Nov 2004 18:19:04 -0000 1.5 *************** *** 18,21 **** --- 18,31 ---- { + struct DebugSphere + { + DebugSphere () { vPosition.Null(); fD = 10.0f; pColors[0] = pColors[1] = pColors[2] = pColors[3] = 1.0f; q = gluNewQuadric();} + ~DebugSphere () { gluDeleteQuadric(q); } + GLUquadric* q; + Vector3 vPosition; + float fD; + float pColors[4]; + }; + class Engine; *************** *** 39,42 **** --- 49,54 ---- void AddPointLight (PointLight*); void RemovePointLight (PointLight*); + + void AddDebugSphere (DebugSphere* s) { pDebugSpheres.push_back(s); } /**Ajoute un objet qui sera detruit (delete) apres 'time' secondes * Cette fonction ne test PAS si l'objet existe deja dans la liste ! (-> risque de duplication) *************** *** 58,62 **** void _RenderLightedMesh (Mesh* m); void _RenderLight (PointLight*); ! Mesh* pFirstObject; Mesh* pCurrentObject; --- 70,76 ---- void _RenderLightedMesh (Mesh* m); void _RenderLight (PointLight*); ! ! std::vector<DebugSphere*> pDebugSpheres; ! Mesh* pFirstObject; Mesh* pCurrentObject; Index: q3bsp.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/q3bsp.cc,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** q3bsp.cc 6 Nov 2004 17:05:39 -0000 1.9 --- q3bsp.cc 9 Nov 2004 18:19:04 -0000 1.10 *************** *** 1131,1135 **** void Q3Bsp::Render() { ! static float angle = 0.0f; angle += 0.01f; Vector3 vObjectLightPosition(300*cos(angle),50,300*sin(angle)); --- 1131,1135 ---- void Q3Bsp::Render() { ! /*static float angle = 0.0f; angle += 0.01f; Vector3 vObjectLightPosition(300*cos(angle),50,300*sin(angle)); *************** *** 1151,1155 **** glTranslatef(vObjectLightPosition2.x, vObjectLightPosition2.y, vObjectLightPosition2.z); gluSphere( pquad, 10,10,10); ! glPopMatrix(); (*_glActiveTextureARB)(GL_TEXTURE0); glEnable(GL_TEXTURE_2D); --- 1151,1155 ---- glTranslatef(vObjectLightPosition2.x, vObjectLightPosition2.y, vObjectLightPosition2.z); gluSphere( pquad, 10,10,10); ! glPopMatrix();*/ (*_glActiveTextureARB)(GL_TEXTURE0); glEnable(GL_TEXTURE_2D); *************** *** 1158,1162 **** RenderBSP (); ! if (*iBump) { glEnable(GL_BLEND); --- 1158,1162 ---- RenderBSP (); ! /*if (*iBump) { glEnable(GL_BLEND); *************** *** 1170,1174 **** glDisable (GL_BLEND); //_RenderLights (); ! } } --- 1170,1174 ---- glDisable (GL_BLEND); //_RenderLights (); ! }*/ } Index: glrenderer.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/glrenderer.cc,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** glrenderer.cc 7 Nov 2004 11:27:47 -0000 1.14 --- glrenderer.cc 9 Nov 2004 18:19:04 -0000 1.15 *************** *** 1067,1070 **** --- 1067,1071 ---- #ifdef DEBUG if (!mesh->bCamera) { + glLineWidth(2.0f); Vector3 fwd, rgt, up; //mesh->GetRotation().ToAngleVectors(fwd, rgt, up); *************** *** 1091,1094 **** --- 1092,1096 ---- glVertex3fv (&up.x); glEnd (); + glLineWidth(1.0f); } #endif *************** *** 1869,1872 **** --- 1871,1884 ---- } glEnd (); + + + glPushMatrix(); + Vector3 vb = b->vWorldOrigin + b->vBSCenter; + glTranslatef(vb.x, vb.y, vb.z); + GLUquadric* pQ = gluNewQuadric(); + gluSphere(pQ, b->fBSRadius, 10, 10); + gluDeleteQuadric(pQ); + glPopMatrix(); + if (!bWireFrame) glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); Index: physicnode.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicnode.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** physicnode.h 28 Oct 2004 21:10:16 -0000 1.3 --- physicnode.h 9 Nov 2004 18:19:04 -0000 1.4 *************** *** 44,48 **** inline bool Clip () { return bClip; } inline void SetClip (bool b) { bClip = b; } ! /** * Informations sur la position de l'objet par rapport au sol --- 44,48 ---- inline bool Clip () { return bClip; } inline void SetClip (bool b) { bClip = b; } ! /** * Informations sur la position de l'objet par rapport au sol *************** *** 124,127 **** --- 124,128 ---- bool bClip; bool bOnGround; + bool bBlockTrace; Vector3 vAccel; Index: boundingbox.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/boundingbox.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** boundingbox.cc 7 Nov 2004 19:43:48 -0000 1.3 --- boundingbox.cc 9 Nov 2004 18:19:04 -0000 1.4 *************** *** 126,130 **** //calcul de l'intersection Vector3 D = end.Normalize(); ! Vector3 EO = vWorldOrigin - begin; float v = EO*D; float disc = fBSRadius*fBSRadius - (EO*EO - v*v); --- 126,130 ---- //calcul de l'intersection Vector3 D = end.Normalize(); ! Vector3 EO = (vWorldOrigin+vBSCenter) - begin; float v = EO*D; float disc = fBSRadius*fBSRadius - (EO*EO - v*v); *************** *** 141,188 **** bool BoundingBox::TraceRay (Vector3 begin, Vector3 end, Vector3& colPoint, Vector3& colNormal) { ! float startFraction = -1.0f; ! float endFraction = 1.0f; ! bool startsOut = false; ! bool endsOut = false; ! ! for (unsigned int i=0; i<6; i++) ! { ! float startDistance = (begin*pPlanes[i].vNormal) - pPlanes[i].fD; ! float endDistance = (end*pPlanes[i].vNormal) - pPlanes[i].fD; ! ! if (startDistance > 0) startsOut = true; ! if (endDistance > 0) endsOut = true; ! ! if (startDistance > 0 && endDistance > 0) //les deux sont en dehors de la boite ! return false; ! if (startDistance <= 0 && endDistance <= 0) //les deux sont derriere ce plan ! continue; ! ! if (startDistance > endDistance) ! { ! float fraction = (startDistance - EPSILON) / (startDistance - endDistance); ! if (fraction > startFraction) ! { ! startFraction = fraction; ! } ! } ! else ! { ! float fraction = (startDistance + EPSILON) / (startDistance - endDistance); ! if (fraction < endFraction) ! { ! endFraction = fraction; ! } ! } ! } ! ! if (startFraction < endFraction) { ! if (startFraction > -1) ! { ! return true; ! } } ! return false; } --- 141,152 ---- bool BoundingBox::TraceRay (Vector3 begin, Vector3 end, Vector3& colPoint, Vector3& colNormal) { ! /*bool col = false; ! for (int i=0; i<6; i++) { ! if (pPlanes[i].IntersectRay(begin,end,colPoint)) ! col = true; } ! return col;*/ ! return TraceSphereRay(begin, end, colPoint); } |
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27919 Modified Files: aicontroller.cc aicontroller.h controller.cc controller.h game.cc game.h pawn.h playercontroller.cc playercontroller.h Log Message: collisions Index: aicontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/aicontroller.cc,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** aicontroller.cc 2 Nov 2004 15:41:43 -0000 1.7 --- aicontroller.cc 9 Nov 2004 18:19:02 -0000 1.8 *************** *** 16,21 **** --- 16,41 ---- int AIController::STRAFERIGHT = 1; + AIController::AIController(Pawn* p) : Controller(p) + { + pSphere = new DebugSphere (); + } + void AIController::Think (float eTime) { + //Test des tirs + { + Vector3 vTarget = pPawn->GetRotation().GetXAxis(); + Vector3 vPosition = pPawn->GetPosition()+vViewOffset; + vTarget = vPosition + vTarget*1000; + + CollisionResult cR = Game::pSelf->Trace(vPosition, vTarget, pPawn); + pSphere->vPosition = cR.EndPoint; + std::cout << cR.EndPoint << std::endl; + + if (cR.pNode != NULL && cR.pNode->GetPhysicCallBack() != NULL) + cR.pNode->GetPhysicCallBack()->Collide(NULL, cR.EndPoint, cR.Normal); + } + + /* if (!initialised) // A mettre ailleurs... mais je ne vais pas hacker tggame.. je laisse ca aux experts ;) *************** *** 45,50 **** void AIController::Collide (SceneNode* other, const Vector3& vPoint, const Vector3& vCollisionNormal) { ! // fYaw=rand()%360; ! // std::cout << vPoint << std::endl; } --- 65,69 ---- void AIController::Collide (SceneNode* other, const Vector3& vPoint, const Vector3& vCollisionNormal) { ! pPawn->SetAnimation("death"); } Index: pawn.h =================================================================== RCS file: /cvsroot/epfl/tggame/pawn.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** pawn.h 6 Nov 2004 17:05:51 -0000 1.9 --- pawn.h 9 Nov 2004 18:19:03 -0000 1.10 *************** *** 47,50 **** --- 47,51 ---- inline void SetMoveSpeed (float s) { fMoveSpeed = s; } + inline void SetAnimation (const std::string& s) { pModel->SetAnimation(s); } inline void Attach (SceneNode* s) { pPhysic->AttachNode(s); } *************** *** 56,60 **** inline void SetVisible (bool b) { pModel->SetRender(b); } ! //Model* GetModel () { return pModel; } protected: --- 57,63 ---- inline void SetVisible (bool b) { pModel->SetRender(b); } ! ! inline PhysicNode* GetPhysic() { return pPhysic; } ! //Model* GetModel () { return pModel; } protected: Index: game.h =================================================================== RCS file: /cvsroot/epfl/tggame/game.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** game.h 25 Oct 2004 20:04:14 -0000 1.8 --- game.h 9 Nov 2004 18:19:03 -0000 1.9 *************** *** 53,59 **** --- 53,62 ---- void PostFrame (); + CollisionResult Trace(const Vector3& vBegin, const Vector3& vEnd, Pawn* edict); + inline SceneManager* GetSceneManager () { return pSceneManager; } inline World* GetWorld () { return pWorld; } inline Engine* GetEngine () { return pEngine; } + inline PhysicEngine* GetPhysicEngine () { return pPhysicEngine; } inline Console* GetConsole () { return pConsole; } Index: aicontroller.h =================================================================== RCS file: /cvsroot/epfl/tggame/aicontroller.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** aicontroller.h 31 Oct 2004 11:40:44 -0000 1.4 --- aicontroller.h 9 Nov 2004 18:19:03 -0000 1.5 *************** *** 11,16 **** static int STRAFELEFT; static int STRAFERIGHT; public: ! AIController (Pawn* p) : Controller(p) {} virtual ~AIController() {} --- 11,18 ---- static int STRAFELEFT; static int STRAFERIGHT; + + DebugSphere* pSphere; public: ! AIController (Pawn* p); virtual ~AIController() {} Index: game.cc =================================================================== RCS file: /cvsroot/epfl/tggame/game.cc,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** game.cc 7 Nov 2004 19:44:59 -0000 1.27 --- game.cc 9 Nov 2004 18:19:03 -0000 1.28 *************** *** 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 --- 99,102 ---- *************** *** 110,115 **** pEngine->pMeshManager->Load("pinky", "data/models/player/hazmat.md5mesh"); pEngine->pMeshManager->LoadAnim("pinky", "data/models/player/stand.md5anim"); ! MD5Instance* pModel = Engine::pMeshManager->LoadInstance("machinegun"); pModel->SetAnimation("idle"); --- 109,115 ---- pEngine->pMeshManager->Load("pinky", "data/models/player/hazmat.md5mesh"); pEngine->pMeshManager->LoadAnim("pinky", "data/models/player/stand.md5anim"); + pEngine->pMeshManager->LoadAnim("pinky", "data/models/player/death.md5anim"); ! //creation de l'arme MD5Instance* pModel = Engine::pMeshManager->LoadInstance("machinegun"); pModel->SetAnimation("idle"); *************** *** 118,125 **** 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); --- 118,125 ---- q *= Quaternion(90, Vector3(0,1,0)); pModel->SetRotation(q); pModel->SetPosition(Vector3(5,0,-5)); pSceneManager->AddWorldObject(pModel); + //creation du joueur Pawn* p = new Pawn(); pSceneManager->SetCamera(cam); *************** *** 128,131 **** --- 128,134 ---- pLocalController = new PlayerController(p); vControllers.push_back(pLocalController); + cam->SetViewOffset(Vector3(0,70,0)); + pLocalController->SetViewOffset(Vector3(0,70,0)); + //p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(20,80,20)); p->Attach (cam); *************** *** 145,149 **** p->SetRotation(Quaternion(-90, Vector3(1,0,0))); p->SetPosition(Vector3(0,70,0)); ! //p->SetRotationVelocity(Quaternion(10,Vector3(0,1,1))); //p->SetRotation(Quaternion(90,Vector3(0,1,0))); --- 148,153 ---- p->SetRotation(Quaternion(-90, Vector3(1,0,0))); p->SetPosition(Vector3(0,70,0)); ! c->SetViewOffset(Vector3(0,70,0)); ! //p->SetRotationVelocity(Quaternion(10,Vector3(0,1,1))); //p->SetRotation(Quaternion(90,Vector3(0,1,0))); *************** *** 152,155 **** --- 156,164 ---- } + CollisionResult Game::Trace(const Vector3& vBegin, const Vector3& vEnd, Pawn* edict) + { + return pPhysicEngine->Trace(vBegin, vEnd, edict->GetPhysic()); + } + void Game::PreFrame () { Index: controller.h =================================================================== RCS file: /cvsroot/epfl/tggame/controller.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** controller.h 28 Oct 2004 21:20:33 -0000 1.7 --- controller.h 9 Nov 2004 18:19:03 -0000 1.8 *************** *** 26,33 **** --- 26,36 ---- inline Pawn* GetPawn () { return pPawn; } + + void SetViewOffset (const Vector3& v) { vViewOffset = v; } protected: Pawn* pPawn; bool bDir[4]; + Vector3 vViewOffset; Vector3 vLastVel; //pour les mouvements Index: playercontroller.h =================================================================== RCS file: /cvsroot/epfl/tggame/playercontroller.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** playercontroller.h 31 Oct 2004 11:40:44 -0000 1.5 --- playercontroller.h 9 Nov 2004 18:19:03 -0000 1.6 *************** *** 18,21 **** --- 18,23 ---- static int STRAFELEFT; static int STRAFERIGHT; + + DebugSphere* pSphere; public: PlayerController (Pawn*); Index: playercontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/playercontroller.cc,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** playercontroller.cc 31 Oct 2004 11:40:44 -0000 1.11 --- playercontroller.cc 9 Nov 2004 18:19:03 -0000 1.12 *************** *** 13,53 **** { Game::pSelf->GetConsole()->Register("clip", this, CLIP); } void PlayerController::Think (float eTime) { ! float fSensivity = 0.02; ! static float ry = 0; ! static float rx = 0; ! ! int mX, mY; ! int middleX, middleY; ! Game::pSelf->GetEngine()->GetMouseState(&mX,&mY); ! 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); ! 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); } void PlayerController::Collide (SceneNode* other, const Vector3& vPoint, const Vector3& vCollisionNormal) { ! // std::cout << "playercontroller" << std::endl; } --- 13,74 ---- { Game::pSelf->GetConsole()->Register("clip", this, CLIP); + pSphere = new DebugSphere (); + Game::pSelf->GetSceneManager()->AddDebugSphere(pSphere); } void PlayerController::Think (float eTime) { ! //Test des tirs ! { ! Vector3 vTarget = pPawn->GetRotation().GetZAxis(); ! Vector3 vPosition = pPawn->GetPosition()+vViewOffset; ! vTarget = vPosition - vTarget*1000; ! CollisionResult cR = Game::pSelf->Trace(vPosition, vTarget, pPawn); ! pSphere->vPosition = cR.EndPoint; ! if (cR.pNode != NULL && cR.pNode->GetPhysicCallBack() != NULL) ! cR.pNode->GetPhysicCallBack()->Collide(NULL, cR.EndPoint, cR.Normal); ! } ! ! //Mouvement de la souris ! { ! float fSensivity = 0.02; ! static float ry = 0; ! static float rx = 0; ! ! int mX, mY; ! int middleX, middleY; ! Game::pSelf->GetEngine()->GetMouseState(&mX,&mY); ! 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); ! 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); ! } ! ! ! } void PlayerController::Collide (SceneNode* other, const Vector3& vPoint, const Vector3& vCollisionNormal) { ! std::cerr << "playercontroller" << std::endl; } Index: controller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/controller.cc,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** controller.cc 30 Oct 2004 17:46:47 -0000 1.8 --- controller.cc 9 Nov 2004 18:19:03 -0000 1.9 *************** *** 5,8 **** --- 5,10 ---- { pPawn = p; + p->GetPhysic()->SetPhysicCallBack(this); + vViewOffset.Null(); //iForward = iStrafe = 0; for (int i=0; i<4; i++) { |