Changed: #1469 Input and output structures for steps and modifiers. Now 2 structures instead of one

--HG--
branch : gsoc2012-fabien
hg/feature/gsoc2012-fabien
Fabien_HENON 12 years ago
parent 050f3f644a
commit 1fca8f4b6a

@ -20,33 +20,73 @@
#include "nel/misc/vector.h" #include "nel/misc/vector.h"
/************************************************************************/
/* Class that contains new information about the camera
*
* \author Fabien Henon
* \date 2012
*/
/************************************************************************/
struct TCameraAnimationOutputInfo
{
TCameraAnimationOutputInfo() {}
NLMISC::CVector CamPos; /// Camera position
NLMISC::CVector CamLookAtDir; /// Camera look at direction
};
/************************************************************************/ /************************************************************************/
/* Class that contains information about the camera /* Class that contains current information about the camera
* *
* \author Fabien Henon * \author Fabien Henon
* \date 2012 * \date 2012
*/ */
/************************************************************************/ /************************************************************************/
struct TCameraAnimationInfo struct TCameraAnimationInputInfo
{ {
TCameraAnimationInfo(const NLMISC::CVector& camPos, TCameraAnimationInputInfo(const NLMISC::CVector& currCamPos, const NLMISC::CVector& currCamLookAtDir,
const NLMISC::CVector& camLookAtDir, const NLMISC::CVector& startCamPos, const NLMISC::CVector& startCamLookAtDir,
float elapsedTimeSinceStartStep) float elapsedTimeSinceStartStep)
{ {
CamPos = camPos; CamPos = currCamPos;
CamLookAtDir = camLookAtDir; CamLookAtDir = currCamLookAtDir;
StartCamPos = startCamPos;
StartCamLookAtDir = startCamLookAtDir;
ElapsedTimeSinceStartStep = elapsedTimeSinceStartStep; ElapsedTimeSinceStartStep = elapsedTimeSinceStartStep;
} }
TCameraAnimationInfo() {} TCameraAnimationInputInfo(const TCameraAnimationOutputInfo& output, const TCameraAnimationInputInfo& input)
{
CamPos = output.CamPos;
CamLookAtDir = output.CamLookAtDir;
NLMISC::CVector CamPos; /// Camera position StartCamPos = input.StartCamPos;
NLMISC::CVector CamLookAtDir; /// Camera look at direction StartCamLookAtDir = input.StartCamLookAtDir;
ElapsedTimeSinceStartStep = input.ElapsedTimeSinceStartStep;
}
TCameraAnimationOutputInfo toOutput() const
{
TCameraAnimationOutputInfo output;
output.CamPos = CamPos;
output.CamLookAtDir = CamLookAtDir;
return output;
}
NLMISC::CVector CamPos; /// Current camera position
NLMISC::CVector CamLookAtDir; /// Current camera look at direction
NLMISC::CVector StartCamPos; /// Start camera position
NLMISC::CVector StartCamLookAtDir; /// Start 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
}; };
#endif /* RY_CAMERAANIMATIONINFO_H */ #endif /* RY_CAMERAANIMATIONINFO_H */

@ -36,7 +36,7 @@ public:
/// Function that updates the modifier /// Function that updates the modifier
/// currCamInfo contains information about the current camera position and look at position /// currCamInfo contains information about the current camera position and look at position
/// The function must return the new camera information /// The function must return the new camera information
virtual TCameraAnimationInfo updateModifier(const TCameraAnimationInfo& currCamInfo) = 0; virtual TCameraAnimationOutputInfo updateModifier(const TCameraAnimationInputInfo& currCamInfo) = 0;
/// Function called when the modifier is stopped /// Function called when the modifier is stopped
virtual void stopModifier() = 0; virtual void stopModifier() = 0;

@ -45,9 +45,9 @@ public:
} }
/// Function that plays the modifier /// Function that plays the modifier
virtual TCameraAnimationInfo updateModifier(const TCameraAnimationInfo& currCamInfo) virtual TCameraAnimationOutputInfo updateModifier(const TCameraAnimationInputInfo& currCamInfo)
{ {
return currCamInfo; return currCamInfo.toOutput();
} }
virtual void stopModifier() virtual void stopModifier()
@ -86,9 +86,9 @@ public:
} }
/// Function that plays the modifier /// Function that plays the modifier
virtual TCameraAnimationInfo updateModifier(const TCameraAnimationInfo& currCamInfo) virtual TCameraAnimationOutputInfo updateModifier(const TCameraAnimationInputInfo& currCamInfo)
{ {
return currCamInfo; return currCamInfo.toOutput();
} }
virtual void stopModifier() virtual void stopModifier()

