diff --git a/code/ryzom/client/src/camera_animation_manager/camera_animation_info.h b/code/ryzom/client/src/camera_animation_manager/camera_animation_info.h index fe615e5f9..869d07d45 100644 --- a/code/ryzom/client/src/camera_animation_manager/camera_animation_info.h +++ b/code/ryzom/client/src/camera_animation_manager/camera_animation_info.h @@ -20,33 +20,73 @@ #include "nel/misc/vector.h" +/************************************************************************/ +/* Class that contains new information about the camera + * + * \author Fabien Henon + * \date 2012 + */ +/************************************************************************/ +struct TCameraAnimationOutputInfo +{ + TCameraAnimationOutputInfo() {} + + NLMISC::CVector CamPos; /// Camera position + NLMISC::CVector CamLookAtDir; /// Camera look at direction +}; /************************************************************************/ -/* Class that contains information about the camera +/* Class that contains current information about the camera * * \author Fabien Henon * \date 2012 */ /************************************************************************/ -struct TCameraAnimationInfo +struct TCameraAnimationInputInfo { - TCameraAnimationInfo(const NLMISC::CVector& camPos, - const NLMISC::CVector& camLookAtDir, - float elapsedTimeSinceStartStep) + TCameraAnimationInputInfo(const NLMISC::CVector& currCamPos, const NLMISC::CVector& currCamLookAtDir, + const NLMISC::CVector& startCamPos, const NLMISC::CVector& startCamLookAtDir, + float elapsedTimeSinceStartStep) { - CamPos = camPos; - CamLookAtDir = camLookAtDir; + CamPos = currCamPos; + CamLookAtDir = currCamLookAtDir; + + StartCamPos = startCamPos; + StartCamLookAtDir = startCamLookAtDir; + ElapsedTimeSinceStartStep = elapsedTimeSinceStartStep; } - TCameraAnimationInfo() {} + TCameraAnimationInputInfo(const TCameraAnimationOutputInfo& output, const TCameraAnimationInputInfo& input) + { + CamPos = output.CamPos; + CamLookAtDir = output.CamLookAtDir; - NLMISC::CVector CamPos; /// Camera position - NLMISC::CVector CamLookAtDir; /// Camera look at direction + StartCamPos = input.StartCamPos; + StartCamLookAtDir = input.StartCamLookAtDir; + + ElapsedTimeSinceStartStep = input.ElapsedTimeSinceStartStep; + } + + TCameraAnimationOutputInfo toOutput() const + { + TCameraAnimationOutputInfo output; + output.CamPos = CamPos; + output.CamLookAtDir = CamLookAtDir; + return output; + } + + NLMISC::CVector CamPos; /// Current camera position + NLMISC::CVector CamLookAtDir; /// Current camera look at direction + + NLMISC::CVector StartCamPos; /// Start camera position + NLMISC::CVector StartCamLookAtDir; /// Start camera look at direction float ElapsedTimeSinceStartStep; /// Elapsed time in second since the beginning of this step }; + + #endif /* RY_CAMERAANIMATIONINFO_H */ diff --git a/code/ryzom/client/src/camera_animation_manager/camera_animation_modifier_player_factory.h b/code/ryzom/client/src/camera_animation_manager/camera_animation_modifier_player_factory.h index 97a0be2ba..e860f5202 100644 --- a/code/ryzom/client/src/camera_animation_manager/camera_animation_modifier_player_factory.h +++ b/code/ryzom/client/src/camera_animation_manager/camera_animation_modifier_player_factory.h @@ -36,7 +36,7 @@ public: /// Function that updates the modifier /// currCamInfo contains information about the current camera position and look at position /// The function must return the new camera information - virtual TCameraAnimationInfo updateModifier(const TCameraAnimationInfo& currCamInfo) = 0; + virtual TCameraAnimationOutputInfo updateModifier(const TCameraAnimationInputInfo& currCamInfo) = 0; /// Function called when the modifier is stopped virtual void stopModifier() = 0; diff --git a/code/ryzom/client/src/camera_animation_manager/camera_animation_modifiers_players.cpp b/code/ryzom/client/src/camera_animation_manager/camera_animation_modifiers_players.cpp index 976ae4365..886278725 100644 --- a/code/ryzom/client/src/camera_animation_manager/camera_animation_modifiers_players.cpp +++ b/code/ryzom/client/src/camera_animation_manager/camera_animation_modifiers_players.cpp @@ -45,9 +45,9 @@ public: } /// Function that plays the modifier - virtual TCameraAnimationInfo updateModifier(const TCameraAnimationInfo& currCamInfo) + virtual TCameraAnimationOutputInfo updateModifier(const TCameraAnimationInputInfo& currCamInfo) { - return currCamInfo; + return currCamInfo.toOutput(); } virtual void stopModifier() @@ -86,9 +86,9 @@ public: } /// Function that plays the modifier - virtual TCameraAnimationInfo updateModifier(const TCameraAnimationInfo& currCamInfo) + virtual TCameraAnimationOutputInfo updateModifier(const TCameraAnimationInputInfo& currCamInfo) { - return currCamInfo; + return currCamInfo.toOutput(); } virtual void stopModifier() 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 508e0f4c2..b4f4ec3b6 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 @@ -122,20 +122,24 @@ bool CCameraAnimationPlayer::isPlaying() return _IsPlaying; } -TCameraAnimationInfo CCameraAnimationPlayer::update() +TCameraAnimationOutputInfo CCameraAnimationPlayer::update() { // We update the elapsed time for this step _ElapsedTimeForCurrStep += DT; - TCameraAnimationInfo currCamInfo(_StartStepCamLookAtDir, _StartStepCamPos, _ElapsedTimeForCurrStep); + NLMISC::CVector currCamPos = View.currentViewPos(); + NLMISC::CVector currLookAtDir = View.currentView(); + + TCameraAnimationInputInfo currCamInfo(currCamPos, currLookAtDir, + _StartStepCamPos, _StartStepCamLookAtDir, _ElapsedTimeForCurrStep); if (!isPlaying()) - return currCamInfo; + return currCamInfo.toOutput(); if (_CurrStep == NULL) - return currCamInfo; + return currCamInfo.toOutput(); // We update the current step - currCamInfo = _CurrStep->updateStepAndModifiers(currCamInfo); + TCameraAnimationOutputInfo newCamInfo = _CurrStep->updateStepAndModifiers(currCamInfo); - return currCamInfo; + return newCamInfo; } diff --git a/code/ryzom/client/src/camera_animation_manager/camera_animation_player.h b/code/ryzom/client/src/camera_animation_manager/camera_animation_player.h index 4832fbd5e..d671799e4 100644 --- a/code/ryzom/client/src/camera_animation_manager/camera_animation_player.h +++ b/code/ryzom/client/src/camera_animation_manager/camera_animation_player.h @@ -67,7 +67,7 @@ public: bool isPlaying(); /// Updates the camera by calling the update function of the current step and modifiers - TCameraAnimationInfo update(); + TCameraAnimationOutputInfo update(); private: /// Constructor 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 8acaf9a4b..9f28107b4 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 @@ -92,18 +92,20 @@ void ICameraAnimationStepPlayer::addModifier(ICameraAnimationModifierPlayer* mod Modifiers.push_back(modifier); } -TCameraAnimationInfo ICameraAnimationStepPlayer::updateStepAndModifiers(const TCameraAnimationInfo& currCamInfo) +TCameraAnimationOutputInfo ICameraAnimationStepPlayer::updateStepAndModifiers(const TCameraAnimationInputInfo& currCamInfo) { // Updates the step - TCameraAnimationInfo newInfo = updateStep(currCamInfo); + TCameraAnimationOutputInfo newInfo = updateStep(currCamInfo); // Updates the modifiers for (std::vector::iterator it = Modifiers.begin(); it != Modifiers.end(); ++it) { ICameraAnimationModifierPlayer* modifier = *it; + TCameraAnimationInputInfo input(newInfo, currCamInfo); + // We update the modifier - newInfo = modifier->updateModifier(newInfo); + newInfo = modifier->updateModifier(input); } return newInfo; } 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 11170e85b..3fc7e0e86 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 @@ -40,7 +40,7 @@ public: /// Function that updates the camera with the step /// currCamInfo contains information about the current camera position and look at position /// The function must return the new camera information - virtual TCameraAnimationInfo updateStep(const TCameraAnimationInfo& currCamInfo) = 0; + virtual TCameraAnimationOutputInfo updateStep(const TCameraAnimationInputInfo& currCamInfo) = 0; /// Function called when the step stops virtual void stopStep() = 0; @@ -52,7 +52,7 @@ public: void addModifier(ICameraAnimationModifierPlayer* modifier); // Plays the step and its modifiers - TCameraAnimationInfo updateStepAndModifiers(const TCameraAnimationInfo& currCamInfo); + TCameraAnimationOutputInfo updateStepAndModifiers(const TCameraAnimationInputInfo& currCamInfo); // Stops the step and its modifiers void stopStepAndModifiers(); diff --git a/code/ryzom/client/src/camera_animation_manager/camera_animation_steps_players.cpp b/code/ryzom/client/src/camera_animation_manager/camera_animation_steps_players.cpp index f62b15ac0..dea74ac16 100644 --- a/code/ryzom/client/src/camera_animation_manager/camera_animation_steps_players.cpp +++ b/code/ryzom/client/src/camera_animation_manager/camera_animation_steps_players.cpp @@ -19,6 +19,7 @@ #include "game_share/position_or_entity_type.h" #include "camera_animation_manager/camera_animation_info.h" #include "camera_animation_manager/position_or_entity_pos_resolver.h" +#include "client_cfg.h" /// Basic camera animation step that has generic values @@ -73,12 +74,12 @@ public: } /// Function that plays the step - virtual TCameraAnimationInfo updateStep(const TCameraAnimationInfo& currCamInfo) + virtual TCameraAnimationOutputInfo updateStep(const TCameraAnimationInputInfo& currCamInfo) { - TCameraAnimationInfo camInfo; + TCameraAnimationOutputInfo camInfo; // We don't change the position - camInfo.CamPos = currCamInfo.CamPos; + camInfo.CamPos = currCamInfo.StartCamPos; float ratio = currCamInfo.ElapsedTimeSinceStartStep / getDuration(); @@ -86,7 +87,7 @@ public: NLMISC::CVector finalDir = resolvePositionOrEntityPosition(LookAtPos) - camInfo.CamPos; // We get the current look at direction - camInfo.CamLookAtDir = computeCurrentLookAtDir(ratio, currCamInfo.CamLookAtDir, finalDir); + camInfo.CamLookAtDir = computeCurrentLookAtDir(ratio, currCamInfo.StartCamLookAtDir, finalDir); return camInfo; } @@ -121,24 +122,24 @@ public: } /// Function that plays the step - virtual TCameraAnimationInfo updateStep(const TCameraAnimationInfo& currCamInfo) + virtual TCameraAnimationOutputInfo updateStep(const TCameraAnimationInputInfo& currCamInfo) { - TCameraAnimationInfo camInfo; + TCameraAnimationOutputInfo camInfo; float ratio = currCamInfo.ElapsedTimeSinceStartStep / getDuration(); // We compute the current position between the starting position and the final position - NLMISC::CVector movementVector = resolvePositionOrEntityPosition(EndPos) - currCamInfo.CamPos; + NLMISC::CVector movementVector = resolvePositionOrEntityPosition(EndPos) - currCamInfo.StartCamPos; // We current position is computed using the ratio and the starting position NLMISC::CVector offset = movementVector * ratio; - camInfo.CamPos = currCamInfo.CamPos + offset; + camInfo.CamPos = currCamInfo.StartCamPos + offset; // Now we compute the current look at direction NLMISC::CVector finalDir = resolvePositionOrEntityPosition(LookAtPos) - camInfo.CamPos; // We get the current look at direction - camInfo.CamLookAtDir = computeCurrentLookAtDir(ratio, currCamInfo.CamLookAtDir, finalDir); + camInfo.CamLookAtDir = computeCurrentLookAtDir(ratio, currCamInfo.StartCamLookAtDir, finalDir); return camInfo; } @@ -177,13 +178,15 @@ public: } /// Function that plays the step - virtual TCameraAnimationInfo updateStep(const TCameraAnimationInfo& currCamInfo) + virtual TCameraAnimationOutputInfo updateStep(const TCameraAnimationInputInfo& currCamInfo) { - TCameraAnimationInfo camInfo; + TCameraAnimationOutputInfo camInfo; - // We compute the distance + // We compute the distance between the entity to follow and our current position + NLMISC::CVector entityPos = resolvePositionOrEntityPosition(EntityToFollow); + NLMISC::CVector distanceVec = entityPos - currCamInfo.CamPos; - return currCamInfo; + return camInfo; } virtual void stopStep() @@ -224,9 +227,9 @@ public: } /// Function that plays the step - virtual TCameraAnimationInfo updateStep(const TCameraAnimationInfo& currCamInfo) + virtual TCameraAnimationOutputInfo updateStep(const TCameraAnimationInputInfo& currCamInfo) { - return currCamInfo; + return currCamInfo.toOutput(); } virtual void stopStep() @@ -264,9 +267,9 @@ public: } /// Function that plays the step - virtual TCameraAnimationInfo updateStep(const TCameraAnimationInfo& currCamInfo) + virtual TCameraAnimationOutputInfo updateStep(const TCameraAnimationInputInfo& currCamInfo) { - return currCamInfo; + return currCamInfo.toOutput(); } virtual void stopStep() diff --git a/code/ryzom/client/src/motion/modes/cam_anim_mode.cpp b/code/ryzom/client/src/motion/modes/cam_anim_mode.cpp index fc9c4f3e3..9122c5dcc 100644 --- a/code/ryzom/client/src/motion/modes/cam_anim_mode.cpp +++ b/code/ryzom/client/src/motion/modes/cam_anim_mode.cpp @@ -80,7 +80,7 @@ void CUserControls::camAnimModeStop() void CUserControls::camAnimMode() { // Call the camera animation update function to update the view - TCameraAnimationInfo newCamInfo = CCameraAnimationPlayer::getInstance()->update(); + TCameraAnimationOutputInfo newCamInfo = CCameraAnimationPlayer::getInstance()->update(); // We normalize the look at direction newCamInfo.CamLookAtDir.normalize();