Added: #1469 Implementation of the Return step

--HG--
branch : gsoc2012-fabien
hg/feature/gsoc2012-fabien
Fabien_HENON 12 years ago
parent 15ae25878f
commit e218106b3e

@ -46,6 +46,7 @@ struct TCameraAnimationInputInfo
{ {
TCameraAnimationInputInfo(const NLMISC::CVector& currCamPos, const NLMISC::CVector& currCamLookAtDir, TCameraAnimationInputInfo(const NLMISC::CVector& currCamPos, const NLMISC::CVector& currCamLookAtDir,
const NLMISC::CVector& startCamPos, const NLMISC::CVector& startCamLookAtDir, const NLMISC::CVector& startCamPos, const NLMISC::CVector& startCamLookAtDir,
const NLMISC::CVector& animStartCamPos, const NLMISC::CVector& animStartCamLookAtDir,
float elapsedTimeSinceStartStep) float elapsedTimeSinceStartStep)
{ {
CamPos = currCamPos; CamPos = currCamPos;
@ -54,6 +55,9 @@ struct TCameraAnimationInputInfo
StartCamPos = startCamPos; StartCamPos = startCamPos;
StartCamLookAtDir = startCamLookAtDir; StartCamLookAtDir = startCamLookAtDir;
AnimStartCamPos = startCamPos;
AnimStartCamLookAtDir = startCamLookAtDir;
ElapsedTimeSinceStartStep = elapsedTimeSinceStartStep; ElapsedTimeSinceStartStep = elapsedTimeSinceStartStep;
} }
@ -65,6 +69,9 @@ struct TCameraAnimationInputInfo
StartCamPos = input.StartCamPos; StartCamPos = input.StartCamPos;
StartCamLookAtDir = input.StartCamLookAtDir; StartCamLookAtDir = input.StartCamLookAtDir;
AnimStartCamPos = input.AnimStartCamPos;
AnimStartCamLookAtDir = input.AnimStartCamLookAtDir;
ElapsedTimeSinceStartStep = input.ElapsedTimeSinceStartStep; ElapsedTimeSinceStartStep = input.ElapsedTimeSinceStartStep;
} }
@ -82,6 +89,9 @@ struct TCameraAnimationInputInfo
NLMISC::CVector StartCamPos; /// Start camera position NLMISC::CVector StartCamPos; /// Start camera position
NLMISC::CVector StartCamLookAtDir; /// Start camera look at direction NLMISC::CVector StartCamLookAtDir; /// Start camera look at direction
NLMISC::CVector AnimStartCamPos; /// Camera position at animation start
NLMISC::CVector AnimStartCamLookAtDir; /// Camera look at direction an animation start
float ElapsedTimeSinceStartStep; /// Elapsed time in second since the beginning of this step float ElapsedTimeSinceStartStep; /// Elapsed time in second since the beginning of this step
}; };

@ -131,7 +131,9 @@ TCameraAnimationOutputInfo CCameraAnimationPlayer::update()
NLMISC::CVector currLookAtDir = View.currentView(); NLMISC::CVector currLookAtDir = View.currentView();
TCameraAnimationInputInfo currCamInfo(currCamPos, currLookAtDir, TCameraAnimationInputInfo currCamInfo(currCamPos, currLookAtDir,
_StartStepCamPos, _StartStepCamLookAtDir, _ElapsedTimeForCurrStep); _StartStepCamPos, _StartStepCamLookAtDir,
_LastViewPos, _LastView,
_ElapsedTimeForCurrStep);
if (!isPlaying()) if (!isPlaying())
return currCamInfo.toOutput(); return currCamInfo.toOutput();

@ -357,7 +357,21 @@ public:
/// Function that plays the step /// Function that plays the step
virtual TCameraAnimationOutputInfo updateStep(const TCameraAnimationInputInfo& currCamInfo) virtual TCameraAnimationOutputInfo updateStep(const TCameraAnimationInputInfo& currCamInfo)
{ {
return currCamInfo.toOutput(); TCameraAnimationOutputInfo camInfo;
float ratio = currCamInfo.ElapsedTimeSinceStartStep / getDuration();
// We compute the current position between the starting position and the final position
NLMISC::CVector movementVector = resolvePositionOrEntityPosition(currCamInfo.AnimStartCamPos) - currCamInfo.StartCamPos;
// We current position is computed using the ratio and the starting position
NLMISC::CVector offset = movementVector * ratio;
camInfo.CamPos = currCamInfo.StartCamPos + offset;
// We get the current look at direction
camInfo.CamLookAtDir = computeCurrentLookAtDir(ratio, currCamInfo.StartCamLookAtDir, currCamInfo.AnimStartCamLookAtDir);
return camInfo;
} }
virtual void stopStep() virtual void stopStep()

Loading…
Cancel
Save