void cPhysics::Init( ){
	///collision configuration contains default setup for memory, collision setup. Advanced users can create their own configuration.
	mpCollisionConfiguration = new btDefaultCollisionConfiguration();

	///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
	mpDispatcher = new btCollisionDispatcher(mpCollisionConfiguration);

	///btDbvtBroadphase is a good general purpose broadphase. You can also try out btAxis3Sweep.
	mpOverlappingPairCache = new btDbvtBroadphase();

	///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded)
	mpSolver = new btSequentialImpulseConstraintSolver;
	mpWorld = new btDiscreteDynamicsWorld(mpDispatcher, mpOverlappingPairCache, mpSolver, mpCollisionConfiguration);
	mpWorld->setGravity(btVector3(0,-10,0));

	///create a few basic rigid bodies
	btCollisionShape* lpGroundShape = new btBoxShape(btVector3(btScalar(10.),btScalar(10.),btScalar(10.)));
	mapCollisionShapes.push_back(lpGroundShape);
	GetNewBody( lpGroundShape, 0.0f, cVec3( 0.0f, -10.0f, 0.0f ));
	GetNewBody( lpGroundShape, 0.0f, cVec3( -20.0f, 0.0f, 0.0f ));
	GetNewBody( lpGroundShape, 0.0f, cVec3( 20.0f, 0.0f, 0.0f ));
	GetNewBody( lpGroundShape, 0.0f, cVec3( 0.0f, 0.0f, -20.0f ));
	GetNewBody( lpGroundShape, 0.0f, cVec3( 0.0f, 0.0f, 20.0f ));

	// Draws debug info of bullet
	cPhysicsDebugDraw::Get( ).setDebugMode( cPhysicsDebugDraw::DBG_DrawWireframe );
	mpWorld->setDebugDrawer( &cPhysicsDebugDraw::Get( ) );
}
void Vehicle::ResetVehicleParams(){
	gVehicleSteering = 0.f;
	m_carChassis->setCenterOfMassTransform(btTransform::getIdentity());
	m_carChassis->setLinearVelocity(btVector3(0, 0, 0));
	m_carChassis->setAngularVelocity(btVector3(0, 0, 0));

	// Posicion inicial
	cMatrix lTransMatrix, lRotMatrix, lTransform;
	lTransMatrix.LoadTranslation(cVec3(0.f, 0.f, 0.f));
	lRotMatrix.LoadIdentity();

	lRotMatrix.LoadRotation(cVec3(0.f, 1.f, 0.f), PI);
	lTransform = lRotMatrix * lTransMatrix;
	m_carChassis->setWorldTransform(cPhysics::Get().Local2Bullet(lTransform));

	cPhysics::Get().GetBulletWorld()->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(m_carChassis->getBroadphaseHandle(), cPhysics::Get().GetBulletWorld()->getDispatcher());
	if (m_vehicle)
	{
		m_vehicle->resetSuspension();
		for (int i=0;i<m_vehicle->getNumWheels();i++)
		{
			//synchronize the wheels with the (interpolated) chassis worldtransform
			m_vehicle->updateWheelTransform(i,true);
		}
	}
}
void cGame::RenderTitleLoad ( float progress ) 
{

	// Titulo MAD DRIVE

	cMatrix lmTranslation;
	lmTranslation.LoadTranslation(cVec3(0.f, 220.f, 0.f));

	cGraphicManager::Get().SetWorldMatrix(lmTranslation);
	
	cTexture* lpTexture;
	if (progress == 1.f)
		lpTexture = (cTexture*) mMad_drive.GetResource();
	else
		lpTexture = (cTexture*) mMad_drive_loading.GetResource();
	glBindTexture(GL_TEXTURE_2D, lpTexture->GetTextureHandle());
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);					// scale linearly when image bigger than texture
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);	// scale linearly when image smalled than texture
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

	glBegin(GL_QUADS);

		 glTexCoord2f(0.0f, 1.0f); glVertex3f(-90, -50, 0);
		 glTexCoord2f(1.0f, 1.0f); glVertex3f(90, -50, 0);
		 glTexCoord2f(1.0f, 0.0f); glVertex3f(90, 50, 0);
		 glTexCoord2f(0.0f, 0.0f); glVertex3f(-90, 50, 0);

	glEnd();

	cGraphicManager::Get().SetWorldMatrix(lmTranslation.LoadIdentity());

	// LOADING

	lmTranslation.LoadTranslation(cVec3(0.f, 70.f, 0.f));

	cGraphicManager::Get().SetWorldMatrix(lmTranslation);
	
	lpTexture = (cTexture*) mLoading.GetResource();
	glBindTexture(GL_TEXTURE_2D, lpTexture->GetTextureHandle());
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);					// scale linearly when image bigger than texture
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);	// scale linearly when image smalled than texture
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

	glBegin(GL_QUADS);

		 glTexCoord2f(0.0f, 1.0f); glVertex3f(-90, -50, 0);
		 glTexCoord2f(1.0f, 1.0f); glVertex3f(90, -50, 0);
		 glTexCoord2f(1.0f, 0.0f); glVertex3f(90, 50, 0);
		 glTexCoord2f(0.0f, 0.0f); glVertex3f(-90, 50, 0);

	glEnd();

	cGraphicManager::Get().SetWorldMatrix(lmTranslation.LoadIdentity());

}
void cGame::RenderProgressBar ( float progress ) 
{

	cMatrix lmTranslation;
	lmTranslation.LoadTranslation(cVec3(-300.f, 10.f, 0.f));

	cGraphicManager::Get().SetWorldMatrix(lmTranslation);
	
	glDisable(GL_TEXTURE_2D);
		cGraphicManager::Get().DrawRect(0.f, 0.f, 600.f * progress, 2.f, cVec3(progress, 0.f, 0.f));
		//cGraphicManager::Get().DrawRect(0.f, 0.f, 200.f, 2.f, cVec3(1.f, 0.f, 0.f)); 
	glEnable(GL_TEXTURE_2D);

	cGraphicManager::Get().SetWorldMatrix(lmTranslation.LoadIdentity());

}
Пример #5
0
void cSkeletalMesh::RenderSkeleton(void)
{
	cMatrix lWorld;				// REALLY WEIRD MATRIX SET UP
	lWorld.LoadIdentity();

	lWorld.LoadScale(0.01f);	// SCALING BECAUSE ORIGINAL MODEL IT´S TOO BIG ( IN OTHER CASE: JUST QUIT IT )
	cGraphicManager::Get().SetWorldMatrix(lWorld);


	unsigned luiBoneCount = mpCal3DModel->getSkeleton()->getCoreSkeleton()->getVectorCoreBone().size();
	assert(luiBoneCount < 120);

	float mafLines[120] [6];
	int liBones = mpCal3DModel->getSkeleton()->getBoneLines(&mafLines[0][0]);
	for (int liIndex = 0; liIndex < liBones; ++liIndex)
	{
		cVec3 lvP1( mafLines[liIndex][0],
					mafLines[liIndex][1],
					mafLines[liIndex][2] );

		cVec3 lvP2( mafLines[liIndex][3],
					mafLines[liIndex][4],
					mafLines[liIndex][5] );

		cGraphicManager::Get().DrawLine( lvP1, lvP2, cVec3(1.0f, 1.0f, 1.0f) );
	}
	lWorld.LoadIdentity();
	cGraphicManager::Get().SetWorldMatrix(lWorld);
}
Пример #6
0
    cVec3 cQuaternion::GetEuler() const
    {
      const float sqw = w * w;
      const float sqx = x * x;
      const float sqy = y * y;
      const float sqz = z * z;
      const float unit = sqx + sqy + sqz + sqw; // if normalised is one, otherwise is correction factor
      const float test = (x * y) + (z * w);

      float heading = 0.0f;
      float attitude = 0.0f;
      float bank = 0.0f;

      if (test > 0.499f * unit) { // singularity at north pole
        heading = 2.0f * atan2(x, w);
        attitude = math::cPI / 2.0f;
        bank = 0.0f;
      } else if (test < -0.499f * unit) { // singularity at south pole
        heading = -2.0f * atan2(x, w);
        attitude = -math::cPI / 2.0f;
        bank = 0.0f;
      } else {
        assert(unit != 0.0f);
        heading = atan2(2.0f * y * w - 2.0f * x * z, sqx - sqy - sqz + sqw);
        attitude = asin(2.0f * test / unit);
        bank = atan2(2.0f * x * w - 2.0f * y * z, -sqx + sqy - sqz + sqw);
      }

      return cVec3(bank, heading, attitude);
    }
