Add snow flakes to Snow Mountain. Still to be improved

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7403 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2011-01-14 01:31:15 +00:00
parent 4a41af8088
commit f7bcc2a6a5
6 changed files with 101 additions and 16 deletions

32
data/snow.xml Normal file
View File

@ -0,0 +1,32 @@
<?xml version="1.0"?>
<!-- For sky particles, the size of the box is ignored -->
<particles emitter="box">
<spreading angle="3" />
<velocity x="0.0"
y="-0.01"
z="0.0" />
<material file="snowflake.png"/>
<!-- Amount of particles emitted per second -->
<rate min="800"
max="900" />
<!-- Minimal and maximal lifetime of a particle, in milliseconds. -->
<lifetime min="5000"
max="6000" />
<!-- Size of the particles -->
<size min="0.40"
max="0.60" />
<color min="255 255 255"
max="255 255 255" />
<!-- How much time in milliseconds before the particle is fully faded out -->
<fadeout time="100" />
</particles>

View File

@ -37,7 +37,7 @@ class ParticleEmitter : public NoCopy
private:
/** Irrlicht's particle systems. */
scene::IParticleSystemSceneNode *m_node; /* left wheel */
scene::IParticleSystemSceneNode *m_node;
core::vector3df m_position;
@ -62,6 +62,8 @@ public:
const ParticleKind* getParticlesInfo() const { return m_particle_type; }
void setParticleType(const ParticleKind* p);
scene::IParticleSystemSceneNode* getNode() { return m_node; }
};
#endif

View File

@ -47,7 +47,7 @@ ParticleKind::ParticleKind(const std::string file) : m_min_start_color(255,255,2
m_velocity_x = 0.001f;
m_velocity_y = 0.001f;
m_velocity_z = 0.001f;
m_gravity_strength = -0.03f;
m_gravity_strength = 0.0f;
m_force_lost_to_gravity_time = 1000;

View File

@ -125,7 +125,11 @@ public:
/** Get the time it takes for gravity to completely replace the emission force. Meaningless if gravity is disabled. */
int getForceLostToGravityTime() const { return m_force_lost_to_gravity_time; }
void setBoxSizeX (float newVal) { m_box_x = newVal; }
void setBoxSizeY (float newVal) { m_box_y = newVal; }
void setBoxSizeZ (float newVal) { m_box_z = newVal; }
};
#endif

View File

