Changed: #1469 Computation for look at direction put in a method

--HG--
branch : gsoc2012-fabien
hg/feature/gsoc2012-fabien
Fabien_HENON 13 years ago
parent c29dc1bf43
commit 39d4791628

@ -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;
}

@ -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<ICameraAnimationModifierPlayer*> Modifiers;
};

@ -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;
}

Loading…
Cancel
Save