Jump to content
  • Advertisement
Sign in to follow this  

Math on waypoints interpolation

This topic is 607 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

float frameRate = (float)(CSimApplication::m_pSimApp->GetFrameRate());
float oneStep = 1 / frameRate;
float factor = (l_transform->m_MotionInfo.m_fSpeed /
            l_transform->m_MotionInfo.m_fDist) * m_fElapsedTime;
l_transform->m_MotionInfo.m_fS += oneStep * factor;

If I calculate onestep from the frame rate of the game

For example: 25

oneStep = 1/25 = 0.04

When m_fS is 1.0, the object finishes one waypoint

I just multiply a factor with considerations of speed, distance and current time elapsed

Can I assume

if speed increases, factor increases, the interpolator runs faster.

If distance increases, factor.decreases, the interpolator runs slower

If time elapsed increases, factor increases, the interpolator runs faster.

Not sure still cannot get it right.

Note: I just clamp the fS if frames run out


CB1 fS:0.00128073
CB2 fS:0.00128357
CB1 fS:0.0025631
CB2 fS:0.0025688
CB1 fS:0.00384876
CB2 fS:0.00385733
CB1 fS:0.00513939
CB2 fS:0.00515085
CB1 fS:0.00643669
CB2 fS:0.00645107
CB1 fS:0.0077424
CB2 fS:0.00775973
CB1 fS:0.00905829
CB2 fS:0.00907863
CB1 fS:0.0103862
CB2 fS:0.0104096
CB1 fS:0.0117281
CB2 fS:0.0117546
CB1 fS:0.0130859
CB2 fS:0.0131156
CB1 fS:0.0144616
CB2 fS:1
CB1 fS:0.000868756
CB2 fS:0.00228571
CB1 fS:0.00173827
CB2 fS:0.00457666
CB1 fS:0.00260929
CB2 fS:0.00687815
CB1 fS:0.0034826
CB2 fS:0.00919557
CB1 fS:0.00435895
CB2 fS:0.0115345
CB1 fS:0.00523915
CB2 fS:0.0139007
CB1 fS:0.00612397
CB2 fS:0.0163003
CB1 fS:0.00701426
CB2 fS:0.0187396
CB1 fS:0.00791083
CB2 fS:0.0212256
CB1 fS:0.00881454
CB2 fS:0.0237654
CB1 fS:0.0097263
CB2 fS:1
CB1 fS:0.000609747
CB2 fS:0.00161624
CB1 fS:0.00121987
CB2 fS:0.0032351
CB1 fS:0.00183073
CB2 fS:0.00485922
CB1 fS:0.00244272
CB2 fS:0.00649126
CB1 fS:0.0030562
CB2 fS:0.00813397
CB1 fS:0.00367156
CB2 fS:0.00979015
CB1 fS:0.00428919
CB2 fS:0.0114627
CB1 fS:0.00490949
CB2 fS:0.0131546
CB1 fS:0.00553284
CB2 fS:0.0148691
CB1 fS:0.00615966
CB2 fS:0.0166095
CB1 fS:0.00679037
CB2 fS:1
Edited by lucky6969b

Share this post

Link to post
Share on other sites

Complete code would be nice, but a clearly strange thing is that fS is claimed to be dimensionless (increasing from 0 to 1 during the transition between two waypoints) but it is a time instead.

Can you explain how interpolation between waypoints affects, and is affected by, the movement described by the speed, distnce and elapsed time variables?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!