Removed tabs.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4317 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk
2009-12-17 23:38:47 +00:00
parent 5eac1154c2
commit f8920355fe
5 changed files with 166 additions and 166 deletions

View File

@@ -32,41 +32,41 @@ class Ipo;
class AnimationBase
{
private:
/** Two types of animations: cyclic ones that play all the time, and
* one time only (which might get triggered more than once). */
enum AnimTimeType { ATT_CYCLIC, ATT_CYCLIC_ONCE } m_anim_type;
/** Two types of animations: cyclic ones that play all the time, and
* one time only (which might get triggered more than once). */
enum AnimTimeType { ATT_CYCLIC, ATT_CYCLIC_ONCE } m_anim_type;
/** True if the animation is currently playing. */
bool m_playing;
/** True if the animation is currently playing. */
bool m_playing;
/** For one time animations: start time. */
float m_start;
/** For one time animations: start time. */
float m_start;
/** For cyclic animations: duration of the cycle. */
float m_cycle_length;
/** For cyclic animations: duration of the cycle. */
float m_cycle_length;
/** The current time in the cycle of a cyclic animation. */
float m_current_time;
/** The current time in the cycle of a cyclic animation. */
float m_current_time;
/** The inital position of this object. */
core::vector3df m_initial_xyz;
/** The initial rotation of this object. */
core::vector3df m_initial_hpr;
/** The inital position of this object. */
core::vector3df m_initial_xyz;
/** The initial rotation of this object. */
core::vector3df m_initial_hpr;
protected:
/** All IPOs for this animation. */
std::vector<Ipo*> m_all_ipos;
/** All IPOs for this animation. */
std::vector<Ipo*> m_all_ipos;
public:
AnimationBase(const XMLNode &node, float fps);
virtual ~AnimationBase();
virtual void update(float dt, core::vector3df *xyz, core::vector3df *hpr);
/** This needs to be implemented by the inheriting classes. It is called
* once per frame from the track. */
virtual void update(float dt) = 0;
void setInitialTransform(const core::vector3df &xyz,
const core::vector3df &hpr);
void reset();
virtual void update(float dt, core::vector3df *xyz, core::vector3df *hpr);
/** This needs to be implemented by the inheriting classes. It is called
* once per frame from the track. */
virtual void update(float dt) = 0;
void setInitialTransform(const core::vector3df &xyz,
const core::vector3df &hpr);
void reset();
}; // AnimationBase

View File

@@ -31,13 +31,13 @@ class XMLNode;
class AnimationManager
{
private:
std::vector<AnimationBase*> m_all_animations;
std::vector<AnimationBase*> m_all_animations;
public:
AnimationManager(const Track &track, const XMLNode &node);
AnimationManager(const Track &track, const XMLNode &node);
~AnimationManager();
void update(float dt);
void reset();
void update(float dt);
void reset();
}; // AnimationManager
#endif

View File

@@ -33,9 +33,9 @@ class BillboardAnimation : public AnimationBase
private:
public:
BillboardAnimation(const Track &track, const XMLNode &node, float fps);
BillboardAnimation(const Track &track, const XMLNode &node, float fps);
virtual ~BillboardAnimation(){}
virtual void update(float dt);
virtual void update(float dt);
}; // BillboardAnimation

View File

