|
From: julien r. <jul...@us...> - 2004-10-24 13:37:08
|
Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3822 Modified Files: camera.cc camera.h glrenderer.cc glrenderernv15.cc physicengine.cc physicnode.cc physicnode.h quaternion.h scenemanager.cc scenenode.h vector3.cc vector3.h Log Message: Index: physicengine.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicengine.cc,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** physicengine.cc 21 Oct 2004 21:18:28 -0000 1.11 --- physicengine.cc 24 Oct 2004 13:36:59 -0000 1.12 *************** *** 91,95 **** { n->SetPosition(n->GetPosition()+n->GetVelocity()*eTime); ! n->SetRot(n->GetRot()+n->GetRotVelocity()*eTime); n->UpdatePosition(); --- 91,95 ---- { n->SetPosition(n->GetPosition()+n->GetVelocity()*eTime); ! n->SetRotation(n->GetRotation()+n->GetRotationVelocity()*eTime); n->UpdatePosition(); *************** *** 180,184 **** n->SetOnGround(false); ! n->SetRot(n->GetRot()+n->GetRotVelocity()*eTime); n->UpdatePosition(); --- 180,184 ---- n->SetOnGround(false); ! n->SetRotation(n->GetRotation()+n->GetRotationVelocity()*eTime); n->UpdatePosition(); Index: scenemanager.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/scenemanager.cc,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** scenemanager.cc 21 Oct 2004 21:18:28 -0000 1.8 --- scenemanager.cc 24 Oct 2004 13:36:59 -0000 1.9 *************** *** 68,74 **** ! /*Vector3 Target = pCamera->GetForward(); ! Target = pCamera->vPosition+Target*10000; ! CollisionResult myResult = Trace(pCamera->vPosition, Target); glPointSize(5.0f); --- 68,75 ---- ! //Vector3 Target = pCamera->GetForward(); ! Vector3 Target = Vector3::UNIT_X; ! Target = pCamera->GetForward()+Target*100000; ! CollisionResult myResult = pPhysicEngine->Trace(pCamera->GetForward(), Target); glPointSize(5.0f); *************** *** 81,85 **** GLUquadric* pquad = gluNewQuadric(); gluSphere( pquad, 10,10,10); ! glPopMatrix();*/ } --- 82,86 ---- GLUquadric* pquad = gluNewQuadric(); gluSphere( pquad, 10,10,10); ! glPopMatrix(); } *************** *** 101,105 **** #endif #ifdef DEBUG ! Engine::pRenderer->RenderBBox(m->GetBBox()); #endif } --- 102,106 ---- #endif #ifdef DEBUG ! //Engine::pRenderer->RenderBBox(m->GetBBox()); #endif } Index: physicnode.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicnode.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** physicnode.cc 21 Oct 2004 21:21:00 -0000 1.1 --- physicnode.cc 24 Oct 2004 13:36:59 -0000 1.2 *************** *** 24,28 **** n = vNodes[i]; n->SetPosition(vPosition); ! n->SetEuler(vEuler); } } --- 24,28 ---- n = vNodes[i]; n->SetPosition(vPosition); ! n->SetRotation(vEuler); } } Index: physicnode.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicnode.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** physicnode.h 21 Oct 2004 21:21:00 -0000 1.1 --- physicnode.h 24 Oct 2004 13:36:59 -0000 1.2 *************** *** 86,92 **** /* Rotation */ ! inline Vector3 GetRot () { return vEuler; } ! inline void SetRot (const Vector3& v) { vEuler = v; } ! inline void AddRot (const Vector3& v) { vEuler += v; } inline float GetXRot () { return vEuler.x; } inline float GetYRot () { return vEuler.y; } --- 86,92 ---- /* Rotation */ ! inline Vector3 GetRotation () { return vEuler; } ! inline void SetRotation (const Vector3& v) { vEuler = v; } ! inline void AddRotation (const Vector3& v) { vEuler += v; } inline float GetXRot () { return vEuler.x; } inline float GetYRot () { return vEuler.y; } *************** *** 100,105 **** /* Vitesse de rotation */ ! inline Vector3 GetRotVelocity () { return vEulerVelocity; } ! inline void SetRotVelocity (const Vector3& v) { vEulerVelocity = v; } inline void AddRotVelocity (const Vector3& v) { vEulerVelocity += v; } inline float GetXRotVelocity () { return vEulerVelocity.x; } --- 100,105 ---- /* Vitesse de rotation */ ! inline Vector3 GetRotationVelocity () { return vEulerVelocity; } ! inline void SetRotationVelocity (const Vector3& v) { vEulerVelocity = v; } inline void AddRotVelocity (const Vector3& v) { vEulerVelocity += v; } inline float GetXRotVelocity () { return vEulerVelocity.x; } Index: camera.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/camera.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** camera.h 26 Sep 2004 13:15:05 -0000 1.1.1.1 --- camera.h 24 Oct 2004 13:36:59 -0000 1.2 *************** *** 16,22 **** { public: ! float fYaw, fPitch, fRoll; float fSpeed; float fSensivity; /** * Variables utilises pour deplacer la camera --- 16,24 ---- { public: ! //float fYaw, fPitch, fRoll; float fSpeed; float fSensivity; + + Vector3 vRot; /** * Variables utilises pour deplacer la camera Index: quaternion.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/quaternion.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** quaternion.h 26 Sep 2004 13:15:18 -0000 1.1.1.1 --- quaternion.h 24 Oct 2004 13:36:59 -0000 1.2 *************** *** 17,24 **** { public: ! Quaternion () : r(1), x(0), y(0), z(0) {} //par defaut, on met le quaternion identite ! Quaternion (float f, float i, float j, float k) { SetRotation(f,i,j,k); } ! Quaternion (const Quaternion& q) : r(q.r), x(q.x), y(q.y), z(q.z) {} ! Quaternion (float f, Vector3 v) { SetRotation(f, v);} Quaternion operator = (const Quaternion& q); --- 17,24 ---- { public: ! inline Quaternion () : r(1), x(0), y(0), z(0) {} //par defaut, on met le quaternion identite ! inline Quaternion (float f, float i, float j, float k) { SetRotation(f,i,j,k); } ! inline Quaternion (const Quaternion& q) : r(q.r), x(q.x), y(q.y), z(q.z) {} ! inline Quaternion (float f, Vector3 v) { SetRotation(f, v);} Quaternion operator = (const Quaternion& q); *************** *** 34,38 **** Quaternion operator * (float f); Quaternion operator *= (float f); ! float Norm (); float Magnitude (); --- 34,39 ---- Quaternion operator * (float f); Quaternion operator *= (float f); ! ! inline void Null() { r=1;x=y=z=0; } float Norm (); float Magnitude (); Index: glrenderer.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/glrenderer.cc,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** glrenderer.cc 21 Oct 2004 21:18:28 -0000 1.8 --- glrenderer.cc 24 Oct 2004 13:36:59 -0000 1.9 *************** *** 776,782 **** void GLRenderer::_RotateNode (SceneNode* s) { ! glRotatef(s->GetXRot(), 1, 0, 0); ! glRotatef(s->GetYRot(), 0, 1, 0); ! glRotatef(s->GetZRot(), 0, 0, 1); } --- 776,784 ---- void GLRenderer::_RotateNode (SceneNode* s) { ! glRotatef(s->GetRotation().x, 1, 0, 0); ! glRotatef(s->GetRotation().y, 0, 1, 0); ! glRotatef(s->GetRotation().z, 0, 0, 1); ! /*Vector3 axis = s->GetRotation().GetRotationAxis(); ! glRotatef(s->GetRotation().GetRotationAngle(),axis.x, axis.y, axis.z);*/ } *************** *** 1060,1063 **** --- 1062,1087 ---- glTranslatef(mesh->GetPosition().x, mesh->GetPosition().y, mesh->GetPosition().z); + + #ifdef DEBUG + Vector3 fwd, rgt, up; + mesh->GetRotation().ToAngleVectors(fwd, rgt, up); + fwd *= 10; + rgt *= 10; + up *= 10; + glBegin (GL_LINES); + glColor3f (1,0,0); + glVertex3f (0,0,0); + glVertex3fv (&fwd.x); + + glColor3f(0,0,1); + glVertex3f (0,0,0); + glVertex3fv (&rgt.x); + + glColor3f(0,1,0); + glVertex3f (0,0,0); + glVertex3fv (&up.x); + glEnd (); + #endif + _RotateNode(mesh); *************** *** 1080,1086 **** glEnable(GL_CULL_FACE); glFrontFace(GL_CW); - //std::cout << "adress : " << mesh << std::endl; - for (unsigned int j=0; j<iNumMeshes; j++) { --- 1104,1108 ---- *************** *** 1097,1106 **** if (mesh->GetMaterial(j) && mesh->GetMaterial(j)->HasPrimary()) glBindTexture (GL_TEXTURE_2D, mesh->GetMaterial(j)->GetFirstTexture()->iId); ! /*glVertexPointer(3, GL_FLOAT, sizeof(Vertice) , &pVerts[0].vPosition); glTexCoordPointer(2, GL_FLOAT, sizeof(Vertice), &pVerts[0].s); glEnableClientState(GL_VERTEX_ARRAY); ! glDrawElements(GL_TRIANGLES, mesh->GetTrianglesCount(j)*3, GL_UNSIGNED_INT, pIndexes);*/ ! glBegin (GL_TRIANGLES); for (unsigned int i=0; i<mesh->GetTrianglesCount(j)*3; i++) { --- 1119,1128 ---- if (mesh->GetMaterial(j) && mesh->GetMaterial(j)->HasPrimary()) glBindTexture (GL_TEXTURE_2D, mesh->GetMaterial(j)->GetFirstTexture()->iId); ! glVertexPointer(3, GL_FLOAT, sizeof(Vertice) , &pVerts[0].vPosition); glTexCoordPointer(2, GL_FLOAT, sizeof(Vertice), &pVerts[0].s); glEnableClientState(GL_VERTEX_ARRAY); ! glDrawElements(GL_TRIANGLES, mesh->GetTrianglesCount(j)*3, GL_UNSIGNED_INT, pIndexes); ! /*glBegin (GL_TRIANGLES); for (unsigned int i=0; i<mesh->GetTrianglesCount(j)*3; i++) { *************** *** 1110,1114 **** //std::cout << "\t" << pIndexes[i] << std::endl; } ! glEnd (); --- 1132,1136 ---- //std::cout << "\t" << pIndexes[i] << std::endl; } ! glEnd ();*/ Index: camera.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/camera.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** camera.cc 21 Oct 2004 21:18:28 -0000 1.3 --- camera.cc 24 Oct 2004 13:36:59 -0000 1.4 *************** *** 9,15 **** fSpeed = s; fSensivity = sen; ! fYaw = fY; ! fPitch = fP; ! fRoll = fR; iForward = 0; iStrafe = 0; --- 9,15 ---- fSpeed = s; fSensivity = sen; ! vRot.y = fY; ! vRot.z = fP; ! vRot.x = fR; iForward = 0; iStrafe = 0; *************** *** 25,29 **** void Camera::Update (float time) { ! if (Engine::pConsole->GetState()) //si la console est ouverte, on desactive la souris) return; --- 25,29 ---- void Camera::Update (float time) { ! if (Engine::pConsole->GetState()) //si la console est ouverte, on desactive la souris return; *************** *** 35,40 **** //On se fout du temps pour ce qui est des mouvements de souris... ! fYaw += ((float)mX-middleX)*fSensivity/**time*/*6; ! fPitch += ((float)mY-middleY)*fSensivity/*time*/*6; SDL_WarpMouse (middleX, middleY); --- 35,40 ---- //On se fout du temps pour ce qui est des mouvements de souris... ! vRot.y += ((float)mX-middleX)*fSensivity/**time*/*6; ! vRot.x += ((float)mY-middleY)*fSensivity/*time*/*6; SDL_WarpMouse (middleX, middleY); *************** *** 94,103 **** }*/ ! _AngleToVectors (); } /** * Tire de la methode du meme nom de Quake II */ ! void Camera::_AngleToVectors() { --- 94,104 ---- }*/ ! vRot.ToAngleVectors(vForward, vRight, vUp); ! //_AngleToVectors (); } /** * Tire de la methode du meme nom de Quake II */ ! /*void Camera::_AngleToVectors() { *************** *** 128,153 **** vUp.y = 1; vUp.z = 0; ! /* ! ! ! vForward.x = cos_p*cos_y; ! vForward.y = -1*sin_p; ! vForward.z = -1*cos_p*sin_y; ! ! vRight.x = -1*sin_r*sin_p*cos_y+-1*cos_r*-sin_y; ! vRight.y = -1*sin_r*cos_p; ! vRight.z = sin_r*sin_p*sin_y+cos_r*cos_y; ! ! vUp.x = cos_r*sin_p*cos_y-sin_r*-sin_y; ! vUp.y = cos_r*cos_p; ! vUp.z = -cos_r*sin_p*sin_y+sin_r*cos_y; ! */ ! } void Camera::Look () { glMatrixMode (GL_MODELVIEW); ! glRotatef(fPitch, 1.0f, 0.0f, 0.0f); ! glRotatef(fYaw, 0.0f, 1.0f, 0.0f); glTranslatef(-vPosition.x, -vPosition.y, -vPosition.z); frustum.Update(); --- 129,139 ---- vUp.y = 1; vUp.z = 0; ! }*/ void Camera::Look () { glMatrixMode (GL_MODELVIEW); ! glRotatef(vRot.x, 1.0f, 0.0f, 0.0f); ! glRotatef(vRot.y, 0.0f, 1.0f, 0.0f); glTranslatef(-vPosition.x, -vPosition.y, -vPosition.z); frustum.Update(); Index: vector3.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/vector3.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** vector3.h 10 Oct 2004 20:49:09 -0000 1.2 --- vector3.h 24 Oct 2004 13:36:59 -0000 1.3 *************** *** 17,21 **** ~Vector3 () {}; ! void Cross(const Vector3 &v1, const Vector3 &v2); float Magnitude() const; --- 17,22 ---- ~Vector3 () {}; ! void ToAngleVectors (Vector3&, Vector3&, Vector3&); ! void Cross(const Vector3 &v1, const Vector3 &v2); float Magnitude() const; Index: scenenode.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/scenenode.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** scenenode.h 21 Oct 2004 21:18:28 -0000 1.4 --- scenenode.h 24 Oct 2004 13:36:59 -0000 1.5 *************** *** 35,40 **** /* Rotation */ ! Vector3 GetEuler () { return vEuler; } ! virtual void SetEuler (const Vector3& v) { vEuler = v; } inline float GetXRot () { return vEuler.x; } inline float GetYRot () { return vEuler.y; } --- 35,40 ---- /* Rotation */ ! Vector3 GetRotation () { return vEuler; } ! virtual void SetRotation (const Vector3& v) { vEuler = v; } inline float GetXRot () { return vEuler.x; } inline float GetYRot () { return vEuler.y; } Index: vector3.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/vector3.cc,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** vector3.cc 26 Sep 2004 13:15:17 -0000 1.1.1.1 --- vector3.cc 24 Oct 2004 13:36:59 -0000 1.2 *************** *** 5,8 **** --- 5,51 ---- { + void Vector3::ToAngleVectors(Vector3& forward, Vector3& right, Vector3& up) + { + float angle; + float sr, sp, sy, cr, cp, cy; + /* + * Ces formules sont prises de Quake II (q_shared.c:AngleVectors) + * Il faut savoir que par rapport a q2, les axes de tg sont pas les memes : + * y = z; + * z = -y; + */ + //Ca devrait etre y, mais pour utiliser les formules de q2, on inverse + angle = z*DEGTORAD; + sy = sinf(angle); + cy = cosf(angle); + //ca devrait etre z, mais pour utiliser les formules de q2, on echange + angle = y*DEGTORAD; + sp = sinf(angle); + cp = cosf(angle); + angle = x*DEGTORAD; + sr = sinf(angle); + cr = cosf(angle); + + forward.x = cp*cy; + forward.y = cp*sy; + forward.z = -sp; + + right.x = cr*sp*cy+-sr*-sy; + right.y = cr*sp*sy+-sr*cy; + right.z = cr*cp; + + up.x = sr*sp*cy+cr*-sy; + up.y = sr*sp*sy+cr*cy; + up.z = sr*cp; + + /*Vector3 tmp = up; + up = -right; + right = tmp;*/ + + /*forward.Set(cp*cy, cp*sy, -sp); + up.Set(cr*sp*cy+-sr*-sy,cr*sp*sy+-sr*cy, cr*cp); + right.Set(-1*sr*sp*cy+-1*cr*-sy,-1*sr*sp*sy+-1*cr*cy,-1*sr*cp);*/ + } + void Vector3::Cross(const Vector3 &v1, const Vector3 &v2) { Index: glrenderernv15.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/glrenderernv15.cc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** glrenderernv15.cc 21 Oct 2004 21:18:28 -0000 1.6 --- glrenderernv15.cc 24 Oct 2004 13:36:59 -0000 1.7 *************** *** 55,59 **** //vObjectLightPosition.Set(50*sinf(angle),0, 60*cosf(angle)); ! float transform[16]; glPushMatrix(); glLoadIdentity(); --- 55,59 ---- //vObjectLightPosition.Set(50*sinf(angle),0, 60*cosf(angle)); ! /*float transform[16]; glPushMatrix(); glLoadIdentity(); *************** *** 67,71 **** glPopMatrix(); vObjectLightPosition = Util::MultVectorMatrix44(vLightPos, transform); ! /*glPushMatrix(); glTranslatef(vObjectLightPosition.x, vObjectLightPosition.y, vObjectLightPosition.z); --- 67,71 ---- glPopMatrix(); vObjectLightPosition = Util::MultVectorMatrix44(vLightPos, transform); ! */ /*glPushMatrix(); glTranslatef(vObjectLightPosition.x, vObjectLightPosition.y, vObjectLightPosition.z); |