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; |