Interpolation using Lerp4 Author Message
Member

 Post: #1 Interpolation using Lerp4 Hey, Ive done some interpolation in my network game, but i got stuck with movement correction when i jump down etc. But i have looked over the Lerp4 functions and they look like Cubic Splines. But i have no idea how to use those. Can someone give me some pointers to the right direction? Thnx, ~Dynad There is always evil somewhere, you just have to look for it properly.
02-25-2010 09:33 PM
Chris
Member

 Post: #2 RE: Interpolation using Lerp4 I'm also working with Dynad on this; I used Lerp4 to draw a spline between three characters and the main player using: Code: ```if (Characters.elms() > 2) {     for (int i=1;i<500;i++)     {         Vec cubicInterp = Lerp4(Characters[0].pos(),Characters[1].pos(),                 Characters[2].pos(),Players[0].pos(),(float)i/125);         Ball(0.03,cubicInterp).draw(RED,true);     } }``` But how can we encode velocity data onto a spline, as with the article: http://www.gamedev.net/reference/article...cle914.asp or Pages 19 and 20 on this paper: http://www8.cs.umu.se/education/examina/...uZhang.pdf Also, how can we make the player follow the future path of the spline correctly, with reference to the velocity data? Really looking forward to replies, Chris (This post was last modified: 02-26-2010 01:51 AM by Chris.)
02-26-2010 01:14 AM
Esenthel

 Post: #3 RE: Interpolation using Lerp4 the last parameter in Lerp4 can be only in range 0..1 (this should be mentioned in the header of the function) when you reach 1+ you should use the next set of 4 base values, and start again from 0..1 step
02-26-2010 02:57 PM
Chris
Member

 Post: #4 RE: Interpolation using Lerp4 Thanks for this, that's useful. Do you have any ideas on how to address the other two problems (using velocities (with reference to paper and problem of multiplayer gaming) and making characters follow splines)? We're just trying to get a kickass implementation for the networking of our games, and the raknet tutorial - which means doing something a little better than linear interpolation/extrapolation for dead reckoning Thanks, Chris
02-26-2010 04:08 PM
Chris
Member

 Post: #5 RE: Interpolation using Lerp4 I'm still really struggeling with this. Is anyone, like a maths wizz, able to help? This is a problem all decent network-game implementations need to face: Here's my guess interpretation of the cubic spline interpolation solution to the dead reckoning problem. It doesn't work, I guess i'm using the wrong variables for t and apacket in the article, and perhaps some of my understanding is flawed - I can't work out how to implement the variables from the article in the Lerp4/spline function. Code: ```void Character::ReceivedMovementPacket(Vec pos, Vec vel) {     old_pos = new_pos;     new_pos = pos;     old_vel = new_vel;     new_vel = vel; } Bool Character::update() {     // Handle messages received by packets here     Flt pos_on_spline = 1;     Vec coord3 = new_pos+new_vel*Time.d()+0.5*T.speed*(Time.d()*Time.d());     pos(Lerp4(old_pos,old_pos+old_vel,coord3,coord3-(new_pos + speed * Time.d()),pos_on_spline));     return __super::update(); }``` - This code just sticks the character wherever you set vec pos. I want to just send the character extrapolated packet data and have it interpolate properly. Also, i'm not sure how to, "Make the object travel along the spline for T frames." Explanation A: (Read part 'D' at the bottom) http://www.gamedev.net/reference/article...cle914.asp Explanation B: (Look at pages 19-20) http://www8.cs.umu.se/education/examina/...uZhang.pdf Related code (lots of comments): http://www.mindcontrol.org/~hplus/interpolation.html Related implementation: http://www.mindcontrol.org/~hplus/epic/ Related reading: http://www.gamedev.net/reference/article...le1370.asp EDIT: Here's an implementation of what we've done so far: http://www.cwkx.com/storage/V1.4%20Extra...ectory.zip Specifically look at Character.h, Character.cpp (Lines 26-27), Game.cpp (Line 146 - pretending to receive character packets from server) (This post was last modified: 03-07-2010 02:36 AM by Chris.)
03-06-2010 09:38 PM
Member

 Post: #6 RE: Interpolation using Lerp4 Yea Esenthel do have some idea how to fix our problem?? There is always evil somewhere, you just have to look for it properly.
03-07-2010 01:16 AM
Esenthel