//Alters p to be a particle newly produced by the fountain.
void Explosion::CreateParticle(Particle* p) {
	float a = -60.0f;
	float b = 60.0f;
	float deviation_x = ((b - a) * ((float)rand() / RAND_MAX)) + a;
	float x = deviation_x * 0.01; // + mvParticleSysPos.x;
	float y = rand() % 1 * 0.01;
	float z = rand() % 1 * 0.01;
	p->pos = cVec3(x, 1, 1); 
	p->velocity = CurVelocity() + cVec3(0.5f * randomFloat() - 0.25f,
										0.5f * randomFloat() - 0.25f,
										0.5f * randomFloat() - 0.25f);

	p->color = cVec3(0.329412,0.329412,0.329412); 
	p->timeAlive = 0;
	p->lifespan = randomFloat() + 0.85f; 
}
//Advances the particle fountain by STEP_TIME seconds.
void Explosion::StepParticles() {
	
	for (int i = 0; i < NUM_PARTICLES; i++) {
		Particle* p = particles + i;
		
		p->pos += p->velocity * STEP_TIME;
		p->velocity += cVec3(0.0f, GRAVITY * STEP_TIME, 0.0f);
		p->timeAlive += STEP_TIME;

		if (p->timeAlive >= p->lifespan / 4)
			p->color = cVec3(0.329412,0.329412,0.329412); 
			//p->color = cVec3(0.9,0.9,1.0);
		if (p->timeAlive > p->lifespan) {
			CreateParticle(p);
		}
	}
}
Пример #9
0
    cVec3 cVec3::operator*(const float rhs) const
    {
      float newX = x * rhs;
      float newY = y * rhs;
      float newZ = z * rhs;

      return cVec3(newX, newY, newZ);
    }
Пример #10
0
 cVec3 cVec3::GetRotatedZ(double angle) const
 {
   return cVec3(
     x * cosf((float)angle) - y * sinf((float)angle),
     x * sinf((float)angle) + y * cosf((float)angle),
     z
   );
 }
Пример #11
0
 cVec3 cVec3::GetRotatedY(double angle) const
 {
   return cVec3(
     x * cosf((float)angle) + z * sinf((float)angle),
     y,
     -x * sinf((float)angle) + z * cosf((float)angle)
   );
 }
Пример #12
0
 cVec3 cVec3::GetRotatedX(double angle) const
 {
   return cVec3(
     x,
     y * cosf((float)angle) - z * sinf((float)angle),
     y * sinf((float)angle) + z * cosf((float)angle)
   );
 }
Пример #13
0
    cVec3 cVec3::GetPackedTo01() const
    {
      cVec3 temp(*this);

      temp.Normalise();

      temp = temp * 0.5f + cVec3(0.5f, 0.5f, 0.5f);

      return temp;
    }
