From: <hik...@us...> - 2010-10-12 10:17:14
|
Revision: 6277 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=6277&view=rev Author: hikerstk Date: 2010-10-12 10:17:08 +0000 (Tue, 12 Oct 2010) Log Message: ----------- Added support for scaling IPOs. Modified Paths: -------------- main/trunk/src/animations/animation_base.cpp main/trunk/src/animations/animation_base.hpp main/trunk/src/animations/billboard_animation.cpp main/trunk/src/animations/ipo.cpp main/trunk/src/animations/ipo.hpp main/trunk/src/animations/three_d_animation.cpp Modified: main/trunk/src/animations/animation_base.cpp =================================================================== --- main/trunk/src/animations/animation_base.cpp 2010-10-12 10:06:37 UTC (rev 6276) +++ main/trunk/src/animations/animation_base.cpp 2010-10-12 10:17:08 UTC (rev 6277) @@ -83,12 +83,12 @@ * \param hpr Rotation to be updated. */ void AnimationBase::update(float dt, core::vector3df *xyz, - core::vector3df *hpr) + core::vector3df *hpr, core::vector3df *scale) { std::vector<Ipo*>::iterator i; for(i=m_all_ipos.begin(); i<m_all_ipos.end(); i++) { - (*i)->update(dt, xyz, hpr); + (*i)->update(dt, xyz, hpr, scale); } // for i in m_all_ipos } // float dt Modified: main/trunk/src/animations/animation_base.hpp =================================================================== --- main/trunk/src/animations/animation_base.hpp 2010-10-12 10:06:37 UTC (rev 6276) +++ main/trunk/src/animations/animation_base.hpp 2010-10-12 10:17:08 UTC (rev 6277) @@ -70,7 +70,8 @@ public: AnimationBase(const XMLNode &node); virtual ~AnimationBase(); - virtual void update(float dt, core::vector3df *xyz, core::vector3df *hpr); + virtual void update(float dt, core::vector3df *xyz, core::vector3df *hpr, + core::vector3df *scale); /** This needs to be implemented by the inheriting classes. It is called * once per frame from the track. */ virtual void update(float dt) = 0; Modified: main/trunk/src/animations/billboard_animation.cpp =================================================================== --- main/trunk/src/animations/billboard_animation.cpp 2010-10-12 10:06:37 UTC (rev 6276) +++ main/trunk/src/animations/billboard_animation.cpp 2010-10-12 10:17:08 UTC (rev 6277) @@ -36,6 +36,7 @@ // FIXME: not implemented yet. core::vector3df xyz(0, 0, 0); core::vector3df hpr(0, 0, 0); - AnimationBase::update(dt, &xyz, &hpr); + core::vector3df scale(1,1,1); + AnimationBase::update(dt, &xyz, &hpr, &scale); } // update Modified: main/trunk/src/animations/ipo.cpp =================================================================== --- main/trunk/src/animations/ipo.cpp 2010-10-12 10:06:37 UTC (rev 6276) +++ main/trunk/src/animations/ipo.cpp 2010-10-12 10:17:08 UTC (rev 6277) @@ -22,7 +22,9 @@ #include "io/xml_node.hpp" const std::string Ipo::m_all_channel_names[IPO_MAX] = - {"LocX", "LocY", "LocZ", "RotX", "RotY", "RotZ"}; + {"LocX", "LocY", "LocZ", + "RotX", "RotY", "RotZ", + "ScaleX", "ScaleY", "ScaleZ" }; Ipo::Ipo(const XMLNode &curve, float fps) { @@ -110,19 +112,23 @@ * \param xyz The position that needs to be updated. * \param hpr The rotation that needs to be updated. */ -void Ipo::update(float dt, core::vector3df *xyz, core::vector3df *hpr) +void Ipo::update(float dt, core::vector3df *xyz, core::vector3df *hpr, + core::vector3df *scale) { m_time += dt; if(m_extend!=ET_CONST && m_time>m_max_time) m_time = 0; switch(m_channel) { - case Ipo::IPO_LOCX : xyz->X = get(); break; - case Ipo::IPO_LOCY : xyz->Y = get(); break; - case Ipo::IPO_LOCZ : xyz->Z = get(); break; - case Ipo::IPO_ROTX : hpr->X = -get(); break; // the - signs are odd, - case Ipo::IPO_ROTY : hpr->Y = -get(); break; // but it works - case Ipo::IPO_ROTZ : hpr->Z = get(); break; // why no - ?? + case Ipo::IPO_LOCX : xyz->X = get(); break; + case Ipo::IPO_LOCY : xyz->Y = get(); break; + case Ipo::IPO_LOCZ : xyz->Z = get(); break; + case Ipo::IPO_ROTX : hpr->X = -get(); break; // the - signs are odd, + case Ipo::IPO_ROTY : hpr->Y = -get(); break; // but it works + case Ipo::IPO_ROTZ : hpr->Z = get(); break; // why no - ?? + case Ipo::IPO_SCALEX : scale->X = get(); break; + case Ipo::IPO_SCALEY : scale->Y = get(); break; + case Ipo::IPO_SCALEZ : scale->Z = get(); break; default: assert(false); // shut up compiler warning } // switch Modified: main/trunk/src/animations/ipo.hpp =================================================================== --- main/trunk/src/animations/ipo.hpp 2010-10-12 10:06:37 UTC (rev 6276) +++ main/trunk/src/animations/ipo.hpp 2010-10-12 10:17:08 UTC (rev 6277) @@ -38,8 +38,9 @@ { public: /** All supported ipo types. */ - enum IpoChannelType {IPO_LOCX, IPO_LOCY, IPO_LOCZ, - IPO_ROTX, IPO_ROTY, IPO_ROTZ, + enum IpoChannelType {IPO_LOCX, IPO_LOCY, IPO_LOCZ, + IPO_ROTX, IPO_ROTY, IPO_ROTZ, + IPO_SCALEX, IPO_SCALEY, IPO_SCALEZ, IPO_MAX}; static const std::string m_all_channel_names[IPO_MAX]; private: @@ -74,7 +75,8 @@ core::vector3df m_initial_hpr; public: Ipo(const XMLNode &curve, float fps); - void update(float dt, core::vector3df *xyz, core::vector3df *hpr); + void update(float dt, core::vector3df *xyz, core::vector3df *hpr, + core::vector3df *scale); float get() const; void setInitialTransform(const core::vector3df &xyz, const core::vector3df &hpr); Modified: main/trunk/src/animations/three_d_animation.cpp =================================================================== --- main/trunk/src/animations/three_d_animation.cpp 2010-10-12 10:06:37 UTC (rev 6276) +++ main/trunk/src/animations/three_d_animation.cpp 2010-10-12 10:17:08 UTC (rev 6277) @@ -124,9 +124,12 @@ { core::vector3df xyz = m_animated_node->getPosition(); core::vector3df hpr = m_animated_node->getRotation(); - AnimationBase::update(dt, &xyz, &hpr); //updates all IPOs + core::vector3df scale = m_animated_node->getScale(); + AnimationBase::update(dt, &xyz, &hpr, &scale); //updates all IPOs + printf("xyz = %f %f %f\n", xyz.X, xyz.Y, xyz.Z); m_animated_node->setPosition(xyz); m_animated_node->setRotation(hpr); + m_animated_node->setScale(scale); // Now update the position of the bullet body if there is one: if(m_body) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |