From a27c34c7054658286d04a242e8c029c8d217849a Mon Sep 17 00:00:00 2001 From: Fabien_HENON Date: Fri, 27 Jul 2012 19:35:07 +0200 Subject: [PATCH] Added: #1469 Integration of the modifiers in the processus of steps --HG-- branch : gsoc2012-fabien --- ...mera_animation_modifier_player_factory.cpp | 3 ++ .../camera_animation_player.cpp | 2 +- .../camera_animation_step_player_factory.cpp | 51 +++++++++++++++++++ .../camera_animation_step_player_factory.h | 11 ++++ .../camera_animation_step_factory.h | 3 -- 5 files changed, 66 insertions(+), 4 deletions(-) diff --git a/code/ryzom/client/src/camera_animation_manager/camera_animation_modifier_player_factory.cpp b/code/ryzom/client/src/camera_animation_manager/camera_animation_modifier_player_factory.cpp index 0221a88c3..cef5fd27c 100644 --- a/code/ryzom/client/src/camera_animation_manager/camera_animation_modifier_player_factory.cpp +++ b/code/ryzom/client/src/camera_animation_manager/camera_animation_modifier_player_factory.cpp @@ -21,6 +21,9 @@ std::vector >* IC ICameraAnimationModifierPlayer* ICameraAnimationModifierPlayerFactory::initModifier(const std::string& name, NLMISC::CBitMemStream& impulse) { + if (!Entries) + return NULL; + // We search the correct modifier type in our entries for (uint i = 0; i < Entries->size(); i++) { diff --git a/code/ryzom/client/src/camera_animation_manager/camera_animation_player.cpp b/code/ryzom/client/src/camera_animation_manager/camera_animation_player.cpp index b16660f70..95a61e009 100644 --- a/code/ryzom/client/src/camera_animation_manager/camera_animation_player.cpp +++ b/code/ryzom/client/src/camera_animation_manager/camera_animation_player.cpp @@ -78,7 +78,7 @@ void CCameraAnimationPlayer::playStep(const std::string& stepName, NLMISC::CBitM _Steps.push_back(step); // We start playing the step - step->playStep(); + step->playStepAndModifiers(); } bool CCameraAnimationPlayer::isPlaying() diff --git a/code/ryzom/client/src/camera_animation_manager/camera_animation_step_player_factory.cpp b/code/ryzom/client/src/camera_animation_manager/camera_animation_step_player_factory.cpp index 250bc4f32..36b07d4b2 100644 --- a/code/ryzom/client/src/camera_animation_manager/camera_animation_step_player_factory.cpp +++ b/code/ryzom/client/src/camera_animation_manager/camera_animation_step_player_factory.cpp @@ -43,6 +43,27 @@ ICameraAnimationStepPlayer* ICameraAnimationStepPlayerFactory::initStep(const st 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; } } @@ -55,3 +76,33 @@ void ICameraAnimationStepPlayerFactory::init() Entries = new std::vector >; } +ICameraAnimationStepPlayer::~ICameraAnimationStepPlayer() +{ + // We release all the modifiers + for (std::vector::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::iterator it = Modifiers.begin(); it != Modifiers.end(); ++it) + { + ICameraAnimationModifierPlayer* modifier = *it; + + // We play the modifier + modifier->playModifier(); + } +} \ No newline at end of file diff --git a/code/ryzom/client/src/camera_animation_manager/camera_animation_step_player_factory.h b/code/ryzom/client/src/camera_animation_manager/camera_animation_step_player_factory.h index daaa936f8..81d5379d9 100644 --- a/code/ryzom/client/src/camera_animation_manager/camera_animation_step_player_factory.h +++ b/code/ryzom/client/src/camera_animation_manager/camera_animation_step_player_factory.h @@ -20,6 +20,7 @@ #include #include #include "nel\misc\bit_mem_stream.h" +#include "camera_animation_manager\camera_animation_modifier_player_factory.h" /************************************************************************/ /* Interface for camera animation steps. @@ -29,13 +30,23 @@ class ICameraAnimationStepPlayer { public: + virtual ~ICameraAnimationStepPlayer(); + /// This function is called when it's time to init the step from an impulse virtual bool initStep(NLMISC::CBitMemStream& impulse) = 0; /// Function that plays the step 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: + // The list of modifiers + std::vector Modifiers; }; /************************************************************************/ diff --git a/code/ryzom/server/src/entities_game_service/camera_animation_manager/camera_animation_step_factory.h b/code/ryzom/server/src/entities_game_service/camera_animation_manager/camera_animation_step_factory.h index d7349543f..d929997a5 100644 --- a/code/ryzom/server/src/entities_game_service/camera_animation_manager/camera_animation_step_factory.h +++ b/code/ryzom/server/src/entities_game_service/camera_animation_manager/camera_animation_step_factory.h @@ -71,9 +71,6 @@ protected: static void init(); virtual ICameraAnimationStep * instanciate() = 0; static std::vector >* Entries; - - // The list of modifiers - std::vector Modifiers; }; // Define used to register the different types of camera animation steps