Proud::CPositionFollower Class Reference

Public Member Functions

PROUD_API void SetGravity (const Vector3 &value)
 
PROUD_API void SetTargetVelocity (const Vector3 &value)
 
PROUD_API void SetTargetPosition (const Vector3 &value)
 
PROUD_API Vector3 GetSplineFollowerPosition () const
 
PROUD_API Vector3 GetSplineFollowerVelocity () const
 
PROUD_API Vector3 GetGravity () const
 
PROUD_API Vector3 GetTargetVelocity () const
 
PROUD_API Vector3 GetTargetPosition () const
 
PROUD_API void SetFollowerVelocity (const Vector3 &value)
 
PROUD_API void SetFollowerPosition (const Vector3 &value)
 
PROUD_API Vector3 GetFollowerVelocity () const
 
PROUD_API Vector3 GetFollowerPosition () const
 
PROUD_API void SetWarpThreshold (double warpThreshold)
 
PROUD_API bool IsFirstUse ()
 
PROUD_API void SetFollowDuration (double duration)
 
PROUD_API double GetFollowDuration ()
 
PROUD_API void EnableAutoFollowDuration (bool val)
 
PROUD_API void GetTarget (Vector3 &position, Vector3 &velocity) const
 
PROUD_API void GetFollower (Vector3 &position, Vector3 &velocity) const
 
PROUD_API void SetFollower (Vector3 position, Vector3 velocity)
 
virtual PROUD_API void FrameMove (double elapsedTime)
 
virtual PROUD_API 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

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

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

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

This method must be called by each time frame.

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

Outputs the last value entered to SetFollowDuration

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

TODO:translate needed. Gets position, velocity of follower

PROUD_API 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
PROUD_API 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
PROUD_API Vector3 Proud::CPositionFollower::GetGravity ( ) const

Gets the last input value of gravity

PROUD_API Vector3 Proud::CPositionFollower::GetSplineFollowerPosition ( ) const

Gets the location of follower that moves in spline shape

PROUD_API Vector3 Proud::CPositionFollower::GetSplineFollowerVelocity ( ) const

Gets the current speed of follower moves in spline shape

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

TODO:translate needed. Gets pos, vel of target that follower follows

PROUD_API 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
PROUD_API Vector3 Proud::CPositionFollower::GetTargetVelocity ( ) const

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

PROUD_API bool Proud::CPositionFollower::IsFirstUse ( )

FrameMove() used more than once?

PROUD_API 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)
PROUD_API void Proud::CPositionFollower::SetFollower ( Vector3  position,
Vector3  velocity 
)

Calls SetFollowerVelocity,SetFollowerPosition at the same time

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

Sets the location of position follower itself

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

Sets the speed of position follower itself

  • Used to set the initial condition of remote object
PROUD_API 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 PROUD_API void Proud::CPositionFollower::SetTarget ( Vector3  position,
Vector3  velocity 
)
virtual

Calls SetTargetPosition and SetTargetVelocity at the same time

PROUD_API 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.
PROUD_API 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.
PROUD_API 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