Update to irrlicht only, non-irrlicht part should be unchanged.
- Tracks and kart models are now loaded and converted into bullet physics. - A simple camera is implemented, so a loaded track can be displayed (note: the current SVN version does not contain a track converted for irrlicht yet) - Otherwise the irrlicht version is not working, i.e. no menus atm, ... git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@3115 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
35e6e0ecf8
commit
3b7bfd5367
@ -57,6 +57,8 @@ supertuxkart_SOURCES = \
|
|||||||
audio/sound_manager.hpp \
|
audio/sound_manager.hpp \
|
||||||
utils/constants.hpp \
|
utils/constants.hpp \
|
||||||
utils/coord.hpp \
|
utils/coord.hpp \
|
||||||
|
utils/mesh_tools.hpp \
|
||||||
|
utils/mesh_tools.cpp \
|
||||||
utils/random_generator.hpp \
|
utils/random_generator.hpp \
|
||||||
utils/random_generator.cpp \
|
utils/random_generator.cpp \
|
||||||
utils/ssg_help.cpp \
|
utils/ssg_help.cpp \
|
||||||
|
@ -134,7 +134,10 @@ void ChallengeData::error(const char *id) const
|
|||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
msg << "Undefined or incorrect value for '" << id
|
msg << "Undefined or incorrect value for '" << id
|
||||||
<< "' in challenge file '" << m_filename << "'.";
|
<< "' in challenge file '" << m_filename << "'.";
|
||||||
|
#ifndef HAVE_IRRLICHT
|
||||||
|
// FIXME: disable this till all tracks are converted
|
||||||
throw std::runtime_error(msg.str());
|
throw std::runtime_error(msg.str());
|
||||||
|
#endif
|
||||||
} // error
|
} // error
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** Checks if this challenge is valid, i.e. contains a valid track or a valid
|
/** Checks if this challenge is valid, i.e. contains a valid track or a valid
|
||||||
|
@ -135,6 +135,9 @@ FileManager::FileManager()
|
|||||||
pushTextureSearchPath(m_root_dir+"/data/textures");
|
pushTextureSearchPath(m_root_dir+"/data/textures");
|
||||||
pushModelSearchPath (m_root_dir+"/data/models" );
|
pushModelSearchPath (m_root_dir+"/data/models" );
|
||||||
pushMusicSearchPath (m_root_dir+"/data/music" );
|
pushMusicSearchPath (m_root_dir+"/data/music" );
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
m_file_system->addFolderFileArchive("data/models");
|
||||||
|
#endif
|
||||||
// Add more paths from the STK_MUSIC_PATH environment variable
|
// Add more paths from the STK_MUSIC_PATH environment variable
|
||||||
if(getenv("SUPERTUXKART_MUSIC_PATH")!=NULL)
|
if(getenv("SUPERTUXKART_MUSIC_PATH")!=NULL)
|
||||||
{
|
{
|
||||||
@ -176,16 +179,24 @@ FileManager::FileManager()
|
|||||||
}
|
}
|
||||||
} // FileManager
|
} // FileManager
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
/** Remove the dummy file system (which is called from IrrDriver before
|
||||||
|
* creating the actual device.
|
||||||
|
*/
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
void FileManager::dropFileSystem()
|
||||||
|
{
|
||||||
|
m_device->drop();
|
||||||
|
} // dropFileSystem
|
||||||
|
#endif
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#ifdef HAVE_IRRLICHT
|
#ifdef HAVE_IRRLICHT
|
||||||
/** This function is used to re-initialise the file-manager after reading in
|
/** This function is used to re-initialise the file-manager after reading in
|
||||||
* the user configuration data.
|
* the user configuration data.
|
||||||
*/
|
*/
|
||||||
void FileManager::reInit()
|
void FileManager::setDevice(IrrlichtDevice *device)
|
||||||
{
|
{
|
||||||
// Drop the NULL device
|
m_device = device;
|
||||||
m_device->drop();
|
|
||||||
m_device = irr_driver->getDevice();
|
|
||||||
m_device->grab(); // To make sure that the device still exists while
|
m_device->grab(); // To make sure that the device still exists while
|
||||||
// file_manager has a pointer to the file system.
|
// file_manager has a pointer to the file system.
|
||||||
m_file_system = m_device->getFileSystem();
|
m_file_system = m_device->getFileSystem();
|
||||||
@ -205,6 +216,26 @@ FileManager::~FileManager()
|
|||||||
} // ~FileManager
|
} // ~FileManager
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
void FileManager::pushModelSearchPath(const std::string& path)
|
||||||
|
{
|
||||||
|
m_model_search_path.push_back(path);
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
m_file_system->addFolderFileArchive(path.c_str());
|
||||||
|
#endif
|
||||||
|
} // pushModelSearchPath
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void FileManager::pushTextureSearchPath(const std::string& path)
|
||||||
|
{
|
||||||
|
m_texture_search_path.push_back(path);
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
m_file_system->addFolderFileArchive(path.c_str());
|
||||||
|
#endif
|
||||||
|
} // pushTextureSearchPath
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
bool FileManager::findFile(std::string& full_path,
|
bool FileManager::findFile(std::string& full_path,
|
||||||
const std::string& fname,
|
const std::string& fname,
|
||||||
const std::vector<std::string>& search_path) const
|
const std::vector<std::string>& search_path) const
|
||||||
@ -212,7 +243,8 @@ bool FileManager::findFile(std::string& full_path,
|
|||||||
#ifndef HAVE_IRRLICHT
|
#ifndef HAVE_IRRLICHT
|
||||||
struct stat mystat;
|
struct stat mystat;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// FIXME: this should become a reverse iterator.
|
||||||
for(std::vector<std::string>::const_iterator i = search_path.begin();
|
for(std::vector<std::string>::const_iterator i = search_path.begin();
|
||||||
i != search_path.end(); ++i)
|
i != search_path.end(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,8 @@ public:
|
|||||||
FileManager();
|
FileManager();
|
||||||
~FileManager();
|
~FileManager();
|
||||||
#ifdef HAVE_IRRLICHT
|
#ifdef HAVE_IRRLICHT
|
||||||
void reInit();
|
void setDevice(IrrlichtDevice *device);
|
||||||
|
void dropFileSystem();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string getHomeDir () const;
|
std::string getHomeDir () const;
|
||||||
@ -83,10 +84,8 @@ public:
|
|||||||
bool is_full_path=false,
|
bool is_full_path=false,
|
||||||
bool make_full_path=false) const;
|
bool make_full_path=false) const;
|
||||||
|
|
||||||
void pushTextureSearchPath(const std::string& path)
|
void pushTextureSearchPath(const std::string& path);
|
||||||
{ m_texture_search_path.push_back(path);}
|
void pushModelSearchPath (const std::string& path);
|
||||||
void pushModelSearchPath (const std::string& path)
|
|
||||||
{ m_model_search_path.push_back(path); }
|
|
||||||
void pushMusicSearchPath (const std::string& path)
|
void pushMusicSearchPath (const std::string& path)
|
||||||
{ m_music_search_path.push_back(path); }
|
{ m_music_search_path.push_back(path); }
|
||||||
void popTextureSearchPath () {m_texture_search_path.pop_back(); }
|
void popTextureSearchPath () {m_texture_search_path.pop_back(); }
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <plib/ssg.h>
|
#include <plib/ssg.h>
|
||||||
#include "user_config.hpp"
|
#include "user_config.hpp"
|
||||||
#include "audio/sound_manager.hpp"
|
#include "audio/sound_manager.hpp"
|
||||||
|
#include "graphics/irr_driver.hpp"
|
||||||
#include "karts/player_kart.hpp"
|
#include "karts/player_kart.hpp"
|
||||||
#include "modes/world.hpp"
|
#include "modes/world.hpp"
|
||||||
#include "race_manager.hpp"
|
#include "race_manager.hpp"
|
||||||
@ -35,7 +36,11 @@ Camera::Camera(int camera_index, const Kart* kart)
|
|||||||
{
|
{
|
||||||
m_mode = CM_NORMAL;
|
m_mode = CM_NORMAL;
|
||||||
m_index = camera_index;
|
m_index = camera_index;
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
m_camera = irr_driver->addCamera();
|
||||||
|
#else
|
||||||
m_context = new ssgContext ;
|
m_context = new ssgContext ;
|
||||||
|
#endif
|
||||||
m_distance = kart->getKartProperties()->getCameraDistance();
|
m_distance = kart->getKartProperties()->getCameraDistance();
|
||||||
m_kart = kart;
|
m_kart = kart;
|
||||||
m_xyz = kart->getXYZ();
|
m_xyz = kart->getXYZ();
|
||||||
@ -43,11 +48,13 @@ Camera::Camera(int camera_index, const Kart* kart)
|
|||||||
|
|
||||||
// FIXME: clipping should be configurable for slower machines
|
// FIXME: clipping should be configurable for slower machines
|
||||||
const Track* track = RaceManager::getTrack();
|
const Track* track = RaceManager::getTrack();
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
if (track->useFog())
|
if (track->useFog())
|
||||||
m_context -> setNearFar ( 0.05f, track->getFogEnd() ) ;
|
m_context -> setNearFar ( 0.05f, track->getFogEnd() ) ;
|
||||||
else
|
else
|
||||||
m_context -> setNearFar ( 0.05f, 1000.0f ) ;
|
m_context -> setNearFar ( 0.05f, 1000.0f ) ;
|
||||||
|
#endif
|
||||||
setScreenPosition(camera_index);
|
setScreenPosition(camera_index);
|
||||||
} // Camera
|
} // Camera
|
||||||
|
|
||||||
@ -55,7 +62,10 @@ Camera::Camera(int camera_index, const Kart* kart)
|
|||||||
Camera::~Camera()
|
Camera::~Camera()
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
if(m_context) delete m_context;
|
if(m_context) delete m_context;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -66,12 +76,18 @@ void Camera::setScreenPosition(int camera_index)
|
|||||||
|
|
||||||
if (num_players == 1)
|
if (num_players == 1)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
m_context -> setFOV ( 75.0f, 0.0f ) ;
|
m_context -> setFOV ( 75.0f, 0.0f ) ;
|
||||||
|
#endif
|
||||||
m_x = 0.0f; m_y = 0.0f; m_w = 1.0f; m_h = 1.0f ;
|
m_x = 0.0f; m_y = 0.0f; m_w = 1.0f; m_h = 1.0f ;
|
||||||
}
|
}
|
||||||
else if (num_players == 2)
|
else if (num_players == 2)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
m_context -> setFOV ( 85.0f, 85.0f*3.0f/8.0f ) ;
|
m_context -> setFOV ( 85.0f, 85.0f*3.0f/8.0f ) ;
|
||||||
|
#endif
|
||||||
switch ( camera_index )
|
switch ( camera_index )
|
||||||
{
|
{
|
||||||
case 0 : m_x = 0.0f; m_y = 0.5f; m_w = 1.0f; m_h = 0.5f; break;
|
case 0 : m_x = 0.0f; m_y = 0.5f; m_w = 1.0f; m_h = 0.5f; break;
|
||||||
@ -80,18 +96,28 @@ void Camera::setScreenPosition(int camera_index)
|
|||||||
}
|
}
|
||||||
else if (num_players == 3)
|
else if (num_players == 3)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
m_context -> setFOV ( 50.0f, 0.0f );
|
m_context -> setFOV ( 50.0f, 0.0f );
|
||||||
|
#endif
|
||||||
switch ( camera_index )
|
switch ( camera_index )
|
||||||
{
|
{
|
||||||
case 0 : m_x = 0.0f; m_y = 0.5f; m_w = 0.5f; m_h = 0.5f; break;
|
case 0 : m_x = 0.0f; m_y = 0.5f; m_w = 0.5f; m_h = 0.5f; break;
|
||||||
case 1 : m_x = 0.5f; m_y = 0.5f; m_w = 0.5f; m_h = 0.5f; break;
|
case 1 : m_x = 0.5f; m_y = 0.5f; m_w = 0.5f; m_h = 0.5f; break;
|
||||||
case 2 : m_x = 0.0f; m_y = 0.0f; m_w = 1.0f; m_h = 0.5f;
|
case 2 : m_x = 0.0f; m_y = 0.0f; m_w = 1.0f; m_h = 0.5f;
|
||||||
m_context -> setFOV ( 85.0f, 85.0f*3.0f/8.0f ); break;
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
|
m_context -> setFOV ( 85.0f, 85.0f*3.0f/8.0f );
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (num_players == 4)
|
else if (num_players == 4)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
m_context -> setFOV ( 50.0f, 0.0f );
|
m_context -> setFOV ( 50.0f, 0.0f );
|
||||||
|
#endif
|
||||||
switch ( camera_index )
|
switch ( camera_index )
|
||||||
{
|
{
|
||||||
case 0 : m_x = 0.0f; m_y = 0.5f; m_w = 0.5f; m_h = 0.5f; break;
|
case 0 : m_x = 0.0f; m_y = 0.5f; m_w = 0.5f; m_h = 0.5f; break;
|
||||||
@ -234,7 +260,12 @@ void Camera::update (float dt)
|
|||||||
Coord c(result);
|
Coord c(result);
|
||||||
m_xyz = c.getXYZ();
|
m_xyz = c.getXYZ();
|
||||||
m_hpr = c.getHPR();
|
m_hpr = c.getHPR();
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
m_camera->setPosition(m_xyz.toIrrVector());
|
||||||
|
//m_camera->setTarget(kart_xyz.toIrrVector());
|
||||||
|
#else
|
||||||
m_context -> setCamera(&c.toSgCoord());
|
m_context -> setCamera(&c.toSgCoord());
|
||||||
|
#endif
|
||||||
if(race_manager->getNumLocalPlayers() < 2)
|
if(race_manager->getNumLocalPlayers() < 2)
|
||||||
sound_manager->positionListener(m_xyz, kart_xyz - m_xyz);
|
sound_manager->positionListener(m_xyz, kart_xyz - m_xyz);
|
||||||
} // update
|
} // update
|
||||||
@ -249,7 +280,10 @@ void Camera::finalCamera(float dt)
|
|||||||
m_xyz += m_velocity*dt;
|
m_xyz += m_velocity*dt;
|
||||||
m_hpr += m_angular_velocity*dt;
|
m_hpr += m_angular_velocity*dt;
|
||||||
Coord coord(m_xyz, m_hpr);
|
Coord coord(m_xyz, m_hpr);
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
m_context->setCamera(&coord.toSgCoord());
|
m_context->setCamera(&coord.toSgCoord());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#undef TEST_END_CAMERA_POSITION
|
#undef TEST_END_CAMERA_POSITION
|
||||||
#ifdef TEST_END_CAMERA_POSITION
|
#ifdef TEST_END_CAMERA_POSITION
|
||||||
@ -281,7 +315,9 @@ void Camera::apply ()
|
|||||||
(int)((float)height * m_y),
|
(int)((float)height * m_y),
|
||||||
(int)((float)width * m_w),
|
(int)((float)width * m_w),
|
||||||
(int)((float)height * m_h) ) ;
|
(int)((float)height * m_h) ) ;
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
m_context -> makeCurrent () ;
|
m_context -> makeCurrent () ;
|
||||||
|
#endif
|
||||||
} // apply
|
} // apply
|
||||||
|
|
||||||
|
@ -23,8 +23,12 @@
|
|||||||
#define HEADER_CAMERA_HPP
|
#define HEADER_CAMERA_HPP
|
||||||
|
|
||||||
#include "utils/vec3.hpp"
|
#include "utils/vec3.hpp"
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#include "irrlicht.h"
|
||||||
|
using namespace irr;
|
||||||
|
#else
|
||||||
class ssgContext;
|
class ssgContext;
|
||||||
|
#endif
|
||||||
class Kart;
|
class Kart;
|
||||||
|
|
||||||
class Camera
|
class Camera
|
||||||
@ -39,7 +43,12 @@ public:
|
|||||||
CM_SIMPLE_REPLAY
|
CM_SIMPLE_REPLAY
|
||||||
};
|
};
|
||||||
protected:
|
protected:
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
scene::ICameraSceneNode
|
||||||
|
*m_camera;
|
||||||
|
#else
|
||||||
ssgContext *m_context;
|
ssgContext *m_context;
|
||||||
|
#endif
|
||||||
Vec3 m_xyz; // current position of camera
|
Vec3 m_xyz; // current position of camera
|
||||||
Vec3 m_hpr; // heading, pitch, roll of camera
|
Vec3 m_hpr; // heading, pitch, roll of camera
|
||||||
const Kart *m_kart; // the kart the camera is attached to
|
const Kart *m_kart; // the kart the camera is attached to
|
||||||
@ -54,7 +63,8 @@ protected:
|
|||||||
float m_final_time; // time when final camera mode started
|
float m_final_time; // time when final camera mode started
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void finalCamera (float dt); // handle the final camera
|
void finalCamera (float dt); // handle the final camera
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Camera (int camera_index, const Kart* kart);
|
Camera (int camera_index, const Kart* kart);
|
||||||
~Camera ();
|
~Camera ();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// $Id: sdldrv.hpp 694 2006-08-29 07:42:36Z hiker $
|
// $Id: irr_driver.cpp 694 2006-08-29 07:42:36Z hiker $
|
||||||
//
|
//
|
||||||
// SuperTuxKart - a fun racing game with go-kart
|
// SuperTuxKart - a fun racing game with go-kart
|
||||||
// Copyright (C) 2009 Joerg Henrichs
|
// Copyright (C) 2009 Joerg Henrichs
|
||||||
@ -22,11 +22,13 @@
|
|||||||
using namespace core;
|
using namespace core;
|
||||||
|
|
||||||
#include "user_config.hpp"
|
#include "user_config.hpp"
|
||||||
|
#include "file_manager.hpp"
|
||||||
|
|
||||||
IrrDriver *irr_driver = NULL;
|
IrrDriver *irr_driver = NULL;
|
||||||
|
|
||||||
IrrDriver::IrrDriver()
|
IrrDriver::IrrDriver()
|
||||||
{
|
{
|
||||||
|
file_manager->dropFileSystem();
|
||||||
// Try different drivers: start with opengl, then DirectX
|
// Try different drivers: start with opengl, then DirectX
|
||||||
for(int driver_type=0; driver_type<3; driver_type++)
|
for(int driver_type=0; driver_type<3; driver_type++)
|
||||||
{
|
{
|
||||||
@ -56,7 +58,10 @@ IrrDriver::IrrDriver()
|
|||||||
fprintf(stderr, "Couldn't initialise irrlicht device. Quitting.\n");
|
fprintf(stderr, "Couldn't initialise irrlicht device. Quitting.\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
// Stores the new file system pointer.
|
||||||
|
file_manager->setDevice(m_device);
|
||||||
|
m_device->setWindowCaption(L"SuperTuxKart");
|
||||||
|
m_scene_manager = m_device->getSceneManager();
|
||||||
} // IrrDriver
|
} // IrrDriver
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -65,6 +70,64 @@ IrrDriver::~IrrDriver()
|
|||||||
m_device->drop();
|
m_device->drop();
|
||||||
} // ~IrrDriver
|
} // ~IrrDriver
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
/** Loads an animated mesh and returns a pointer to it.
|
||||||
|
* \param filename File to load.
|
||||||
|
*/
|
||||||
|
scene::IAnimatedMesh *IrrDriver::getAnimatedMesh(const std::string &filename)
|
||||||
|
{
|
||||||
|
return m_scene_manager->getMesh(filename.c_str());
|
||||||
|
} // getAnimatedMesh
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
/** Adds a mesh that will be optimised using an oct tree.
|
||||||
|
* \param mesh Mesh to add.
|
||||||
|
*/
|
||||||
|
scene::ISceneNode *IrrDriver::addOctTree(scene::IMesh *mesh)
|
||||||
|
{
|
||||||
|
return m_scene_manager->addOctTreeSceneNode(mesh);
|
||||||
|
} // addOctTree
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
/** Adds a static mesh to scene. This should be used for smaller objects,
|
||||||
|
* since the node is not optimised.
|
||||||
|
* \param mesh The mesh to add.
|
||||||
|
*/
|
||||||
|
scene::ISceneNode *IrrDriver::addMesh(scene::IMesh *mesh)
|
||||||
|
{
|
||||||
|
return m_scene_manager->addMeshSceneNode(mesh);
|
||||||
|
} // addMesh
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
/** Adds an animated mesh to the scene.
|
||||||
|
* \param mesh The animated mesh to add.
|
||||||
|
*/
|
||||||
|
scene::ISceneNode *IrrDriver::addAnimatedMesh(scene::IAnimatedMesh *mesh)
|
||||||
|
{
|
||||||
|
return m_scene_manager->addAnimatedMeshSceneNode(mesh);
|
||||||
|
} // addAnimatedMesh
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
/** Adds a camera to the scene.
|
||||||
|
*/
|
||||||
|
scene::ICameraSceneNode *IrrDriver::addCamera()
|
||||||
|
{
|
||||||
|
return m_scene_manager->addCameraSceneNode();
|
||||||
|
} // addCamera
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
/** Update, called once per frame.
|
||||||
|
* \param dt Time since last update
|
||||||
|
*/
|
||||||
|
void IrrDriver::update(float dt)
|
||||||
|
{
|
||||||
|
|
||||||
|
m_device->getVideoDriver()->beginScene(true, true, video::SColor(255,100,101,140));
|
||||||
|
m_scene_manager->drawAll();
|
||||||
|
m_device->getVideoDriver()->endScene();
|
||||||
|
} // update
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Irrlicht Event handler.
|
// Irrlicht Event handler.
|
||||||
bool IrrDriver::OnEvent(const irr::SEvent &event)
|
bool IrrDriver::OnEvent(const irr::SEvent &event)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// $Id: sdldrv.hpp 694 2006-08-29 07:42:36Z hiker $
|
// $Id: irr_driver.hpp 694 2006-08-29 07:42:36Z hiker $
|
||||||
//
|
//
|
||||||
// SuperTuxKart - a fun racing game with go-kart
|
// SuperTuxKart - a fun racing game with go-kart
|
||||||
// Copyright (C) 2009 Joerg Henrichs
|
// Copyright (C) 2009 Joerg Henrichs
|
||||||
@ -22,6 +22,8 @@
|
|||||||
#ifndef HEADER_IRR_DRIVER_HPP
|
#ifndef HEADER_IRR_DRIVER_HPP
|
||||||
#define HEADER_IRR_DRIVER_HPP
|
#define HEADER_IRR_DRIVER_HPP
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "irrlicht.h"
|
#include "irrlicht.h"
|
||||||
using namespace irr;
|
using namespace irr;
|
||||||
|
|
||||||
@ -30,12 +32,21 @@ class IrrDriver : public IEventReceiver
|
|||||||
private:
|
private:
|
||||||
/** The irrlicht device. */
|
/** The irrlicht device. */
|
||||||
IrrlichtDevice *m_device;
|
IrrlichtDevice *m_device;
|
||||||
|
scene::ISceneManager *m_scene_manager;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IrrDriver();
|
IrrDriver();
|
||||||
~IrrDriver();
|
~IrrDriver();
|
||||||
IrrlichtDevice *getDevice() const { return m_device; }
|
IrrlichtDevice *getDevice() const { return m_device; }
|
||||||
bool OnEvent(const irr::SEvent &event);
|
scene::ISceneManager *getSceneManager() const { return m_scene_manager; }
|
||||||
|
scene::IAnimatedMesh *getAnimatedMesh(const std::string &name);
|
||||||
|
bool OnEvent(const irr::SEvent &event);
|
||||||
|
scene::ISceneNode *addOctTree(scene::IMesh *mesh);
|
||||||
|
scene::ISceneNode *addMesh(scene::IMesh *mesh);
|
||||||
|
scene::ISceneNode *addAnimatedMesh(scene::IAnimatedMesh *mesh);
|
||||||
|
scene::ICameraSceneNode
|
||||||
|
*addCamera();
|
||||||
|
void update(float dt);
|
||||||
}; // IrrDriver
|
}; // IrrDriver
|
||||||
|
|
||||||
extern IrrDriver *irr_driver;
|
extern IrrDriver *irr_driver;
|
||||||
|
@ -142,7 +142,10 @@ void Scene::draw(float dt)
|
|||||||
{
|
{
|
||||||
// Use this for faster profiling by disabling drawing the scene graph
|
// Use this for faster profiling by disabling drawing the scene graph
|
||||||
//if(!user_config->m_profile)ssgCullAndDraw ( m_scenegraph );
|
//if(!user_config->m_profile)ssgCullAndDraw ( m_scenegraph );
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
ssgCullAndDraw ( m_scenegraph );
|
ssgCullAndDraw ( m_scenegraph );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef HAVE_GLUT
|
#ifdef HAVE_GLUT
|
||||||
else
|
else
|
||||||
|
@ -331,8 +331,10 @@ void CharSel::switchCharacter(int n)
|
|||||||
m_kart = new ssgTransform;
|
m_kart = new ssgTransform;
|
||||||
m_kart->ref();
|
m_kart->ref();
|
||||||
KartModel* kartentity = kp->getKartModel();
|
KartModel* kartentity = kp->getKartModel();
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
m_kart->addKid(kartentity->getRoot());
|
m_kart->addKid(kartentity->getRoot());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} // switchCharacter
|
} // switchCharacter
|
||||||
|
|
||||||
|
@ -22,10 +22,10 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "main_loop.hpp"
|
#include "main_loop.hpp"
|
||||||
#include "widget_manager.hpp"
|
#include "sdldrv.hpp"
|
||||||
#include "user_config.hpp"
|
#include "user_config.hpp"
|
||||||
#include "menu_manager.hpp"
|
#include "menu_manager.hpp"
|
||||||
#include "sdldrv.hpp"
|
#include "gui/widget_manager.hpp"
|
||||||
#include "utils/translation.hpp"
|
#include "utils/translation.hpp"
|
||||||
#include "utils/string_utils.hpp"
|
#include "utils/string_utils.hpp"
|
||||||
|
|
||||||
|
@ -45,17 +45,22 @@ int delete_fonts()
|
|||||||
// =============================================================================
|
// =============================================================================
|
||||||
Font::Font(const char *fontname)
|
Font::Font(const char *fontname)
|
||||||
{
|
{
|
||||||
|
#ifndef HAVE_IRRLICHT
|
||||||
m_fnt = new fntTexFont(file_manager->getFontFile(fontname).c_str(),
|
m_fnt = new fntTexFont(file_manager->getFontFile(fontname).c_str(),
|
||||||
GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR);
|
GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR);
|
||||||
m_text_out = new fntRenderer();
|
m_text_out = new fntRenderer();
|
||||||
m_text_out->setFont(m_fnt);
|
m_text_out->setFont(m_fnt);
|
||||||
|
#endif
|
||||||
} // Font
|
} // Font
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
Font::~Font()
|
Font::~Font()
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
delete m_text_out;
|
delete m_text_out;
|
||||||
delete m_fnt;
|
delete m_fnt;
|
||||||
|
#endif
|
||||||
} // ~Font
|
} // ~Font
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -66,7 +71,8 @@ void Font::Print(const char *text, int size,
|
|||||||
float scale_x, float scale_y,
|
float scale_x, float scale_y,
|
||||||
int left, int right, int top, int bottom, bool doShadow)
|
int left, int right, int top, int bottom, bool doShadow)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
// Only scale for lower resolution
|
// Only scale for lower resolution
|
||||||
float fontScaling = user_config->m_width<800 ? ((float)user_config->m_width/800.0f)
|
float fontScaling = user_config->m_width<800 ? ((float)user_config->m_width/800.0f)
|
||||||
: 1.0f;
|
: 1.0f;
|
||||||
@ -92,7 +98,6 @@ void Font::Print(const char *text, int size,
|
|||||||
int height = top-bottom+1;
|
int height = top-bottom+1;
|
||||||
y = (height - H)/2 + bottom;
|
y = (height - H)/2 + bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_text_out->begin();
|
m_text_out->begin();
|
||||||
m_text_out->setPointSize((float)sz);
|
m_text_out->setPointSize((float)sz);
|
||||||
if(doShadow)
|
if(doShadow)
|
||||||
@ -113,7 +118,7 @@ void Font::Print(const char *text, int size,
|
|||||||
}
|
}
|
||||||
m_text_out->puts(text);
|
m_text_out->puts(text);
|
||||||
m_text_out->end();
|
m_text_out->end();
|
||||||
|
#endif
|
||||||
} // Print
|
} // Print
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -147,7 +152,7 @@ void Font::PrintBold(const std::string &text, int size, int x, int y,
|
|||||||
y = (height - H)/2 + bottom;
|
y = (height - H)/2 + bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef HAVE_IRRLICHT
|
||||||
m_text_out->begin();
|
m_text_out->begin();
|
||||||
m_text_out->setPointSize((float)sz);
|
m_text_out->setPointSize((float)sz);
|
||||||
|
|
||||||
@ -184,13 +189,14 @@ void Font::PrintBold(const std::string &text, int size, int x, int y,
|
|||||||
m_text_out->puts(text.c_str());
|
m_text_out->puts(text.c_str());
|
||||||
}
|
}
|
||||||
m_text_out->end();
|
m_text_out->end();
|
||||||
|
#endif
|
||||||
} // PrintBold
|
} // PrintBold
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
void Font::getBBox(const std::string &text, int size, bool italic,
|
void Font::getBBox(const std::string &text, int size, bool italic,
|
||||||
float *left, float *right, float *bot, float *top)
|
float *left, float *right, float *bot, float *top)
|
||||||
{
|
{
|
||||||
|
#ifndef HAVE_IRRLICHT
|
||||||
m_fnt->getBBox(text.c_str(), (float)size, italic, left, right, bot, top);
|
m_fnt->getBBox(text.c_str(), (float)size, italic, left, right, bot, top);
|
||||||
if(user_config->m_width<800) {
|
if(user_config->m_width<800) {
|
||||||
float fract=(float)user_config->m_width/800.0f;
|
float fract=(float)user_config->m_width/800.0f;
|
||||||
@ -199,7 +205,7 @@ void Font::getBBox(const std::string &text, int size, bool italic,
|
|||||||
if(bot) *bot *= fract;
|
if(bot) *bot *= fract;
|
||||||
if(top) *top *= fract;
|
if(top) *top *= fract;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -209,6 +215,7 @@ void Font::getBBoxMultiLine(const std::string &text, int size, bool italic,
|
|||||||
// Plib does not handle multi-lines strings as expected. So as a work
|
// Plib does not handle multi-lines strings as expected. So as a work
|
||||||
// around we split strings into lines, and compute the size for each
|
// around we split strings into lines, and compute the size for each
|
||||||
// line, and take the maximum size at the end.
|
// line, and take the maximum size at the end.
|
||||||
|
#ifndef HAVE_IRRLICHT
|
||||||
std::vector<std::string> s=StringUtils::split(text,'\n');
|
std::vector<std::string> s=StringUtils::split(text,'\n');
|
||||||
m_fnt->getBBox(s[0].c_str(), (float)size, italic, left, right, bot, top);
|
m_fnt->getBBox(s[0].c_str(), (float)size, italic, left, right, bot, top);
|
||||||
for(unsigned int i=1; i<s.size(); i++)
|
for(unsigned int i=1; i<s.size(); i++)
|
||||||
@ -227,5 +234,5 @@ void Font::getBBoxMultiLine(const std::string &text, int size, bool italic,
|
|||||||
if(bot) *bot *= fract;
|
if(bot) *bot *= fract;
|
||||||
if(top) *top *= fract;
|
if(top) *top *= fract;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,10 @@ GrandPrixEnd::GrandPrixEnd()
|
|||||||
m_kart = new ssgTransform;
|
m_kart = new ssgTransform;
|
||||||
m_kart->ref();
|
m_kart->ref();
|
||||||
KartModel* kartentity = WINNING_KART->getKartModel();
|
KartModel* kartentity = WINNING_KART->getKartModel();
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
m_kart->addKid(kartentity->getRoot());
|
m_kart->addKid(kartentity->getRoot());
|
||||||
|
#endif
|
||||||
|
|
||||||
m_winner_sound->play();
|
m_winner_sound->play();
|
||||||
|
|
||||||
|
@ -374,7 +374,10 @@ void RaceGUI::drawPlayerIcons (const KartIconDisplayInfo* info)
|
|||||||
}
|
}
|
||||||
//The material of the icons should not have a non-zero alpha_ref value,
|
//The material of the icons should not have a non-zero alpha_ref value,
|
||||||
//because if so the next call can make the text look aliased.
|
//because if so the next call can make the text look aliased.
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
players_gst -> apply ();
|
players_gst -> apply ();
|
||||||
|
#endif
|
||||||
last_players_gst = players_gst;
|
last_players_gst = players_gst;
|
||||||
glBegin ( GL_QUADS ) ;
|
glBegin ( GL_QUADS ) ;
|
||||||
glColor4f ( 1, 1, 1, 1 ) ;
|
glColor4f ( 1, 1, 1, 1 ) ;
|
||||||
@ -612,6 +615,8 @@ void RaceGUI::drawSpeed(Kart* kart, int offset_x, int offset_y,
|
|||||||
offset_x += (int)((user_config->m_width-10)*ratio_x) - width;
|
offset_x += (int)((user_config->m_width-10)*ratio_x) - width;
|
||||||
offset_y += (int)(10*ratio_y);
|
offset_y += (int)(10*ratio_y);
|
||||||
|
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
m_speed_back_icon->getState()->force();
|
m_speed_back_icon->getState()->force();
|
||||||
// If the colour isn't set, the speedometer is blended with the last
|
// If the colour isn't set, the speedometer is blended with the last
|
||||||
@ -661,7 +666,7 @@ void RaceGUI::drawSpeed(Kart* kart, int offset_x, int offset_y,
|
|||||||
|
|
||||||
glEnd () ;
|
glEnd () ;
|
||||||
} // speed<0
|
} // speed<0
|
||||||
|
#endif
|
||||||
} // drawSpeed
|
} // drawSpeed
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -728,6 +728,10 @@
|
|||||||
RelativePath="..\..\graphics\irr_driver.cpp"
|
RelativePath="..\..\graphics\irr_driver.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\graphics\mesh_tools.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\graphics\moving_texture.cpp"
|
RelativePath="..\..\graphics\moving_texture.cpp"
|
||||||
>
|
>
|
||||||
@ -1430,6 +1434,10 @@
|
|||||||
RelativePath="..\..\graphics\irr_driver.hpp"
|
RelativePath="..\..\graphics\irr_driver.hpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\graphics\mesh_tools.hpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\graphics\moving_texture.hpp"
|
RelativePath="..\..\graphics\moving_texture.hpp"
|
||||||
>
|
>
|
||||||
|
@ -35,8 +35,10 @@ Attachment::Attachment(Kart* _kart)
|
|||||||
m_type = ATTACH_NOTHING;
|
m_type = ATTACH_NOTHING;
|
||||||
m_time_left = 0.0;
|
m_time_left = 0.0;
|
||||||
m_kart = _kart;
|
m_kart = _kart;
|
||||||
m_holder = new ssgSelector();
|
|
||||||
m_previous_owner = NULL;
|
m_previous_owner = NULL;
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
|
m_holder = new ssgSelector();
|
||||||
m_kart->getModelTransform()->addKid(m_holder);
|
m_kart->getModelTransform()->addKid(m_holder);
|
||||||
|
|
||||||
for(int i=ATTACH_FIRST; i<ATTACH_MAX; i++)
|
for(int i=ATTACH_FIRST; i<ATTACH_MAX; i++)
|
||||||
@ -45,6 +47,7 @@ Attachment::Attachment(Kart* _kart)
|
|||||||
m_holder->addKid(p);
|
m_holder->addKid(p);
|
||||||
}
|
}
|
||||||
m_holder->select(0);
|
m_holder->select(0);
|
||||||
|
#endif
|
||||||
} // Attachment
|
} // Attachment
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -80,7 +83,10 @@ void Attachment::clear()
|
|||||||
{
|
{
|
||||||
m_type=ATTACH_NOTHING;
|
m_type=ATTACH_NOTHING;
|
||||||
m_time_left=0.0;
|
m_time_left=0.0;
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
m_holder->select(0);
|
m_holder->select(0);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Resets the weight of the kart if the previous attachment affected it
|
// Resets the weight of the kart if the previous attachment affected it
|
||||||
// (e.g. anvil). This must be done *after* setting m_type to
|
// (e.g. anvil). This must be done *after* setting m_type to
|
||||||
|
@ -68,8 +68,11 @@ void AttachmentManager::loadModels()
|
|||||||
{
|
{
|
||||||
// FIXME LEAK: these models are not removed (unimportant, since they
|
// FIXME LEAK: these models are not removed (unimportant, since they
|
||||||
// have to be in memory till the end of the game.
|
// have to be in memory till the end of the game.
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
m_attachments[iat[i].attachment]=loader->load(iat[i].file, CB_ATTACHMENT);
|
m_attachments[iat[i].attachment]=loader->load(iat[i].file, CB_ATTACHMENT);
|
||||||
m_attachments[iat[i].attachment]->ref();
|
m_attachments[iat[i].attachment]->ref();
|
||||||
|
#endif
|
||||||
} // for
|
} // for
|
||||||
} // reInit
|
} // reInit
|
||||||
|
|
||||||
|
@ -64,9 +64,12 @@ Flyable::Flyable(Kart *kart, PowerupType type, float mass) : Moveable()
|
|||||||
m_max_lifespan = -1;
|
m_max_lifespan = -1;
|
||||||
|
|
||||||
// Add the graphical model
|
// Add the graphical model
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
ssgTransform *m = getModelTransform();
|
ssgTransform *m = getModelTransform();
|
||||||
m->addKid(m_st_model[type]);
|
m->addKid(m_st_model[type]);
|
||||||
stk_scene->add(m);
|
stk_scene->add(m);
|
||||||
|
#endif
|
||||||
} // Flyable
|
} // Flyable
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
void Flyable::createPhysics(float y_offset, const btVector3 &velocity,
|
void Flyable::createPhysics(float y_offset, const btVector3 &velocity,
|
||||||
@ -128,8 +131,10 @@ void Flyable::init(const lisp::Lisp* lisp, ssgEntity *model,
|
|||||||
|
|
||||||
// Store the size of the model
|
// Store the size of the model
|
||||||
Vec3 min, max;
|
Vec3 min, max;
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
SSGHelp::MinMax(model, &min, &max);
|
SSGHelp::MinMax(model, &min, &max);
|
||||||
|
#endif
|
||||||
m_st_extend[type] = btVector3(max-min);
|
m_st_extend[type] = btVector3(max-min);
|
||||||
m_st_model[type] = model;
|
m_st_model[type] = model;
|
||||||
} // init
|
} // init
|
||||||
@ -257,9 +262,12 @@ void Flyable::hit(Kart *kart_hit, MovingPhysics* moving_physics)
|
|||||||
projectile_manager->notifyRemove();
|
projectile_manager->notifyRemove();
|
||||||
|
|
||||||
// Now remove this projectile from the graph:
|
// Now remove this projectile from the graph:
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
ssgTransform *m = getModelTransform();
|
ssgTransform *m = getModelTransform();
|
||||||
m->removeAllKids();
|
m->removeAllKids();
|
||||||
stk_scene->remove(m);
|
stk_scene->remove(m);
|
||||||
|
#endif
|
||||||
|
|
||||||
// The explosion is a bit higher in the air
|
// The explosion is a bit higher in the air
|
||||||
Vec3 pos_explosion=getXYZ();
|
Vec3 pos_explosion=getXYZ();
|
||||||
|
@ -37,11 +37,14 @@ Item::Item(ItemType type, const Vec3& xyz, const Vec3& normal,
|
|||||||
m_type = type;
|
m_type = type;
|
||||||
m_collected = false;
|
m_collected = false;
|
||||||
m_time_till_return = 0.0f; // not strictly necessary, see isCollected()
|
m_time_till_return = 0.0f; // not strictly necessary, see isCollected()
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
m_root = new ssgTransform();
|
m_root = new ssgTransform();
|
||||||
m_root->ref();
|
m_root->ref();
|
||||||
m_root->setTransform(const_cast<sgCoord*>(&m_coord.toSgCoord()));
|
m_root->setTransform(const_cast<sgCoord*>(&m_coord.toSgCoord()));
|
||||||
m_root->addKid(model);
|
m_root->addKid(model);
|
||||||
stk_scene->add(m_root);
|
stk_scene->add(m_root);
|
||||||
|
#endif
|
||||||
} // Item
|
} // Item
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -94,9 +97,12 @@ void Item::update(float delta)
|
|||||||
|
|
||||||
if(!m_rotate) return;
|
if(!m_rotate) return;
|
||||||
// have it rotate
|
// have it rotate
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
Vec3 rotation(delta*M_PI, 0, 0);
|
Vec3 rotation(delta*M_PI, 0, 0);
|
||||||
m_coord.setHPR(m_coord.getHPR()+rotation);
|
m_coord.setHPR(m_coord.getHPR()+rotation);
|
||||||
m_root->setTransform(const_cast<sgCoord*>(&m_coord.toSgCoord()));
|
m_root->setTransform(const_cast<sgCoord*>(&m_coord.toSgCoord()));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} // update
|
} // update
|
||||||
|
|
||||||
|
@ -108,6 +108,8 @@ void ItemManager::removeTextures()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
ItemManager::~ItemManager()
|
ItemManager::~ItemManager()
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
for(CI_type i=m_all_models.begin(); i!=m_all_models.end(); ++i)
|
for(CI_type i=m_all_models.begin(); i!=m_all_models.end(); ++i)
|
||||||
{
|
{
|
||||||
// We can't use ssgDeRefDelete here, since then the object would be
|
// We can't use ssgDeRefDelete here, since then the object would be
|
||||||
@ -115,6 +117,7 @@ ItemManager::~ItemManager()
|
|||||||
// accesses.
|
// accesses.
|
||||||
i->second->deRef();
|
i->second->deRef();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
m_all_models.clear();
|
m_all_models.clear();
|
||||||
} // ~ItemManager
|
} // ~ItemManager
|
||||||
|
|
||||||
@ -131,6 +134,8 @@ void ItemManager::loadDefaultItems()
|
|||||||
for(std::set<std::string>::iterator i = files.begin();
|
for(std::set<std::string>::iterator i = files.begin();
|
||||||
i != files.end(); ++i)
|
i != files.end(); ++i)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
if(!StringUtils::has_suffix(*i, ".ac")) continue;
|
if(!StringUtils::has_suffix(*i, ".ac")) continue;
|
||||||
ssgEntity* h = loader->load(*i, CB_ITEM,
|
ssgEntity* h = loader->load(*i, CB_ITEM,
|
||||||
/*optimise*/true,
|
/*optimise*/true,
|
||||||
@ -139,6 +144,7 @@ void ItemManager::loadDefaultItems()
|
|||||||
h->ref();
|
h->ref();
|
||||||
h->setName(shortName.c_str());
|
h->setName(shortName.c_str());
|
||||||
m_all_models[shortName] = h;
|
m_all_models[shortName] = h;
|
||||||
|
#endif
|
||||||
} // for i
|
} // for i
|
||||||
|
|
||||||
|
|
||||||
@ -196,8 +202,11 @@ void ItemManager::setDefaultItemStyle()
|
|||||||
}
|
}
|
||||||
} // if i->second
|
} // if i->second
|
||||||
}
|
}
|
||||||
|
#ifndef HAVE_IRRLICHT
|
||||||
|
// For now disable this, irrlicht does not yet load any items.
|
||||||
throw std::runtime_error(msg.str());
|
throw std::runtime_error(msg.str());
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
#endif
|
||||||
} // if bError
|
} // if bError
|
||||||
|
|
||||||
} // setDefaultItemStyle
|
} // setDefaultItemStyle
|
||||||
|
@ -122,9 +122,12 @@ void Plunger::update(float dt)
|
|||||||
{
|
{
|
||||||
setHasHit();
|
setHasHit();
|
||||||
projectile_manager->notifyRemove();
|
projectile_manager->notifyRemove();
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
ssgTransform *m = getModelTransform();
|
ssgTransform *m = getModelTransform();
|
||||||
m->removeAllKids();
|
m->removeAllKids();
|
||||||
stk_scene->remove(m);
|
stk_scene->remove(m);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if(m_rubber_band != NULL) m_rubber_band->update(dt);
|
if(m_rubber_band != NULL) m_rubber_band->update(dt);
|
||||||
return;
|
return;
|
||||||
@ -171,7 +174,10 @@ void Plunger::hit(Kart *kart, MovingPhysics *mp)
|
|||||||
// objects is simply removed from the scene graph, it might be auto-deleted
|
// objects is simply removed from the scene graph, it might be auto-deleted
|
||||||
// because the ref count reaches zero.
|
// because the ref count reaches zero.
|
||||||
Vec3 hell(0, 0, -10000);
|
Vec3 hell(0, 0, -10000);
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
getModelTransform()->setTransform(hell.toFloat());
|
getModelTransform()->setTransform(hell.toFloat());
|
||||||
|
#endif
|
||||||
RaceManager::getWorld()->getPhysics()->removeBody(getBody());
|
RaceManager::getWorld()->getPhysics()->removeBody(getBody());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -182,7 +188,10 @@ void Plunger::hit(Kart *kart, MovingPhysics *mp)
|
|||||||
// objects is simply removed from the scene graph, it might be auto-deleted
|
// objects is simply removed from the scene graph, it might be auto-deleted
|
||||||
// because the ref count reaches zero.
|
// because the ref count reaches zero.
|
||||||
Vec3 hell(0, 0, -10000);
|
Vec3 hell(0, 0, -10000);
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
getModelTransform()->setTransform(hell.toFloat());
|
getModelTransform()->setTransform(hell.toFloat());
|
||||||
|
#endif
|
||||||
RaceManager::getWorld()->getPhysics()->removeBody(getBody());
|
RaceManager::getWorld()->getPhysics()->removeBody(getBody());
|
||||||
|
|
||||||
if(kart)
|
if(kart)
|
||||||
|
@ -123,12 +123,15 @@ void PowerupManager::LoadNode(const lisp::Lisp* lisp, int collectType )
|
|||||||
|
|
||||||
if(sModel!="")
|
if(sModel!="")
|
||||||
{
|
{
|
||||||
// FIXME LEAK: not freed (uniportant, since the models have to exist
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
|
// FIXME LEAK: not freed (unimportant, since the models have to exist
|
||||||
// for the whole game anyway).
|
// for the whole game anyway).
|
||||||
ssgEntity* e = loader->load(sModel, CB_COLLECTABLE);
|
ssgEntity* e = loader->load(sModel, CB_COLLECTABLE);
|
||||||
m_all_models[collectType] = e;
|
m_all_models[collectType] = e;
|
||||||
e->ref();
|
e->ref();
|
||||||
e->clrTraversalMaskBits(SSGTRAV_ISECT|SSGTRAV_HOT);
|
e->clrTraversalMaskBits(SSGTRAV_ISECT|SSGTRAV_HOT);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -35,7 +35,8 @@ ProjectileManager *projectile_manager=0;
|
|||||||
|
|
||||||
void ProjectileManager::loadData()
|
void ProjectileManager::loadData()
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
// Load the explosion model and find the actual selector branch in it.
|
// Load the explosion model and find the actual selector branch in it.
|
||||||
// Only the explosion model is loaded here, see powerup_manager.
|
// Only the explosion model is loaded here, see powerup_manager.
|
||||||
m_explosion_model = find_selector((ssgBranch*)loader->load("explode.ac",
|
m_explosion_model = find_selector((ssgBranch*)loader->load("explode.ac",
|
||||||
@ -46,7 +47,7 @@ void ProjectileManager::loadData()
|
|||||||
fprintf ( stderr, "explode.ac doesn't have an 'explosion' object.\n" ) ;
|
fprintf ( stderr, "explode.ac doesn't have an 'explosion' object.\n" ) ;
|
||||||
exit ( 1 ) ;
|
exit ( 1 ) ;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} // loadData
|
} // loadData
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -65,8 +66,11 @@ void ProjectileManager::cleanup()
|
|||||||
for(Projectiles::iterator i = m_active_projectiles.begin();
|
for(Projectiles::iterator i = m_active_projectiles.begin();
|
||||||
i != m_active_projectiles.end(); ++i)
|
i != m_active_projectiles.end(); ++i)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
ssgTransform *m = (*i)->getModelTransform();
|
ssgTransform *m = (*i)->getModelTransform();
|
||||||
m->removeAllKids();
|
m->removeAllKids();
|
||||||
|
#endif
|
||||||
delete *i;
|
delete *i;
|
||||||
}
|
}
|
||||||
m_active_projectiles.clear();
|
m_active_projectiles.clear();
|
||||||
|
@ -270,7 +270,10 @@ void Kart::eliminate()
|
|||||||
|
|
||||||
// make the kart invisible by placing it way under the track
|
// make the kart invisible by placing it way under the track
|
||||||
sgVec3 hell; hell[0]=0.0f; hell[1]=0.0f; hell[2] = -10000.0f;
|
sgVec3 hell; hell[0]=0.0f; hell[1]=0.0f; hell[2] = -10000.0f;
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
getModelTransform()->setTransform(hell);
|
getModelTransform()->setTransform(hell);
|
||||||
|
#endif
|
||||||
} // eliminate
|
} // eliminate
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -643,12 +646,18 @@ void Kart::update(float dt)
|
|||||||
if( (!isOnGround() || m_rescue) && m_shadow_enabled)
|
if( (!isOnGround() || m_rescue) && m_shadow_enabled)
|
||||||
{
|
{
|
||||||
m_shadow_enabled = false;
|
m_shadow_enabled = false;
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
m_model_transform->removeKid(m_shadow);
|
m_model_transform->removeKid(m_shadow);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if(!m_shadow_enabled && isOnGround() && !m_rescue)
|
if(!m_shadow_enabled && isOnGround() && !m_rescue)
|
||||||
{
|
{
|
||||||
m_shadow_enabled = true;
|
m_shadow_enabled = true;
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
m_model_transform->addKid(m_shadow);
|
m_model_transform->addKid(m_shadow);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} // update
|
} // update
|
||||||
|
|
||||||
@ -984,10 +993,15 @@ void Kart::loadData()
|
|||||||
{
|
{
|
||||||
float r [ 2 ] = { -10.0f, 100.0f } ;
|
float r [ 2 ] = { -10.0f, 100.0f } ;
|
||||||
|
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
m_kart_properties->getKartModel()->attachModel(&m_root);
|
||||||
|
#else
|
||||||
ssgEntity *obj = m_kart_properties->getKartModel()->getRoot();
|
ssgEntity *obj = m_kart_properties->getKartModel()->getRoot();
|
||||||
|
#endif
|
||||||
createPhysics();
|
createPhysics();
|
||||||
|
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
SSGHelp::createDisplayLists(obj); // create all display lists
|
SSGHelp::createDisplayLists(obj); // create all display lists
|
||||||
ssgRangeSelector *lod = new ssgRangeSelector ;
|
ssgRangeSelector *lod = new ssgRangeSelector ;
|
||||||
|
|
||||||
@ -995,7 +1009,7 @@ void Kart::loadData()
|
|||||||
lod -> setRanges ( r, 2 ) ;
|
lod -> setRanges ( r, 2 ) ;
|
||||||
|
|
||||||
getModelTransform() -> addKid ( lod ) ;
|
getModelTransform() -> addKid ( lod ) ;
|
||||||
|
#endif
|
||||||
// Attach Particle System
|
// Attach Particle System
|
||||||
m_smoke_system = new Smoke(this);
|
m_smoke_system = new Smoke(this);
|
||||||
m_smoke_system->ref();
|
m_smoke_system->ref();
|
||||||
@ -1004,11 +1018,13 @@ void Kart::loadData()
|
|||||||
|
|
||||||
if(m_kart_properties->hasSkidmarks())
|
if(m_kart_properties->hasSkidmarks())
|
||||||
m_skidmarks = new SkidMarks(*this);
|
m_skidmarks = new SkidMarks(*this);
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
m_shadow = createShadow(m_kart_properties->getShadowFile(), -1, 1, -1, 1);
|
m_shadow = createShadow(m_kart_properties->getShadowFile(), -1, 1, -1, 1);
|
||||||
m_shadow->ref();
|
m_shadow->ref();
|
||||||
m_model_transform->addKid ( m_shadow );
|
m_model_transform->addKid ( m_shadow );
|
||||||
m_shadow_enabled = true;
|
m_shadow_enabled = true;
|
||||||
|
#endif
|
||||||
} // loadData
|
} // loadData
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -19,9 +19,12 @@
|
|||||||
|
|
||||||
#include "karts/kart_model.hpp"
|
#include "karts/kart_model.hpp"
|
||||||
|
|
||||||
|
#include "file_manager.hpp"
|
||||||
#include "loader.hpp"
|
#include "loader.hpp"
|
||||||
#include "stk_config.hpp"
|
#include "stk_config.hpp"
|
||||||
#include "user_config.hpp"
|
#include "user_config.hpp"
|
||||||
|
#include "graphics/irr_driver.hpp"
|
||||||
|
#include "graphics/mesh_tools.hpp"
|
||||||
#include "utils/constants.hpp"
|
#include "utils/constants.hpp"
|
||||||
#include "utils/ssg_help.hpp"
|
#include "utils/ssg_help.hpp"
|
||||||
|
|
||||||
@ -43,12 +46,20 @@ KartModel::KartModel()
|
|||||||
m_max_suspension[i] = 1.3f;
|
m_max_suspension[i] = 1.3f;
|
||||||
m_dampen_suspension_amplitude[i] = 2.5f;
|
m_dampen_suspension_amplitude[i] = 2.5f;
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
m_wheel_filename[0] = "wheel-front-right.3ds";
|
||||||
|
m_wheel_filename[1] = "wheel-front-left.3ds";
|
||||||
|
m_wheel_filename[2] = "wheel-rear-right.3ds";
|
||||||
|
m_wheel_filename[3] = "wheel-rear-left.a3ds";
|
||||||
|
m_mesh = NULL;
|
||||||
|
#else
|
||||||
m_wheel_filename[0] = "wheel-front-right.ac";
|
m_wheel_filename[0] = "wheel-front-right.ac";
|
||||||
m_wheel_filename[1] = "wheel-front-left.ac";
|
m_wheel_filename[1] = "wheel-front-left.ac";
|
||||||
m_wheel_filename[2] = "wheel-rear-right.ac";
|
m_wheel_filename[2] = "wheel-rear-right.ac";
|
||||||
m_wheel_filename[3] = "wheel-rear-left.ac";
|
m_wheel_filename[3] = "wheel-rear-left.ac";
|
||||||
|
m_root = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
m_root = NULL;
|
|
||||||
} // KartModel
|
} // KartModel
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -72,15 +83,48 @@ KartModel::~KartModel()
|
|||||||
// This automatically frees the wheels and the kart model.
|
// This automatically frees the wheels and the kart model.
|
||||||
// m_root can be zero in case of STKConfig, which has a kart_properties
|
// m_root can be zero in case of STKConfig, which has a kart_properties
|
||||||
// attribute (for the default values) as well.
|
// attribute (for the default values) as well.
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
if(m_root) m_root->removeAllKids();
|
if(m_root) m_root->removeAllKids();
|
||||||
ssgDeRefDelete(m_root);
|
ssgDeRefDelete(m_root);
|
||||||
|
#endif
|
||||||
} // ~KartModel
|
} // ~KartModel
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
/** Attach the kart model and wheels to the scene node.
|
||||||
|
* \param node Node to attach the models to.
|
||||||
|
*/
|
||||||
|
void KartModel::attachModel(scene::ISceneNode **node)
|
||||||
|
{
|
||||||
|
*node = irr_driver->addMesh(m_mesh);
|
||||||
|
for(unsigned int i=0; i<4; i++)
|
||||||
|
{
|
||||||
|
// *node->addChild(m_wh
|
||||||
|
}
|
||||||
|
} // attachModel
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/** Loads the 3d model and all wheels.
|
/** Loads the 3d model and all wheels.
|
||||||
*/
|
*/
|
||||||
void KartModel::loadModels()
|
void KartModel::loadModels(const std::string &kart_ident)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
std::string full_path = file_manager->getKartFile(m_model_filename);
|
||||||
|
m_mesh = irr_driver->getAnimatedMesh(full_path)->getMesh(0);
|
||||||
|
Vec3 min, max;
|
||||||
|
MeshTools::minMax3D(m_mesh, &min, &max);
|
||||||
|
Vec3 size = max-min;
|
||||||
|
m_z_offset = min.getZ();
|
||||||
|
m_kart_width = size.getX();
|
||||||
|
m_kart_height = size.getY();
|
||||||
|
m_kart_length = size.getZ();
|
||||||
|
// FIXME: How do we handle this? it's a mesh only, so we can't
|
||||||
|
// simply move it in a transform (unless we turn it into a scene
|
||||||
|
// node). m_z_offset should probably be made available to kart.
|
||||||
|
// Vec3 move_kart_to_0_z(0, 0, m_z_offset);
|
||||||
|
// m_root->setTransform(move_kart_to_0_z);
|
||||||
|
#else
|
||||||
ssgEntity *obj = loader->load(m_model_filename, CB_KART);
|
ssgEntity *obj = loader->load(m_model_filename, CB_KART);
|
||||||
if(!obj)
|
if(!obj)
|
||||||
{
|
{
|
||||||
@ -100,6 +144,7 @@ void KartModel::loadModels()
|
|||||||
sgVec3 move_kart_to_0_z;
|
sgVec3 move_kart_to_0_z;
|
||||||
sgSetVec3(move_kart_to_0_z, 0, 0, m_z_offset);
|
sgSetVec3(move_kart_to_0_z, 0, 0, m_z_offset);
|
||||||
m_root->setTransform(move_kart_to_0_z);
|
m_root->setTransform(move_kart_to_0_z);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Now set default some default parameters (if not defined) that
|
// Now set default some default parameters (if not defined) that
|
||||||
// depend on the size of the kart model (wheel position, center
|
// depend on the size of the kart model (wheel position, center
|
||||||
@ -122,6 +167,12 @@ void KartModel::loadModels()
|
|||||||
// depend on the size of the model.
|
// depend on the size of the model.
|
||||||
for(unsigned int i=0; i<4; i++)
|
for(unsigned int i=0; i<4; i++)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
std::string full_wheel = file_manager->getKartFile(m_wheel_filename[i],
|
||||||
|
kart_ident);
|
||||||
|
m_wheel_model[i] = irr_driver->getAnimatedMesh(full_wheel)->getMesh(0);
|
||||||
|
// FIXME: wheel handling still missing.
|
||||||
|
#else
|
||||||
m_wheel_model[i] = loader->load(m_wheel_filename[i], CB_KART);
|
m_wheel_model[i] = loader->load(m_wheel_filename[i], CB_KART);
|
||||||
m_wheel_transform[i]= new ssgTransform();
|
m_wheel_transform[i]= new ssgTransform();
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -142,6 +193,7 @@ void KartModel::loadModels()
|
|||||||
hpr);
|
hpr);
|
||||||
m_wheel_transform[i]->setTransform(wheel_loc);
|
m_wheel_transform[i]->setTransform(wheel_loc);
|
||||||
} // if m_wheel_model[i]
|
} // if m_wheel_model[i]
|
||||||
|
#endif
|
||||||
} // for i<4
|
} // for i<4
|
||||||
if(!m_wheel_model[0])
|
if(!m_wheel_model[0])
|
||||||
{
|
{
|
||||||
@ -220,6 +272,9 @@ void KartModel::setDefaultPhysicsPosition(const Vec3 ¢er_shift,
|
|||||||
void KartModel::adjustWheels(float rotation, float steer,
|
void KartModel::adjustWheels(float rotation, float steer,
|
||||||
const float suspension[4])
|
const float suspension[4])
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
// FIXME: missing
|
||||||
|
#else
|
||||||
sgMat4 wheel_front;
|
sgMat4 wheel_front;
|
||||||
sgMat4 wheel_steer;
|
sgMat4 wheel_steer;
|
||||||
sgMat4 wheel_rot;
|
sgMat4 wheel_rot;
|
||||||
@ -261,7 +316,7 @@ void KartModel::adjustWheels(float rotation, float steer,
|
|||||||
sgCopyVec3(wheel_rot[3], m_wheel_graphics_position[3].toFloat());
|
sgCopyVec3(wheel_rot[3], m_wheel_graphics_position[3].toFloat());
|
||||||
wheel_rot[3][2] += clamped_suspension[3];
|
wheel_rot[3][2] += clamped_suspension[3];
|
||||||
m_wheel_transform[3]->setTransform(wheel_rot);
|
m_wheel_transform[3]->setTransform(wheel_rot);
|
||||||
|
#endif
|
||||||
} // adjustWheels
|
} // adjustWheels
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -23,7 +23,12 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#define _WINSOCKAPI_
|
#define _WINSOCKAPI_
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#include "irrlicht.h"
|
||||||
|
using namespace irr;
|
||||||
|
#else
|
||||||
#include <plib/ssg.h>
|
#include <plib/ssg.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "no_copy.hpp"
|
#include "no_copy.hpp"
|
||||||
#include "lisp/lisp.hpp"
|
#include "lisp/lisp.hpp"
|
||||||
@ -37,8 +42,13 @@
|
|||||||
class KartModel
|
class KartModel
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
/** The mesh of the model. */
|
||||||
|
scene::IMesh *m_mesh;
|
||||||
|
#else
|
||||||
/** The transform node/root of the kart model. */
|
/** The transform node/root of the kart model. */
|
||||||
ssgTransform *m_root;
|
ssgTransform *m_root;
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Value used to indicate undefined entries. */
|
/** Value used to indicate undefined entries. */
|
||||||
static float UNDEFINED;
|
static float UNDEFINED;
|
||||||
@ -46,8 +56,13 @@ private:
|
|||||||
/** Name of the 3d model file. */
|
/** Name of the 3d model file. */
|
||||||
std::string m_model_filename;
|
std::string m_model_filename;
|
||||||
|
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
/** The four wheel models. */
|
||||||
|
scene::IMesh *m_wheel_model[4];
|
||||||
|
#else
|
||||||
/** The four wheel models. */
|
/** The four wheel models. */
|
||||||
ssgEntity *m_wheel_model[4];
|
ssgEntity *m_wheel_model[4];
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Filename of the wheel models. */
|
/** Filename of the wheel models. */
|
||||||
std::string m_wheel_filename[4];
|
std::string m_wheel_filename[4];
|
||||||
@ -73,10 +88,15 @@ private:
|
|||||||
/** value used to divide the visual movement of wheels (because the actual movement
|
/** value used to divide the visual movement of wheels (because the actual movement
|
||||||
of wheels in bullet is too large and looks strange). 1=no change, 2=half the amplitude */
|
of wheels in bullet is too large and looks strange). 1=no change, 2=half the amplitude */
|
||||||
float m_dampen_suspension_amplitude[4];
|
float m_dampen_suspension_amplitude[4];
|
||||||
|
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
/** The transform for the wheels, used to rotate the wheels and display
|
||||||
|
* the suspension in the race. */
|
||||||
|
#else
|
||||||
/** The transform for the wheels, used to rotate the wheels and display
|
/** The transform for the wheels, used to rotate the wheels and display
|
||||||
* the suspension in the race. */
|
* the suspension in the race. */
|
||||||
ssgTransform *m_wheel_transform[4];
|
ssgTransform *m_wheel_transform[4];
|
||||||
|
#endif
|
||||||
|
|
||||||
float m_kart_width; /**< Width of kart. */
|
float m_kart_width; /**< Width of kart. */
|
||||||
float m_kart_length; /**< Length of kart. */
|
float m_kart_length; /**< Length of kart. */
|
||||||
@ -91,8 +111,12 @@ public:
|
|||||||
KartModel();
|
KartModel();
|
||||||
~KartModel();
|
~KartModel();
|
||||||
void loadInfo(const lisp::Lisp* lisp);
|
void loadInfo(const lisp::Lisp* lisp);
|
||||||
void loadModels();
|
void loadModels(const std::string &kart_ident);
|
||||||
ssgTransform *getRoot() { return m_root; }
|
#ifdef HAVE_IRRLICHT
|
||||||
|
void attachModel(scene::ISceneNode **node);
|
||||||
|
#else
|
||||||
|
ssgTransform *getRoot() const { return m_root; }
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Returns the position of a wheel relative to the kart.
|
/** Returns the position of a wheel relative to the kart.
|
||||||
* \param i Index of the wheel: 0=front right, 1 = front left, 2 = rear
|
* \param i Index of the wheel: 0=front right, 1 = front left, 2 = rear
|
||||||
@ -108,9 +132,6 @@ public:
|
|||||||
const Vec3& getWheelPhysicsPosition(int i) const
|
const Vec3& getWheelPhysicsPosition(int i) const
|
||||||
{return m_wheel_physics_position[i];}
|
{return m_wheel_physics_position[i];}
|
||||||
|
|
||||||
/** Returns the model of a wheel. */
|
|
||||||
ssgEntity *getWheelModel(int i) const {return m_wheel_model[i];}
|
|
||||||
|
|
||||||
/** Returns the radius of the graphical wheels.
|
/** Returns the radius of the graphical wheels.
|
||||||
* \param i Index of the wheel: 0=front right, 1 = front left, 2 = rear
|
* \param i Index of the wheel: 0=front right, 1 = front left, 2 = rear
|
||||||
* right, 3 = rear left. */
|
* right, 3 = rear left. */
|
||||||
|
@ -142,7 +142,7 @@ void KartProperties::load(const std::string &filename, const std::string &node,
|
|||||||
// Only load the model if the .kart file has the appropriate version,
|
// Only load the model if the .kart file has the appropriate version,
|
||||||
// otherwise warnings are printed.
|
// otherwise warnings are printed.
|
||||||
if(m_version>=1)
|
if(m_version>=1)
|
||||||
m_kart_model.loadModels();
|
m_kart_model.loadModels(m_ident);
|
||||||
if(m_gravity_center_shift.getX()==UNDEFINED)
|
if(m_gravity_center_shift.getX()==UNDEFINED)
|
||||||
{
|
{
|
||||||
m_gravity_center_shift.setX(0);
|
m_gravity_center_shift.setX(0);
|
||||||
|
@ -77,7 +77,11 @@ void KartPropertiesManager::loadKartData(bool dont_load_models)
|
|||||||
std::string kart_file;
|
std::string kart_file;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
kart_file = file_manager->getKartFile((*i)+".irrkart");
|
||||||
|
#else
|
||||||
kart_file = file_manager->getKartFile((*i)+".kart");
|
kart_file = file_manager->getKartFile((*i)+".kart");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "material_manager.hpp"
|
#include "material_manager.hpp"
|
||||||
#include "material.hpp"
|
#include "material.hpp"
|
||||||
#include "user_config.hpp"
|
#include "user_config.hpp"
|
||||||
|
#include "graphics/irr_driver.hpp"
|
||||||
#include "karts/player_kart.hpp"
|
#include "karts/player_kart.hpp"
|
||||||
#include "utils/coord.hpp"
|
#include "utils/coord.hpp"
|
||||||
|
|
||||||
@ -31,9 +32,12 @@ Moveable::Moveable()
|
|||||||
m_body = 0;
|
m_body = 0;
|
||||||
m_motion_state = 0;
|
m_motion_state = 0;
|
||||||
m_first_time = true ;
|
m_first_time = true ;
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
m_mesh = 0;
|
||||||
|
#else
|
||||||
m_model_transform = new ssgTransform();
|
m_model_transform = new ssgTransform();
|
||||||
|
|
||||||
m_model_transform->ref();
|
m_model_transform->ref();
|
||||||
|
#endif
|
||||||
} // Moveable
|
} // Moveable
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -51,8 +55,11 @@ void Moveable::updateGraphics(const Vec3& off_xyz, const Vec3& off_hpr)
|
|||||||
Vec3 xyz=getXYZ()+off_xyz;
|
Vec3 xyz=getXYZ()+off_xyz;
|
||||||
Vec3 hpr=getHPR()+off_hpr;
|
Vec3 hpr=getHPR()+off_hpr;
|
||||||
sgCoord c=Coord(xyz, hpr).toSgCoord();
|
sgCoord c=Coord(xyz, hpr).toSgCoord();
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
m_root->setPosition(xyz.toIrrVector());
|
||||||
|
#else
|
||||||
m_model_transform->setTransform(&c);
|
m_model_transform->setTransform(&c);
|
||||||
|
#endif
|
||||||
} // updateGraphics
|
} // updateGraphics
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -22,8 +22,14 @@
|
|||||||
#define HEADER_MOVEABLE_HPP
|
#define HEADER_MOVEABLE_HPP
|
||||||
|
|
||||||
#define _WINSOCKAPI_
|
#define _WINSOCKAPI_
|
||||||
#include <plib/ssg.h>
|
#ifdef HAVE_IRRLICHT
|
||||||
|
# include "irrlicht.h"
|
||||||
|
using namespace irr;
|
||||||
|
#else
|
||||||
|
# include <plib/ssg.h>
|
||||||
|
#endif
|
||||||
#include "btBulletDynamicsCommon.h"
|
#include "btBulletDynamicsCommon.h"
|
||||||
|
|
||||||
#include "user_pointer.hpp"
|
#include "user_pointer.hpp"
|
||||||
#include "physics/kart_motion_state.hpp"
|
#include "physics/kart_motion_state.hpp"
|
||||||
#include "utils/vec3.hpp"
|
#include "utils/vec3.hpp"
|
||||||
@ -45,7 +51,13 @@ private:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
UserPointer m_user_pointer;
|
UserPointer m_user_pointer;
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
scene::IAnimatedMesh *m_animated_mesh;
|
||||||
|
scene::IMesh *m_mesh;
|
||||||
|
scene::ISceneNode *m_root;
|
||||||
|
#else
|
||||||
ssgTransform *m_model_transform; /**<The transform the model is attached to. */
|
ssgTransform *m_model_transform; /**<The transform the model is attached to. */
|
||||||
|
#endif
|
||||||
int m_first_time ;
|
int m_first_time ;
|
||||||
btRigidBody *m_body;
|
btRigidBody *m_body;
|
||||||
KartMotionState *m_motion_state;
|
KartMotionState *m_motion_state;
|
||||||
@ -53,9 +65,14 @@ protected:
|
|||||||
public:
|
public:
|
||||||
Moveable();
|
Moveable();
|
||||||
virtual ~Moveable();
|
virtual ~Moveable();
|
||||||
ssgTransform *getModelTransform() {return m_model_transform; }
|
#ifdef HAVE_IRRLICHT
|
||||||
|
scene::ISceneNode
|
||||||
|
*getRoot() {return m_root; }
|
||||||
|
#else
|
||||||
|
ssgTransform *getModelTransform() {return m_model_transform; }
|
||||||
|
#endif
|
||||||
virtual const btVector3
|
virtual const btVector3
|
||||||
&getVelocity() const {return m_body->getLinearVelocity();}
|
&getVelocity() const {return m_body->getLinearVelocity();}
|
||||||
const btVector3
|
const btVector3
|
||||||
&getVelocityLC() const {return m_velocityLC; }
|
&getVelocityLC() const {return m_velocityLC; }
|
||||||
virtual void setVelocity(const btVector3& v) {m_body->setLinearVelocity(v); }
|
virtual void setVelocity(const btVector3& v) {m_body->setLinearVelocity(v); }
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#ifndef HEADER_LOADER_H
|
#ifndef HEADER_LOADER_HPP
|
||||||
#define HEADER_LOADER_H
|
#define HEADER_LOADER_HPP
|
||||||
|
|
||||||
#define _WINSOCKAPI_
|
#define _WINSOCKAPI_
|
||||||
#include <plib/ssg.h>
|
#include <plib/ssg.h>
|
||||||
|
@ -230,7 +230,8 @@ int handleCmdLine(int argc, char **argv)
|
|||||||
fprintf(stdout, "Track %s has not been unlocked yet. \n", argv[i+1]);
|
fprintf(stdout, "Track %s has not been unlocked yet. \n", argv[i+1]);
|
||||||
fprintf(stdout, "Use --list-tracks to list available tracks.\n\n");
|
fprintf(stdout, "Use --list-tracks to list available tracks.\n\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
else if( (!strcmp(argv[i], "--stk-config")) && i+1<argc )
|
else if( (!strcmp(argv[i], "--stk-config")) && i+1<argc )
|
||||||
{
|
{
|
||||||
@ -441,8 +442,6 @@ void InitTuxkart()
|
|||||||
user_config = new UserConfig();
|
user_config = new UserConfig();
|
||||||
#ifdef HAVE_IRRLICHT
|
#ifdef HAVE_IRRLICHT
|
||||||
irr_driver = new IrrDriver();
|
irr_driver = new IrrDriver();
|
||||||
// Re-init file manager to use the new device.
|
|
||||||
file_manager->reInit();
|
|
||||||
#endif
|
#endif
|
||||||
loader = new Loader();
|
loader = new Loader();
|
||||||
loader->setCreateStateCallback(getAppState);
|
loader->setCreateStateCallback(getAppState);
|
||||||
@ -552,7 +551,9 @@ int main(int argc, char *argv[] )
|
|||||||
|
|
||||||
//FIXME: this needs a better organization
|
//FIXME: this needs a better organization
|
||||||
inputDriver = new SDLDriver ();
|
inputDriver = new SDLDriver ();
|
||||||
ssgInit () ;
|
#ifndef HAVE_IRRLICHT
|
||||||
|
ssgInit();
|
||||||
|
#endif
|
||||||
|
|
||||||
main_loop = new MainLoop();
|
main_loop = new MainLoop();
|
||||||
// loadMaterials needs ssgLoadTextures (internally), which can
|
// loadMaterials needs ssgLoadTextures (internally), which can
|
||||||
|
@ -21,15 +21,16 @@
|
|||||||
|
|
||||||
#include <SDL/SDL.h>
|
#include <SDL/SDL.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include "history.hpp"
|
||||||
#include "sdldrv.hpp"
|
#include "sdldrv.hpp"
|
||||||
#include "material_manager.hpp"
|
#include "material_manager.hpp"
|
||||||
#include "race_manager.hpp"
|
#include "race_manager.hpp"
|
||||||
#include "modes/world.hpp"
|
|
||||||
#include "user_config.hpp"
|
|
||||||
#include "history.hpp"
|
|
||||||
#include "audio/sound_manager.hpp"
|
#include "audio/sound_manager.hpp"
|
||||||
|
#include "graphics/irr_driver.hpp"
|
||||||
#include "graphics/scene.hpp"
|
#include "graphics/scene.hpp"
|
||||||
#include "gui/menu_manager.hpp"
|
#include "gui/menu_manager.hpp"
|
||||||
|
#include "modes/world.hpp"
|
||||||
|
#include "user_config.hpp"
|
||||||
#include "network/network_manager.hpp"
|
#include "network/network_manager.hpp"
|
||||||
|
|
||||||
MainLoop* main_loop = 0;
|
MainLoop* main_loop = 0;
|
||||||
@ -204,8 +205,12 @@ void MainLoop::run()
|
|||||||
menu_manager->update();
|
menu_manager->update();
|
||||||
sound_manager->update(dt);
|
sound_manager->update(dt);
|
||||||
|
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
irr_driver->update(dt);
|
||||||
|
#else
|
||||||
glFlush();
|
glFlush();
|
||||||
SDL_GL_SwapBuffers();
|
SDL_GL_SwapBuffers();
|
||||||
|
#endif
|
||||||
} // while !m_exit
|
} // while !m_exit
|
||||||
} // run
|
} // run
|
||||||
|
|
||||||
|
@ -141,10 +141,12 @@ void World::init()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} // if !user_config->m_profile
|
} // if !user_config->m_profile
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
newkart -> getModelTransform() -> clrTraversalMaskBits(SSGTRAV_ISECT|SSGTRAV_HOT);
|
newkart -> getModelTransform() -> clrTraversalMaskBits(SSGTRAV_ISECT|SSGTRAV_HOT);
|
||||||
|
|
||||||
stk_scene->add ( newkart -> getModelTransform() ) ;
|
stk_scene->add ( newkart -> getModelTransform() ) ;
|
||||||
|
#endif
|
||||||
m_kart.push_back(newkart);
|
m_kart.push_back(newkart);
|
||||||
newkart->setWorldKartId(m_kart.size()-1);
|
newkart->setWorldKartId(m_kart.size()-1);
|
||||||
} // for i
|
} // for i
|
||||||
|
@ -59,7 +59,11 @@ SDLDriver::SDLDriver()
|
|||||||
: m_sensed_input(0), m_action_map(0), m_main_surface(0), m_flags(0), m_stick_infos(0),
|
: m_sensed_input(0), m_action_map(0), m_main_surface(0), m_flags(0), m_stick_infos(0),
|
||||||
m_mode(BOOTSTRAP), m_mouse_val_x(0), m_mouse_val_y(0)
|
m_mode(BOOTSTRAP), m_mouse_val_x(0), m_mouse_val_y(0)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_TIMER) < 0)
|
||||||
|
#else
|
||||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_TIMER) < 0)
|
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_TIMER) < 0)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError());
|
fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError());
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -105,8 +109,9 @@ SDLDriver::SDLDriver()
|
|||||||
SDL_JoystickEventState(SDL_ENABLE);
|
SDL_JoystickEventState(SDL_ENABLE);
|
||||||
|
|
||||||
initStickInfos();
|
initStickInfos();
|
||||||
|
#ifndef HAVE_IRRLICHT
|
||||||
SDL_WM_SetCaption("SuperTuxKart", NULL);
|
SDL_WM_SetCaption("SuperTuxKart", NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Get into menu mode initially.
|
// Get into menu mode initially.
|
||||||
setMode(MENU);
|
setMode(MENU);
|
||||||
@ -255,6 +260,7 @@ void SDLDriver::toggleFullscreen(bool resetTextures)
|
|||||||
*/
|
*/
|
||||||
void SDLDriver::setVideoMode(bool resetTextures)
|
void SDLDriver::setVideoMode(bool resetTextures)
|
||||||
{
|
{
|
||||||
|
#ifndef HAVE_IRRLICHT
|
||||||
//Is SDL_FreeSurface necessary? SDL wiki says not??
|
//Is SDL_FreeSurface necessary? SDL wiki says not??
|
||||||
SDL_FreeSurface(m_main_surface);
|
SDL_FreeSurface(m_main_surface);
|
||||||
|
|
||||||
@ -299,7 +305,7 @@ void SDLDriver::setVideoMode(bool resetTextures)
|
|||||||
}
|
}
|
||||||
} // !m_main_surface
|
} // !m_main_surface
|
||||||
} // !m_main_surface
|
} // !m_main_surface
|
||||||
|
#endif
|
||||||
#if defined(WIN32) || defined(__APPLE__)
|
#if defined(WIN32) || defined(__APPLE__)
|
||||||
if(resetTextures)
|
if(resetTextures)
|
||||||
{
|
{
|
||||||
|
@ -24,7 +24,9 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#define _WINSOCKAPI_
|
#define _WINSOCKAPI_
|
||||||
#include <plib/ssgAux.h>
|
#include <plib/ssgAux.h>
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#include "irrlicht.h"
|
||||||
|
#endif
|
||||||
#include "file_manager.hpp"
|
#include "file_manager.hpp"
|
||||||
#include "loader.hpp"
|
#include "loader.hpp"
|
||||||
#include "stk_config.hpp"
|
#include "stk_config.hpp"
|
||||||
@ -32,6 +34,8 @@
|
|||||||
#include "isect.hpp"
|
#include "isect.hpp"
|
||||||
#include "user_config.hpp"
|
#include "user_config.hpp"
|
||||||
#include "audio/sound_manager.hpp"
|
#include "audio/sound_manager.hpp"
|
||||||
|
#include "graphics/irr_driver.hpp"
|
||||||
|
#include "graphics/mesh_tools.hpp"
|
||||||
#include "graphics/scene.hpp"
|
#include "graphics/scene.hpp"
|
||||||
#include "items/item.hpp"
|
#include "items/item.hpp"
|
||||||
#include "items/item_manager.hpp"
|
#include "items/item_manager.hpp"
|
||||||
@ -63,6 +67,10 @@ Track::Track( std::string filename_, float w, float h, bool stretch )
|
|||||||
m_screenshot = "";
|
m_screenshot = "";
|
||||||
m_top_view = "";
|
m_top_view = "";
|
||||||
m_version = 0;
|
m_version = 0;
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
m_all_nodes.clear();
|
||||||
|
m_all_meshes.clear();
|
||||||
|
#endif
|
||||||
m_has_final_camera = false;
|
m_has_final_camera = false;
|
||||||
m_is_arena = false;
|
m_is_arena = false;
|
||||||
loadTrack(m_filename);
|
loadTrack(m_filename);
|
||||||
@ -827,9 +835,9 @@ void Track::draw2Dview (float x_offset, float y_offset) const
|
|||||||
} // draw2Dview
|
} // draw2Dview
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Track::loadTrack(std::string filename_)
|
void Track::loadTrack(const std::string &filename)
|
||||||
{
|
{
|
||||||
m_filename = filename_;
|
m_filename = filename;
|
||||||
|
|
||||||
m_ident = StringUtils::basename(StringUtils::without_extension(m_filename));
|
m_ident = StringUtils::basename(StringUtils::without_extension(m_filename));
|
||||||
std::string path = StringUtils::without_extension(m_filename);
|
std::string path = StringUtils::without_extension(m_filename);
|
||||||
@ -1085,22 +1093,80 @@ Track::readDrivelineFromFile(std::vector<Vec3>& line, const std::string& file_ex
|
|||||||
//* Convert the ssg track tree into its physics equivalents.
|
//* Convert the ssg track tree into its physics equivalents.
|
||||||
void Track::createPhysicsModel()
|
void Track::createPhysicsModel()
|
||||||
{
|
{
|
||||||
|
#ifndef HAVE_IRRLICHT
|
||||||
if(!m_model) return;
|
if(!m_model) return;
|
||||||
|
#endif
|
||||||
|
|
||||||
m_track_mesh = new TriangleMesh();
|
m_track_mesh = new TriangleMesh();
|
||||||
m_non_collision_mesh = new TriangleMesh();
|
m_non_collision_mesh = new TriangleMesh();
|
||||||
|
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
convertTrackToBullet();
|
||||||
|
#else
|
||||||
// Collect all triangles in the track_mesh
|
// Collect all triangles in the track_mesh
|
||||||
sgMat4 mat;
|
sgMat4 mat;
|
||||||
sgMakeIdentMat4(mat);
|
sgMakeIdentMat4(mat);
|
||||||
convertTrackToBullet(m_model, mat);
|
convertTrackToBullet(m_model, mat);
|
||||||
m_track_mesh->createBody();
|
m_track_mesh->createBody();
|
||||||
|
#endif
|
||||||
m_non_collision_mesh->createBody(btCollisionObject::CF_NO_CONTACT_RESPONSE);
|
m_non_collision_mesh->createBody(btCollisionObject::CF_NO_CONTACT_RESPONSE);
|
||||||
|
|
||||||
} // createPhysicsModel
|
} // createPhysicsModel
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
//* Convert the ssg track tree into its physics equivalents.
|
//* Convert the ssg track tree into its physics equivalents.
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
void Track::convertTrackToBullet()
|
||||||
|
{
|
||||||
|
// 0: start line
|
||||||
|
// 1: left/right drivelines or so
|
||||||
|
// 2: road
|
||||||
|
// 3: zipper or collectables??
|
||||||
|
// 4: barriers
|
||||||
|
// 5: plane
|
||||||
|
for(unsigned int i=0; i<m_all_meshes.size(); i++)
|
||||||
|
{
|
||||||
|
const scene::IMesh *track = m_all_meshes[i];
|
||||||
|
for(unsigned int i=0; i<track->getMeshBufferCount(); i++) {
|
||||||
|
scene::IMeshBuffer *mb = track->getMeshBuffer(i);
|
||||||
|
// FIXME: take translation/rotation into accou
|
||||||
|
if(mb->getVertexType()!=video::EVT_STANDARD) {
|
||||||
|
fprintf(stderr, "WARNING: Physics::convertTrack: Ignoring type '%d'!",
|
||||||
|
mb->getVertexType());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
video::SMaterial irrMaterial=mb->getMaterial();
|
||||||
|
video::ITexture* t=irrMaterial.getTexture(0);
|
||||||
|
// FIXME: if no material is given, perhaps define a default?
|
||||||
|
const Material* material=0;
|
||||||
|
if(t) {
|
||||||
|
//material=g_MaterialManager->getMaterial(t->getName());
|
||||||
|
printf("%s\n",t->getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
u16 *mbIndices = mb->getIndices();
|
||||||
|
btVector3 vertices[3];
|
||||||
|
irr::video::S3DVertex* mbVertices=(irr::video::S3DVertex*)mb->getVertices();
|
||||||
|
for(unsigned int j=0; j<mb->getIndexCount(); j+=3) {
|
||||||
|
for(unsigned int k=0; k<3; k++) {
|
||||||
|
int indx=mbIndices[j+k];
|
||||||
|
// FIXME: notice: irrlicht's and STK's axis are different
|
||||||
|
// (STK: Z up, irrlicht: Y up). We might want to change
|
||||||
|
// this as well, makes it easier to work with bullet and
|
||||||
|
// irrlicht together, without having to swap indices.
|
||||||
|
vertices[k] = btVector3( mbVertices[indx].Pos.X,
|
||||||
|
mbVertices[indx].Pos.Z,
|
||||||
|
mbVertices[indx].Pos.Y );
|
||||||
|
} // for k
|
||||||
|
m_track_mesh->addTriangle(vertices[0], vertices[1], vertices[2], material);
|
||||||
|
} // for j
|
||||||
|
} // for i<getMeshBufferCount
|
||||||
|
} // for obj in children
|
||||||
|
m_track_mesh->createBody();
|
||||||
|
|
||||||
|
} // convertTrackToBullet
|
||||||
|
|
||||||
|
#else
|
||||||
void Track::convertTrackToBullet(ssgEntity *track, sgMat4 m)
|
void Track::convertTrackToBullet(ssgEntity *track, sgMat4 m)
|
||||||
{
|
{
|
||||||
if(!track) return;
|
if(!track) return;
|
||||||
@ -1166,7 +1232,7 @@ void Track::convertTrackToBullet(ssgEntity *track, sgMat4 m)
|
|||||||
assert(!"Unkown ssg type in convertTrackToBullet");
|
assert(!"Unkown ssg type in convertTrackToBullet");
|
||||||
}
|
}
|
||||||
} // convertTrackToBullet
|
} // convertTrackToBullet
|
||||||
|
#endif
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
void Track::loadTrackModel()
|
void Track::loadTrackModel()
|
||||||
{
|
{
|
||||||
@ -1184,7 +1250,11 @@ void Track::loadTrackModel()
|
|||||||
// no temporary materials.dat file, ignore
|
// no temporary materials.dat file, ignore
|
||||||
(void)e;
|
(void)e;
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
std::string path = file_manager->getTrackFile(getIdent()+".irrloc");
|
||||||
|
#else
|
||||||
std::string path = file_manager->getTrackFile(getIdent()+".loc");
|
std::string path = file_manager->getTrackFile(getIdent()+".loc");
|
||||||
|
#endif
|
||||||
|
|
||||||
FILE *fd = fopen (path.c_str(), "r" );
|
FILE *fd = fopen (path.c_str(), "r" );
|
||||||
if ( fd == NULL )
|
if ( fd == NULL )
|
||||||
@ -1195,8 +1265,11 @@ void Track::loadTrackModel()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start building the scene graph
|
// Start building the scene graph
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
m_model = new ssgBranch ;
|
m_model = new ssgBranch ;
|
||||||
stk_scene->add(m_model);
|
stk_scene->add(m_model);
|
||||||
|
#endif
|
||||||
|
|
||||||
char s [ 1024 ] ;
|
char s [ 1024 ] ;
|
||||||
|
|
||||||
@ -1359,10 +1432,11 @@ void Track::loadTrackModel()
|
|||||||
if ( need_hat )
|
if ( need_hat )
|
||||||
{
|
{
|
||||||
sgVec3 nrm ;
|
sgVec3 nrm ;
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
loc.xyz[2] = 1000.0f ;
|
loc.xyz[2] = 1000.0f ;
|
||||||
loc.xyz[2] = getHeightAndNormal ( m_model, loc.xyz, nrm ) ;
|
loc.xyz[2] = getHeightAndNormal ( m_model, loc.xyz, nrm ) ;
|
||||||
|
#endif
|
||||||
if ( fit_skin )
|
if ( fit_skin )
|
||||||
{
|
{
|
||||||
float sy = sin ( -loc.hpr [ 0 ] * SG_DEGREES_TO_RADIANS ) ;
|
float sy = sin ( -loc.hpr [ 0 ] * SG_DEGREES_TO_RADIANS ) ;
|
||||||
@ -1375,10 +1449,16 @@ void Track::loadTrackModel()
|
|||||||
}
|
}
|
||||||
} // if need_hat
|
} // if need_hat
|
||||||
|
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
std::string full_path = file_manager->getTrackFile(fname, getIdent());
|
||||||
|
scene::IAnimatedMesh *obj = irr_driver->getAnimatedMesh(full_path);
|
||||||
|
m_all_meshes.push_back(obj->getMesh(0));
|
||||||
|
#else
|
||||||
ssgEntity *obj = loader->load(file_manager->getModelFile(fname),
|
ssgEntity *obj = loader->load(file_manager->getModelFile(fname),
|
||||||
CB_TRACK,
|
CB_TRACK,
|
||||||
/* optimise */ true,
|
/* optimise */ true,
|
||||||
/*is_full_path*/ true);
|
/*is_full_path*/ true);
|
||||||
|
#endif
|
||||||
if(!obj)
|
if(!obj)
|
||||||
{
|
{
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
@ -1388,6 +1468,13 @@ void Track::loadTrackModel()
|
|||||||
file_manager->popModelSearchPath ();
|
file_manager->popModelSearchPath ();
|
||||||
throw std::runtime_error(msg.str());
|
throw std::runtime_error(msg.str());
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
// FIXME: for now only static objects
|
||||||
|
scene::ISceneNode *node = irr_driver->addOctTree(obj->getMesh(0));
|
||||||
|
m_all_nodes.push_back(node);
|
||||||
|
node->setMaterialFlag(video::EMF_LIGHTING, false);
|
||||||
|
|
||||||
|
#else
|
||||||
SSGHelp::createDisplayLists(obj);
|
SSGHelp::createDisplayLists(obj);
|
||||||
ssgRangeSelector *lod = new ssgRangeSelector ;
|
ssgRangeSelector *lod = new ssgRangeSelector ;
|
||||||
ssgTransform *trans = new ssgTransform ( & loc ) ;
|
ssgTransform *trans = new ssgTransform ( & loc ) ;
|
||||||
@ -1398,6 +1485,7 @@ void Track::loadTrackModel()
|
|||||||
trans -> addKid(lod );
|
trans -> addKid(lod );
|
||||||
m_model-> addKid(trans );
|
m_model-> addKid(trans );
|
||||||
lod -> setRanges(r, 2);
|
lod -> setRanges(r, 2);
|
||||||
|
#endif
|
||||||
if(user_config->m_track_debug)
|
if(user_config->m_track_debug)
|
||||||
addDebugToScene(user_config->m_track_debug);
|
addDebugToScene(user_config->m_track_debug);
|
||||||
|
|
||||||
@ -1414,7 +1502,12 @@ void Track::loadTrackModel()
|
|||||||
file_manager->popModelSearchPath ();
|
file_manager->popModelSearchPath ();
|
||||||
|
|
||||||
Vec3 min, max;
|
Vec3 min, max;
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
// FIXME: for now assume that mesh 0 is the actual track.
|
||||||
|
MeshTools::minMax3D(m_all_meshes[0], &min, &max);
|
||||||
|
#else
|
||||||
SSGHelp::MinMax(m_model, &min, &max);
|
SSGHelp::MinMax(m_model, &min, &max);
|
||||||
|
#endif
|
||||||
RaceManager::getWorld()->getPhysics()->init(min, max);
|
RaceManager::getWorld()->getPhysics()->init(min, max);
|
||||||
createPhysicsModel();
|
createPhysicsModel();
|
||||||
} // loadTrack
|
} // loadTrack
|
||||||
@ -1427,7 +1520,10 @@ void Track::itemCommand (sgVec3 *xyz, int type, int bNeedHeight )
|
|||||||
if(bNeedHeight) (*xyz)[2] = 1000000.0f;
|
if(bNeedHeight) (*xyz)[2] = 1000000.0f;
|
||||||
|
|
||||||
// Even if 3d data are given, make sure that the item is on the ground
|
// Even if 3d data are given, make sure that the item is on the ground
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
(*xyz)[2] = getHeight( m_model, *xyz ) + 0.06f;
|
(*xyz)[2] = getHeight( m_model, *xyz ) + 0.06f;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Some modes (e.g. time trial) don't have any bonus boxes
|
// Some modes (e.g. time trial) don't have any bonus boxes
|
||||||
if(type==ITEM_BONUS_BOX && !RaceManager::getWorld()->enableBonusBoxes())
|
if(type==ITEM_BONUS_BOX && !RaceManager::getWorld()->enableBonusBoxes())
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#ifndef HEADER_TRACK_H
|
#ifndef HEADER_TRACK_HPP
|
||||||
#define HEADER_TRACK_H
|
#define HEADER_TRACK_HPP
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
# include <OpenGL/gl.h>
|
# include <OpenGL/gl.h>
|
||||||
@ -29,6 +29,10 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <plib/sg.h>
|
#include <plib/sg.h>
|
||||||
#include <plib/ssg.h>
|
#include <plib/ssg.h>
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#include "irrlicht.h"
|
||||||
|
using namespace irr;
|
||||||
|
#endif
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "LinearMath/btTransform.h"
|
#include "LinearMath/btTransform.h"
|
||||||
@ -52,7 +56,12 @@ private:
|
|||||||
std::string m_designer;
|
std::string m_designer;
|
||||||
std::string m_filename;
|
std::string m_filename;
|
||||||
std::vector<std::string> m_groups;
|
std::vector<std::string> m_groups;
|
||||||
ssgBranch* m_model;
|
#ifdef HAVE_IRRLICHT
|
||||||
|
std::vector<scene::ISceneNode*> m_all_nodes;
|
||||||
|
std::vector<scene::IMesh*> m_all_meshes;
|
||||||
|
#else
|
||||||
|
ssgBranch *m_model;
|
||||||
|
#endif
|
||||||
TriangleMesh* m_track_mesh;
|
TriangleMesh* m_track_mesh;
|
||||||
TriangleMesh* m_non_collision_mesh;
|
TriangleMesh* m_non_collision_mesh;
|
||||||
bool m_has_final_camera;
|
bool m_has_final_camera;
|
||||||
@ -154,7 +163,10 @@ public:
|
|||||||
bool isShortcut (const int OLDSEC, const int NEWSEC) const;
|
bool isShortcut (const int OLDSEC, const int NEWSEC) const;
|
||||||
void addMusic (MusicInformation* mi)
|
void addMusic (MusicInformation* mi)
|
||||||
{m_music.push_back(mi); }
|
{m_music.push_back(mi); }
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#else
|
||||||
ssgBranch* getModel () const {return m_model; }
|
ssgBranch* getModel () const {return m_model; }
|
||||||
|
#endif
|
||||||
float getGravity () const {return m_gravity; }
|
float getGravity () const {return m_gravity; }
|
||||||
/** Returns the version of the .track file. */
|
/** Returns the version of the .track file. */
|
||||||
int getVersion () const {return m_version; }
|
int getVersion () const {return m_version; }
|
||||||
@ -196,13 +208,16 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void loadTrack (std::string filename);
|
void loadTrack (const std::string &filename);
|
||||||
void itemCommand (sgVec3 *xyz, int item_type, int bNeedHeight);
|
void itemCommand (sgVec3 *xyz, int item_type, int bNeedHeight);
|
||||||
void loadDriveline ();
|
void loadDriveline ();
|
||||||
void readDrivelineFromFile (std::vector<Vec3>& line,
|
void readDrivelineFromFile (std::vector<Vec3>& line,
|
||||||
const std::string& file_ext);
|
const std::string& file_ext);
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
void convertTrackToBullet ();
|
||||||
|
#else
|
||||||
void convertTrackToBullet (ssgEntity *track, sgMat4 m);
|
void convertTrackToBullet (ssgEntity *track, sgMat4 m);
|
||||||
|
#endif
|
||||||
float pointSideToLine(const Vec3& L1, const Vec3& L2,
|
float pointSideToLine(const Vec3& L1, const Vec3& L2,
|
||||||
const Vec3& P ) const;
|
const Vec3& P ) const;
|
||||||
int pointInQuad(const Vec3& A, const Vec3& B,
|
int pointInQuad(const Vec3& A, const Vec3& B,
|
||||||
|
@ -131,7 +131,11 @@ void TrackManager::loadTrackList ()
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// getTrackFile appends dir, so it's opening: *dir/*dir.track
|
// getTrackFile appends dir, so it's opening: *dir/*dir.track
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
config_file = file_manager->getTrackFile((*dir)+".irrtrack");
|
||||||
|
#else
|
||||||
config_file = file_manager->getTrackFile((*dir)+".track");
|
config_file = file_manager->getTrackFile((*dir)+".track");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
|
@ -14,9 +14,13 @@
|
|||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
#ifndef HEADER_VEC3_H
|
#ifndef HEADER_VEC3_HPP
|
||||||
#define HEADER_VEC3_H
|
#define HEADER_VEC3_HPP
|
||||||
|
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
#include "irrlicht.h"
|
||||||
|
using namespace irr;
|
||||||
|
#endif
|
||||||
#define _WINSOCKAPI_
|
#define _WINSOCKAPI_
|
||||||
#include <plib/sg.h>
|
#include <plib/sg.h>
|
||||||
|
|
||||||
@ -28,8 +32,11 @@
|
|||||||
class Vec3 : public btVector3
|
class Vec3 : public btVector3
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
core::vector3df m_irr_vector;
|
||||||
|
#endif
|
||||||
inline float clampToUnity(float f) {return f<-1?f:(f>1?1:f);}
|
inline float clampToUnity(float f) {return f<-1?f:(f>1?1:f);}
|
||||||
void setPitchRoll(const Vec3 &normal);
|
void setPitchRoll(const Vec3 &normal);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline Vec3(sgVec3 a) : btVector3(a[0], a[1], a[2]) {}
|
inline Vec3(sgVec3 a) : btVector3(a[0], a[1], a[2]) {}
|
||||||
@ -54,6 +61,14 @@ public:
|
|||||||
inline const void setPitch(float f) {m_y = f;}
|
inline const void setPitch(float f) {m_y = f;}
|
||||||
inline const void setRoll(float f) {m_z = f;}
|
inline const void setRoll(float f) {m_z = f;}
|
||||||
float* toFloat() const {return (float*)this; }
|
float* toFloat() const {return (float*)this; }
|
||||||
|
#ifdef HAVE_IRRLICHT
|
||||||
|
/** Converts a Vec3 to an irrlicht 3d floating point vector. */
|
||||||
|
const core::vector3df &toIrrVector()
|
||||||
|
{
|
||||||
|
m_irr_vector.set(m_x, m_z, m_y);
|
||||||
|
return m_irr_vector;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
void degreeToRad();
|
void degreeToRad();
|
||||||
Vec3& operator=(const btVector3& a) {*(btVector3*)this=a; return *this;}
|
Vec3& operator=(const btVector3& a) {*(btVector3*)this=a; return *this;}
|
||||||
Vec3& operator=(const btMatrix3x3& m) {setHPR(m); return *this;}
|
Vec3& operator=(const btMatrix3x3& m) {setHPR(m); return *this;}
|
||||||
|
Loading…
Reference in New Issue
Block a user