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 b5791b50c..f2957da43 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 @@ -122,3 +122,30 @@ void ICameraAnimationStepPlayer::stopStepAndModifiers() modifier->stopModifier(); } } + +NLMISC::CVector ICameraAnimationStepPlayer::computeCurrentLookAtDir(float ratio, const NLMISC::CVector& currPos, const NLMISC::CVector& startLookAtDir, + const NLMISC::CVector& endLookAtDir) +{ + // We normalize the start look at direction + NLMISC::CVector startDir = startLookAtDir; + startDir.normalize(); + + // We normalize the final look at direction + NLMISC::CVector finalDir = endLookAtDir; + finalDir.normalize(); + + // We compute a vector that goes from the starting look at dir to the final look at dir + NLMISC::CVector startToFinal = finalDir - startDir; + + // We multiply this vector by the ratio so that we can have a vector that represent the current position we are looking at + startToFinal = startToFinal * ratio; + + // We compute the position we are looking at + NLMISC::CVector currLookAtPos = startDir + startToFinal; + + // We compute the direction + NLMISC::CVector currLookAtDir = currLookAtPos - currPos; + currLookAtDir.normalize(); + + return currLookAtDir; +} 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 3d15f581d..bd54bc73b 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 @@ -22,6 +22,7 @@ #include "nel/misc/bit_mem_stream.h" #include "camera_animation_manager/camera_animation_modifier_player_factory.h" #include "camera_animation_manager/camera_animation_info.h" +#include "nel/misc/vector.h" /************************************************************************/ /* Interface for camera animation steps. @@ -57,6 +58,13 @@ public: void stopStepAndModifiers(); protected: + + /// Compute the current look at direction depending on the current position, the starting look at direction, + /// the ending look at direction and the progression expressed as a ratio (value between 0 and 1 that expresses the + /// progression) + NLMISC::CVector computeCurrentLookAtDir(float ratio, const NLMISC::CVector& currPos, const NLMISC::CVector& startLookAtDir, + const NLMISC::CVector& endLookAtDir); + // The list of modifiers std::vector Modifiers; }; 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 d2dba764f..fd287d208 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 @@ -84,24 +84,12 @@ public: // We compute the starting look at direction NLMISC::CVector startDir = currCamInfo.CamLookAtDir - currCamInfo.CamPos; - startDir.normalize(); // We compute the final look at direction NLMISC::CVector finalDir = resolvePositionOrEntityPosition(LookAtPos) - currCamInfo.CamPos; - finalDir.normalize(); - // We compute a vector that goes from the starting look at dir to the final look at dir - NLMISC::CVector startToFinal = finalDir - startDir; - - // We multiply this vector by the ratio so that we can have a vector that represent the current position we are looking at - startToFinal = startToFinal * ratio; - - // We compute the position we are looking at - NLMISC::CVector currLookAtPos = startDir + startToFinal; - - // We compute the direction - camInfo.CamLookAtDir = currLookAtPos - camInfo.CamPos; - camInfo.CamLookAtDir.normalize(); + // We get the current look at direction + camInfo.CamLookAtDir = computeCurrentLookAtDir(ratio, camInfo.CamPos, startDir, finalDir); return camInfo; }