Proud::CPositionFollower Class Reference

Public Member Functions

void SetGravity (const Vector3 &value)
 
void SetTargetVelocity (const Vector3 &value)
 
void SetTargetPosition (const Vector3 &value)
 
Vector3 GetSplineFollowerPosition () const
 
Vector3 GetSplineFollowerVelocity () const
 
Vector3 GetGravity () const
 
Vector3 GetTargetVelocity () const
 
Vector3 GetTargetPosition () const
 
void SetFollowerVelocity (const Vector3 &value)
 
void SetFollowerPosition (const Vector3 &value)
 
Vector3 GetFollowerVelocity () const
 
Vector3 GetFollowerPosition () const
 
void SetWarpThreshold (double warpThreshold)
 
bool IsFirstUse ()
 
void SetFollowDuration (double duration)
 
double GetFollowDuration ()
 
void EnableAutoFollowDuration (bool val)
 
void GetTarget (Vector3 &position, Vector3 &velocity) const
 
void GetFollower (Vector3 &position, Vector3 &velocity) const
 
void SetFollower (Vector3 position, Vector3 velocity)
 
virtual void FrameMove (double elapsedTime)
 
virtual void SetTarget (Vector3 position, Vector3 velocity)
 

Detailed Description

Class that smoothing processes position,velocity of remote object that are 'jittering'ed into linear interpolation

For an example, it is useful when dead reckoning remote object.

(Later, it'd be useful if this class is strengthened to have interpolation function that converts orientation into quarternion.)

General usage

Considerations on gravity

  • In a game that has jump motions, the character jumps while moving in linear fashion must be somewhat un-natural. So, during jump motion, there must be gravity acting to result downward curve motion. In that case, you can use SetGravity to pre-input the gravity value.

Member Function Documentation

void Proud::CPositionFollower::EnableAutoFollowDuration ( bool  val)

If set as true then it automatically controls the time taken for follower to get to taget.

virtual void Proud::CPositionFollower::FrameMove ( double  elapsedTime)
virtual

This method must be called by each time frame.

Parameters
elapsedTimelength of a frame(in second)
double Proud::CPositionFollower::GetFollowDuration ( )

Outputs the last value entered to SetFollowDuration

void Proud::CPositionFollower::GetFollower ( Vector3 position,
Vector3 velocity 
) const

TODO:translate needed. Gets position, velocity of follower

Vector3 Proud::CPositionFollower::GetFollowerPosition ( ) const

Gets the current location of position follower itself

  • Can be different to the value entered in SetFollowerPosition since it is continuously updated by FrameMove
Vector3 Proud::CPositionFollower::GetFollowerVelocity ( ) const

Gets the current speed of position follower itself

  • Can be different to the value entered in SetFollowerVelocity since it is continuously updated by FrameMove
Vector3 Proud::CPositionFollower::GetGravity ( ) const

Gets the last input value of gravity

Vector3 Proud::CPositionFollower::GetSplineFollowerPosition ( ) const

Gets the location of follower that moves in spline shape

Vector3 Proud::CPositionFollower::GetSplineFollowerVelocity ( ) const

Gets the current speed of follower moves in spline shape

void Proud::CPositionFollower::GetTarget ( Vector3 position,
Vector3 velocity 
) const

TODO:translate needed. Calculate the pos and vel of the target followed by the follower.

Parameters
positionVector 3 location of the target to be obtained for the position.
velocityVector 3 speed of the target to be obtained for the velocity.
Vector3 Proud::CPositionFollower::GetTargetPosition ( ) const

Get the current location of target location that position follower is following

  • Can be different to the value entered in SetTargetPosition since it is continuously updated by FrameMove
Vector3 Proud::CPositionFollower::GetTargetVelocity ( ) const

Gets the current speed of target location that position follower is following

bool Proud::CPositionFollower::IsFirstUse ( )

FrameMove() used more than once?

void Proud::CPositionFollower::SetFollowDuration ( double  duration)

Sets the time taken that follower gets to target

  • This method will be ignored if EnableAutoFollowDuration(true) is called. Instead, it automatically finds suitable duration internally.
  • Usually, it is ideal to set this value a little bit larger than the period that calls SetTargetPosition,SetTarget,SetTargetVelocity. If the value is too small then the movement will be jumpy but if too large then the precision of movement will be lost.
    Parameters
    durationtime taken that follower gets to target (in second)
void Proud::CPositionFollower::SetFollower ( Vector3  position,
Vector3  velocity 
)

Calls SetFollowerVelocity,SetFollowerPosition at the same time

void Proud::CPositionFollower::SetFollowerPosition ( const Vector3 value)

Sets the location of position follower itself

  • Used to set the initial condition of remote object
void Proud::CPositionFollower::SetFollowerVelocity ( const Vector3 value)

Sets the speed of position follower itself

  • Used to set the initial condition of remote object
void Proud::CPositionFollower::SetGravity ( const Vector3 value)

Sets gravity

  • Once gravity is set then both follower and taget are affected. For an example, if it is a jumping character then it will need this method.
virtual void Proud::CPositionFollower::SetTarget ( Vector3  position,
Vector3  velocity 
)
virtual

Calls SetTargetPosition and SetTargetVelocity at the same time

void Proud::CPositionFollower::SetTargetPosition ( const Vector3 value)

Sets the location of invisible object that position follower is to follow

  • When the location of opponent character is received from other host, there is a need to call this method.
void Proud::CPositionFollower::SetTargetVelocity ( const Vector3 value)

Sets the speed of invisible object that position follower is to follow

  • When the location of opponent character is received from other host, there is a need to call this method.
void Proud::CPositionFollower::SetWarpThreshold ( double  warpThreshold)

If newly received target position is too far from the location of follower, it may be location error due to intentional warp, resapwn or extreme lags. In this case, performing location correction will make the situation worse. if warp threshold is set then it does not perform correction but forcefully synchronizes follower with target location.

Parameters
warpThresholddistance as critical value that can ignore location correction