1
// $Id: animation_base.cpp 1681 2008-04-09 13:52:48Z hikerstk $
3
// SuperTuxKart - a fun racing game with go-kart
4
// Copyright (C) 2009 Joerg Henrichs
6
// This program is free software; you can redistribute it and/or
7
// modify it under the terms of the GNU General Public License
8
// as published by the Free Software Foundation; either version 3
9
// of the License, or (at your option) any later version.
11
// This program is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
// GNU General Public License for more details.
16
// You should have received a copy of the GNU General Public License
17
// along with this program; if not, write to the Free Software
18
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
#include "animations/animation_base.hpp"
22
#include "animations/ipo.hpp"
23
#include "graphics/irr_driver.hpp"
24
#include "io/file_manager.hpp"
25
#include "io/xml_node.hpp"
27
AnimationBase::AnimationBase(const XMLNode &node)
31
node.get("fps", &fps);
32
for(unsigned int i=0; i<node.getNumNodes(); i++)
34
Ipo *ipo = new Ipo(*node.getNode(i), fps);
35
m_all_ipos.push_back(ipo);
36
} // for i<getNumNodes()
40
// ----------------------------------------------------------------------------
43
AnimationBase::~AnimationBase()
45
std::vector<Ipo*>::iterator i;
46
for(i=m_all_ipos.begin(); i<m_all_ipos.end(); i++)
51
// ----------------------------------------------------------------------------
52
/** Stores the initial transform (in the IPOs actually). This is necessary
54
* \param xyz Position of the object.
55
* \param hpr Rotation of the object.
57
void AnimationBase::setInitialTransform(const core::vector3df &xyz,
58
const core::vector3df &hpr)
60
std::vector<Ipo*>::iterator i;
61
for(i=m_all_ipos.begin(); i<m_all_ipos.end(); i++)
63
(*i)->setInitialTransform(xyz, hpr);
64
} // for i in m_all_ipos
67
// ----------------------------------------------------------------------------
68
/** Resets all IPOs for this animation.
70
void AnimationBase::reset()
72
std::vector<Ipo*>::iterator i;
73
for(i=m_all_ipos.begin(); i<m_all_ipos.end(); i++)
76
} // for i in m_all_ipos
79
// ----------------------------------------------------------------------------
80
/** Updates the time, position and rotation. Called once per framce.
81
* \param dt Time since last call.
82
* \param xyz Position to be updated.
83
* \param hpr Rotation to be updated.
85
void AnimationBase::update(float dt, core::vector3df *xyz,
86
core::vector3df *hpr, core::vector3df *scale)
88
std::vector<Ipo*>::iterator i;
89
for(i=m_all_ipos.begin(); i<m_all_ipos.end(); i++)
91
(*i)->update(dt, xyz, hpr, scale);
92
} // for i in m_all_ipos