@@ -1,4 +1,4 @@
// $Id: ipo.cpp 1681 2008-04-09 13:52:48Z hikerstk $
// $Id: ipo.cpp 1681 2008-04-09 13:52:48Z hikerstk $
//
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2009 Joerg Henrichs
@@ -26,57 +26,57 @@ const std::string Ipo::m_all_channel_names[IPO_MAX] =
Ipo::Ipo(const XMLNode &curve, float fps)
{
if(curve.getName()!="curve")
{
fprintf(stderr, "Expected 'curve' for animation, got '%s' --> Ignored.\n",
curve.getName().c_str());
return;
}
std::string channel;
curve.get("channel", &channel);
m_channel=IPO_MAX;
for(unsigned int i=IPO_LOCX; i<IPO_MAX; i++)
{
if(m_all_channel_names[i]==channel) m_channel=(IpoChannelType)i;
}
if(m_channel==IPO_MAX)
{
fprintf(stderr, "Unknown animation channel: '%s' - aborting.\n", channel.c_str());
exit(-1);
}
if(curve.getName()!="curve")
{
fprintf(stderr, "Expected 'curve' for animation, got '%s' --> Ignored.\n",
curve.getName().c_str());
return;
}
std::string channel;
curve.get("channel", &channel);
m_channel=IPO_MAX;
for(unsigned int i=IPO_LOCX; i<IPO_MAX; i++)
{
if(m_all_channel_names[i]==channel) m_channel=(IpoChannelType)i;
}
if(m_channel==IPO_MAX)
{
fprintf(stderr, "Unknown animation channel: '%s' - aborting.\n", channel.c_str());
exit(-1);
}
std::string interp;
curve.get("interpolation", &interp);
if (interp=="const" ) m_interpolation = IP_CONST;
else if(interp=="linear") m_interpolation = IP_LINEAR;
else m_interpolation = IP_BEZIER;
std::string interp;
curve.get("interpolation", &interp);
if (interp=="const" ) m_interpolation = IP_CONST;
else if(interp=="linear") m_interpolation = IP_LINEAR;
else m_interpolation = IP_BEZIER;
m_min_time = 999999;
m_max_time = -1;
for(unsigned int i=0; i<curve.getNumNodes(); i++)
{
const XMLNode *node = curve.getNode(i);
core::vector2df xy;
node->get("c", &xy);
// Convert blender's frame number (1 ...) into time (0 ...)
float t = (xy.X-1)/fps;
if(t<m_min_time) m_min_time = t;
if(t>m_max_time) m_max_time = t;
xy.X = t;
m_points.push_back(xy);
if(m_interpolation==IP_BEZIER)
{
core::vector2df handle;
node->get("h1", &handle);
handle.X = (xy.X-1)/fps;
m_handle1.push_back(handle);
node->get("h2", &handle);
handle.X = (xy.X-1)/fps;
m_handle2.push_back(handle);
}
} // for i<getNumNodes()
reset();
m_min_time = 999999;
m_max_time = -1;
for(unsigned int i=0; i<curve.getNumNodes(); i++)
{
const XMLNode *node = curve.getNode(i);
core::vector2df xy;
node->get("c", &xy);
// Convert blender's frame number (1 ...) into time (0 ...)
float t = (xy.X-1)/fps;
if(t<m_min_time) m_min_time = t;
if(t>m_max_time) m_max_time = t;
xy.X = t;
m_points.push_back(xy);
if(m_interpolation==IP_BEZIER)
{
core::vector2df handle;
node->get("h1", &handle);
handle.X = (xy.X-1)/fps;
m_handle1.push_back(handle);
node->get("h2", &handle);
handle.X = (xy.X-1)/fps;
m_handle2.push_back(handle);
}
} // for i<getNumNodes()
reset();
} // Ipo
// ----------------------------------------------------------------------------
@@ -85,10 +85,10 @@ Ipo::Ipo(const XMLNode &curve, float fps)
* \param hpr Rotation of the object.
*/
void Ipo::setInitialTransform(const core::vector3df &xyz,
const core::vector3df &hpr)
const core::vector3df &hpr)
{
m_initial_xyz = xyz;
m_initial_hpr = hpr;
m_initial_xyz = xyz;
m_initial_hpr = hpr;
} // setInitialTransform
// ----------------------------------------------------------------------------
@@ -96,7 +96,7 @@ void Ipo::setInitialTransform(const core::vector3df &xyz,
*/
void Ipo::reset()
{
m_time = 0;
m_time = 0;
} // reset
// ----------------------------------------------------------------------------
@@ -108,19 +108,19 @@ void Ipo::reset()
*/
void Ipo::update(float dt, core::vector3df *xyz, core::vector3df *hpr)
{
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 - ??
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 - ??
default: assert(false); // shut up compiler warning
} // switch
} // switch
} // update
@@ -130,41 +130,41 @@ void Ipo::update(float dt, core::vector3df *xyz, core::vector3df *hpr)
*/
float Ipo::get() const
{
if(m_time<m_min_time)
{
// FIXME: should take extend into account!
return 0;
}
unsigned int n=0;
// Search for the first point in the (sorted) array which is greater or equal
// to the current time.
// FIXME: we should store the last point to speed this up!
while(n<m_points.size()-1 && m_time >=m_points[n].X)
n++;
n--;
switch(m_interpolation)
{
case IP_CONST : return m_points[n].Y;
case IP_LINEAR : {
float t = m_time-m_points[n].X;
return m_points[n].Y + t*(m_points[n+1].Y-m_points[n].Y) /
(m_points[n+1].X-m_points[n].X);
}
case IP_BEZIER: {
if(n==m_points.size()-1)
{
// FIXME: only const implemented atm.
return m_points[n].Y;
}
core::vector2df c = 3.0f*(m_handle2[n]-m_points[n]);
core::vector2df b = 3.0f*(m_handle1[n+1]-m_handle2[n])-c;
core::vector2df a = m_points[n+1] - m_points[n] - c - b;
float t = (m_time-m_points[n].X)/(m_points[n+1].X-m_points[n].X);
core::vector2df r = ((a*t+b)*t+c)*t+m_points[n];
return r.Y;
}
} // switch
// Keep the compiler happy:
return 0;
if(m_time<m_min_time)
{
// FIXME: should take extend into account!
return 0;
}
unsigned int n=0;
// Search for the first point in the (sorted) array which is greater or equal
// to the current time.
// FIXME: we should store the last point to speed this up!
while(n<m_points.size()-1 && m_time >=m_points[n].X)
n++;
n--;
switch(m_interpolation)
{
case IP_CONST : return m_points[n].Y;
case IP_LINEAR : {
float t = m_time-m_points[n].X;
return m_points[n].Y + t*(m_points[n+1].Y-m_points[n].Y) /
(m_points[n+1].X-m_points[n].X);
}
case IP_BEZIER: {
if(n==m_points.size()-1)
{
// FIXME: only const implemented atm.
return m_points[n].Y;
}
core::vector2df c = 3.0f*(m_handle2[n]-m_points[n]);
core::vector2df b = 3.0f*(m_handle1[n+1]-m_handle2[n])-c;
core::vector2df a = m_points[n+1] - m_points[n] - c - b;
float t = (m_time-m_points[n].X)/(m_points[n+1].X-m_points[n].X);
core::vector2df r = ((a*t+b)*t+c)*t+m_points[n];
return r.Y;
}
} // switch
// Keep the compiler happy:
return 0;
} // get
// ----------------------------------------------------------------------------