Пример #14
0
bool cGame::Load2DCameraProperties( void ) {

	//Init Camera 2D, para las cadenas de texto.
	//Se inicializa la cámara 2D con una perspectiva ortogonal.
	//El (0,0) está situado en el centro de la pantalla y las dimensiones están 
	// establecidas en píxeles.
	float lfRight = (float)mProperties.muiWidth / 2.0f;
	float lfLeft = -lfRight;
	float lfTop = (float)mProperties.muiHeight / 2.0f;
	float lfBottom = -lfTop;
	m2DCamera.Init();
	m2DCamera.SetOrtho(lfLeft, lfRight, lfBottom, lfTop, 0.1f, 100.0f);
	//Se pone la cámara2D en la posición (0,0) de nuestro mundo,
	// apuntando al origen del mismo, e indicando que el vector UP de la cámara apunta hacia arriba.
	m2DCamera.SetLookAt( cVec3(0.0f, 0.0f, 1.f), cVec3(0.0f, 0.f, 0.f), cVec3(0.0f, 1.f, 0.f) );

	return true;

}
Пример #15
0
void Ruin::Init(cObject* ruin, cMatrix position){
	mRuinObj = ruin;
	mRuinPosition = position;
	// Redimensionamiento de los modelos 3d
	mScaleMatrix.LoadScale(.3f);

	mBoundingBox.InitBox( 0.0f, cVec3(5.f, 2.8f, 1.5f) );
	mBBoxObject.SetWorldMatrix( position );
	mBBoxObject.SetScaleMatrix( mScaleMatrix );
	mBBoxObject.CreatePhysics( &mBoundingBox );
}
/// one-time class and physics initialization
void Terrain::initialize(void)
{
//	std::cerr << "initializing...\n";

	/* This code is inside cPhysics class */

	// set up basic state
/*	m_upAxis = 1;		// start with Y-axis as "up"
	m_type = PHY_FLOAT;
	m_model = eRadial;//eFractal;
	m_isDynamic = true;

	// set up the physics world
	m_collisionConfiguration = new btDefaultCollisionConfiguration();
	m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
	btVector3 worldMin(-1000,-1000,-1000);
	btVector3 worldMax(1000,1000,1000);
	m_overlappingPairCache = new btAxisSweep3(worldMin,worldMax);
	m_constraintSolver = new btSequentialImpulseConstraintSolver();
	m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_constraintSolver,m_collisionConfiguration);

	// initialize axis- or type-dependent physics from here
	this->resetPhysics();	*/

	clearWorld();

	// get new heightfield of appropriate type
	m_rawHeightfieldData = getRawHeightfieldData(eRadial, PHY_FLOAT, m_minHeight, m_maxHeight);

	bool flipQuadEdges = false;													// width, height, *heightmapData, scale, minHeight, maxHeight, upAxis, heightMapDatatype, flipQuadEdges 
	btHeightfieldTerrainShape * heightfieldShape = new btHeightfieldTerrainShape(s_gridSize, s_gridSize, m_rawHeightfieldData, s_gridHeightScale, m_minHeight, m_maxHeight, m_upAxis, PHY_FLOAT, flipQuadEdges);
	assert(heightfieldShape);

	// scale the shape
	btVector3 localScaling = getUpVector(m_upAxis, s_gridSpacing, 1.0);
	heightfieldShape->setLocalScaling(localScaling);

	// stash this shape away
	cPhysics::Get().getCollisionShapes().push_back(heightfieldShape);
	//m_collisionShapes.push_back(heightfieldShape);

	// set origin to middle of heightfield
	btTransform tr;
	tr.setIdentity();
	tr.setOrigin(btVector3(0,-20,0));

	// create ground object
	float mass = 0.0;
	//localCreateRigidBody(mass, tr, heightfieldShape);

   //We can also use DemoApplication::localCreateRigidBody, but for clarity it is provided here:
   
	btRigidBody* body = cPhysics::Get().GetNewBody(heightfieldShape, mass, cVec3(0, -20, 0));
}
Пример #17
0
bool cGame::Load3DCameraProperties( void ) {

	// Init Camera 3D
	m3DCamera.Init();  
	// Inicializa camara godmode
	mGodCamera.Init();
	float lfAspect = (float)mProperties.muiWidth/(float)mProperties.muiHeight;
	m3DCamera.SetPerspective(45.0f, lfAspect,0.1f, 5000.0f);
	mGodCamera.SetPerspective( 45.0f, lfAspect, 0.1f, 10000.0f );

	//Se aleja la cámara para ver bien la escena que vamos a cargar posteriormente.
	m3DCamera.SetLookAt( cVec3(0.f, 1.5f, 20.f), cVec3(0.f, 1.5f, 0.f), cVec3(0.0f, 1.f, 0.f) );

	// Resetea color de fondo
	glClearColor(1.0f, 0.9f, 0.7f, 1.0f);
	// Ocultar geometria no mostrada
	glEnable(GL_CULL_FACE);

	return true;

}
Пример #18
0
    cVec3 cQuaternion::GetRotatedVector(const cVec3& value) const
    {
      cQuaternion qtemp;

      qtemp.x = value.x;
      qtemp.y = value.y;
      qtemp.z = value.z;
      qtemp.w = 0;

      const cQuaternion qout = (*this) * qtemp * GetConjugate();

      return cVec3(qout.x, qout.y, qout.z);
    }
//Inicializa los atributos
void cChaserSnapOrientation::Init(cCharacter * lpCharacter){
		mpCharacter = lpCharacter;
		mTarget = cVec3(0.0f, 0.0f, 0.0f);		
}
cVec3 cPhysics::Bullet2Local( const btVector3& lFrom ){
	return cVec3( lFrom.x(), lFrom.y(), lFrom.z() );
}
Пример #21
0
 cVec3 cQuaternion::GetAxis() const
 {
   const float fScale = 1.0f / sqrt((x * x) + (y * y) + (z * z));
   return cVec3(fScale * x, fScale * y, fScale * z);
 }
Пример #22
0
void cAABox::setMax(float x, float y, float z){
	Max = cVec3(x,y,z);
}
Пример #23
0
void cAABox::setMin(float x, float y, float z){
	Min = cVec3(x,y,z);
}
//Función para inicializar el juego.
bool cGame::Init()
{	
	mbFinish = false;
	//	LoadResources();
	//Se rellena la estructura de tipo cApplicationProperties: 
	mProperties.macApplicationName = "Práctica 4: Carga Básica de Escena y Malla";
	mProperties.mbFullscreen = false;
	mProperties.muiBits = 16;
	mProperties.muiWidth = 640;
	mProperties.muiHeight = 480;	
	
	//Se inicializa el objeto ventana con la propiedades establecidas:
    bool lbResult = cWindow::Get().Init( mProperties );
		
	if ( lbResult )
	{
		//Se inicializa la clase que encapsula las operaciones de OpenGL:
		lbResult = cGraphicManager::Get().Init( &cWindow::Get() );   
		if (lbResult)
		{
			// Init Camera 3D
			m3DCamera.Init();  
			float lfAspect = (float)mProperties.muiWidth/(float)mProperties.muiHeight;
			m3DCamera.SetPerspective(45.0f, lfAspect,0.1f,100.0f);
			//Se pone la cámara en la posición (5,5,5) de nuestro mundo,
			// apuntando al origen del mismo, e indicando que el vector UP de la cámara apunta hacia arriba.
			//m3DCamera.SetLookAt( cVec3(5.0f, 5.f, 5.f), cVec3(0.0f, 0.f, 0.f), cVec3(0.0f, 1.f, 0.f) );		

			//Se aleja la cámara para ver bien la escena que vamos a cargar posteriormente.
			m3DCamera.SetLookAt( cVec3(20.0f, 15.f, 15.f),cVec3(0.0f, 0.f, 0.f), cVec3(0.0f, 1.f, 0.f) );

			//Se inicializa la clase cInputManager que representa el gestor de entrada (keyboard, gamepad, mouse, ...).
			//Se le pasa la tabla "kaActionMapping" (de InputConfiguration.cpp) que indica la relación entre las acciones y los dispositivos.
			//También se pasa "eIA_Count" (de InputConfiguration.h) que indica cuantas acciones de entrada hay.
			cInputManager::Get().Init( kaActionMapping, eIA_Count );

			//Se inicializa la clase que gestiona la texturas indicando que habrá 1, por ejemplo.
			cTextureManager::Get().Init(10);

			//Se inicializa la clase que gestiona los materiales.
			cMaterialManager::Get().Init(10);

			//Init Camera 2D, para las cadenas de texto.
			//Se inicializa la cámara 2D con una perspectiva ortogonal.
			//El (0,0) está situado en el centro de la pantalla y las dimensiones están 
			// establecidas en píxeles.
			float lfRight = (float)mProperties.muiWidth / 2.0f;
			float lfLeft = -lfRight;
			float lfTop = (float)mProperties.muiHeight / 2.0f;
			float lfBottom = -lfTop;
			m2DCamera.Init();
			m2DCamera.SetOrtho(lfLeft, lfRight, lfBottom, lfTop, 0.1f, 100.0f);
			//Se pone la cámara2D en la posición (0,0) de nuestro mundo,
			// apuntando al origen del mismo, e indicando que el vector UP de la cámara apunta hacia arriba.
			m2DCamera.SetLookAt( cVec3(0.0f, 0.0f, 1.f), cVec3(0.0f, 0.f, 0.f), cVec3(0.0f, 1.f, 0.f) );

			// Init the Font.
			mFont.Init("./Data/Fonts/Test1.fnt");

			//Se inicializa el gestor de mallas: habrá 4 mallas en la escena (mirar ./Data/Scene/).
			cMeshManager::Get().Init(4);

			//Se inicializa el gestor de escenas.
			cSceneManager::Get().Init(10);         

			//Se carga la escena.
			mScene = cSceneManager::Get().LoadResource( "TestLevel", "./Data/Scene/dragonsmall.DAE" ); 			
		}		
		else
		{
			//Si algo falla se libera la ventana.
			cWindow::Get().Deinit();
		}
	}
    return lbResult;	
}
//Función para renderizar el juego:
void cGame::Render()
{
	/* Orden de las instrucciones
	•    Limpiado de Buffers
	•    Activación de Cámara 3D
	•    Renderizado de Geometría 3D sólida
	•    Renderizado de Geometría 3D con transparencia
	•    Activación de Cámara 2D
	•    Renderizado de Cámara 2D
	•    Effectos de postprocesado
	•    Intercambio de los bufferes
	*/

	// 1) Limpiado de Buffers
	// -------------------------------------------------------------
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);        
	 
	// 2) Activación de Cámara 3D
	// -------------------------------------------------------------
	cGraphicManager::Get().ActivateCamera( &m3DCamera );
	 
	// 3) Renderizado de Geometría 3D sólida
	// -------------------------------------------------------------
	// Set the world matrix
	cMatrix lWorld;
	lWorld.LoadIdentity();
	cGraphicManager::Get().SetWorldMatrix(lWorld);
	// Render the debug lines
	cGraphicManager::Get().DrawGrid();
	cGraphicManager::Get().DrawAxis();
	 
	cGraphicManager::Get().DrawPoint( cVec3(1.5f, 0.0f, 1.5f), 
	cVec3(1.0f, 0.0f, 1.0f) );
	cGraphicManager::Get().DrawLine( cVec3(-1.5f, 0.0f, -1.5f), cVec3(-1.5f, 0.0f, 1.5f), cVec3(1.0f, 1.0f, 0.0f) );

	//Desactivamos la textura porque aún no tenemos materiales asignados a las mallas de la escena.
