diff --git a/src/karts/abstract_kart.cpp b/src/karts/abstract_kart.cpp index 190b78ebb..13587973f 100644 --- a/src/karts/abstract_kart.cpp +++ b/src/karts/abstract_kart.cpp @@ -53,6 +53,7 @@ AbstractKart::AbstractKart(const std::string& ident, m_kart_width = m_kart_model->getWidth(); m_kart_height = m_kart_model->getHeight(); m_kart_length = m_kart_model->getLength(); + m_wheel_graphics_position = m_kart_model->getWheelsGraphicsPosition(); } // AbstractKart // ---------------------------------------------------------------------------- diff --git a/src/karts/abstract_kart.hpp b/src/karts/abstract_kart.hpp index b4972112e..36683b2b1 100644 --- a/src/karts/abstract_kart.hpp +++ b/src/karts/abstract_kart.hpp @@ -51,6 +51,8 @@ private: float m_kart_width; /** Height of the kart, copy of the data from KartModel. */ float m_kart_height; + /** The position of all four wheels in the 3d model */ + const Vec3* m_wheel_graphics_position; /** Index of kart in world. */ unsigned int m_world_kart_id; @@ -147,6 +149,12 @@ public: // ------------------------------------------------------------------------ /** Returns true if this kart has no wheels. */ bool isWheeless() const; + // ------------------------------------------------------------------------ + /** Returns the position of a wheel relative to the kart. + * \param i Index of the wheel: 0=front right, 1 = front left, 2 = rear + * right, 3 = rear left. */ + const Vec3& getWheelGraphicsPosition(int i) const + {assert(i>=0 && i<4); return m_wheel_graphics_position[i];} // ======================================================================== // Emergency animation related functions. diff --git a/src/karts/kart_gfx.cpp b/src/karts/kart_gfx.cpp index 975ba06b0..dbde011bd 100644 --- a/src/karts/kart_gfx.cpp +++ b/src/karts/kart_gfx.cpp @@ -40,12 +40,18 @@ KartGFX::KartGFX(const AbstractKart *kart) } m_kart = kart; - + /* + // FIXME Old Positioning system Maybe usefull for another 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); + Vec3 rear_right(kart->getWheelGraphicsPosition(2).toIrrVector().X, (kart->getKartHeight()-0.6f)*0.35f, + kart->getWheelGraphicsPosition(2).toIrrVector().Z); Vec3 rear_center(0, kart->getKartHeight()*0.35f, -kart->getKartLength()*0.35f); diff --git a/src/karts/kart_model.hpp b/src/karts/kart_model.hpp index 49a9caa54..c928e597d 100644 --- a/src/karts/kart_model.hpp +++ b/src/karts/kart_model.hpp @@ -181,6 +181,11 @@ public: const Vec3& getWheelGraphicsPosition(int i) const {assert(i>=0 && i<4); return m_wheel_graphics_position[i];} // ------------------------------------------------------------------------ + /** Returns the position of wheels relative to the kart. + */ + const Vec3* getWheelsGraphicsPosition() const + {return m_wheel_graphics_position;} + // ------------------------------------------------------------------------ /** Returns the position of a wheel relative to the kart for the physics. * The physics wheels can be attached at a different place to make the * karts more stable.