|
From: julien r. <jul...@us...> - 2004-12-05 14:30:12
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21643 Modified Files: boundingbox.cc boundingbox.h camera.h glrenderernv15.cc glrenderernv15.h md5instance.h md5mesh10.cc mesh.h particleemitter.h physicengine.cc physicengine.h physicnode.cc physicnode.h scenenode.cc scenenode.h soundnode.h tgglext.cc tgglext.h Log Message: cf wiki&phorum Index: soundnode.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/soundnode.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** soundnode.h 29 Nov 2004 17:29:50 -0000 1.2 --- soundnode.h 5 Dec 2004 14:29:55 -0000 1.3 *************** *** 23,27 **** void PreRender (float x); - private: Vector3 vSpeed; --- 23,26 ---- Index: physicengine.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicengine.cc,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** physicengine.cc 30 Nov 2004 18:21:56 -0000 1.33 --- physicengine.cc 5 Dec 2004 14:29:55 -0000 1.34 *************** *** 16,20 **** } ! #define MAX_CLIP_PLANES 6 void PhysicEngine::StepSlideMove(PhysicNode* n, float eTime, Vector3& vVelocity, Vector3 origin) --- 16,20 ---- } ! #define MAX_CLIP_PLANES 7 void PhysicEngine::StepSlideMove(PhysicNode* n, float eTime, Vector3& vVelocity, Vector3 origin) *************** *** 22,26 **** CollisionResult trace; int bumpcount = 0; ! Plane pPlanes[5]; int iNumPlanes = 0; Vector3 primal_velocity = vVelocity; --- 22,26 ---- CollisionResult trace; int bumpcount = 0; ! Vector3 pPlanes[MAX_CLIP_PLANES]; int iNumPlanes = 0; Vector3 primal_velocity = vVelocity; *************** *** 35,45 **** { trace = Trace(origin, origin+vVelocity*time_left, n->GetBBox()->vMin, n->GetBBox()->vMax, n); - if (trace.AllSolid) { vVelocity.y = 0; - //FIXME: ça ne semble plus poser problème et ça évite les objets traversant les murs //en fait, on devrait plutot tenter de renvoyer les objets en arriere jusqu'a ce que AllSolid devienne faux (en stockant la position précédente des objets et en y revenant par exemple - //vVelocity.Null(); return; } --- 35,42 ---- *************** *** 63,76 **** } ! pPlanes[iNumPlanes] = Plane(trace.Normal, trace.ColPlane.fD); iNumPlanes++; for (i=0; i<iNumPlanes; i++) { ! ClipVelocity (vVelocity, pPlanes[i].vNormal); for (j=0; j<iNumPlanes; j++) if (j != i) { ! if (vVelocity*pPlanes[j].vNormal < 0) break; } --- 60,74 ---- } ! //pPlanes[iNumPlanes] = Plane(trace.Normal, trace.ColPlane.fD); ! pPlanes[iNumPlanes] = trace.Normal; iNumPlanes++; for (i=0; i<iNumPlanes; i++) { ! ClipVelocity (vVelocity, pPlanes[i]); for (j=0; j<iNumPlanes; j++) if (j != i) { ! if (vVelocity*pPlanes[j] < 0) break; } *************** *** 89,93 **** break; } ! Vector3 dir = pPlanes[0].vNormal%pPlanes[1].vNormal; float d = dir*vVelocity; vVelocity = dir/d; --- 87,91 ---- break; } ! Vector3 dir = pPlanes[0]%pPlanes[1]; float d = dir*vVelocity; vVelocity = dir/d; *************** *** 171,182 **** //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) ! //n->SetOnGround(true); ! n->SetPhysicType(PHYS_WALKING); ! else ! //n->SetOnGround(false); ! n->SetPhysicType(PHYS_FALLING); } --- 169,181 ---- //Classification de la position //BspCollisionResult col = pLevel->CheckRayMove(n->GetPosition(), n->GetPosition()+Vector3::NEGATIVE_UNIT_Y*BASE_HEIGHT, n->GetBBox()->vMin, n->GetBBox()->vMax); ! if (n->GetPhysicType() == PHYS_WALKING || n->GetPhysicType() == PHYS_FALLING) ! { ! 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) ! n->SetPhysicType(PHYS_WALKING); ! else ! n->SetPhysicType(PHYS_FALLING); ! } } *************** *** 212,216 **** Vector3 vVelocity = n->GetVelocity(); if (n->GetPhysicType() == PHYS_FALLING) ! vVelocity.y = -(*pGravity)*n->GetGravityFactor(); 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; --- 211,215 ---- Vector3 vVelocity = n->GetVelocity(); if (n->GetPhysicType() == PHYS_FALLING) ! 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; *************** *** 220,237 **** //mise a jour des volumes englobants n->CalculateBoundingVolume(); ! //on test les collisions avec le monde ! if (pLevel) { ! ! _TryToStep(n, eTime); ! ! Quaternion q = n->GetRotationVelocity()*eTime; ! q.Normalize(); ! n->SetRotation(n->GetRotation()*q); ! ! n->UpdatePosition(); ! } ! //appel de la callback pour les collisions avec la map. Ca permet aux objets style rockets de savoir s'ils doivent exploser CollisionResult trace = Trace(n->GetPosition(), n->GetPosition()+n->GetVelocity()*eTime, n->GetBBox()->vMin, n->GetBBox()->vMax, n); if ((trace.Fraction < 1.0f || trace.AllSolid) && n->GetPhysicCallBack() != NULL) --- 219,241 ---- //mise a jour des volumes englobants n->CalculateBoundingVolume(); ! switch (n->GetPhysicType ()) { ! case PHYS_WALKING: ! case PHYS_FALLING: ! case PHYS_PROJECTILE: ! //on test les collisions avec le monde ! if (pLevel) ! { ! _TryToStep(n, eTime); ! Quaternion q = n->GetRotationVelocity()*eTime; ! q.Normalize(); ! n->SetRotation(n->GetRotation()*q); ! n->UpdatePosition(); ! } ! break; ! default: ! break; } ! //appel de la callback pour les collisions avec la map. Ca permet aux objets style rockets de savoir s'ils doivent exploser CollisionResult trace = Trace(n->GetPosition(), n->GetPosition()+n->GetVelocity()*eTime, n->GetBBox()->vMin, n->GetBBox()->vMax, n); if ((trace.Fraction < 1.0f || trace.AllSolid) && n->GetPhysicCallBack() != NULL) *************** *** 254,269 **** result.Fraction = mapResult.Fraction; result.AllSolid = mapResult.AllSolid; ! result.ColPlane = mapResult.ColPlane; //on trace sur les objets ! /* Vector3 colPoint(0,0,0); ! Vector3 colNormal(0,0,0); float d1, d2; ! Vector3 tmp; 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]->TraceRay(Begin, End, colPoint, colNormal)) { result.pNode = pNodes[i]; d1 = (colPoint - Begin).Magnitude(); --- 258,275 ---- result.Fraction = mapResult.Fraction; result.AllSolid = mapResult.AllSolid; ! //result.ColPlane = mapResult.ColPlane; //on trace sur les objets ! //Vector3 colPoint(0,0,0); ! //Vector3 colNormal(0,0,0); float d1, d2; ! //Vector3 tmp; 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; + pNodes[i]->Trace(result, Begin, End, vMin, vMax); ! ! /*if (pNodes[i]->TraceRay(Begin, End, colPoint, colNormal)) { result.pNode = pNodes[i]; d1 = (colPoint - Begin).Magnitude(); *************** *** 273,282 **** result.Normal = colNormal; result.pNode = pNodes[i]; ! //result.Fraction = (End-Begin).Magnitude()/(colPoint-Begin).Magnitude(); ! //result.AllSolid = false; } ! } } ! */ return result; } --- 279,293 ---- result.Normal = colNormal; result.pNode = pNodes[i]; ! //Vector3 vd1 = End-Begin; ! //Vector3 vd2 = colPoint-Begin; ! //vd1 = vd1.Normalize (); ! //vd2 = vd2.Normalize (); ! //result.Fraction = vd2.Magnitude()/vd1.Magnitude(); ! result.Fraction = (colPoint-Begin).Magnitude()/(End-Begin).Magnitude(); ! result.AllSolid = false; } ! }*/ } ! return result; } Index: tgglext.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/tgglext.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tgglext.cc 17 Nov 2004 23:12:39 -0000 1.5 --- tgglext.cc 5 Dec 2004 14:29:55 -0000 1.6 *************** *** 1,3 **** --- 1,5 ---- #include "tgglext.h" + #include <iostream> + namespace tg { *************** *** 32,35 **** --- 34,40 ---- PFNGLPROGRAMPARAMETER4FNVPROC _glProgramParameter4fNV; + PFNGLPOINTPARAMETERFARBPROC _glPointParameterfARB; + PFNGLPOINTPARAMETERFVARBPROC _glPointParameterfvARB; + #ifdef TGWIN32 *************** *** 37,44 **** #endif #ifdef TGLINUX ! #define GETARBPOINTER(var,type,name) var = (type)SDL_GL_GetProcAddress(name); #endif #ifdef TGOSX ! #define GETARBPOINTER(var,type,name) var = (type)SDL_GL_GetProcAddress(name); #endif --- 42,55 ---- #endif #ifdef TGLINUX ! #define GETARBPOINTER(var,type,name) \ ! var = (type)SDL_GL_GetProcAddress(name); \ ! if (!var) \ ! std::cerr << "Erreur lors du chargement de la fonction : " << name << std::endl; #endif #ifdef TGOSX ! #define GETARBPOINTER(var,type,name) \ ! var = (type)SDL_GL_GetProcAddress(name); \ ! if (!var) \ ! std::cerr << "Erreur lors du chargement de la fonction : " << name << std::endl; #endif *************** *** 71,74 **** --- 82,87 ---- GETARBPOINTER(_glProgramParameter4fNV, PFNGLPROGRAMPARAMETER4FNVPROC, "glProgramParameter4fNV"); + GETARBPOINTER(_glPointParameterfARB, PFNGLPOINTPARAMETERFARBPROC, "glPointParameterfARB"); + GETARBPOINTER(_glPointParameterfvARB, PFNGLPOINTPARAMETERFVARBPROC, "glPointParameterfvARB"); } } Index: physicnode.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicnode.cc,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** physicnode.cc 30 Nov 2004 18:21:56 -0000 1.12 --- physicnode.cc 5 Dec 2004 14:29:55 -0000 1.13 *************** *** 12,16 **** vPosition.Null(); vAccel.Null(); - fGravityFactor = 1.0f; iPhysicType = physType; --- 12,15 ---- *************** *** 40,51 **** } ! 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); } } --- 39,49 ---- } ! ! void PhysicNode::Trace(CollisionResult& result, const Vector3& begin,const Vector3& end, const Vector3& vMin, const Vector3& vMax) { ! return pBBox->Trace(result, begin, end, vMin, vMax, this); } + + } Index: physicnode.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicnode.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** physicnode.h 30 Nov 2004 18:21:56 -0000 1.10 --- physicnode.h 5 Dec 2004 14:29:55 -0000 1.11 *************** *** 33,43 **** inline BoundingBox* GetBBox () { return pBBox; } ! bool TraceRay(Vector3 begin, Vector3 end, Vector3& colPoint, Vector3& colNormal); SceneNode* GetSceneNode (int i = 0) { return vNodes[i]; } - inline float GetGravityFactor () { return fGravityFactor; } - inline void SetGravityFactor (float f) { fGravityFactor = f; } - /** * Retourne un pointeur sur la classe servant de callback en cas de collision --- 33,42 ---- inline BoundingBox* GetBBox () { return pBBox; } ! //bool TraceRay(Vector3 begin, Vector3 end, Vector3& colPoint, Vector3& colNormal); ! void Trace(CollisionResult& result, const Vector3& begin,const Vector3& end, const Vector3& vMin, const Vector3& vMax); ! SceneNode* GetSceneNode (int i = 0) { return vNodes[i]; } /** * Retourne un pointeur sur la classe servant de callback en cas de collision *************** *** 51,56 **** inline void SetPhysicCallBack (PhysicCallBack* p) { pPhysicCallBack = p; } - inline bool Trace (Vector3 Begin, Vector3 End, Vector3& colPoint, Vector3& colNormal) { return vNodes[0]->Trace(Begin, End, colPoint, colNormal); } - /* Position */ inline void SetPosition (Vector3 v) { vPosition = v; } --- 50,53 ---- *************** *** 123,128 **** bool bBlockTrace; int iPhysicType; - /* Comment cet objet est-il influencé par la gravité */ - float fGravityFactor; Vector3 vAccel; --- 120,123 ---- Index: particleemitter.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/particleemitter.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** particleemitter.h 19 Nov 2004 12:04:04 -0000 1.4 --- particleemitter.h 5 Dec 2004 14:29:55 -0000 1.5 *************** *** 54,58 **** void SetShape (EmitterShape* s) { pShape = s; } - Texture* GetTexture () { return pTex; } protected: --- 54,57 ---- Index: tgglext.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/tgglext.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tgglext.h 17 Nov 2004 23:12:39 -0000 1.5 --- tgglext.h 5 Dec 2004 14:29:55 -0000 1.6 *************** *** 43,46 **** --- 43,49 ---- typedef void (APIENTRY * PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + typedef void (APIENTRY * PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); + typedef void (APIENTRY * PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat* params); + extern PFNGLACTIVETEXTUREPROC _glActiveTextureARB; extern PFNGLMULTITEXCOORD3FARBPROC _glMultiTexCoord3fARB; *************** *** 72,75 **** --- 75,81 ---- extern PFNGLPROGRAMPARAMETER4FNVPROC _glProgramParameter4fNV; + extern PFNGLPOINTPARAMETERFARBPROC _glPointParameterfARB; + extern PFNGLPOINTPARAMETERFVARBPROC _glPointParameterfvARB; + #define GL_VERTEX_PROGRAM_NV 0x8620 #define GL_PROGRAM_ERROR_POSITION_NV 0x864B *************** *** 77,80 **** --- 83,96 ---- #define GL_MODELVIEW_PROJECTION_NV 0x8629 + + #define GL_POINT_SIZE_MIN_ARB 0x8126 + #define GL_POINT_SIZE_MAX_ARB 0x8127 + #define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 + #define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 + + #define GL_POINT_SPRITE_ARB 0x8861 + #define GL_COORD_REPLACE_ARB 0x8862 + + void InitARBFunctions (); Index: mesh.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/mesh.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** mesh.h 19 Nov 2004 18:54:42 -0000 1.5 --- mesh.h 5 Dec 2004 14:29:55 -0000 1.6 *************** *** 71,74 **** --- 71,75 ---- virtual void DrawVisibleEdges () = 0; + /** * Permet d'attacher des scenode à des joints ou a des mesh Index: physicengine.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicengine.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** physicengine.h 30 Nov 2004 18:21:56 -0000 1.11 --- physicengine.h 5 Dec 2004 14:29:55 -0000 1.12 *************** *** 20,24 **** //le node qui a ete touche. NULL si c'est la carte qui est touche ou si rien n'est touche PhysicNode* pNode; ! Plane ColPlane; }; --- 20,24 ---- //le node qui a ete touche. NULL si c'est la carte qui est touche ou si rien n'est touche PhysicNode* pNode; ! // Plane ColPlane; }; Index: camera.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/camera.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** camera.h 19 Nov 2004 12:04:04 -0000 1.6 --- camera.h 5 Dec 2004 14:29:55 -0000 1.7 *************** *** 49,53 **** inline Frustum* GetFrustum() { return &frustum; } ! protected: --- 49,53 ---- inline Frustum* GetFrustum() { return &frustum; } ! bool Trace (Vector3 Begin, Vector3 End, Vector3& colPoint, Vector3& colNormal) {return false;} protected: Index: glrenderernv15.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/glrenderernv15.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** glrenderernv15.h 17 Nov 2004 23:12:38 -0000 1.3 --- glrenderernv15.h 5 Dec 2004 14:29:55 -0000 1.4 *************** *** 12,15 **** --- 12,16 ---- void EndBump (); void Initialize (); + //void RenderParticles (ParticleEmitter* p); protected: void RenderBumpMappedMesh (Mesh*, const Vector3&); Index: md5instance.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5instance.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** md5instance.h 19 Nov 2004 18:54:42 -0000 1.11 --- md5instance.h 5 Dec 2004 14:29:55 -0000 1.12 *************** *** 44,50 **** - /*bool Trace (Vector3 Begin, Vector3 End, Vector3& colPoint, Vector3& colNormal); - bool TriangleTrace(Vector3 Begin, Vector3 End, Vector3& colPoint, Vector3& colNormal);*/ - void Attach (const std::string& jointName, SceneNode* s); void Detach (const std::string& jointName, SceneNode* s); --- 44,47 ---- Index: scenenode.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/scenenode.cc,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** scenenode.cc 17 Nov 2004 23:12:39 -0000 1.9 --- scenenode.cc 5 Dec 2004 14:29:55 -0000 1.10 *************** *** 48,58 **** { //pBBox->Move(vPosition); - }*/ - - bool SceneNode::Trace (Vector3 Begin,Vector3 End, Vector3& colPoint, Vector3& colNormal) - { - return pBBox->TraceSphereRay(Begin, End, colPoint); } } //END tg --- 48,54 ---- { //pBBox->Move(vPosition); } + */ } //END tg Index: boundingbox.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/boundingbox.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** boundingbox.h 17 Nov 2004 23:12:37 -0000 1.6 --- boundingbox.h 5 Dec 2004 14:29:55 -0000 1.7 *************** *** 9,12 **** --- 9,15 ---- { + struct CollisionResult; + class PhysicNode; + struct BoundingBox { *************** *** 45,49 **** * Trace un rayon à travers la BBox */ ! bool TraceRay (Vector3 begin, Vector3 end, Vector3& colPoint, Vector3& colNormal); --- 48,55 ---- * Trace un rayon à travers la BBox */ ! //bool TraceRay (Vector3 begin, Vector3 end, Vector3& colPoint, Vector3& colNormal); ! void Trace (CollisionResult& result, const Vector3& begin,const Vector3& end, const Vector3& vMin, const Vector3& vMax, PhysicNode* who); ! ! Index: boundingbox.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/boundingbox.cc,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** boundingbox.cc 17 Nov 2004 23:12:37 -0000 1.9 --- boundingbox.cc 5 Dec 2004 14:29:55 -0000 1.10 *************** *** 1,3 **** --- 1,5 ---- #include "boundingbox.h" + #include "physicengine.h" + #include "physicnode.h" namespace tg *************** *** 136,140 **** --- 138,292 ---- return true; } + void BoundingBox::Trace(CollisionResult& result, const Vector3& begin,const Vector3& end, const Vector3& vMin, const Vector3& vMax, PhysicNode* who) + { + float startFraction = -1.0f; + float endFraction = 1.0f; + float startDistance, endDistance; + bool bStartsOut = false; + bool bEndsOut = false; + /*float fraction = 1.0f; + + bool bAllSolid = false;*/ + + int colPlane=-1; + for (int j=0;j<6;j++) { + if (vMin == Vector3::ZERO && vMax == Vector3::ZERO) { //on trace avec un rayon en fait + startDistance = pPlanes[j].GetDistance(begin); + endDistance = pPlanes[j].GetDistance(end); + } + else { + Vector3 offset; + offset.x = pPlanes[j].vNormal.x < 0 ? vMax.x : vMin.x; + offset.y = pPlanes[j].vNormal.y < 0 ? vMax.y : vMin.y; + offset.z = pPlanes[j].vNormal.z < 0 ? vMax.z : vMin.z; + startDistance = pPlanes[j].GetDistance(begin+offset); + endDistance = pPlanes[j].GetDistance(end+offset); + } + + if (startDistance > 0 ) bStartsOut = true; + if (endDistance > 0 ) bEndsOut = true; + + if (startDistance > 0 && endDistance>=startDistance) //les deux sont devant le plan, donc dehors + return; + else if (startDistance <= 0 && endDistance <= 0) //les deux sont dedans, seront coupé par un autre plan + continue; + + if (startDistance>endDistance) { + float fraction = (startDistance - EPSILON)/(startDistance - endDistance); + if ( fraction > startFraction) { + startFraction = fraction; + colPlane = j; + } + } + else { + float fraction = (startDistance + EPSILON)/(startDistance - endDistance); + if ( fraction < endFraction) { + endFraction = fraction; + //colPlane = j; + } + } + + } + + + // After checking all sides if startOut remain false, then the Start Point is complete in the brush + if (bStartsOut == false) + { + //result.StartOut = false; + // if also the EndPoint is in this brush, then the ray is complete in this brush + if (bEndsOut == false) + result.AllSolid = true; + } + + // if there was collision against the brush (S < E) + if (startFraction < endFraction) + { + if (startFraction > -1 && startFraction < result.Fraction) + { + // UpDate OutPut values + if (startFraction < 0) startFraction = 0; + result.Fraction = startFraction; + if (colPlane != -1) + result.Normal = pPlanes[colPlane].vNormal; + result.EndPoint = begin + (end-begin)*result.Fraction; + } + } + } + #if 0 + bool BoundingBox::TraceRay (Vector3 begin, Vector3 end, Vector3& colPoint, Vector3& colNormal) + { + float startFraction = -1.0f; + float endFraction = 1.0f; + float startDistance, endDistance; + bool bStartsOut = false; + bool bEndsOut = false; + float fraction = 1.0f; + + bool bAllSolid = false; + + int colPlane=-1; + for (int j=0;j<6;j++) { + startDistance = pPlanes[j].GetDistance(begin); + endDistance = pPlanes[j].GetDistance(end); + + if (startDistance > 0 ) bStartsOut = true; + if (endDistance > 0 ) bEndsOut = true; + + if (startDistance > 0 && endDistance>=startDistance) //les deux sont devant le plan, donc dehors + return false; + else if (startDistance <= 0 && endDistance <= 0) //les deux sont dedans, seront coupé par un autre plan + continue; + + if (startDistance>endDistance) { + fraction = (startDistance - EPSILON)/(startDistance - endDistance); + if ( fraction > startFraction) { + startFraction = fraction; + colPlane = j; + } + } + else { + fraction = (startDistance + EPSILON)/(startDistance - endDistance); + if ( fraction < endFraction) { + endFraction = fraction; + //colPlane = j; + } + } + + } + + + // After checking all sides if startOut remain false, then the Start Point is complete in the brush + if (bStartsOut == false) + { + //result.StartOut = false; + + // if also the EndPoint is in this brush, then the ray is complete in this brush + if (bEndsOut == false) + //result.AllSolid = true; + bAllSolid = true; + return (fraction < 1.0f); + } + + // if there was collision against the brush (S < E) + if (startFraction < endFraction) + { + if (startFraction > -1 /*&& startFraction < result.Fraction*/) + { + // UpDate OutPut values + + if (startFraction < 0) startFraction = 0; + fraction = startFraction; + if (colPlane != -1) + colNormal = pPlanes[colPlane].vNormal; + else + colNormal.Null(); + colPoint = (end-begin)*fraction; + } + } + + } + #endif + #if 0 bool Clip (float fDenom, float fNumer, float& rfT0, float& rfT1) *************** *** 186,190 **** { //return TraceSphereRay(begin, end, colPoint); ! /*int iB, iE; Vector3 cP; for (int i=0; i<6; i++) --- 338,342 ---- { //return TraceSphereRay(begin, end, colPoint); ! int iB, iE; Vector3 cP; for (int i=0; i<6; i++) *************** *** 200,205 **** colPoint = cP; } ! return true;*/ ! Vector3 kOrigin = begin - vWorldOrigin; Vector3 kDirection = end - begin; --- 352,357 ---- colPoint = cP; } ! return true; ! /*Vector3 kOrigin = begin - vWorldOrigin; Vector3 kDirection = end - begin; *************** *** 265,271 **** colPoint = akPoint[0]; colPoint += vWorldOrigin; //std::cout << colPoint << std::endl; ! return bIntersects; } ! } //END tg --- 417,428 ---- colPoint = akPoint[0]; colPoint += vWorldOrigin; + //FIXME: ugly hack pour trouver la normale de collision + for (int i=0; i<6; i++) + if (pPlanes[i].ClassifyPoint(colPoint) == POINT_ON_PLANE) + colNormal = pPlanes[i].vNormal; + //std::cout << colPoint << std::endl; ! return bIntersects;*/ } ! #endif } //END tg Index: md5mesh10.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5mesh10.cc,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** md5mesh10.cc 22 Nov 2004 21:19:07 -0000 1.10 --- md5mesh10.cc 5 Dec 2004 14:29:55 -0000 1.11 *************** *** 1,4 **** --- 1,5 ---- #include "md5mesh10.h" #include "quaternion.h" + #include "engine.h" namespace tg *************** *** 120,128 **** pMeshes[i].pMaterial = new Material (); ! Texture* tmpTex = new Texture (); ! tmpTex->LoadBMP((char*)pMeshes[i].sNormal.data(), TG_TEXTURE_2D); pMeshes[i].pMaterial->SetNormalTexture(tmpTex); ! tmpTex = new Texture(); ! tmpTex->LoadBMP((char*)pMeshes[i].sColor.data(), TG_TEXTURE_2D); pMeshes[i].pMaterial->SetFirstTexture(tmpTex); --- 121,131 ---- pMeshes[i].pMaterial = new Material (); ! //Texture* tmpTex = new Texture (); ! //tmpTex->LoadBMP((char*)pMeshes[i].sNormal.data(), TG_TEXTURE_2D); ! Texture* tmpTex = Engine::pEngine->pTextureManager->LoadTexture((char*)pMeshes[i].sNormal.data(), TG_TEXTURE_2D); pMeshes[i].pMaterial->SetNormalTexture(tmpTex); ! //tmpTex = new Texture(); ! //tmpTex->LoadBMP((char*)pMeshes[i].sColor.data(), TG_TEXTURE_2D); ! tmpTex = Engine::pEngine->pTextureManager->LoadTexture((char*)pMeshes[i].sColor.data(), TG_TEXTURE_2D); pMeshes[i].pMaterial->SetFirstTexture(tmpTex); Index: scenenode.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/scenenode.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** scenenode.h 19 Nov 2004 12:04:04 -0000 1.10 --- scenenode.h 5 Dec 2004 14:29:55 -0000 1.11 *************** *** 61,68 **** // - virtual bool Trace (Vector3 Begin, Vector3 End, Vector3& colPoint, Vector3& colNormal); - - //BoundingBox* pBBox; - int iLeaf; //utilise par les noeuds a duree limite (SceneManager::AddTimed). Inferieur a 0 si noeud non-limite dans le temps --- 61,64 ---- Index: glrenderernv15.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/glrenderernv15.cc,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** glrenderernv15.cc 17 Nov 2004 23:12:38 -0000 1.9 --- glrenderernv15.cc 5 Dec 2004 14:29:55 -0000 1.10 *************** *** 34,38 **** --- 34,81 ---- } + #if 0 + void GLRendererNV15::RenderParticles (ParticleEmitter* p) + { + //TODO: Le rendu des particules en fil de fer texture donne qq chose de vraiment pas mal ! + + static float** pQuads; + static float size; + size = p->GetSize (); + pQuads = p->GetQuads (); + + float quadratic[] = { 0.0f, 0.0f, 0.01f }; + (*_glPointParameterfvARB)( GL_POINT_DISTANCE_ATTENUATION_ARB, quadratic ); + float maxSize = 0.0f; + glGetFloatv( GL_POINT_SIZE_MAX_ARB, &maxSize ); + glPointSize( 200.0f ); + (*_glPointParameterfARB)( GL_POINT_SIZE_MAX_ARB, maxSize ); + (*_glPointParameterfARB)( GL_POINT_SIZE_MIN_ARB, 1.0f ); + + glDepthMask(GL_FALSE); + glDisable(GL_CULL_FACE); + glEnable(GL_BLEND); + glBlendFunc( GL_SRC_ALPHA, GL_ONE ); + + //BindMaterial (p->GetMaterial()); + (*_glActiveTextureARB)(GL_TEXTURE0); + glEnable (GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, p->GetTexture()->iId); + glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE ); + glEnable( GL_POINT_SPRITE_ARB ); + glBegin (GL_POINTS); + for (int i=0; i<p->GetParticlesCount();i++) + { + glColor4f (pQuads[i][3], pQuads[i][4], pQuads[i][5], pQuads[i][6]); + glVertex3f(pQuads[i][0], pQuads[i][1], pQuads[i][2]); + } + glEnd (); + glDisable( GL_POINT_SPRITE_ARB ); + glDepthMask (GL_TRUE); + glEnable(GL_CULL_FACE); + glDisable(GL_BLEND); + + } + #endif /** * Important ! Il faut que la depth func soit en GL_LEQUAL et pas en GL_LESS, car sinon, lors de la deuxieme pass, le modele "coloré" ne sera pas dessiné, les valeurs étants égales mais pas supérieur !!!!!! |