Add gravity to particles, use gravity for water splash + fix camera modes like look back
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7378 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
9aaab2e6ae
commit
7a81498f19
@ -14,8 +14,8 @@
|
||||
max="1200" />
|
||||
|
||||
<!-- Minimal and maximal lifetime of a particle, in milliseconds. -->
|
||||
<lifetime min="600"
|
||||
max="900" />
|
||||
<lifetime min="1600"
|
||||
max="1900" />
|
||||
|
||||
<!-- Size of the particles -->
|
||||
<size min="0.60"
|
||||
@ -27,4 +27,6 @@
|
||||
<!-- How much time in milliseconds before the particle is fully faded out -->
|
||||
<fadeout time="500" />
|
||||
|
||||
<gravity strength="-0.01"
|
||||
only-force-time="1000" />
|
||||
</particles>
|
||||
|
@ -209,4 +209,12 @@ void ParticleEmitter::setParticleType(const ParticleKind* type)
|
||||
type->getFadeoutTime());
|
||||
m_node->addAffector(af);
|
||||
af->drop();
|
||||
|
||||
if (type->getGravityStrength() != 0)
|
||||
{
|
||||
scene::IParticleGravityAffector *gaf = m_node->createGravityAffector(core::vector3df(00.0f, type->getGravityStrength(), 0.0f),
|
||||
type->getForceLostToGravityTime());
|
||||
m_node->addAffector(gaf);
|
||||
gaf->drop();
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,9 @@ 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_force_lost_to_gravity_time = 1000;
|
||||
|
||||
|
||||
// ----- Read XML file
|
||||
|
||||
@ -189,6 +192,14 @@ ParticleKind::ParticleKind(const std::string file) : m_min_start_color(255,255,2
|
||||
|
||||
//std::cout << "m_fadeout_time = " << m_fadeout_time << "\n";
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
const XMLNode* gravity = xml->getNode("gravity");
|
||||
if (gravity != NULL)
|
||||
{
|
||||
gravity->get("strength", &m_gravity_strength);
|
||||
gravity->get("only-force-time", &m_force_lost_to_gravity_time);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
delete xml;
|
||||
|
@ -71,6 +71,12 @@ private:
|
||||
video::SColor m_min_start_color;
|
||||
video::SColor m_max_start_color;
|
||||
|
||||
/** Strength of gravity, not sure what the units are. Make it 0 to disable */
|
||||
float m_gravity_strength;
|
||||
|
||||
/** Time it takes for gravity to completely replace the emission force */
|
||||
int m_force_lost_to_gravity_time;
|
||||
|
||||
/** For box emitters only */
|
||||
float m_box_x, m_box_y, m_box_z;
|
||||
|
||||
@ -112,6 +118,13 @@ public:
|
||||
float getVelocityX () const { return m_velocity_x; }
|
||||
float getVelocityY () const { return m_velocity_y; }
|
||||
float getVelocityZ () const { return m_velocity_z; }
|
||||
|
||||
/** Get the strength of gravity, not sure what the units are. Will be 0 if disabled. */
|
||||
float getGravityStrength() const { return m_gravity_strength; }
|
||||
|
||||
/** 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; }
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -1656,7 +1656,11 @@ void Kart::updateGraphics(const Vec3& offset_xyz,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_camera != NULL) m_camera->setFallMode(false);
|
||||
if (m_camera != NULL && m_camera->getMode() == Camera::CM_FALLING)
|
||||
{
|
||||
m_camera->setFallMode(false);
|
||||
}
|
||||
|
||||
m_water_splash_system->setCreationRate(0);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user