//	glDisable(GL_TEXTURE_2D);
	//Para renderizar la escena llamaremos al render de la escena a través de mScene (manejador de la escena, de tipo cResourceHandle).
	((cScene *)mScene.GetResource())->Render();
//	glEnable(GL_TEXTURE_2D);
	 
	// 4) Renderizado de Geometría 3D con transparencia
	// -------------------------------------------------------------
	 
	// 5) Activación de Cámara 2D  
	// -------------------------------------------------------------
	cGraphicManager::Get().ActivateCamera( &m2DCamera );
	 
	// 6) Renderizado de Cámara 2D
	// -------------------------------------------------------------
	//Se dibujan algunas cadenas de texto.
	mFont.SetColour( 1.0f, 0.0f, 0.0f );
	mFont.Write(0,200,0, "Año Totó pingüino() ¡!¿?", 0, FONT_ALIGN_CENTER);
	 
	mFont.SetColour( 0.0f, 1.0f, 1.0f );
	mFont.WriteBox(100,100,0,100, "Esto es un test \nmultilinea", 0, FONT_ALIGN_CENTER);	


	 
	// 7) Efectos de postprocesado
	// -------------------------------------------------------------
	 
	// 8) Intercambio de los bufferes
	// -------------------------------------------------------------
	cGraphicManager::Get().SwapBuffer();
}
//Función para inicializar el juego.
bool cGame::Init()
{	
	mbFinish = false;
	//	LoadResources();
	//Se rellena la estructura de tipo cApplicationProperties: 
	mProperties.macApplicationName = "Práctica 2: Animación esqueletal";
	mProperties.mbFullscreen = false;
	mProperties.muiBits = 16;
	mProperties.muiWidth = 640;
	mProperties.muiHeight = 480;	
	
	//Se inicializa el objeto ventana con la propiedades establecidas:
    bool lbResult = cWindow::Get().Init( mProperties );
		
	if ( lbResult )
	{
		//Se inicializa la clase que encapsula las operaciones de OpenGL:
		lbResult = cGraphicManager::Get().Init( &cWindow::Get() );   
		if (lbResult)
		{
			// Init Camera 3D
			m3DCamera.Init();  
			float lfAspect = (float)mProperties.muiWidth/(float)mProperties.muiHeight;
			m3DCamera.SetPerspective(45.0f, lfAspect,0.1f,100.0f);
			//Se pone la cámara en la posición (5,5,5) de nuestro mundo,
			// apuntando al origen del mismo, e indicando que el vector UP de la cámara apunta hacia arriba.
			//m3DCamera.SetLookAt( cVec3(5.0f, 5.f, 5.f), cVec3(0.0f, 0.f, 0.f), cVec3(0.0f, 1.f, 0.f) );		

			//Se aleja la cámara para ver bien la escena que vamos a cargar posteriormente.
			m3DCamera.SetLookAt( cVec3(5.f, 5.f, 5.f),cVec3(0.0f, 0.f, 0.f), cVec3(0.0f, 1.f, 0.f) );

			//Se inicializa la clase cInputManager que representa el gestor de entrada (keyboard, gamepad, mouse, ...).
			//Se le pasa la tabla "kaActionMapping" (de InputConfiguration.cpp) que indica la relación entre las acciones y los dispositivos.
			//También se pasa "eIA_Count" (de InputConfiguration.h) que indica cuantas acciones de entrada hay.
			cInputManager::Get().Init( kaActionMapping, eIA_Count );

			//Se inicializa la clase que gestiona la texturas indicando que habrá 1, por ejemplo.
			cTextureManager::Get().Init(10);

			//Se inicializa la clase que gestiona los materiales.
			cMaterialManager::Get().Init(10);

			// Init of effects management
			cEffectManager::Get().Init(10);

			//Init Camera 2D, para las cadenas de texto.
			//Se inicializa la cámara 2D con una perspectiva ortogonal.
			//El (0,0) está situado en el centro de la pantalla y las dimensiones están 
			// establecidas en píxeles.
			float lfRight = (float)mProperties.muiWidth / 2.0f;
			float lfLeft = -lfRight;
			float lfTop = (float)mProperties.muiHeight / 2.0f;
			float lfBottom = -lfTop;
			m2DCamera.Init();
			m2DCamera.SetOrtho(lfLeft, lfRight, lfBottom, lfTop, 0.1f, 100.0f);
			//Se pone la cámara2D en la posición (0,0) de nuestro mundo,
			// apuntando al origen del mismo, e indicando que el vector UP de la cámara apunta hacia arriba.
			m2DCamera.SetLookAt( cVec3(0.0f, 0.0f, 1.f), cVec3(0.0f, 0.f, 0.f), cVec3(0.0f, 1.f, 0.f) );

			// Init the Font.
			mFont.Init("./Data/Fonts/Test1.fnt");

			//Se inicializa el gestor de mallas: habrá 4 mallas en la escena (mirar ./Data/Scene/) + Skeletal mesh.
			cMeshManager::Get().Init(5);

			//Se inicializa el gestor de escenas.
			cSceneManager::Get().Init(10);         

			//Se carga la escena.
			mScene = cSceneManager::Get().LoadResource( "TestLevel", "./Data/Scene/dragonsmall.DAE" ); 		

			cSkeletalManager::Get().Init(5);
			// Inits skeleton model
			cSkeletalManager::Get().LoadResource("Skeleton", "./Data/Skeletal/SkeletonModel.xml");
		
			// Loads skeleton 
			mSkeletalMesh = cMeshManager::Get().LoadResource("Skeleton1", "Skeleton", kuiSkeletalMesh);

			// Get skeleton mesh
			cSkeletalMesh* lpSkeletonMesh=(cSkeletalMesh*)mSkeletalMesh.GetResource();

			// Play idle animation 
			lpSkeletonMesh->PlayAnim("Idle", 1.0f, 1.0f);
			
			// Load Skeleton meshes
			cResourceHandle lMaterial = cMaterialManager::Get().LoadResource("Skeleton", "./Data/Material/SkeletonMaterial.xml");
			
			
			
			assert(lMaterial.IsValidHandle());
			mObject.AddMesh(mSkeletalMesh, lMaterial);
			cMatrix lMatrix;
			lMatrix.LoadScale(0.01f);
			mObject.SetWorldMatrix(lMatrix);
		}		
		else
		{
			//Si algo falla se libera la ventana.
			cWindow::Get().Deinit();
		}
	}

	// Application start time
	mfAcTime = 0.0f;

    return lbResult;	
}
void Vehicle::initPhysics(string lsType){

	float mass, connectionHeight;

	if (lsType.compare("Mustang") == 0) {
		m_chassisShape = new btBoxShape(btVector3(1.f, 0.5f, 2.f));
		mass = 800.f;
		connectionHeight = 1.2f;
	}
	else if (lsType.compare("Truck") == 0) {
		m_chassisShape = new btBoxShape(btVector3(1.5f, 1.2f, 2.7f));
		mass = 1200.f;
		connectionHeight = .85f;
		wheelRadius =  0.54f;	//** 0.5f;
		wheelWidth = 0.4f;		//* 0.4f;
		steeringClamp = 0.1f;
		maxEngineForce = 98000.f;
	}

	// stash this shape away
	cPhysics::Get().getCollisionShapes().push_back(m_chassisShape);

	m_compound = new btCompoundShape();
	cPhysics::Get().getCollisionShapes().push_back(m_compound);
	btTransform localTrans;
	localTrans.setIdentity();
	//localTrans effectively shifts the center of mass with respect to the chassis
	localTrans.setOrigin(btVector3(0,1.4,0));		//** localTrans.setOrigin(btVector3(0,1,0));

	m_compound->addChildShape(localTrans,m_chassisShape);
	
	m_carChassis = cPhysics::Get().GetNewBody(m_compound, mass, cVec3(0.f, 0.f, 0.f), 329.9f); //chassisShape

	//m_carChassis->setDamping(0.2,0.2);
	
	m_wheelShape = new btCylinderShapeX(btVector3(wheelWidth, wheelRadius, wheelRadius));
	
	ResetVehicleParams();

	/// create vehicle
	{
		
		m_vehicleRayCaster = new btDefaultVehicleRaycaster(cPhysics::Get().GetBulletWorld());
		m_vehicle = new btRaycastVehicle(m_tuning, m_carChassis, m_vehicleRayCaster);
		
		///never deactivate the vehicle
		m_carChassis->setActivationState(DISABLE_DEACTIVATION);

		cPhysics::Get().GetBulletWorld()->addVehicle(m_vehicle);		//** ->addVehicle(m_vehicle);

		bool isFrontWheel=true;

		//choose coordinate system
		m_vehicle->setCoordinateSystem(rightIndex, upIndex, forwardIndex);

		// front left
		btVector3 connectionPointCS0;
		if (lsType.compare("Truck") == 0)
			connectionPointCS0 = btVector3(CUBE_HALF_EXTENTS-(0.3*wheelWidth) + 0.25f,connectionHeight,(2*CUBE_HALF_EXTENTS-wheelRadius) + 0.2f);
		else 
			connectionPointCS0 = btVector3(CUBE_HALF_EXTENTS-(0.3*wheelWidth),connectionHeight,2*CUBE_HALF_EXTENTS-wheelRadius);

		m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,wheelAxleCS,suspensionRestLength,wheelRadius,m_tuning,isFrontWheel);	
			
		// front right
		if (lsType.compare("Truck") == 0)
			connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth) - 0.25f,connectionHeight,(2*CUBE_HALF_EXTENTS-wheelRadius) + 0.2f);
		else			
			connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth),connectionHeight,2*CUBE_HALF_EXTENTS-wheelRadius);

		m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,wheelAxleCS,suspensionRestLength,wheelRadius,m_tuning,isFrontWheel);

		// rear left
		if (lsType.compare("Truck") == 0)
			connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth) - 0.25f,connectionHeight,(-2*CUBE_HALF_EXTENTS+wheelRadius) + 0.18f);
		else
			connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth),connectionHeight,-2*CUBE_HALF_EXTENTS+wheelRadius);


		isFrontWheel = false;
		m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,wheelAxleCS,suspensionRestLength,wheelRadius,m_tuning,isFrontWheel);
		
		// rear right
		if (lsType.compare("Truck") == 0)
			connectionPointCS0 = btVector3(CUBE_HALF_EXTENTS-(0.3*wheelWidth) + 0.25f,connectionHeight,(-2*CUBE_HALF_EXTENTS+wheelRadius) + 0.18f);
		else
			connectionPointCS0 = btVector3(CUBE_HALF_EXTENTS-(0.3*wheelWidth),connectionHeight,-2*CUBE_HALF_EXTENTS+wheelRadius);

		btWheelInfo& wheel_RR = m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,wheelAxleCS,suspensionRestLength,wheelRadius,m_tuning,isFrontWheel);
		
		for (int i=0;i<m_vehicle->getNumWheels();i++){
			btWheelInfo& wheel = m_vehicle->getWheelInfo(i);
			wheel.m_suspensionStiffness = suspensionStiffness;
			wheel.m_wheelsDampingRelaxation = suspensionDamping;
			wheel.m_wheelsDampingCompression = suspensionCompression;
			wheel.m_frictionSlip = wheelFriction;
			wheel.m_rollInfluence = rollInfluence;
		}
	}
}
Пример #28
0
//Función para actualizar el juego.
void cGame::Update( float lfTimestep )
{ 			
	//Se actualiza la ventana:
	cWindow::Get().Update();

	// Updates application duration time
	mfAcTime += lfTimestep;

	//Se actualiza el InputManager.
	cInputManager::Get().Update(lfTimestep);

	// Checks if the effect has to be reloaded
	bool lbreloadEffect = IsPressed(eIA_ReloadEffectManager);
	if (lbreloadEffect) {
		cEffectManager::Get().Reload();
	}

	// Se actualiza niebla
	miFogStep ++;

	if (miFogStep == 1000) {
		if (mbFogIncreasing) {
			if (mfFogDensity >= 0.0005f)
				mbFogIncreasing = false;
			else
				mfFogDensity += 0.00001f;
		} else {
			if (mfFogDensity <= 0.0002f)
				mbFogIncreasing = true;
			else
				mfFogDensity -= 0.00001f;
		}

		miFogStep %= 1000;
	}
	glFogf (GL_FOG_DENSITY, mfFogDensity);

	// Recoge input teclado
	bool lbmoveFront = IsPressed( eIA_MoveFront );
	bool lbmoveBack = IsPressed( eIA_MoveBack );
	bool lbmoveLeft = IsPressed( eIA_MoveLeft );
	bool lbmoveRight = IsPressed( eIA_MoveRight );	
	bool lbswitchCamera = BecomePressed( eIA_SwitchCamera );
	bool lbswitchRasterizationMode = BecomePressed( eIA_SwitchFillLineMode );

	// Switch entre camara de juego/godmode
	if (lbswitchCamera)
		mbInGame = !mbInGame;
	// Switch entre el modo de rasterizacion solido/wireframe
	if (lbswitchRasterizationMode)
		mbRasterizationMode = !mbRasterizationMode;

	// Actualiza el flag de movimiento del personaje
	CharacterPos::Get().ResetChanged();
	// Calcula velocidad * tiempo transcurrido
	CharacterPos::Get().Update(lfTimestep);

	// Rotaciones del ratón
	float lfYaw = GetValue( eIA_MouseYaw );
	float lfPitch = GetValue( eIA_MousePitch );

	bool lbAuxCamera = IsPressed( eIA_SwitchCameraAux );

	// En modo juego, actualiza jugador
	if (mbInGame){
		mGodCamera.ResetYawPitch();
		if ( lbmoveFront && mMustang.IsAlive() ) {
			//CharacterPos::Get().MoveFront();
			//mVehicle.MoveForward(lfTimestep);
			mMustang.MoveForward(lfTimestep);
		}
		else if ( lbmoveBack && mMustang.IsAlive() ){
			//CharacterPos::Get().MoveBack();
			//mVehicle.Break(lfTimestep);
			mMustang.Break(lfTimestep);	
		}
		if ( lbmoveLeft && mMustang.IsAlive() ){
			//CharacterPos::Get().TurnLeft();
			//mVehicle.SteeringLeft(lfTimestep);
			mMustang.SteeringLeft(lfTimestep);
		}
		else if ( lbmoveRight && mMustang.IsAlive() ){
			//CharacterPos::Get().TurnRight();
			//mVehicle.SteeringRight(lfTimestep);
			mMustang.SteeringRight(lfTimestep);
		}

		// Actualizacion de cámara de juego
		// Si se pulsa la tecla de camara auxiliar se cambia la orientacion de la camara
		float lfDistance, lfYOffset;
		cVec3 lvYViewOffset;
		if (lbAuxCamera) {
			lfDistance = -4.f;	
			lfYOffset = 2.8f;
			lvYViewOffset = cVec3(0.f, 3.f, 0.f);
		} else {
			lfDistance = 8.f;
			lfYOffset = 3.3f;
			lvYViewOffset = cVec3(0.f, 0.0f, 0.f);
		}

		//cVec3 vVector = CharacterPos::Get().GetCharacterPosition() - CharacterPos::Get().GetFront() * lfDistance;

		/*m3DCamera.SetLookAt( cVec3(vVector.x,
								   vVector.y + 1.5f,
								   vVector.z),
								   CharacterPos::Get().GetCharacterPosition(), 
								   cVec3(0.0f, 1.f, 0.f) );*/
		//cVec3 vVector = mVehicle.GetChasisPos() - mVehicle.GetChasisRot() * lfDistance;
		cVec3 vVector = mMustang.GetVehicleBullet()->GetChasisPos() - mMustang.GetVehicleBullet()->GetChasisRot()  * lfDistance;

		m3DCamera.SetLookAt( cVec3(vVector.x,
								   vVector.y + lfYOffset,
								   vVector.z),
								   mMustang.GetVehicleBullet()->GetChasisPos() + lvYViewOffset, 
								   cVec3(0.0f, 1.f, 0.f) );

		bool lbFireMainWeapon = IsPressed( eIA_Fire );

		// Si no esta vivo el jugador entonces no puede disparar
		(!mMustang.IsAlive())?lbFireMainWeapon = false : lbFireMainWeapon = lbFireMainWeapon; 

		// Resetea estados de daño
		InitDamageStates();

		mMustang.Update(lfTimestep, lfYaw, lfPitch, lbAuxCamera, lbFireMainWeapon);
		mTruck.Update(lfTimestep);

	// Modo Godmode	
	} else {
		// Actualizacion camara godmode
		if ( lbmoveFront ) {
			mGodCamera.MoveFront(lfTimestep);				
		}
		else if ( lbmoveBack ){
			mGodCamera.MoveBack(lfTimestep);
		}
		if ( lbmoveLeft ){
			mGodCamera.MoveLeft(lfTimestep);
		}
		else if ( lbmoveRight ){
			mGodCamera.MoveRight(lfTimestep);
		}
		if (lfYaw || lfPitch){
			mGodCamera.MoveYawPitch(lfYaw, lfPitch, lfTimestep);
		}

		// Resetea estados de daño
		InitDamageStates();

		mMustang.Update(lfTimestep, lfYaw, lfPitch);
		mTruck.Update(lfTimestep);
	}

	//mObject.SetPosition(CharacterPos::Get().GetCharacterPosition(), CharacterPos::Get().GetYaw());

	// Actualiza personaje
	//mObject.Update(lfTimestep);

	// Update bullet physics object
	cPhysics::Get().Update(lfTimestep);

	//Se actualizan los personajes:
	cCharacterManager::Get().Update(lfTimestep);

//	((cScene *)mScene.GetResource())->Update(lfTimestep);

	// Update physic objects
	for ( unsigned int luiIndex = 0; luiIndex < 10; ++luiIndex) {
		maSphereObjects[luiIndex].Update(lfTimestep);
	}

	// Ruinas
	for ( unsigned int luiIndex = 0; luiIndex < RUINS_NUMBER; ++luiIndex) {
		maRuins[luiIndex].Update(lfTimestep);
	}

	//((cScene *)mMusExt.GetResource())->Update(lfTimestep);
	((cScene *)mMusNeu.GetResource())->Update(lfTimestep);

	// Check if the animation keys (stop/start) are pressed
	cSkeletalMesh* lpSkeletonMesh =(cSkeletalMesh*)mSkeletalMesh.GetResource();

	/*static bool mbJogging = false;

	bool lbPlayJogPressed = BecomePressed(eIA_PlayJog);
	bool lbStopJogPressed = BecomePressed(eIA_StopJog);
	bool lbPlayWavePressed = BecomePressed(eIA_PlayWave);
	bool lbStopWavePressed = BecomePressed(eIA_StopWave);

	// Jog animation
	if (lbPlayJogPressed && !mbJogging){
		mbJogging = true;
		lpSkeletonMesh->PlayAnim("Jog", 1.0f, 0.1f);
		lpSkeletonMesh->StopAnim("Idle", 0.1f);
	}else if (lbStopJogPressed && mbJogging){
		mbJogging = false;
		lpSkeletonMesh->PlayAnim("Idle", 1.0f, 0.1f);
		lpSkeletonMesh->StopAnim("Jog", 0.1f);
	}

	// Wave animation
	if (lbPlayWavePressed){
		lpSkeletonMesh->PlayAnim("Wave", 1.0f, 0.1f, 0.1f);
	}else if (lbStopWavePressed){
		lpSkeletonMesh->StopAnim("Wave", 0.1f);
	}*/
	
	//Se comprueba si hay que cerrar la aplicación, por ejemplo a causa de 
	// que el usuario haya cerrado la ventana. 
	mbFinish = mbFinish || cWindow::Get().GetCloseApplication()
		         //También se verifica si se ha producido la acción de entrada que cierra la aplicación:
				 // Pulsar la tecla ESC del teclado, el botón 1 del JoyStick o el botón central del ratón.
	             || IsPressed(eIA_CloseApplication);
	//Si es así, se cambia el booleano
	// que controla el cierre de la aplicación.

	if ( mbFinish )
	{
		return;
	}	
}
Пример #29
0
//Función para inicializar el juego.
bool cGame::Init()
{	
	mbFinish = false;

	bool lbResult;

	lbResult = LoadResources();

	cMatrix lScaleMatrix, lOffsetMatrix;

	// Preparamos ya la escala y el offset que usaran el resto de objetos
	lScaleMatrix.LoadScale( .02f );
	lOffsetMatrix.LoadTranslation( cVec3( 0.0f, 0.0f, 0.0f ) );
	// Inicializamos el modelo de esfera
	mSphereModel.InitSphere( 1.0f, 2.0f );
	for ( unsigned int luiIndex = 0; luiIndex < 10; ++luiIndex) {
		maSphereObjects.push_back( mModelObject );
		cPhysicObject &lSphereObject = maSphereObjects.back();
		cMatrix lTransMatrix;
		lTransMatrix.LoadTranslation( cVec3( 0.0, 4.0 + 5.0 * luiIndex, 0.5 * luiIndex ) ); // Las creamos formando una columna
		lSphereObject.SetWorldMatrix( lTransMatrix );
		lSphereObject.SetScaleMatrix( lScaleMatrix );
		lSphereObject.SetDrawOffsetMatrix( lOffsetMatrix );
		lSphereObject.CreatePhysics( &mSphereModel );
	}	

	// Play idle animation 
	//lpSkeletonMesh->PlayAnim("Idle", 1.0f, 1.0f);
	

	// Posicionamiento inicial del personaje
	/*cMatrix lRotation, lTranslation;
	lTranslation.LoadTranslation(cVec3(0.f, -1.f, 0.f));
	mObject.SetDrawOffsetMatrix( lTranslation );
	mObject.SetKinematic( );	

	CharacterPos::Get().Init(cVec3(0.f, 0.f, 15.f), C_720PI, 10, 0.5f);*/

	// Estamos en modo juego, no depuración
	mbInGame = true;
	// Se inicializa en modo rasterizacion solida
	mbRasterizationMode = true;

	mMustang.Init(&mExt, &mInt, &mMet, &mTire, &mWeaponMuzzle1, &mWeaponMuzzle2, &mWeaponMuzzle3, &mArrowEnemy, &mPositiveAmmunition, &mNegativeAmmunition, 
		&mMustangExteriorDes, &mMustangInteriorDes
		, &mExplosion_sprite, &mExplosion_sprite1, &mParticle, &mCrosshair, &mhud1, &mhud1_mask, &mPositivelive, &mNegativelive);

	// Incializacion de enemigo 1 (Truck)
	mTruck.Init(cVec3(0.f, 0.0f, -90.f), &mTruckExterior, &mTruckWea, &mTruckTire, &mWeaponMuzzle1, &mWeaponMuzzle2, &mWeaponMuzzle3, &mTruckExteriorDes, &mTruckWeaponDes, &mExplosion_sprite, &mExplosion_sprite1, &mParticle);

	// Inicializa obstaculo (ruina)

	float a = - MAP_SIZE / 2;
	float b = MAP_SIZE / 2;

	for ( unsigned int luiIndex = 0; luiIndex < RUINS_NUMBER; ++luiIndex) {
		
		float random_x = ((b - a) * ((float)rand() / RAND_MAX)) + a;
		float random_z = ((b - a) * ((float)rand() / RAND_MAX)) + a;
		float random_angle = PI * rand();

		cMatrix lmRuinPos, lmRuinRotate, lmRuinPosRot;
		lmRuinPos.LoadTranslation(cVec3(random_x, -0.5f, random_z));
		lmRuinRotate.LoadRotation(cVec3(0.f, 1.f, 0.f), random_angle);

		lmRuinPosRot = lmRuinPos * lmRuinRotate;
		mRuin.Init(&mRuinObs, lmRuinPosRot);

		maRuins.push_back( mRuin );
		
	}

	// Inicializa obstaculo (matorrales)

	for ( unsigned int luiIndex = 0; luiIndex < BUSH_NUMBER; ++luiIndex) {
		
		float random_x = ((b - a) * ((float)rand() / RAND_MAX)) + a;
		float random_z = ((b - a) * ((float)rand() / RAND_MAX)) + a;
		
		cMatrix lmBushPos;
		lmBushPos.LoadTranslation(cVec3(random_x, -3.0f, random_z));

		//lmRuinPos.LoadTranslation(cVec3(0.f, -0.5f, 0.f));
		mBush.Init(&mBushTexture, &mBushTextureMask, lmBushPos);

		maBushes.push_back( mBush );
		
	}

	GLfloat density = 0.0002f;

	//GLfloat fogColor[4] = {0.5, 0.5, 0.5, 1.0}; 
	GLfloat fogColor[4] = {1.0f, 0.9f, 0.7f, 1.0f};

	glEnable (GL_FOG);

	glFogi (GL_FOG_MODE, GL_EXP2);


	glFogfv (GL_FOG_COLOR, fogColor);

	glFogf (GL_FOG_DENSITY, density);

	glHint (GL_FOG_HINT, GL_NICEST);

	// Contador de animacion niebla
	miFogStep = 0;
	mfFogDensity = density;
	mbFogIncreasing = true;

	// Application start time
	mfAcTime = 0.0f;

    return lbResult;	
}
Пример #30
0
//Función para renderizar el juego:
void cGame::Render()
{
	/* Orden de las instrucciones
	•    Limpiado de Buffers
	•    Activación de Cámara 3D
	•    Renderizado de Geometría 3D sólida and render of the skeleton mesh
	•    Render of bullet debug info
	•    Renderizado de Geometría 3D con transparencia
	•    Activación de Cámara 2D
	•    Renderizado de Cámara 2D
	•    Effectos de postprocesado
	•    Intercambio de los bufferes
	*/

	// 1) Limpiado de Buffers
	// -------------------------------------------------------------
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);        
	 
	// 2) Activación de Cámara 3D
	// -------------------------------------------------------------
	if (mbInGame)
		cGraphicManager::Get().ActivateCamera( &m3DCamera );
	else	
		cGraphicManager::Get().ActivateCamera( &mGodCamera );

	// Modo de rasterizacion solida/wireframe
	if (mbRasterizationMode){
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
		cPhysicsDebugDraw::Get( ).setDebugMode( cPhysicsDebugDraw::DBG_NoDebug );
	} else {
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		cPhysicsDebugDraw::Get( ).setDebugMode( cPhysicsDebugDraw::DBG_DrawWireframe );
	}

	// 3) Renderizado de Geometría 3D sólida
	// -------------------------------------------------------------
	// Set the world matrix
	cMatrix lWorld;
	lWorld.LoadIdentity();
	cGraphicManager::Get().SetWorldMatrix(lWorld);

	// 3.0) Pinta el skybox
	mSkybox.Render();

	// 3.1) Display the terrain mesh.
	mHeightmap.Render();
