Added the ability to specify a case color (fixed mine to have black clear color). Not supported yet by track exporter

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5084 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2010-03-27 19:19:09 +00:00
parent 56f77a2d49
commit ada40cf7a3
5 changed files with 53 additions and 16 deletions

View File

@@ -768,11 +768,21 @@ void IrrDriver::update(float dt)
World *world = World::getWorld();
const bool inRace = world!=NULL;
// With bullet debug view we have to clear the back buffer, but
// that's not necessary for non-debug
bool back_buffer_clear = inRace && world->getPhysics()->isDebug();
m_device->getVideoDriver()->beginScene(back_buffer_clear,
true, video::SColor(255,100,101,140));
bool back_buffer_clear = inRace && (world->getPhysics()->isDebug() || world->clearBackBuffer());
if (world != NULL)
{
m_device->getVideoDriver()->beginScene(back_buffer_clear,
true, world->getClearColor());
}
else
{
m_device->getVideoDriver()->beginScene(back_buffer_clear,
true, video::SColor(255,100,101,140));
}
{ // Just to mark the begin/end scene block
GUIEngine::GameState state = StateManager::get()->getGameState();

View File

@@ -74,13 +74,14 @@ World* World::m_world = NULL;
* after the constructor. Those functions must be called in the init()
* function, which is called immediately after the constructor.
*/
World::World() : WorldStatus()
World::World() : WorldStatus(), m_clear_color(255,100,101,140)
{
m_physics = NULL;
m_race_gui = NULL;
m_use_highscores = true;
m_track = NULL;
m_physics = NULL;
m_race_gui = NULL;
m_use_highscores = true;
m_track = NULL;
m_clear_back_buffer = false;
WorldStatus::setClockMode(CLOCK_CHRONO);
} // World
@@ -125,7 +126,7 @@ void World::init()
// Load the track models - this must be done before the karts so that the
// karts can be positioned properly on (and not in) the tracks.
m_track->loadTrackModel();
m_track->loadTrackModel(this);
for(unsigned int i=0; i<num_karts; i++)
{

View File

@@ -121,6 +121,10 @@ protected:
/** Pointer to the race GUI. The race GUI is handedl by world. */
RaceGUI *m_race_gui;
bool m_clear_back_buffer;
irr::video::SColor m_clear_color;
virtual void onGo();
/** Returns true if the race is over. Must be defined by all modes. */
virtual bool isRaceOver() = 0;
@@ -246,6 +250,13 @@ public:
* Array dimension must be the number of karts.
*/
virtual void raceResultOrder( int order[] ) = 0;
bool clearBackBuffer() const { return m_clear_back_buffer; }
const irr::video::SColor& getClearColor() const { return m_clear_color; }
void setClearBackBuffer(bool enabled) { m_clear_back_buffer = enabled; }
void setClearbackBufferColor(irr::video::SColor color) { m_clear_color = color; }
};
#endif

View File

@@ -625,7 +625,7 @@ void Track::createWater(const XMLNode &node)
* \param mode_id Which of the modes of a track to use. This determines which
* scene, quad, and graph file to load.
*/
void Track::loadTrackModel(unsigned int mode_id)
void Track::loadTrackModel(World* parent, unsigned int mode_id)
{
//m_is_arena = false;
m_track_object_manager = new TrackObjectManager();
@@ -733,14 +733,14 @@ void Track::loadTrackModel(unsigned int mode_id)
node->get("fog-start", &m_fog_start);
node->get("fog-end", &m_fog_end);
}
else if(name=="sky-dome" || name=="sky-box")
else if(name=="sky-dome" || name=="sky-box" || name=="sky-color")
{
handleSky(*node, path);
}
else
{
fprintf(stderr, "Warning: element '%s' not found.\n",
node->getName().c_str());
fprintf(stderr, "Warning: while loading track '%s', element '%s' was met but is unknown.\n",
m_ident.c_str(), node->getName().c_str());
}
}
@@ -776,6 +776,11 @@ void Track::loadTrackModel(unsigned int mode_id)
{
m_all_nodes.push_back(irr_driver->addSkyBox(m_sky_textures));
}
else if(m_sky_type==SKY_COLOR)
{
parent->setClearBackBuffer(true);
parent->setClearbackBufferColor(m_sky_color);
}
file_manager->popTextureSearchPath();
file_manager->popModelSearchPath ();
@@ -857,6 +862,12 @@ void Track::handleSky(const XMLNode &xml_node, const std::string &filename)
{
m_sky_type = SKY_BOX;
}
}
else if (xml_node.getName() == "sky-color")
{
m_sky_type = SKY_COLOR;
xml_node.get("rgb", &m_sky_color);
} // if sky-box
} // handleSky

View File

@@ -48,6 +48,7 @@ class MovingTexture;
class PhysicalObject;
class TrackObjectManager;
class TriangleMesh;
class World;
class XMLNode;
class Track
@@ -91,12 +92,15 @@ private:
/** The type of sky to be used for the track. */
enum {SKY_NONE, SKY_BOX,
SKY_DOME} m_sky_type;
SKY_DOME, SKY_COLOR} m_sky_type;
/** A list of the textures for the sky to use. It contains one texture
* in case of a dome, and 6 textures for a box. */
std::vector<std::string> m_sky_textures;
/** Used if m_sky_type is SKY_COLOR only */
irr::video::SColor m_sky_color;
/** The list of all animated textures. */
std::vector<MovingTexture*> m_animated_textures;
@@ -181,7 +185,7 @@ public:
/** Returns the texture with the mini map for this track. */
const video::ITexture*getMiniMap () const { return m_mini_map; }
const Vec3& trackToSpatial (const int SECTOR) const;
void loadTrackModel (unsigned int mode_id=0);
void loadTrackModel (World* parent, unsigned int mode_id=0);
void addMusic (MusicInformation* mi)
{m_music.push_back(mi); }
float getGravity () const {return m_gravity; }