Added support for scaling IPOs.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@6277 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -83,12 +83,12 @@ void AnimationBase::reset()
|
||||
* \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
|
||||
|
||||
@@ -70,7 +70,8 @@ protected:
|
||||
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;
|
||||
|
||||
@@ -36,6 +36,7 @@ void BillboardAnimation::update(float dt)
|
||||
// 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
|
||||
|
||||
@@ -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 @@ void Ipo::reset()
|
||||
* \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
|
||||
|
||||
|
||||
@@ -38,8 +38,9 @@ class Ipo : public NoCopy
|
||||
{
|
||||
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 @@ private:
|
||||
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);
|
||||
|
||||
@@ -124,9 +124,12 @@ void ThreeDAnimation::update(float dt)
|
||||
{
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user