//	mEntity.EntityRender();

	lWorld.LoadTranslation(cVec3(0.f, 0.f, 0.f));
	cGraphicManager::Get().SetWorldMatrix(lWorld);

	// Render the debug lines
	//cGraphicManager::Get().DrawGrid();
	//cGraphicManager::Get().DrawAxis();

	lWorld.LoadIdentity();	
	cGraphicManager::Get().SetWorldMatrix(lWorld);

	// 3.2) Se dibujan los personajes:
	//cCharacterManager::Get().Render();

	// 3.3) Draws debug info of bullet
	cPhysics::Get().Render();

	// Render physic objects
	for ( unsigned int luiIndex = 0; luiIndex < 10; ++luiIndex ) {
		maSphereObjects[luiIndex].Render();	
	}	

	// Ruinas
	for ( unsigned int luiIndex = 0; luiIndex < RUINS_NUMBER; ++luiIndex ) {
		maRuins[luiIndex].Render();	
	}	

	// Matorrales
	for ( unsigned int luiIndex = 0; luiIndex < BUSH_NUMBER; ++luiIndex ) {
		maBushes[luiIndex].Render();	
	}	

	mTruck.Render();

	mMustang.Render();

	// 3.4) Render of the skeleton mesh
	// -------------------------------------------------------------
	cMatrix lRotation, lCurrPos;
	lCurrPos.LoadIdentity();
	lRotation.LoadRotation(cVec3(0.f, 1.f, 0.f), CharacterPos::Get().GetYaw());
	lCurrPos.SetPosition(CharacterPos::Get().GetCharacterPosition());

	cGraphicManager::Get().SetWorldMatrix(lRotation * lCurrPos);

