Changed: #1469 Fixed last bugs

--HG--
branch : gsoc2012-fabien
hg/feature/gsoc2012-fabien
Fabien_HENON 12 years ago
parent 9f4d2fea74
commit 1774ee7278

@ -55,8 +55,8 @@ struct TCameraAnimationInputInfo
StartCamPos = startCamPos;
StartCamLookAtDir = startCamLookAtDir;
AnimStartCamPos = startCamPos;
AnimStartCamLookAtDir = startCamLookAtDir;
AnimStartCamPos = animStartCamPos;
AnimStartCamLookAtDir = animStartCamLookAtDir;
ElapsedTimeSinceStartStep = elapsedTimeSinceStartStep;
}

@ -23,6 +23,7 @@
#include "sound_manager.h"
#include "nel/misc/random.h"
#include "nel/misc/time_nl.h"
#include "time_client.h"
/////////////////////////////////////////////////////////////////////////////
/// This animation modifier shakes the camera. The parameter is
@ -32,10 +33,19 @@ class CCameraAnimationModifierPlayerShake : public ICameraAnimationModifierPlaye
protected:
float Strength;
float _Dir;
float _WaitTime;
float _CurrTime;
NLMISC::CVector _CurrVec;
public:
CCameraAnimationModifierPlayerShake()
{
Strength = 0.f;
_Dir = 1.f;
_CurrTime = 0.f;
_WaitTime = 0.f;
}
/// This function is called when it's time to init the modifier from an impulse
@ -43,6 +53,10 @@ public:
{
impulse.serial(const_cast<float&>(Strength));
_Dir = 1.f;
_CurrTime = 0.f;
_WaitTime = 0.f;
return true;
}
@ -51,17 +65,28 @@ public:
{
TCameraAnimationOutputInfo output;
NLMISC::CRandom rnd;
rnd.srand((sint32)NLMISC::CTime::getLocalTime());
_CurrTime += DT;
if (_CurrTime >= _WaitTime)
{
/*NLMISC::CRandom rnd;
rnd.srand((sint32)NLMISC::CTime::getLocalTime());*/
// We find a normal vector to the look at dir
NLMISC::CVector newVec(currCamInfo.CamLookAtDir.y * -1.f, currCamInfo.CamLookAtDir.x, currCamInfo.CamLookAtDir.z);
newVec.normalize();
newVec = newVec * (Strength * _Dir);
_Dir *= -1.f;
NLMISC::CVector dirs((float)rnd.randPlusMinus(1), (float)rnd.randPlusMinus(1), (float)rnd.randPlusMinus(1));
dirs.normalize();
_CurrVec = newVec;
// We increase the vector by the strength
dirs = dirs * Strength;
_CurrTime = 0.f;
_WaitTime = 0.1f;
}
output.CamLookAtDir = currCamInfo.CamLookAtDir;
output.CamPos = currCamInfo.CamPos + dirs;
output.CamPos = currCamInfo.CamPos + _CurrVec;
return output;
}

@ -57,9 +57,17 @@ void CCameraAnimationPlayer::start()
// We set the user controls in camAnimMode and we remember the current view and viewPos
_LastView = View.view();
_LastViewPos = View.viewPos();
_AnimStartCamPos = View.currentViewPos();
_AnimStartCamLookAtDir = View.currentView();
_LastMode = UserControls.mode();
UserControls.mode(CUserControls::CamAnimMode);
_HasLastViewInfo = true;
// We set the animation start views so that the camera begins at the real previous position
View.view(_AnimStartCamLookAtDir);
View.viewPos(_AnimStartCamPos);
}
void CCameraAnimationPlayer::stop(bool interrupt)
@ -140,7 +148,7 @@ TCameraAnimationOutputInfo CCameraAnimationPlayer::update()
TCameraAnimationInputInfo currCamInfo(currCamPos, currLookAtDir,
_StartStepCamPos, _StartStepCamLookAtDir,
_LastViewPos, _LastView,
_AnimStartCamPos, _AnimStartCamLookAtDir,
_ElapsedTimeForCurrStep);
if (!isPlaying())