@ -122,20 +122,24 @@ bool CCameraAnimationPlayer::isPlaying()
return _IsPlaying; return _IsPlaying;
} }
TCameraAnimationInfo CCameraAnimationPlayer::update() TCameraAnimationOutputInfo CCameraAnimationPlayer::update()
{ {
// We update the elapsed time for this step // We update the elapsed time for this step
_ElapsedTimeForCurrStep += DT; _ElapsedTimeForCurrStep += DT;
TCameraAnimationInfo currCamInfo(_StartStepCamLookAtDir, _StartStepCamPos, _ElapsedTimeForCurrStep); NLMISC::CVector currCamPos = View.currentViewPos();
NLMISC::CVector currLookAtDir = View.currentView();
TCameraAnimationInputInfo currCamInfo(currCamPos, currLookAtDir,
_StartStepCamPos, _StartStepCamLookAtDir, _ElapsedTimeForCurrStep);
if (!isPlaying()) if (!isPlaying())
return currCamInfo; return currCamInfo.toOutput();
if (_CurrStep == NULL) if (_CurrStep == NULL)
return currCamInfo; return currCamInfo.toOutput();
// We update the current step // We update the current step
currCamInfo = _CurrStep->updateStepAndModifiers(currCamInfo); TCameraAnimationOutputInfo newCamInfo = _CurrStep->updateStepAndModifiers(currCamInfo);
return currCamInfo; return newCamInfo;
} }

@ -67,7 +67,7 @@ public:
bool isPlaying(); bool isPlaying();
/// Updates the camera by calling the update function of the current step and modifiers /// Updates the camera by calling the update function of the current step and modifiers
TCameraAnimationInfo update(); TCameraAnimationOutputInfo update();
private: private:
/// Constructor /// Constructor

@ -92,18 +92,20 @@ void ICameraAnimationStepPlayer::addModifier(ICameraAnimationModifierPlayer* mod
Modifiers.push_back(modifier); Modifiers.push_back(modifier);
} }
TCameraAnimationInfo ICameraAnimationStepPlayer::updateStepAndModifiers(const TCameraAnimationInfo& currCamInfo) TCameraAnimationOutputInfo ICameraAnimationStepPlayer::updateStepAndModifiers(const TCameraAnimationInputInfo& currCamInfo)
{ {
// Updates the step // Updates the step
TCameraAnimationInfo newInfo = updateStep(currCamInfo); TCameraAnimationOutputInfo newInfo = updateStep(currCamInfo);
// Updates the modifiers // Updates the modifiers
for (std::vector<ICameraAnimationModifierPlayer*>::iterator it = Modifiers.begin(); it != Modifiers.end(); ++it) for (std::vector<ICameraAnimationModifierPlayer*>::iterator it = Modifiers.begin(); it != Modifiers.end(); ++it)
{ {
ICameraAnimationModifierPlayer* modifier = *it; ICameraAnimationModifierPlayer* modifier = *it;
TCameraAnimationInputInfo input(newInfo, currCamInfo);
// We update the modifier // We update the modifier
newInfo = modifier->updateModifier(newInfo); newInfo = modifier->updateModifier(input);
} }
return newInfo; return newInfo;
} }

@ -40,7 +40,7 @@ public:
/// Function that updates the camera with the step /// Function that updates the camera with the step
/// currCamInfo contains information about the current camera position and look at position /// currCamInfo contains information about the current camera position and look at position
/// The function must return the new camera information /// The function must return the new camera information
virtual TCameraAnimationInfo updateStep(const TCameraAnimationInfo& currCamInfo) = 0; virtual TCameraAnimationOutputInfo updateStep(const TCameraAnimationInputInfo& currCamInfo) = 0;
/// Function called when the step stops /// Function called when the step stops
virtual void stopStep() = 0; virtual void stopStep() = 0;
@ -52,7 +52,7 @@ public:
void addModifier(ICameraAnimationModifierPlayer* modifier); void addModifier(ICameraAnimationModifierPlayer* modifier);
// Plays the step and its modifiers // Plays the step and its modifiers
TCameraAnimationInfo updateStepAndModifiers(const TCameraAnimationInfo& currCamInfo); TCameraAnimationOutputInfo updateStepAndModifiers(const TCameraAnimationInputInfo& currCamInfo);
// Stops the step and its modifiers // Stops the step and its modifiers
void stopStepAndModifiers(); void stopStepAndModifiers();

