From cf2a9f708917e7eb33df81633b38e44afd281864 Mon Sep 17 00:00:00 2001 From: Benau Date: Fri, 6 Oct 2017 01:08:27 +0800 Subject: [PATCH] Allow configurable exhuast particle, fixes #2878 --- src/karts/kart_gfx.cpp | 14 ++++++++++++-- src/karts/kart_gfx.hpp | 4 ++-- src/karts/kart_model.cpp | 11 +++++++++++ src/karts/kart_model.hpp | 13 +++++++++++++ 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/karts/kart_gfx.cpp b/src/karts/kart_gfx.cpp index 4f22d03b9..611346b39 100644 --- a/src/karts/kart_gfx.cpp +++ b/src/karts/kart_gfx.cpp @@ -111,14 +111,24 @@ KartGFX::KartGFX(const AbstractKart *kart, bool is_day) 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_EXHAUST1, "kart_exhaust.xml",rear_nitro_right, false ); - addEffect(KGFX_EXHAUST2, "kart_exhaust.xml",rear_nitro_left, 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 ); + if (!kart->getKartModel()->getExhaustXML().empty()) + { + const std::string& ex = kart->getKartModel()->getExhaustXML(); + addEffect(KGFX_EXHAUST1, ex, rear_nitro_right, false); + addEffect(KGFX_EXHAUST2, ex, rear_nitro_left, false); + } + else + { + m_all_emitters.push_back(NULL); + m_all_emitters.push_back(NULL); + } + } // KartGFX // ---------------------------------------------------------------------------- diff --git a/src/karts/kart_gfx.hpp b/src/karts/kart_gfx.hpp index 16ed9a0bf..016b35479 100644 --- a/src/karts/kart_gfx.hpp +++ b/src/karts/kart_gfx.hpp @@ -49,8 +49,6 @@ public: KGFX_NITRO2, KGFX_NITROSMOKE1, KGFX_NITROSMOKE2, - KGFX_EXHAUST1, - KGFX_EXHAUST2, KGFX_ZIPPER, KGFX_TERRAIN, KGFX_SKIDL, @@ -59,6 +57,8 @@ public: KGFX_SKID1R = KGFX_SKIDR, KGFX_SKID2L, KGFX_SKID2R, + KGFX_EXHAUST1, + KGFX_EXHAUST2, KGFX_COUNT}; private: diff --git a/src/karts/kart_model.cpp b/src/karts/kart_model.cpp index 7a346b819..a5bf4b619 100644 --- a/src/karts/kart_model.cpp +++ b/src/karts/kart_model.cpp @@ -215,6 +215,10 @@ void KartModel::loadInfo(const XMLNode &node) } } + if (const XMLNode* exhaust = node.getNode("exhaust")) + { + exhaust->get("file", &m_exhaust_xml); + } } // loadInfo // ---------------------------------------------------------------------------- @@ -336,6 +340,7 @@ KartModel* KartModel::makeCopy(KartRenderType krt) km->m_render_info = new RenderInfo(); km->m_inverse_bone_matrices = m_inverse_bone_matrices; km->m_version = m_version; + km->m_exhaust_xml = m_exhaust_xml; km->m_render_info->setKartModelRenderInfo(krt); km->m_nitro_emitter_position[0] = m_nitro_emitter_position[0]; @@ -1206,6 +1211,12 @@ void KartModel::toggleHeadlights(bool on) } // toggleHeadlights //----------------------------------------------------------------------------- +/** Called when a kart is load. this will load all the inverse bone matrices + * for each bone in straight frame. The location, rotation and scale in + * kart.xml for attachments (speedweighted objects, headlight, hat...) are in + * object space, so if you use a inverse bone matrix * that matrix, it will be + * relative to the bone, and you can use the result to set parent. + */ void KartModel::initInverseBoneMatrices() { if (m_version < 3) diff --git a/src/karts/kart_model.hpp b/src/karts/kart_model.hpp index a49a04881..8dc6924e1 100644 --- a/src/karts/kart_model.hpp +++ b/src/karts/kart_model.hpp @@ -310,16 +310,27 @@ private: /** Pointer to the kart object belonging to this kart model. */ AbstractKart* m_kart; + /** Tell the render type of this kart model, either colorized (red / blue now) + * or transparent (ghost kart). */ KartRenderType m_krt; + /** For our engine to get the desired hue / saturation for colorization. */ RenderInfo* m_render_info; + /** True if this kart model can be colorization in red / blue (now only + * used in soccer mode). */ bool m_support_colorization; + /** Used to cache inverse bone matrices for each bone in straight frame + * for attachment. */ std::unordered_map m_inverse_bone_matrices; + /** Version of kart model (in kart.xml). */ unsigned m_version; + /** Exhaust particle file (xml) for the kart, empty if disabled. */ + std::string m_exhaust_xml; + // ------------------------------------------------------------------------ void initInverseBoneMatrices(); // ------------------------------------------------------------------------ @@ -444,6 +455,8 @@ public: // ------------------------------------------------------------------------ const core::matrix4& getInverseBoneMatrix(const std::string& bone_name) const; + // ------------------------------------------------------------------------ + const std::string& getExhaustXML() const { return m_exhaust_xml; } }; // KartModel #endif