32 lines
525 B
C
32 lines
525 B
C
#pragma once
|
|
|
|
struct STargetValue
|
|
{
|
|
float m_fValue;
|
|
float m_fTarget;
|
|
float m_fSpeed;
|
|
float m_fAcceleration;
|
|
float m_fFriction;
|
|
|
|
STargetValue
|
|
( float fValue,
|
|
float fTarget,
|
|
float fSpeed,
|
|
float fAcceleration,
|
|
float fFriction )
|
|
{
|
|
m_fValue= fValue;
|
|
m_fTarget= fTarget;
|
|
m_fSpeed= fSpeed;
|
|
m_fAcceleration= fAcceleration;
|
|
m_fFriction= fFriction;
|
|
}
|
|
|
|
void timeStep()
|
|
{
|
|
m_fValue+= m_fSpeed;
|
|
float fDist= m_fTarget - m_fValue;
|
|
m_fSpeed+= fDist * m_fAcceleration;
|
|
m_fSpeed*= m_fFriction;
|
|
}
|
|
}; |