Moved skidding lights from Kart into KartGFX.
This commit is contained in:
parent
8aabb30687
commit
04c84fd23d
@ -129,8 +129,6 @@ Kart::Kart (const std::string& ident, unsigned int world_kart_id,
|
||||
m_min_nitro_time = 0.0f;
|
||||
m_fire_clicked = 0;
|
||||
m_wrongway_counter = 0;
|
||||
m_skidding_light_1 = NULL;
|
||||
m_skidding_light_2 = NULL;
|
||||
m_type = RaceManager::KT_AI;
|
||||
|
||||
m_view_blocked_by_plunger = 0;
|
||||
@ -256,8 +254,6 @@ Kart::~Kart()
|
||||
m_goo_sound ->deleteSFX();
|
||||
m_beep_sound ->deleteSFX();
|
||||
m_boing_sound ->deleteSFX();
|
||||
m_skidding_light_1->drop();
|
||||
m_skidding_light_2->drop();
|
||||
delete m_kart_gfx;
|
||||
if(m_terrain_sound) m_terrain_sound->deleteSFX();
|
||||
if(m_previous_terrain_sound) m_previous_terrain_sound->deleteSFX();
|
||||
@ -2409,18 +2405,6 @@ void Kart::loadData(RaceManager::KartType type, bool is_animated_model)
|
||||
bool always_animated = (type == RaceManager::KT_PLAYER && race_manager->getNumPlayers() == 1);
|
||||
m_node = m_kart_model->attachModel(is_animated_model, always_animated);
|
||||
|
||||
// Create skidding lights
|
||||
// For the first skidding level
|
||||
m_skidding_light_1 = irr_driver->addLight(core::vector3df(0.0f, 0.1f, m_kart_model->getLength()*-0.5f - 0.05f),
|
||||
0.3f /* force */, 3.0f /* radius */, 1.0f, 0.6f, 0.0f, false, m_node);
|
||||
m_skidding_light_1->setVisible(false);
|
||||
m_skidding_light_1->setName( ("skidding emitter 1 (" + getIdent() + ")").c_str() );
|
||||
// For the second skidding level
|
||||
m_skidding_light_2 = irr_driver->addLight(core::vector3df(0.0f, 0.1f, m_kart_model->getLength()*-0.5f - 0.05f),
|
||||
0.4f /* force */, 4.0f /* radius */, 1.0f, 0.0f, 0.0f, false, m_node);
|
||||
m_skidding_light_2->setVisible(false);
|
||||
m_skidding_light_2->setName( ("skidding emitter 2 (" + getIdent() + ")").c_str() );
|
||||
|
||||
#ifdef DEBUG
|
||||
m_node->setName( (getIdent()+"(lod-node)").c_str() );
|
||||
#endif
|
||||
@ -2711,7 +2695,8 @@ void Kart::setOnScreenText(const wchar_t *text)
|
||||
|
||||
if (CVS->isGLSL())
|
||||
{
|
||||
gui::ScalableFont* font = GUIEngine::getFont() ? GUIEngine::getFont() : GUIEngine::getTitleFont();
|
||||
gui::ScalableFont* font = GUIEngine::getFont() ? GUIEngine::getFont()
|
||||
: GUIEngine::getTitleFont();
|
||||
new STKTextBillboard(text, font,
|
||||
video::SColor(255, 255, 225, 0),
|
||||
video::SColor(255, 255, 89, 0),
|
||||
@ -2723,7 +2708,7 @@ void Kart::setOnScreenText(const wchar_t *text)
|
||||
{
|
||||
scene::ISceneManager* sm = irr_driver->getSceneManager();
|
||||
sm->addBillboardTextSceneNode(GUIEngine::getFont() ? GUIEngine::getFont()
|
||||
: GUIEngine::getTitleFont(),
|
||||
: GUIEngine::getTitleFont(),
|
||||
text,
|
||||
getNode(),
|
||||
core::dimension2df(textsize.Width/55.0f,
|
||||
@ -2739,11 +2724,4 @@ void Kart::setOnScreenText(const wchar_t *text)
|
||||
// when the parent is deleted.
|
||||
} // setOnScreenText
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void Kart::activateSkidLight(unsigned int level)
|
||||
{
|
||||
m_skidding_light_1->setVisible(level == 1);
|
||||
m_skidding_light_2->setVisible(level > 1);
|
||||
} // activateSkidLight
|
||||
|
||||
/* EOF */
|
||||
|
@ -219,11 +219,6 @@ private:
|
||||
/** To prevent using nitro in too short bursts */
|
||||
float m_min_nitro_time;
|
||||
|
||||
/** Lights that are shown when the kart is skidding. */
|
||||
scene::ISceneNode* m_skidding_light_1;
|
||||
/** A light that's shown on the second skid-level with another color. */
|
||||
scene::ISceneNode* m_skidding_light_2;
|
||||
|
||||
void updatePhysics(float dt);
|
||||
void handleMaterialSFX(const Material *material);
|
||||
void handleMaterialGFX();
|
||||
@ -447,9 +442,9 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
/** Counter which is used for displaying wrong way message after a delay */
|
||||
float getWrongwayCounter() { return m_wrongway_counter; }
|
||||
// ------------------------------------------------------------------------
|
||||
void setWrongwayCounter(float counter) { m_wrongway_counter = counter; }
|
||||
|
||||
void activateSkidLight(unsigned int level);
|
||||
}; // Kart
|
||||
|
||||
|
||||
|
@ -45,49 +45,69 @@ KartGFX::KartGFX(const AbstractKart *kart)
|
||||
|
||||
m_kart = kart;
|
||||
|
||||
const KartModel *km = m_kart->getKartModel();
|
||||
const float length = km->getLength();
|
||||
|
||||
scene::ISceneNode *node = m_kart->getNode();
|
||||
// Create nitro light
|
||||
core::vector3df location(0.0f, 0.5f,
|
||||
m_kart->getKartModel()->getLength()*-0.5f - 0.05f);
|
||||
core::vector3df location(0.0f, 0.5f, -0.5f*length - 0.05f);
|
||||
m_nitro_light = irr_driver->addLight(location, /*force*/ 0.4f,
|
||||
/*radius*/5.0f, 0.0f, 0.4f, 1.0f,
|
||||
false, m_kart->getNode());
|
||||
false, node);
|
||||
m_nitro_light->setVisible(false);
|
||||
#ifdef DEBUG
|
||||
m_nitro_light->setName( ("nitro emitter (" + m_kart->getIdent() + ")").c_str() );
|
||||
m_nitro_light->setName( ("nitro emitter (" + m_kart->getIdent()
|
||||
+ ")").c_str() );
|
||||
#endif
|
||||
|
||||
// Create skidding lights
|
||||
// For the first skidding level
|
||||
m_skidding_light_1 =
|
||||
irr_driver->addLight(core::vector3df(0.0f, 0.1f, -0.5f*length - 0.05f),
|
||||
/* force */ 0.3f, /* radius */ 3.0f,
|
||||
1.0f, 0.6f, 0.0f, false, node);
|
||||
m_skidding_light_1->setVisible(false);
|
||||
m_skidding_light_1->setName( ("skidding emitter 1 (" + m_kart->getIdent()
|
||||
+ ")").c_str() );
|
||||
|
||||
// For the second skidding level
|
||||
m_skidding_light_2 =
|
||||
irr_driver->addLight(core::vector3df(0.0f, 0.1f, -0.5f*length - 0.05f),
|
||||
/* force */0.4f, /*radius*/ 4.0f,
|
||||
1.0f, 0.0f, 0.0f, false, node);
|
||||
m_skidding_light_2->setVisible(false);
|
||||
m_skidding_light_2->setName( ("skidding emitter 2 (" + m_kart->getIdent()
|
||||
+ ")").c_str() );
|
||||
|
||||
// Create particle effects
|
||||
Vec3 rear_left(kart->getWheelGraphicsPosition(3).getX(), 0.05f,
|
||||
kart->getWheelGraphicsPosition(3).getZ()-0.1f );
|
||||
Vec3 rear_right(kart->getWheelGraphicsPosition(2).getX(), 0.05f,
|
||||
kart->getWheelGraphicsPosition(2).getZ()-0.1f );
|
||||
|
||||
Vec3 rear_center(0, kart->getKartHeight()*0.35f,
|
||||
-kart->getKartLength()*0.35f);
|
||||
Vec3 rear_center(0, kart->getKartHeight()*0.35f, -0.35f*length);
|
||||
|
||||
Vec3 rear_nitro_center(0, kart->getKartHeight()*0.2f,
|
||||
-kart->getKartLength()*0.1f);
|
||||
Vec3 rear_nitro_center(0, kart->getKartHeight()*0.2f, -0.1f*length);
|
||||
|
||||
// FIXME Used to match the emitter as seen in blender
|
||||
const Vec3 delta(0, 0, 0.6f);
|
||||
Vec3 rear_nitro_right = kart->getKartModel()->getNitroEmittersPositon(0)
|
||||
+ delta;
|
||||
Vec3 rear_nitro_left = kart->getKartModel()->getNitroEmittersPositon(1)
|
||||
+ delta;
|
||||
if (!kart->getKartModel()->hasNitroEmitters())
|
||||
Vec3 rear_nitro_right = km->getNitroEmittersPositon(0) + delta;
|
||||
Vec3 rear_nitro_left = km->getNitroEmittersPositon(1) + delta;
|
||||
if (!km->hasNitroEmitters())
|
||||
rear_nitro_right = rear_nitro_left = rear_nitro_center;
|
||||
|
||||
// Create all effects. Note that they must be created
|
||||
// in the order of KartGFXType.
|
||||
addEffect(KGFX_NITRO1, "nitro.xml", rear_nitro_right, true);
|
||||
addEffect(KGFX_NITRO2, "nitro.xml", rear_nitro_left, true);
|
||||
addEffect(KGFX_NITROSMOKE1, "nitro-smoke.xml", rear_nitro_left, false);
|
||||
addEffect(KGFX_NITRO1, "nitro.xml", rear_nitro_right, true );
|
||||
addEffect(KGFX_NITRO2, "nitro.xml", rear_nitro_left, true );
|
||||
addEffect(KGFX_NITROSMOKE1, "nitro-smoke.xml", rear_nitro_left, false);
|
||||
addEffect(KGFX_NITROSMOKE2, "nitro-smoke.xml", rear_nitro_right, false);
|
||||
addEffect(KGFX_ZIPPER, "zipper_fire.xml", rear_center, true);
|
||||
addEffect(KGFX_TERRAIN, "smoke.xml", Vec3(0, 0, 0), false);
|
||||
addEffect(KGFX_SKID1L, "skid1.xml", rear_left, true);
|
||||
addEffect(KGFX_SKID1R, "skid1.xml", rear_right, true);
|
||||
addEffect(KGFX_SKID2L, "skid2.xml", rear_left, true);
|
||||
addEffect(KGFX_SKID2R, "skid2.xml", rear_right, true);
|
||||
addEffect(KGFX_ZIPPER, "zipper_fire.xml", rear_center, true );
|
||||
addEffect(KGFX_TERRAIN, "smoke.xml", Vec3(0, 0, 0), false);
|
||||
addEffect(KGFX_SKID1L, "skid1.xml", rear_left, true );
|
||||
addEffect(KGFX_SKID1R, "skid1.xml", rear_right, true );
|
||||
addEffect(KGFX_SKID2L, "skid2.xml", rear_left, true );
|
||||
addEffect(KGFX_SKID2R, "skid2.xml", rear_right, true );
|
||||
} // KartGFX
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -101,6 +121,9 @@ KartGFX::~KartGFX()
|
||||
delete m_all_emitters[i];
|
||||
} // for i < KGFX_COUNT
|
||||
m_nitro_light->drop();
|
||||
m_skidding_light_1->drop();
|
||||
m_skidding_light_2->drop();
|
||||
|
||||
} // ~KartGFX
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -129,14 +152,17 @@ void KartGFX::addEffect(KartGFXType type, const std::string &file_name,
|
||||
//kind = new ParticleKind(file_manager->getGfxFile(file_name));
|
||||
// Skid2 is only used to store the emitter type, and a wheeless
|
||||
// kart has no terrain effects.
|
||||
if(type==KGFX_SKID2L || type==KGFX_SKID2R || (type==KGFX_TERRAIN && m_kart->isWheeless()) )
|
||||
if(type==KGFX_SKID2L || type==KGFX_SKID2R ||
|
||||
(type==KGFX_TERRAIN && m_kart->isWheeless()) )
|
||||
emitter = NULL;
|
||||
else if(type==KGFX_TERRAIN)
|
||||
// Terrain is NOT a child of the kart, since bullet returns the
|
||||
// raycast info in world coordinates
|
||||
emitter = new ParticleEmitter(kind, position, NULL, false, important);
|
||||
emitter = new ParticleEmitter(kind, position, NULL, false,
|
||||
important);
|
||||
else
|
||||
emitter = new ParticleEmitter(kind, position, m_kart->getNode(), false, important);
|
||||
emitter = new ParticleEmitter(kind, position, m_kart->getNode(),
|
||||
false, important);
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
@ -357,3 +383,13 @@ void KartGFX::updateNitroGraphics(float nitro_frac, float new_size)
|
||||
|
||||
} // updateGraphics
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Updates the skiddng light (including disabling it).
|
||||
* \param level Which level of light to display: 0 no light at all,
|
||||
* 1: level 1, 2 level 2.
|
||||
*/
|
||||
void KartGFX::updateSkidLight(unsigned int level)
|
||||
{
|
||||
m_skidding_light_1->setVisible(level == 1);
|
||||
m_skidding_light_2->setVisible(level > 1);
|
||||
} // updateSkidLight
|
||||
|
@ -78,6 +78,11 @@ private:
|
||||
/** A light that's shown when the kart uses nitro. */
|
||||
irr::scene::ISceneNode* m_nitro_light;
|
||||
|
||||
/** Light that is shown when the kart is skidding. */
|
||||
irr::scene::ISceneNode* m_skidding_light_1;
|
||||
|
||||
/** A light that's shown on the second skid-level with another color. */
|
||||
irr::scene::ISceneNode* m_skidding_light_2;
|
||||
|
||||
void addEffect(KartGFXType type, const std::string &file_name,
|
||||
const Vec3 &position, bool important);
|
||||
@ -95,5 +100,7 @@ public:
|
||||
void updateTerrain(const ParticleKind *pk);
|
||||
void update(float dt);
|
||||
void updateNitroGraphics(float f, float new_size);
|
||||
void updateSkidLight(unsigned int level);
|
||||
|
||||
}; // KartWGFX
|
||||
#endif
|
||||
|
@ -77,7 +77,7 @@ void Skidding::reset()
|
||||
m_jump_speed = 0.0f;
|
||||
m_kart->getKartGFX()->setCreationRateAbsolute(KartGFX::KGFX_SKIDL, 0);
|
||||
m_kart->getKartGFX()->setCreationRateAbsolute(KartGFX::KGFX_SKIDR, 0);
|
||||
m_kart->activateSkidLight(0);
|
||||
m_kart->getKartGFX()->updateSkidLight(0);
|
||||
m_kart->getControls().m_skid = KartControl::SC_NONE;
|
||||
|
||||
btVector3 rot(0, 0, 0);
|
||||
@ -399,7 +399,7 @@ void Skidding::update(float dt, bool is_on_ground,
|
||||
{
|
||||
m_skid_bonus_ready = true;
|
||||
m_kart->getKartGFX()->setSkidLevel(level);
|
||||
m_kart->activateSkidLight(level);
|
||||
m_kart->getKartGFX()->updateSkidLight(level);
|
||||
}
|
||||
// If player stops skidding, trigger bonus, and change state to
|
||||
// SKID_SHOW_GFX_*
|
||||
@ -453,7 +453,7 @@ void Skidding::update(float dt, bool is_on_ground,
|
||||
->setCreationRateAbsolute(KartGFX::KGFX_SKIDL, 0);
|
||||
m_kart->getKartGFX()
|
||||
->setCreationRateAbsolute(KartGFX::KGFX_SKIDR, 0);
|
||||
m_kart->activateSkidLight(0);
|
||||
m_kart->getKartGFX()->updateSkidLight(0);
|
||||
m_skid_state = SKID_NONE;
|
||||
}
|
||||
} // switch
|
||||
|
Loading…
Reference in New Issue
Block a user