About Store Forum Documentation Contact
Donations:
309$/mo



Post Reply 
Interpolation using Lerp4
Author Message
Dynad Offline
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
Visit this user's website Find all posts by this user Quote this message in a reply
Chris Offline
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);
    }
}

[Image: raknettutorialspline.png]

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
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

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
Find all posts by this user Quote this message in a reply
Chris Offline
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 smile

Thanks,
Chris
02-26-2010 04:08 PM
Find all posts by this user Quote this message in a reply
Chris Offline
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
Find all posts by this user Quote this message in a reply
Dynad Offline
Member

Post: #6
RE: Interpolation using Lerp4
Yea Esenthel do have some idea how to fix our problem?? smile

There is always evil somewhere, you just have to look for it properly.
03-07-2010 01:16 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #7
RE: Interpolation using Lerp4
no, sorry, I will be working on multiplayer functionality in a future release.
03-07-2010 03:03 AM
Find all posts by this user Quote this message in a reply
Mikesanimation Offline
Member

Post: #8
RE: Interpolation using Lerp4
Quote:Also, i'm not sure how to, "Make the object travel along the spline for T frames."

Since you know where he needs to move to, you should be able to calculate how long it needs to take him to get there (I think?), then you could probably just change the player's speed and use actionMoveTo(), where the speed to use could be calculated by figuring out how far he needed to go in what amount of time.

Also,
Quote: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
your pos_on_spline always == 1. So calling that function would just return the position where the final destination is, right?

As far as the other calculations go, I have no clue. I do not know very much about interpolations and such.
(This post was last modified: 03-07-2010 06:26 AM by Mikesanimation.)
03-07-2010 06:23 AM
Find all posts by this user Quote this message in a reply
Post Reply