Game Development Reference
In-Depth Information
23. The coeficients for positions and timings were chosen empirically based on the
perception of the motion. The dynamics are implemented in the Update() method:
void clFlowFlinger::Update( float DeltaTime )
{
float NewVal = 0.0f;
if ( FPressed )
{
vec2 CurPoint = Env_GetMouse();
NewVal = FInitVal;
NewVal -= AccelCoef * ( CurPoint.x - FLastPoint.x );
}
else
{
NewVal = FValue + FVelocity * DeltaTime;
FVelocity -= FVelocity * c_Damping * DeltaTime;
24. When we reach the last image, we just clamp the position on the guiding curves. For
a smooth experience, we also add a rubber band effect, by interpolating the position
using the linear formulas. The Damper coeficient is purely empiric:
const float Damper = 4.5f * DeltaTime;
if ( NewVal > FMaxValue )
{
FVelocity = 0;
NewVal = FMaxValue * Damper +
NewVal * ( 1.0f - Damper );
}
else if ( NewVal < FMinValue )
{
FVelocity = 0;
NewVal = FMinValue * Damper +
NewVal * ( 1.0f - Damper );
}
}
FValue = NewVal;
}
25. A nice set of parameters for comfortable scrolling is deined in the FlowFlinger.h
ile:
const float c_AccelCoeff = 15.0f;
const float c_ValueGain = 0.1f;
const float c_IntGain = 0.1f;
const float c_DiffGain = 0.1f;
const float c_Damping = 0.7f;
You are encouraged to try your own values.
 
Search WWH ::




Custom Search