//	mObject.Render();

	lWorld.LoadIdentity();	
	cGraphicManager::Get().SetWorldMatrix(lWorld);
	//cSkeletalMesh* lpSkeletonMesh = (cSkeletalMesh*)mSkeletalMesh.GetResource();
	//lpSkeletonMesh->RenderSkeleton();	

	 
	// 4) Renderizado de Geometría 3D con transparencia
	// -------------------------------------------------------------

	// 5) Activación de Cámara 2D  
	// -------------------------------------------------------------
	cGraphicManager::Get().ActivateCamera( &m2DCamera );
	 
	// 6) Renderizado de Cámara 2D
	// -------------------------------------------------------------
	// Se dibuja la flecha que persigue los enemigos
	mMustang.RenderArrowEnemy();
	// Se renderiza el HUD
	mMustang.RenderHUD();
	// Se renderiza la mirilla
	mMustang.Crosshair();

	// Correccion sobre el blending para que se vea bien las letras del HUD
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE);

	//Se dibujan algunas cadenas de texto.
	/*glEnable(GL_TEXTURE_2D);
	mFont.SetColour( 1.0f, 0.0f, 0.0f, 0.9f );
	char string_lives[251];
	sprintf(string_lives, "Lives: %d", mMustang.GetCurrentLives());
	//mFont.Write(mProperties.muiWidth - 300, mProperties.muiHeight - 40, 0, string_lives, 0, FONT_ALIGN_RIGHT);
	if (mMustang.IsAlive())
		mFont.Write(500, -280, 0, string_lives, 0, FONT_ALIGN_RIGHT); 
	else 	
		mFont.Write(470, -280, 0, "You are death!", 0, FONT_ALIGN_RIGHT);*/

	//mFont.SetColour( 0.0f, 1.0f, 1.0f, 0.9f );
	//mFont.WriteBox(100, 100, 0, 100, "Esto es un test \nmultilinea", 0, FONT_ALIGN_CENTER);
	 
	// 7) Efectos de postprocesado
	// -------------------------------------------------------------
	 
	// 8) Intercambio de los bufferes
	// -------------------------------------------------------------
	cGraphicManager::Get().SwapBuffer();
}