View File

@@ -34,48 +34,48 @@ class XMLNode;
class Ipo
{
public:
/** All supported ipo types. */
enum IpoChannelType {IPO_LOCX, IPO_LOCY, IPO_LOCZ,
IPO_ROTX, IPO_ROTY, IPO_ROTZ,
IPO_MAX};
static const std::string m_all_channel_names[IPO_MAX];
/** All supported ipo types. */
enum IpoChannelType {IPO_LOCX, IPO_LOCY, IPO_LOCZ,
IPO_ROTX, IPO_ROTY, IPO_ROTZ,
IPO_MAX};
static const std::string m_all_channel_names[IPO_MAX];
private:
/** The type of this IPO. */
IpoChannelType m_channel;
/** The type of this IPO. */
IpoChannelType m_channel;
/** The three interpolations defined by blender. */
enum {IP_CONST, IP_LINEAR, IP_BEZIER} m_interpolation;
/** The four extend types. */
enum {ET_CONST, ET_EXTRAP, ET_CYCLIC_EXTRAP, ET_CYCLIC} m_extend;
/** The three interpolations defined by blender. */
enum {IP_CONST, IP_LINEAR, IP_BEZIER} m_interpolation;
/** The four extend types. */
enum {ET_CONST, ET_EXTRAP, ET_CYCLIC_EXTRAP, ET_CYCLIC} m_extend;
/** The actual control points. */
std::vector<core::vector2df> m_points;
/** Only used for bezier curves: the two handles. */
std::vector<core::vector2df> m_handle1, m_handle2;
/** The actual control points. */
std::vector<core::vector2df> m_points;
/** Only used for bezier curves: the two handles. */
std::vector<core::vector2df> m_handle1, m_handle2;
/** Current time in cycle. */
float m_time;
/** Current time in cycle. */
float m_time;
/** Minium time when this animations starts, usually 0. */
float m_min_time;
/** Minium time when this animations starts, usually 0. */
float m_min_time;
/** Time this animation finishes (or cycles). */
float m_max_time;
/** Time this animation finishes (or cycles). */
float m_max_time;
/** Frames per second for this animation. */
float m_fps;
/** Frames per second for this animation. */
float m_fps;
/** Stores the inital position of the object. */
core::vector3df m_initial_xyz;
/** Stores the inital rotation of the object. */
core::vector3df m_initial_hpr;
/** Stores the inital position of the object. */
core::vector3df m_initial_xyz;
/** Stores the inital rotation of the object. */
core::vector3df m_initial_hpr;
public:
Ipo(const XMLNode &curve, float fps);
void update(float dt, core::vector3df *xyz, core::vector3df *hpr);
float get() const;
void setInitialTransform(const core::vector3df &xyz,
const core::vector3df &hpr);
void reset();
Ipo(const XMLNode &curve, float fps);
void update(float dt, core::vector3df *xyz, core::vector3df *hpr);
float get() const;
void setInitialTransform(const core::vector3df &xyz,
const core::vector3df &hpr);
void reset();
}; // Ipo
#endif