@ -19,6 +19,7 @@
#include "game_share/position_or_entity_type.h" #include "game_share/position_or_entity_type.h"
#include "camera_animation_manager/camera_animation_info.h" #include "camera_animation_manager/camera_animation_info.h"
#include "camera_animation_manager/position_or_entity_pos_resolver.h" #include "camera_animation_manager/position_or_entity_pos_resolver.h"
#include "client_cfg.h"
/// Basic camera animation step that has generic values /// Basic camera animation step that has generic values
@ -73,12 +74,12 @@ public:
} }
/// Function that plays the step /// Function that plays the step
virtual TCameraAnimationInfo updateStep(const TCameraAnimationInfo& currCamInfo) virtual TCameraAnimationOutputInfo updateStep(const TCameraAnimationInputInfo& currCamInfo)
{ {
TCameraAnimationInfo camInfo; TCameraAnimationOutputInfo camInfo;
// We don't change the position // We don't change the position
camInfo.CamPos = currCamInfo.CamPos; camInfo.CamPos = currCamInfo.StartCamPos;
float ratio = currCamInfo.ElapsedTimeSinceStartStep / getDuration(); float ratio = currCamInfo.ElapsedTimeSinceStartStep / getDuration();
@ -86,7 +87,7 @@ public:
NLMISC::CVector finalDir = resolvePositionOrEntityPosition(LookAtPos) - camInfo.CamPos; NLMISC::CVector finalDir = resolvePositionOrEntityPosition(LookAtPos) - camInfo.CamPos;
// We get the current look at direction // We get the current look at direction
camInfo.CamLookAtDir = computeCurrentLookAtDir(ratio, currCamInfo.CamLookAtDir, finalDir); camInfo.CamLookAtDir = computeCurrentLookAtDir(ratio, currCamInfo.StartCamLookAtDir, finalDir);
return camInfo; return camInfo;
} }
@ -121,24 +122,24 @@ public:
} }
/// Function that plays the step /// Function that plays the step
virtual TCameraAnimationInfo updateStep(const TCameraAnimationInfo& currCamInfo) virtual TCameraAnimationOutputInfo updateStep(const TCameraAnimationInputInfo& currCamInfo)
{ {
TCameraAnimationInfo camInfo; TCameraAnimationOutputInfo camInfo;
float ratio = currCamInfo.ElapsedTimeSinceStartStep / getDuration(); float ratio = currCamInfo.ElapsedTimeSinceStartStep / getDuration();
// We compute the current position between the starting position and the final position // We compute the current position between the starting position and the final position
NLMISC::CVector movementVector = resolvePositionOrEntityPosition(EndPos) - currCamInfo.CamPos; NLMISC::CVector movementVector = resolvePositionOrEntityPosition(EndPos) - currCamInfo.StartCamPos;
// We current position is computed using the ratio and the starting position // We current position is computed using the ratio and the starting position
NLMISC::CVector offset = movementVector * ratio; NLMISC::CVector offset = movementVector * ratio;
camInfo.CamPos = currCamInfo.CamPos + offset; camInfo.CamPos = currCamInfo.StartCamPos + offset;
// Now we compute the current look at direction // Now we compute the current look at direction
NLMISC::CVector finalDir = resolvePositionOrEntityPosition(LookAtPos) - camInfo.CamPos; NLMISC::CVector finalDir = resolvePositionOrEntityPosition(LookAtPos) - camInfo.CamPos;
// We get the current look at direction // We get the current look at direction
camInfo.CamLookAtDir = computeCurrentLookAtDir(ratio, currCamInfo.CamLookAtDir, finalDir); camInfo.CamLookAtDir = computeCurrentLookAtDir(ratio, currCamInfo.StartCamLookAtDir, finalDir);
return camInfo; return camInfo;
} }
@ -177,13 +178,15 @@ public:
} }
/// Function that plays the step /// Function that plays the step
virtual TCameraAnimationInfo updateStep(const TCameraAnimationInfo& currCamInfo) virtual TCameraAnimationOutputInfo updateStep(const TCameraAnimationInputInfo& currCamInfo)
{ {
TCameraAnimationInfo camInfo; TCameraAnimationOutputInfo camInfo;
// We compute the distance // We compute the distance between the entity to follow and our current position
NLMISC::CVector entityPos = resolvePositionOrEntityPosition(EntityToFollow);
NLMISC::CVector distanceVec = entityPos - currCamInfo.CamPos;
return currCamInfo; return camInfo;
} }
virtual void stopStep() virtual void stopStep()
@ -224,9 +227,9 @@ public:
} }
/// Function that plays the step /// Function that plays the step
virtual TCameraAnimationInfo updateStep(const TCameraAnimationInfo& currCamInfo) virtual TCameraAnimationOutputInfo updateStep(const TCameraAnimationInputInfo& currCamInfo)
{ {
return currCamInfo; return currCamInfo.toOutput();
} }
virtual void stopStep() virtual void stopStep()
@ -264,9 +267,9 @@ public:
} }
/// Function that plays the step /// Function that plays the step
virtual TCameraAnimationInfo updateStep(const TCameraAnimationInfo& currCamInfo) virtual TCameraAnimationOutputInfo updateStep(const TCameraAnimationInputInfo& currCamInfo)
{ {
return currCamInfo; return currCamInfo.toOutput();
} }
virtual void stopStep() virtual void stopStep()

@ -80,7 +80,7 @@ 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(); TCameraAnimationOutputInfo newCamInfo = CCameraAnimationPlayer::getInstance()->update();
// We normalize the look at direction // We normalize the look at direction
newCamInfo.CamLookAtDir.normalize(); newCamInfo.CamLookAtDir.normalize();

Loading…
Cancel
Save