From 24461197d5b7ca734897627f806ea2a3aea7a7a1 Mon Sep 17 00:00:00 2001 From: Fabien_HENON Date: Tue, 7 Aug 2012 22:30:20 +0200 Subject: [PATCH] Added: #1469 Integration of the camera animation player in the CamAnimMode and storing and restoring of view info at animation start and stop --HG-- branch : gsoc2012-fabien --- .../camera_animation_info.h | 6 ++--- .../camera_animation_player.cpp | 24 ++++++++++++++++--- .../camera_animation_player.h | 6 +++++ .../client/src/motion/modes/cam_anim_mode.cpp | 10 ++++++++ 4 files changed, 40 insertions(+), 6 deletions(-) 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 98a5cfa75..fe615e5f9 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 @@ -31,18 +31,18 @@ struct TCameraAnimationInfo { TCameraAnimationInfo(const NLMISC::CVector& camPos, - const NLMISC::CVector& camLookAt, + const NLMISC::CVector& camLookAtDir, float elapsedTimeSinceStartStep) { CamPos = camPos; - CamLookAt = camLookAt; + CamLookAtDir = camLookAtDir; ElapsedTimeSinceStartStep = elapsedTimeSinceStartStep; } TCameraAnimationInfo() {} NLMISC::CVector CamPos; /// Camera position - NLMISC::CVector CamLookAt; /// Camera look at position + NLMISC::CVector CamLookAtDir; /// Camera look at direction float ElapsedTimeSinceStartStep; /// Elapsed time in second since the beginning of this step }; 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 0ec699f34..e022e4396 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 @@ -20,6 +20,7 @@ #include "camera_animation_manager/camera_animation_step_player_factory.h" #include "time_client.h" #include "view.h" +#include "motion/user_controls.h" using namespace std; using namespace NLMISC; @@ -34,6 +35,7 @@ CCameraAnimationPlayer::CCameraAnimationPlayer() _IsPlaying = false; _CurrStep = NULL; _ElapsedTimeForCurrStep = 0.f; + _HasLastViewInfo = false; } CCameraAnimationPlayer::~CCameraAnimationPlayer() @@ -47,6 +49,13 @@ void CCameraAnimationPlayer::start() stop(); _IsPlaying = true; + + // We set the user controls in camAnimMode and we remember the current view and viewPos + _LastView = View.currentView(); + _LastViewPos = View.currentViewPos(); + _LastMode = UserControls.mode(); + UserControls.mode(CUserControls::CamAnimMode); + _HasLastViewInfo = true; } void CCameraAnimationPlayer::stop() @@ -54,6 +63,15 @@ void CCameraAnimationPlayer::stop() _IsPlaying = false; stopStep(); + + // We reset view and viewPos and the usercontrols mode + if (_HasLastViewInfo) + { + UserControls.mode(_LastMode); + View.view(_LastView); + View.viewPos(_LastViewPos); + _HasLastViewInfo = false; + } } void CCameraAnimationPlayer::stopStep() @@ -103,13 +121,13 @@ bool CCameraAnimationPlayer::isPlaying() TCameraAnimationInfo CCameraAnimationPlayer::update() { // We get the current camera information - NLMISC::CVector camLookAt = View.view(); - NLMISC::CVector camPos = View.viewPos(); + NLMISC::CVector camLookAtDir = View.currentView(); + NLMISC::CVector camPos = View.currentViewPos(); // We update the elapsed time for this step _ElapsedTimeForCurrStep += DT; - TCameraAnimationInfo currCamInfo(camPos, camLookAt, _ElapsedTimeForCurrStep); + TCameraAnimationInfo currCamInfo(camPos, camLookAtDir, _ElapsedTimeForCurrStep); if (!isPlaying()) return currCamInfo; 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 a7a3f253b..58497573f 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 @@ -23,6 +23,7 @@ #include "camera_animation_manager/camera_animation_step_player_factory.h" #include "nel/misc/vector.h" #include "camera_animation_manager\camera_animation_info.h" +#include "motion\user_controls.h" /************************************************************************/ @@ -85,6 +86,11 @@ private: ICameraAnimationStepPlayer* _CurrStep; float _ElapsedTimeForCurrStep; + + NLMISC::CVector _LastView; + NLMISC::CVector _LastViewPos; + CUserControls::TMoveMode _LastMode; + bool _HasLastViewInfo; }; 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 7cef7f8cb..fc9c4f3e3 100644 --- a/code/ryzom/client/src/motion/modes/cam_anim_mode.cpp +++ b/code/ryzom/client/src/motion/modes/cam_anim_mode.cpp @@ -28,6 +28,8 @@ #include "../../view.h" #include "../../interface_v3/interface_manager.h" #include "../../entities.h" +#include "camera_animation_manager/camera_animation_info.h" +#include "camera_animation_manager/camera_animation_player.h" /////////// @@ -78,4 +80,12 @@ void CUserControls::camAnimModeStop() void CUserControls::camAnimMode() { // Call the camera animation update function to update the view + TCameraAnimationInfo newCamInfo = CCameraAnimationPlayer::getInstance()->update(); + + // We normalize the look at direction + newCamInfo.CamLookAtDir.normalize(); + + // We udpate the view + View.view(newCamInfo.CamLookAtDir); + View.viewPos(newCamInfo.CamPos); }// camAnimMode //