Nitro effect improved
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12926 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
f7d6f9e104
commit
ac79047804
@ -54,6 +54,7 @@ AbstractKart::AbstractKart(const std::string& ident,
|
||||
m_kart_height = m_kart_model->getHeight();
|
||||
m_kart_length = m_kart_model->getLength();
|
||||
m_wheel_graphics_position = m_kart_model->getWheelsGraphicsPosition();
|
||||
m_nitro_emitter_position = m_kart_model->getNitroEmittersPositon();
|
||||
} // AbstractKart
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -53,6 +53,8 @@ private:
|
||||
float m_kart_height;
|
||||
/** The position of all four wheels in the 3d model */
|
||||
const Vec3* m_wheel_graphics_position;
|
||||
/** The position of all nitro emitters in the 3d model */
|
||||
const Vec3* m_nitro_emitter_position;
|
||||
|
||||
/** Index of kart in world. */
|
||||
unsigned int m_world_kart_id;
|
||||
@ -155,6 +157,10 @@ public:
|
||||
* right, 3 = rear left. */
|
||||
const Vec3& getWheelGraphicsPosition(int i) const
|
||||
{assert(i>=0 && i<4); return m_wheel_graphics_position[i];}
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the position of a nitro emitter relative to the kart */
|
||||
const Vec3& getNitroEmitterPosition(int i) const
|
||||
{assert(i>=0 && i<2); return m_nitro_emitter_position[i];}
|
||||
|
||||
// ========================================================================
|
||||
// Emergency animation related functions.
|
||||
|
@ -2241,11 +2241,16 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz,
|
||||
// The speed of the kart can be higher (due to powerups) than
|
||||
// the normal maximum speed of the kart.
|
||||
if(f>1.0f) f = 1.0f;
|
||||
m_kart_gfx->setCreationRateRelative(KartGFX::KGFX_NITRO, f);
|
||||
m_kart_gfx->setCreationRateRelative(KartGFX::KGFX_NITRO1, f);
|
||||
m_kart_gfx->setCreationRateRelative(KartGFX::KGFX_NITRO2, f);
|
||||
}
|
||||
else
|
||||
m_kart_gfx->setCreationRateAbsolute(KartGFX::KGFX_NITRO, 0);
|
||||
m_kart_gfx->resizeBox(KartGFX::KGFX_NITRO, getSpeed(), dt);
|
||||
{
|
||||
m_kart_gfx->setCreationRateAbsolute(KartGFX::KGFX_NITRO1, 0);
|
||||
m_kart_gfx->setCreationRateAbsolute(KartGFX::KGFX_NITRO2, 0);
|
||||
}
|
||||
m_kart_gfx->resizeBox(KartGFX::KGFX_NITRO1, getSpeed(), dt);
|
||||
m_kart_gfx->resizeBox(KartGFX::KGFX_NITRO2, getSpeed(), dt);
|
||||
|
||||
m_kart_gfx->resizeBox(KartGFX::KGFX_ZIPPER, getSpeed(), dt);
|
||||
|
||||
|
@ -41,12 +41,14 @@ KartGFX::KartGFX(const AbstractKart *kart)
|
||||
|
||||
m_kart = kart;
|
||||
/*
|
||||
// FIXME Old Positioning system Maybe usefull for another effect
|
||||
// FIXME Old Positioning system Maybe usefull for a future effect
|
||||
Vec3 rear_left(-(kart->getKartWidth()+0.20f)*0.35f, (kart->getKartHeight()-0.6f)*0.35f,
|
||||
-kart->getKartLength()*0.35f);
|
||||
|
||||
Vec3 rear_right((kart->getKartWidth()+0.20f)*0.35f, (kart->getKartHeight()-0.6f)*0.35f,
|
||||
-kart->getKartLength()*0.35f);
|
||||
|
||||
|
||||
*/
|
||||
Vec3 rear_left(kart->getWheelGraphicsPosition(3).toIrrVector().X, (kart->getKartHeight()-0.6f)*0.35f,
|
||||
kart->getWheelGraphicsPosition(3).toIrrVector().Z);
|
||||
@ -56,9 +58,20 @@ KartGFX::KartGFX(const AbstractKart *kart)
|
||||
Vec3 rear_center(0, kart->getKartHeight()*0.35f,
|
||||
-kart->getKartLength()*0.35f);
|
||||
|
||||
// FIXME Used to match the emitter as seen in blender
|
||||
float delta = 0.6;
|
||||
Vec3 rear_nitro_right(kart->getNitroEmitterPosition(0).toIrrVector().X,
|
||||
kart->getNitroEmitterPosition(0).toIrrVector().Y,
|
||||
kart->getNitroEmitterPosition(0).toIrrVector().Z + delta);
|
||||
|
||||
Vec3 rear_nitro_left(kart->getNitroEmitterPosition(1).toIrrVector().X,
|
||||
kart->getNitroEmitterPosition(1).toIrrVector().Y,
|
||||
kart->getNitroEmitterPosition(1).toIrrVector().Z + delta);
|
||||
|
||||
// Create all effects. Note that they must be created
|
||||
// in the order of KartGFXType.
|
||||
addEffect(KGFX_NITRO, "nitro.xml", rear_center);
|
||||
addEffect(KGFX_NITRO1, "nitro.xml", rear_nitro_right);
|
||||
addEffect(KGFX_NITRO2, "nitro.xml", rear_nitro_left);
|
||||
addEffect(KGFX_ZIPPER, "zipper_fire.xml", rear_center);
|
||||
addEffect(KGFX_TERRAIN, "smoke.xml", Vec3(0,0,0));
|
||||
addEffect(KGFX_SKID1L, "skid1.xml", rear_left);
|
||||
|
@ -39,7 +39,8 @@ public:
|
||||
* created. So KGFX_SKID1/2 store the two types, and KGFX_SKID
|
||||
* = KGFX_SKID1 stores the actual emitter node. KGFX_COUNT
|
||||
* is the number of entries and must therefore be last. */
|
||||
enum KartGFXType { KGFX_NITRO=0,
|
||||
enum KartGFXType { KGFX_NITRO1=0,
|
||||
KGFX_NITRO2,
|
||||
KGFX_ZIPPER,
|
||||
KGFX_TERRAIN,
|
||||
KGFX_SKIDL,
|
||||
|
@ -130,6 +130,20 @@ void KartModel::loadInfo(const XMLNode &node)
|
||||
loadWheelInfo(*wheels_node, "rear-right", 2);
|
||||
loadWheelInfo(*wheels_node, "rear-left", 3);
|
||||
}
|
||||
|
||||
// FIXME fallback for karts that don't have nitro emitter
|
||||
m_nitro_emitter_position[0] = Vec3 (0, m_kart_height*0.35f,
|
||||
-m_kart_length*0.35f);
|
||||
|
||||
m_nitro_emitter_position[1] = Vec3 (0, m_kart_height*0.35f,
|
||||
-m_kart_length*0.35f);
|
||||
|
||||
if(const XMLNode *nitroEmitter_node=node.getNode("nitro-emitter"))
|
||||
{
|
||||
loadNitroEmitterInfo(*nitroEmitter_node, "nitro-emitter-a", 0);
|
||||
loadNitroEmitterInfo(*nitroEmitter_node, "nitro-emitter-b", 1);
|
||||
}
|
||||
|
||||
if(const XMLNode *hat_node=node.getNode("hat"))
|
||||
{
|
||||
if(hat_node->get("offset", &m_hat_offset))
|
||||
@ -214,6 +228,10 @@ KartModel* KartModel::makeCopy()
|
||||
km->m_animated_node = NULL;
|
||||
km->m_hat_offset = m_hat_offset;
|
||||
km->m_hat_name = m_hat_name;
|
||||
|
||||
km->m_nitro_emitter_position[0] = m_nitro_emitter_position[0];
|
||||
km->m_nitro_emitter_position[1] = m_nitro_emitter_position[1];
|
||||
|
||||
for(unsigned int i=0; i<4; i++)
|
||||
{
|
||||
km->m_wheel_model[i] = m_wheel_model[i];
|
||||
@ -405,6 +423,31 @@ bool KartModel::loadModels(const KartProperties &kart_properties)
|
||||
return true;
|
||||
} // loadModels
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Loads a single nitro emitter node. Currently this the position of the nitro
|
||||
* emitter relative to the kart.
|
||||
* \param emitter_name Name of the nitro emitter, e.g. emitter-a.
|
||||
* \param index Index of this emitter in the global m_emitter* fields.
|
||||
*/
|
||||
void KartModel::loadNitroEmitterInfo(const XMLNode &node,
|
||||
const std::string &emitter_name, int index)
|
||||
{
|
||||
const XMLNode *emitter_node = node.getNode(emitter_name);
|
||||
if(!emitter_node)
|
||||
{
|
||||
// Only print the warning if a model filename is given. Otherwise the
|
||||
// stk_config file is read (which has no model information).
|
||||
if(m_model_filename!="")
|
||||
{
|
||||
Log::error("Kart_Model", "Missing nitro emitter information for model"
|
||||
"'%s'.", m_model_filename.c_str());
|
||||
Log::error("Kart_Model", "This can be ignored, but the nitro particles will not work");
|
||||
}
|
||||
return;
|
||||
}
|
||||
emitter_node->get("position", &m_nitro_emitter_position[index]);
|
||||
} // loadNitroEmitterInfo
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Loads a single wheel node. Currently this is the name of the wheel model
|
||||
* and the position of the wheel relative to the kart.
|
||||
|
@ -113,6 +113,9 @@ private:
|
||||
|
||||
/** Radius of the graphical wheels. */
|
||||
float m_wheel_graphics_radius[4];
|
||||
|
||||
/** The position of the nitro emitters */
|
||||
Vec3 m_nitro_emitter_position[2];
|
||||
|
||||
/** Minimum suspension length. If the displayed suspension is
|
||||
* shorter than this, the wheel would look wrong. */
|
||||
@ -141,6 +144,9 @@ private:
|
||||
|
||||
void loadWheelInfo(const XMLNode &node,
|
||||
const std::string &wheel_name, int index);
|
||||
|
||||
void loadNitroEmitterInfo(const XMLNode &node,
|
||||
const std::string &emitter_name, int index);
|
||||
|
||||
void OnAnimationEnd(scene::IAnimatedMeshSceneNode *node);
|
||||
|
||||
@ -200,6 +206,11 @@ public:
|
||||
float getWheelGraphicsRadius(int i) const
|
||||
{assert(i>=0 && i<4); return m_wheel_graphics_radius[i]; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the position of nitro emitter relative to the kart.
|
||||
*/
|
||||
const Vec3* getNitroEmittersPositon() const
|
||||
{return m_nitro_emitter_position;}
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the length of the kart model. */
|
||||
float getLength () const {return m_kart_length; }
|
||||
// ------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user