@ -94,6 +94,9 @@ private:
NLMISC::CVector _StartStepCamLookAtDir;
NLMISC::CVector _StartStepCamPos;
NLMISC::CVector _AnimStartCamLookAtDir;
NLMISC::CVector _AnimStartCamPos;
};

@ -132,6 +132,16 @@ public:
// We compute the current position between the starting position and the final position
NLMISC::CVector movementVector = resolvePositionOrEntityPosition(EndPos) - currCamInfo.StartCamPos;
// If the position is an entity, we substract a minimum distance to the entity
if (EndPos.isEntityId())
{
float currDist = movementVector.norm();
float substractRatio = (currDist - ClientCfg.CameraAnimMinEntityDistance) / currDist;
if ((currDist - ClientCfg.CameraAnimMinEntityDistance) < 0.f)
substractRatio = 0.f;
movementVector = movementVector * substractRatio;
}
// We current position is computed using the ratio and the starting position
NLMISC::CVector offset = movementVector * ratio;
camInfo.CamPos = currCamInfo.StartCamPos + offset;
@ -207,14 +217,12 @@ public:
// We add this vector to our position to know our new position
camInfo.CamPos = currCamInfo.CamPos + distanceVec;
// Now we compute the new look at direction
float ratio = currCamInfo.ElapsedTimeSinceStartStep / getDuration();
// We compute the final look at direction
NLMISC::CVector finalDir = resolvePositionOrEntityPosition(LookAtPos) - camInfo.CamPos;
finalDir.normalize();
// We get the current look at direction
camInfo.CamLookAtDir = computeCurrentLookAtDir(ratio, currCamInfo.StartCamLookAtDir, finalDir);
camInfo.CamLookAtDir = finalDir;
return camInfo;
}
@ -308,14 +316,12 @@ public:
camInfo.CamPos = pointPos + newDir;
// Now we compute the new look at direction
float ratio = currCamInfo.ElapsedTimeSinceStartStep / getDuration();
// We compute the final look at direction
NLMISC::CVector finalDir = resolvePositionOrEntityPosition(LookAtPos) - camInfo.CamPos;
finalDir.normalize();
// We get the current look at direction
camInfo.CamLookAtDir = computeCurrentLookAtDir(ratio, currCamInfo.StartCamLookAtDir, finalDir);
camInfo.CamLookAtDir = finalDir;
return camInfo;
}

@ -38,7 +38,10 @@ NLMISC::CVector resolvePositionOrEntityPosition(const TPositionOrEntity& posOrEn
}
else
{
NLMISC::CVector pos = entity->pos();
NLMISC::CVector pos;
if (!entity->getHeadPos(pos))
pos = entity->pos();
return pos;
}
return NLMISC::CVector();

@ -339,7 +339,8 @@ CClientConfig::CClientConfig()
DmWalk = 6.0f; // Default Velocity for the Walk in Ring/DM or Ring/Editor.
DmRun = 20.0f; // Default Velocity for the Run in Ring/DM or Ring/Editor.
MaxCameraAnimationSpeed = 100.0f; // Default maximum speed for camera animation
MaxCameraAnimationSpeed = 4.f; // Default maximum speed for camera animation
CameraAnimMinEntityDistance = 0.8f; // Default distance between the camera and the entity during camera animations
FlyAccel = 1000.f; // Default Acceleration for the fly, in m.s-2
@ -918,6 +919,8 @@ void CClientConfig::setValues()
// Maximum camera animation speed
READ_FLOAT_DEV(MaxCameraAnimationSpeed);
// Default distance between camera and entity in camera animations
READ_FLOAT_DEV(CameraAnimMinEntityDistance);
// Fly

@ -181,6 +181,7 @@ struct CClientConfig
/// Maximum speed for camera animation
float MaxCameraAnimationSpeed;
float CameraAnimMinEntityDistance;
/// Allow debug commands
bool AllowDebugCommands;

Loading…
Cancel
Save