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
hg/feature/gsoc2012-fabien
Fabien_HENON 13 years ago
parent 55725c21b3
commit 24461197d5

@ -31,18 +31,18 @@
struct TCameraAnimationInfo struct TCameraAnimationInfo
{ {
TCameraAnimationInfo(const NLMISC::CVector& camPos, TCameraAnimationInfo(const NLMISC::CVector& camPos,
const NLMISC::CVector& camLookAt, const NLMISC::CVector& camLookAtDir,
float elapsedTimeSinceStartStep) float elapsedTimeSinceStartStep)
{ {
CamPos = camPos; CamPos = camPos;
CamLookAt = camLookAt; CamLookAtDir = camLookAtDir;
ElapsedTimeSinceStartStep = elapsedTimeSinceStartStep; ElapsedTimeSinceStartStep = elapsedTimeSinceStartStep;
} }
TCameraAnimationInfo() {} TCameraAnimationInfo() {}
NLMISC::CVector CamPos; /// Camera position 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 float ElapsedTimeSinceStartStep; /// Elapsed time in second since the beginning of this step
}; };

@ -20,6 +20,7 @@
#include "camera_animation_manager/camera_animation_step_player_factory.h" #include "camera_animation_manager/camera_animation_step_player_factory.h"
#include "time_client.h" #include "time_client.h"
#include "view.h" #include "view.h"
#include "motion/user_controls.h"
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;
@ -34,6 +35,7 @@ CCameraAnimationPlayer::CCameraAnimationPlayer()
_IsPlaying = false; _IsPlaying = false;
_CurrStep = NULL; _CurrStep = NULL;
_ElapsedTimeForCurrStep = 0.f; _ElapsedTimeForCurrStep = 0.f;
_HasLastViewInfo = false;
} }
CCameraAnimationPlayer::~CCameraAnimationPlayer() CCameraAnimationPlayer::~CCameraAnimationPlayer()
@ -47,6 +49,13 @@ void CCameraAnimationPlayer::start()
stop(); stop();
_IsPlaying = true; _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() void CCameraAnimationPlayer::stop()
@ -54,6 +63,15 @@ void CCameraAnimationPlayer::stop()
_IsPlaying = false; _IsPlaying = false;
stopStep(); 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() void CCameraAnimationPlayer::stopStep()
@ -103,13 +121,13 @@ bool CCameraAnimationPlayer::isPlaying()
TCameraAnimationInfo CCameraAnimationPlayer::update() TCameraAnimationInfo CCameraAnimationPlayer::update()
{ {
// We get the current camera information // We get the current camera information
NLMISC::CVector camLookAt = View.view(); NLMISC::CVector camLookAtDir = View.currentView();
NLMISC::CVector camPos = View.viewPos(); NLMISC::CVector camPos = View.currentViewPos();
// We update the elapsed time for this step // We update the elapsed time for this step
_ElapsedTimeForCurrStep += DT; _ElapsedTimeForCurrStep += DT;
TCameraAnimationInfo currCamInfo(camPos, camLookAt, _ElapsedTimeForCurrStep); TCameraAnimationInfo currCamInfo(camPos, camLookAtDir, _ElapsedTimeForCurrStep);
if (!isPlaying()) if (!isPlaying())
return currCamInfo; return currCamInfo;

@ -23,6 +23,7 @@
#include "camera_animation_manager/camera_animation_step_player_factory.h" #include "camera_animation_manager/camera_animation_step_player_factory.h"
#include "nel/misc/vector.h" #include "nel/misc/vector.h"
#include "camera_animation_manager\camera_animation_info.h" #include "camera_animation_manager\camera_animation_info.h"
#include "motion\user_controls.h"
/************************************************************************/ /************************************************************************/
@ -85,6 +86,11 @@ private:
ICameraAnimationStepPlayer* _CurrStep; ICameraAnimationStepPlayer* _CurrStep;
float _ElapsedTimeForCurrStep; float _ElapsedTimeForCurrStep;
NLMISC::CVector _LastView;
NLMISC::CVector _LastViewPos;
CUserControls::TMoveMode _LastMode;
bool _HasLastViewInfo;
}; };

@ -28,6 +28,8 @@
#include "../../view.h" #include "../../view.h"
#include "../../interface_v3/interface_manager.h" #include "../../interface_v3/interface_manager.h"
#include "../../entities.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() void CUserControls::camAnimMode()
{ {
// Call the camera animation update function to update the view // 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 // }// camAnimMode //

Loading…
Cancel
Save