@ -36,6 +36,9 @@ using namespace irr;
#include "graphics/material_manager.hpp"
#include "graphics/mesh_tools.hpp"
#include "graphics/moving_texture.hpp"
#include "graphics/particle_emitter.hpp"
#include "graphics/particle_kind.hpp"
#include "graphics/particle_kind_manager.hpp"
#include "io/file_manager.hpp"
#include "io/xml_node.hpp"
#include "items/item.hpp"
@ -59,22 +62,24 @@ const float Track::NOHIT = -99999.9f;
// ----------------------------------------------------------------------------
Track::Track(std::string filename)
{
m_filename = filename;
m_root = StringUtils::getPath(StringUtils::removeExtension(m_filename));
m_ident = StringUtils::getBasename(m_root);
m_designer = "";
m_screenshot = "";
m_version = 0;
m_track_mesh = new TriangleMesh();
m_filename = filename;
m_root = StringUtils::getPath(StringUtils::removeExtension(m_filename));
m_ident = StringUtils::getBasename(m_root);
m_designer = "";
m_screenshot = "";
m_version = 0;
m_track_mesh = new TriangleMesh();
m_all_nodes.clear();
m_all_meshes.clear();
m_is_arena = false;
m_camera_far = 1000.0f;
m_quad_graph = NULL;
m_check_manager = NULL;
m_mini_map = NULL;
m_sky_dx = 0.05f;
m_sky_dy = 0.0f;
m_is_arena = false;
m_camera_far = 1000.0f;
m_quad_graph = NULL;
m_check_manager = NULL;
m_mini_map = NULL;
m_sky_particles = NULL;
m_sky_particles_emitter = NULL;
m_sky_dx = 0.05f;
m_sky_dy = 0.0f;
loadTrackInfo();
} // Track
@ -85,6 +90,7 @@ Track::~Track()
if(m_quad_graph) delete m_quad_graph;
if(m_check_manager) delete m_check_manager;
if(m_mini_map) irr_driver->removeTexture(m_mini_map);
if(m_sky_particles_emitter) delete m_sky_particles_emitter;
delete m_track_mesh;
} // ~Track
@ -947,6 +953,7 @@ void Track::loadTrackModel(World* parent, unsigned int mode_id)
parent->setClearbackBufferColor(m_sky_color);
}
file_manager->popTextureSearchPath();
file_manager->popModelSearchPath ();
@ -975,6 +982,20 @@ void Track::loadTrackModel(World* parent, unsigned int mode_id)
createPhysicsModel(main_track_count);
if (UserConfigParams::m_track_debug) m_quad_graph->createDebugMesh();
if (UserConfigParams::m_graphical_effects && m_sky_particles != NULL)
{
const float x = (m_aabb_max.getX() + m_aabb_min.getX())/2.0f;
const float z = (m_aabb_max.getZ() + m_aabb_min.getZ())/2.0f;
const float size_x = m_aabb_max.getX() - m_aabb_min.getX();
const float size_z = m_aabb_max.getZ() - m_aabb_min.getZ();
m_sky_particles->setBoxSizeX(size_x);
m_sky_particles->setBoxSizeZ(size_z);
// FIXME: don't hardcode height
printf("&&&& %f %f\n", m_aabb_min.getY(), m_aabb_max.getY());
m_sky_particles_emitter = new ParticleEmitter(m_sky_particles, core::vector3df(x, 25.0f, z));
}
// Only print warning if not in battle mode, since battle tracks don't have
// any quads or check lines.
if(!m_check_manager && race_manager->getMinorMode()!=RaceManager::MINOR_MODE_3_STRIKES)
@ -1021,6 +1042,13 @@ void Track::handleSky(const XMLNode &xml_node, const std::string &filename)
xml_node.get("texture-percent", &m_sky_texture_percent);
xml_node.get("speed-x", &m_sky_dx );
xml_node.get("speed-y", &m_sky_dy);
std::string sky_particles;
xml_node.get("particles", &sky_particles);
if (sky_particles.size() > 0)
{
m_sky_particles = ParticleKindManager::get()->getParticles(sky_particles.c_str());
}
} // if sky-dome
else if(xml_node.getName()=="sky-box")
@ -1039,12 +1067,25 @@ void Track::handleSky(const XMLNode &xml_node, const std::string &filename)
{
m_sky_type = SKY_BOX;
}
std::string sky_particles;
xml_node.get("particles", &sky_particles);
if (sky_particles.size() > 0)
{
m_sky_particles = ParticleKindManager::get()->getParticles(sky_particles.c_str());
}
}
else if (xml_node.getName() == "sky-color")
{
m_sky_type = SKY_COLOR;
xml_node.get("rgb", &m_sky_color);
std::string sky_particles;
xml_node.get("particles", &sky_particles);
if (sky_particles.size() > 0)
{
m_sky_particles = ParticleKindManager::get()->getParticles(sky_particles.c_str());
}
} // if sky-box
} // handleSky

View File

@ -37,6 +37,7 @@ class AnimationManager;
class BezierCurve;
class CheckManager;
class MovingTexture;
class ParticleKind;
class PhysicalObject;
class TrackObjectManager;
class TriangleMesh;
@ -119,6 +120,11 @@ private:
/** If a sky dome is used, percentage of the texture to be used. */
float m_sky_texture_percent;
/** Particles emitted from the sky (e.g. rain or snow) */
ParticleKind* m_sky_particles;
ParticleEmitter* m_sky_particles_emitter;
/** A simple class to keep information about a track mode. */
class TrackMode
{