Added: #1469 Integration of the modifiers in the processus of steps

--HG--
branch : gsoc2012-fabien
hg/feature/gsoc2012-fabien
Fabien_HENON 12 years ago
parent af59474d9c
commit a27c34c705

@ -21,6 +21,9 @@ std::vector<std::pair<std::string, ICameraAnimationModifierPlayerFactory*> >* IC
ICameraAnimationModifierPlayer* ICameraAnimationModifierPlayerFactory::initModifier(const std::string& name, NLMISC::CBitMemStream& impulse) ICameraAnimationModifierPlayer* ICameraAnimationModifierPlayerFactory::initModifier(const std::string& name, NLMISC::CBitMemStream& impulse)
{ {
if (!Entries)
return NULL;
// We search the correct modifier type in our entries // We search the correct modifier type in our entries
for (uint i = 0; i < Entries->size(); i++) for (uint i = 0; i < Entries->size(); i++)
{ {

@ -78,7 +78,7 @@ void CCameraAnimationPlayer::playStep(const std::string& stepName, NLMISC::CBitM
_Steps.push_back(step); _Steps.push_back(step);
// We start playing the step // We start playing the step
step->playStep(); step->playStepAndModifiers();
} }
bool CCameraAnimationPlayer::isPlaying() bool CCameraAnimationPlayer::isPlaying()

@ -43,6 +43,27 @@ ICameraAnimationStepPlayer* ICameraAnimationStepPlayerFactory::initStep(const st
return NULL; return NULL;
} }
// We look for children (modifiers or sound triggers)
uint8 nbModifiers = 0;
impulse.serial(nbModifiers);
for (uint8 i = 0; i < nbModifiers; i++)
{
// We get the modifier name
std::string modifierName = "";
impulse.serial(modifierName);
ICameraAnimationModifierPlayer* modifier = ICameraAnimationModifierPlayerFactory::initModifier(modifierName, impulse);
// We add the modifier to the list
if (modifier)
{
ret->addModifier(modifier);
}
else
{
nlwarning("impossible to init the modifier named %s in step named %s", modifierName.c_str(), name.c_str());
}
}
return ret; return ret;
} }
} }
@ -55,3 +76,33 @@ void ICameraAnimationStepPlayerFactory::init()
Entries = new std::vector<std::pair<std::string, ICameraAnimationStepPlayerFactory*> >; Entries = new std::vector<std::pair<std::string, ICameraAnimationStepPlayerFactory*> >;
} }
ICameraAnimationStepPlayer::~ICameraAnimationStepPlayer()
{
// We release all the modifiers
for (std::vector<ICameraAnimationModifierPlayer*>::iterator it = Modifiers.begin(); it != Modifiers.end(); ++it)
{
ICameraAnimationModifierPlayer* modifier = *it;
delete modifier;
}
Modifiers.clear();
}
void ICameraAnimationStepPlayer::addModifier(ICameraAnimationModifierPlayer* modifier)
{
Modifiers.push_back(modifier);
}
void ICameraAnimationStepPlayer::playStepAndModifiers()
{
// Play the step
playStep();
// Play the modifiers
for (std::vector<ICameraAnimationModifierPlayer*>::iterator it = Modifiers.begin(); it != Modifiers.end(); ++it)
{
ICameraAnimationModifierPlayer* modifier = *it;
// We play the modifier
modifier->playModifier();
}
}

@ -20,6 +20,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "nel\misc\bit_mem_stream.h" #include "nel\misc\bit_mem_stream.h"
#include "camera_animation_manager\camera_animation_modifier_player_factory.h"
/************************************************************************/ /************************************************************************/
/* Interface for camera animation steps. /* Interface for camera animation steps.
@ -29,13 +30,23 @@
class ICameraAnimationStepPlayer class ICameraAnimationStepPlayer
{ {
public: public:
virtual ~ICameraAnimationStepPlayer();
/// This function is called when it's time to init the step from an impulse /// This function is called when it's time to init the step from an impulse
virtual bool initStep(NLMISC::CBitMemStream& impulse) = 0; virtual bool initStep(NLMISC::CBitMemStream& impulse) = 0;
/// Function that plays the step /// Function that plays the step
virtual void playStep() = 0; virtual void playStep() = 0;
/// Function that adds a camera animation modifier to this step
void addModifier(ICameraAnimationModifierPlayer* modifier);
// Plays the step and its modifiers
void playStepAndModifiers();
protected: protected:
// The list of modifiers
std::vector<ICameraAnimationModifierPlayer*> Modifiers;
}; };
/************************************************************************/ /************************************************************************/

@ -71,9 +71,6 @@ protected:
static void init(); static void init();
virtual ICameraAnimationStep * instanciate() = 0; virtual ICameraAnimationStep * instanciate() = 0;
static std::vector<std::pair<std::string, ICameraAnimationStepFactory*> >* Entries; static std::vector<std::pair<std::string, ICameraAnimationStepFactory*> >* Entries;
// The list of modifiers
std::vector<ICameraAnimationModifier*> Modifiers;
}; };
// Define used to register the different types of camera animation steps // Define used to register the different types of camera animation steps

Loading…
Cancel
Save