Added support for bullet debug view (still somewhat buggy, karts are
not shown correctly atm). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3442 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
9f6575c72b
commit
fd82138d8f
@ -19,17 +19,25 @@
|
||||
|
||||
#include "graphics/irr_driver.hpp"
|
||||
|
||||
#ifdef HAVE_GLUT
|
||||
# ifdef __APPLE__
|
||||
# include <GLUT/glut.h>
|
||||
# else
|
||||
# include <GL/glut.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "material_manager.hpp"
|
||||
#include "user_config.hpp"
|
||||
#include "gui/engine.hpp"
|
||||
#include "gui/state_manager.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
|
||||
#include "items/item_manager.hpp"
|
||||
#include "items/powerup_manager.hpp"
|
||||
#include "items/attachment_manager.hpp"
|
||||
#include "items/projectile_manager.hpp"
|
||||
#include "karts/kart_properties_manager.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "material_manager.hpp"
|
||||
#include "gui/font.hpp"
|
||||
|
||||
@ -400,9 +408,62 @@ void IrrDriver::update(float dt)
|
||||
{
|
||||
if(!m_device->run()) return;
|
||||
m_device->getVideoDriver()->beginScene(true, true, video::SColor(255,100,101,140));
|
||||
m_scene_manager->drawAll();
|
||||
#ifdef HAVE_GLUT
|
||||
if(user_config->m_bullet_debug)
|
||||
{
|
||||
// Use bullets debug drawer
|
||||
GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 };
|
||||
GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
|
||||
GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 };
|
||||
/* light_position is NOT default value */
|
||||
GLfloat light_position0[] = { 1.0, 1.0, 1.0, 0.0 };
|
||||
GLfloat light_position1[] = { -1.0, -1.0, -1.0, 0.0 };
|
||||
|
||||
GUIEngine::render(dt);
|
||||
glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
|
||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
|
||||
glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, light_position0);
|
||||
|
||||
glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient);
|
||||
glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse);
|
||||
glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular);
|
||||
glLightfv(GL_LIGHT1, GL_POSITION, light_position1);
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_LIGHT1);
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LESS);
|
||||
|
||||
glClearColor(0.8f,0.8f,0.8f,0);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
float f=2.0f;
|
||||
glFrustum(-f, f, -f, f, 1.0, 1000.0);
|
||||
|
||||
Vec3 xyz = RaceManager::getKart(race_manager->getNumKarts()-1)->getXYZ();
|
||||
gluLookAt(xyz.getX(), xyz.getY()-5.f, xyz.getZ()+4,
|
||||
xyz.getX(), xyz.getY(), xyz.getZ(),
|
||||
0.0f, 0.0f, 1.0f);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
for (unsigned int i = 0 ; i < race_manager->getNumKarts(); ++i)
|
||||
{
|
||||
Kart *kart=RaceManager::getKart((int)i);
|
||||
if(!kart->isEliminated()) kart->draw();
|
||||
}
|
||||
RaceManager::getWorld()->getPhysics()->draw();
|
||||
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
m_scene_manager->drawAll();
|
||||
GUIEngine::render(dt);
|
||||
}
|
||||
|
||||
m_device->getVideoDriver()->endScene();
|
||||
} // update
|
||||
|
@ -26,13 +26,6 @@
|
||||
#include "user_config.hpp"
|
||||
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
#ifdef HAVE_GLUT
|
||||
# ifdef __APPLE__
|
||||
# include <GLUT/glut.h>
|
||||
# else
|
||||
# include <GL/glut.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "scene.hpp"
|
||||
|
||||
@ -137,62 +130,6 @@ void Scene::draw(float dt)
|
||||
{
|
||||
(*i)->update(dt);
|
||||
(*i)->apply ();
|
||||
|
||||
if(!user_config->m_bullet_debug)
|
||||
{
|
||||
// Use this for faster profiling by disabling drawing the scene graph
|
||||
//if(!user_config->m_profile)ssgCullAndDraw ( m_scenegraph );
|
||||
}
|
||||
#ifdef HAVE_GLUT
|
||||
else
|
||||
{
|
||||
// Use bullets debug drawer
|
||||
GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 };
|
||||
GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
|
||||
GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 };
|
||||
/* light_position is NOT default value */
|
||||
GLfloat light_position0[] = { 1.0, 1.0, 1.0, 0.0 };
|
||||
GLfloat light_position1[] = { -1.0, -1.0, -1.0, 0.0 };
|
||||
|
||||
glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
|
||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
|
||||
glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, light_position0);
|
||||
|
||||
glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient);
|
||||
glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse);
|
||||
glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular);
|
||||
glLightfv(GL_LIGHT1, GL_POSITION, light_position1);
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_LIGHT1);
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LESS);
|
||||
|
||||
glClearColor(0.8,0.8,0.8,0);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
float f=2.0f;
|
||||
glFrustum(-f, f, -f, f, 1.0, 1000.0);
|
||||
|
||||
Vec3 xyz = RaceManager::getKart(race_manager->getNumKarts()-1)->getXYZ();
|
||||
gluLookAt(xyz.getX(), xyz.getY()-5.f, xyz.getZ()+4,
|
||||
xyz.getX(), xyz.getY(), xyz.getZ(),
|
||||
0.0f, 0.0f, 1.0f);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
for (unsigned int i = 0 ; i < race_manager->getNumKarts(); ++i)
|
||||
{
|
||||
Kart *kart=RaceManager::getKart((int)i);
|
||||
if(!kart->isEliminated()) kart->draw();
|
||||
}
|
||||
RaceManager::getWorld()->getPhysics()->draw();
|
||||
} // bullet_debug
|
||||
#endif
|
||||
} // for cameras
|
||||
|
||||
if (TRACK->useFog())
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
#include "main_loop.hpp"
|
||||
|
||||
// #include <SDL/SDL.h>
|
||||
#include <assert.h>
|
||||
#include "history.hpp"
|
||||
#include "input/input_manager.hpp"
|
||||
@ -202,9 +201,8 @@ void MainLoop::run()
|
||||
|
||||
input_manager->update(dt);
|
||||
|
||||
#ifdef HAVE_IRRLICHT
|
||||
if(!user_config->m_bullet_debug)
|
||||
irr_driver->update(dt);
|
||||
irr_driver->update(dt);
|
||||
|
||||
// FIXME hacky hacky FPS reporting
|
||||
// it should be moved to the right place when on screen display is done
|
||||
#if 0
|
||||
@ -228,10 +226,6 @@ void MainLoop::run()
|
||||
}
|
||||
} // no else, or you get over 50 'printf ("FPS below 1!\n")' easily
|
||||
if (printFPS) printf("FPS %3d<%3d<%3d\n", minFPS, fps, maxFPS);
|
||||
#endif
|
||||
#else
|
||||
glFlush();
|
||||
SDL_GL_SwapBuffers();
|
||||
#endif
|
||||
} // while !m_exit
|
||||
} // run
|
||||
|
@ -295,8 +295,6 @@ btScalar Physics::solveGroup(btCollisionObject** bodies, int numBodies,
|
||||
/** A debug draw function to show the track and all karts. */
|
||||
void Physics::draw()
|
||||
{
|
||||
if(!user_config->m_bullet_debug) return;
|
||||
|
||||
int num_objects = m_dynamics_world->getNumCollisionObjects();
|
||||
for(int i=0; i<num_objects; i++)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user