Add 3d animation ipo copying to child track objects
This commit is contained in:
parent
607c6932f0
commit
885aec8020
@ -61,6 +61,13 @@ AnimationBase::AnimationBase(Ipo *ipo)
|
||||
calculateAnimationDuration();
|
||||
} // AnimationBase(Ipo)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
AnimationBase::~AnimationBase()
|
||||
{
|
||||
for (Ipo* ipo : m_all_ipos)
|
||||
delete ipo;
|
||||
} // ~AnimationBase
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void AnimationBase::calculateAnimationDuration()
|
||||
{
|
||||
@ -81,7 +88,7 @@ void AnimationBase::calculateAnimationDuration()
|
||||
void AnimationBase::setInitialTransform(const Vec3 &xyz,
|
||||
const Vec3 &hpr)
|
||||
{
|
||||
for_var_in(Ipo*, curr, m_all_ipos)
|
||||
for (Ipo* curr : m_all_ipos)
|
||||
{
|
||||
curr->setInitialTransform(xyz, hpr);
|
||||
}
|
||||
@ -93,7 +100,7 @@ void AnimationBase::setInitialTransform(const Vec3 &xyz,
|
||||
void AnimationBase::reset()
|
||||
{
|
||||
m_current_time = 0;
|
||||
for_var_in(Ipo*, curr, m_all_ipos)
|
||||
for (Ipo* curr : m_all_ipos)
|
||||
{
|
||||
curr->reset();
|
||||
}
|
||||
@ -115,7 +122,7 @@ void AnimationBase::update(float dt, Vec3 *xyz, Vec3 *hpr, Vec3 *scale)
|
||||
|
||||
assert(!std::isnan(m_current_time));
|
||||
|
||||
for_var_in (Ipo*, curr, m_all_ipos)
|
||||
for (Ipo* curr : m_all_ipos)
|
||||
{
|
||||
curr->update(m_current_time, xyz, hpr, scale);
|
||||
}
|
||||
@ -135,7 +142,7 @@ void AnimationBase::getAt(float time, Vec3 *xyz, Vec3 *hpr, Vec3 *scale)
|
||||
// Don't do anything if the animation is disabled
|
||||
if (!m_playing) return;
|
||||
|
||||
for_var_in(Ipo*, curr, m_all_ipos)
|
||||
for (Ipo* curr : m_all_ipos)
|
||||
{
|
||||
curr->update(time, xyz, hpr, scale);
|
||||
}
|
||||
@ -148,7 +155,7 @@ void AnimationBase::getAt(float time, Vec3 *xyz, Vec3 *hpr, Vec3 *scale)
|
||||
*/
|
||||
void AnimationBase::getDerivativeAt(float time, Vec3 *xyz)
|
||||
{
|
||||
for_var_in(Ipo*, curr, m_all_ipos)
|
||||
for (Ipo* curr : m_all_ipos)
|
||||
{
|
||||
curr->getDerivative(time, xyz);
|
||||
}
|
||||
|
@ -26,14 +26,11 @@
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
|
||||
// Note that ipo.hpp is included here in order that PtrVector<Ipo> can call
|
||||
// the proper destructor!
|
||||
#include "animations/ipo.hpp"
|
||||
#include "utils/ptr_vector.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "utils/vec3.hpp"
|
||||
|
||||
class Ipo;
|
||||
class XMLNode;
|
||||
|
||||
/**
|
||||
@ -57,7 +54,7 @@ private:
|
||||
|
||||
protected:
|
||||
/** All IPOs for this animation. */
|
||||
PtrVector<Ipo> m_all_ipos;
|
||||
std::vector<Ipo*> m_all_ipos;
|
||||
|
||||
/** True if the animation is currently playing. */
|
||||
bool m_playing;
|
||||
@ -70,7 +67,7 @@ protected:
|
||||
public:
|
||||
AnimationBase(const XMLNode &node);
|
||||
AnimationBase(Ipo *ipo);
|
||||
virtual ~AnimationBase() {}
|
||||
virtual ~AnimationBase();
|
||||
virtual void update(float dt, Vec3 *xyz=NULL, Vec3 *hpr=NULL,
|
||||
Vec3 *scale=NULL);
|
||||
virtual void getAt(float time, Vec3 *xyz = NULL, Vec3 *hpr = NULL,
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "audio/sfx_base.hpp"
|
||||
#include "animations/ipo.hpp"
|
||||
#include "graphics/material.hpp"
|
||||
#include "graphics/material_manager.hpp"
|
||||
#include "graphics/mesh_tools.hpp"
|
||||
@ -118,3 +119,15 @@ void ThreeDAnimation::updateWithWorldTicks(bool has_physics)
|
||||
m_object->move(xyz.toIrrVector(), hpr, scale.toIrrVector(), true, false);
|
||||
}
|
||||
} // update
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Copying to child process of track object.
|
||||
*/
|
||||
ThreeDAnimation* ThreeDAnimation::clone(TrackObject* obj)
|
||||
{
|
||||
ThreeDAnimation* animation = new ThreeDAnimation(*this);
|
||||
animation->m_object = obj;
|
||||
for (unsigned i = 0; i < m_all_ipos.size(); i++)
|
||||
animation->m_all_ipos[i] = m_all_ipos[i]->clone();
|
||||
return animation;
|
||||
} // clone
|
||||
|
@ -81,6 +81,8 @@ public:
|
||||
bool isExplodeKartObject() const { return m_explode_kart; }
|
||||
bool isFlattenKartObject() const { return m_flatten_kart; }
|
||||
void setPaused(bool mode){ m_is_paused = mode; }
|
||||
// ------------------------------------------------------------------------
|
||||
ThreeDAnimation* clone(TrackObject* obj);
|
||||
}; // ThreeDAnimation
|
||||
#endif
|
||||
|
||||
|
@ -792,7 +792,8 @@ TrackObject* TrackObject::cloneToChild()
|
||||
to_clone->m_visibility_condition.clear();
|
||||
to_clone->m_presentation = NULL;
|
||||
to_clone->m_render_info.reset();
|
||||
to_clone->m_animator = NULL;
|
||||
if (m_animator)
|
||||
to_clone->m_animator = m_animator->clone(to_clone);
|
||||
to_clone->m_parent_library = NULL;
|
||||
to_clone->m_movable_children.clear();
|
||||
to_clone->m_children.clear();
|
||||
|
Loading…
Reference in New Issue
Block a user