www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: .jayderyu on February 06, 2010, 02:28:18 pm

Title: looking for reasonable Object3d net data
Post by: .jayderyu on February 06, 2010, 02:28:18 pm
ok so i'm slow an working on my prototype. I've got server/client stuff.. blah blah.

What i'm looking for is rotation data to send in a ByteBuffer. I have jBullet to do most of the work in regards to movement and stuff. I have commands that tell the system to start moving, stopping, turning, stopping.... but I had thought to send sync data with these messages. Looking through Object3D it seems I might have to send a float[16] through system. That seems a bit heavy handed though. I can't really see much data outside of the matrix that I can grab and dump into the remote Object.
Title: Re: looking for reasonable Object3d net data
Post by: EgonOlsen on February 06, 2010, 08:21:35 pm
For my game Robombs, i'm doing just that. I'm transfering a matrix and a direction as well as a position vector for each object. I'm transfering the rotational part of the matrix only (i.e. the upper 3x3 matrix), which results in 9 floats plus the direction/position vectors with 6 floats. So it sums up to 15 floats/object. Because in Robombs some objects never rotate, i'm treating the identity matrix as a special case and transfer a magic number instead, which means that those objects only need 7 floats. I'm zipping the final data set and transfer it. It's all in the sources: http://jpct.de/download/robombs_src.zip (http://jpct.de/download/robombs_src.zip)

I'm not saying that this is the best way, but it seems to work reasonable well.
Title: Re: looking for reasonable Object3d net data
Post by: .jayderyu on February 07, 2010, 12:15:21 am
I'll try that then. I haven't work a whole lot with networking data before. I've only "finished"(ie playable) one "game" that used networking. I had thought that sending float or int.int  might be a bit heavy on the datapackets. but if your game works well wit it then there can't be that much of a problem with it. i'll take a look through some of the source to. I'm sure I can find some better design in there than what I got.
Title: Re: looking for reasonable Object3d net data
Post by: Disastorm on February 11, 2010, 06:42:19 pm
For my game Robombs, i'm doing just that. I'm transfering a matrix and a direction as well as a position vector for each object. I'm transfering the rotational part of the matrix only (i.e. the upper 3x3 matrix), which results in 9 floats plus the direction/position vectors with 6 floats. So it sums up to 15 floats/object. Because in Robombs some objects never rotate, i'm treating the identity matrix as a special case and transfer a magic number instead, which means that those objects only need 7 floats. I'm zipping the final data set and transfer it. It's all in the sources: http://jpct.de/download/robombs_src.zip (http://jpct.de/download/robombs_src.zip)

I'm not saying that this is the best way, but it seems to work reasonable well.
Hi can you explain what you do? Is it better than sending the rotational matrix and the translational matrix (what is position vector is that just sending the position itself instead of the translational matrix, and it has the same result but requires less bandwidth?)  ?
Title: Re: looking for reasonable Object3d net data
Post by: EgonOlsen on February 11, 2010, 09:01:33 pm
Yes, it requires less bandwidth this way.
Title: Re: looking for reasonable Object3d net data
Post by: Disastorm on February 12, 2010, 06:22:46 am
What is it you send? send Transformed Center and then on other client you set Center ?
Title: Re: looking for reasonable Object3d net data
Post by: .jayderyu on February 12, 2010, 11:51:42 pm
he listed the source code, but I in short i'm using this

This is my only message that I send for gameplay action.
Code: [Select]
public class GearAction implements Serializable
{
  public String userName;

  public float pos_x;
  public float pos_y;
  public float pos_z;
  public float[] torsoRot;
  public float[] legRot;

  public int action;
}
Title: Re: looking for reasonable Object3d net data
Post by: Disastorm on February 13, 2010, 03:33:01 am
Oh thanks.  Ill look through the source later if i have to but basically the "position" is getTransformedCenter I imagine?  And then on the other client do you set the Origin or the Center?  If you set those won't they be affected by any translations you do on the object, or I suppose you can clear the translation matrix and then set the origin each time?
Title: Re: looking for reasonable Object3d net data
Post by: .jayderyu on February 13, 2010, 05:04:00 am

sender
Code: [Select]
SimpleVector p = object.getTransformedCenter();
action.x = p.x;
action.y = p.y;
action.z = p.z;

reciever
Code: [Select]
SimpleVector p = new SimpleVector(action.x, action.y, action.z);
SimpleVector local = Object.getTransformedCenter();
SimpleVector tran = local.calcSub(p); //or p.calcSub(local)
// update tran for motion and time difference.
Object.translate(tran);


Title: Re: looking for reasonable Object3d net data
Post by: EgonOlsen on February 13, 2010, 09:37:23 am
I don't use getTransformedCenter, i'm using getTransformation().
Title: Re: looking for reasonable Object3d net data
Post by: Disastorm on February 14, 2010, 07:42:22 am
i think u mean getTranslation? thanks, that sounds like a good idea.
Title: Re: looking for reasonable Object3d net data
Post by: EgonOlsen on February 14, 2010, 10:16:13 am
Yes, getTranslation of course.  Typing on Android's virtual keyboard makes you write funny things sometimes.
Title: Re: looking for reasonable Object3d net data
Post by: Disastorm on February 15, 2010, 07:36:47 am
if i dont keep the object moving between sending information then it looks a little choppy and if i keep the object moving it looks like rubber bandy.  how do you deal with this?  The rubber bandy mostly happens if the player does something other than moving in the same constant direction, so like turning or something, i guess thats because the other client doesnt know hes going to turn and makes him move forward but then corrects it once it found out he turned.  How do most games deal with this?  Do i just have to send data faster than every 50 ms ??  What is a good rate, do most games keep sending it with no time in between (0ms )?
Title: Re: looking for reasonable Object3d net data
Post by: .jayderyu on February 15, 2010, 10:55:01 am
Part of the problem might with the time syncing. I don't know how to suggest syncing up time and deadreckoning better. You need a solid form of deadreckoning going. I only suggested the basics, but here is some gamedev articles about it.

dead reckoning cubic splines
http://www.gamedev.net/reference/programming/features/cubicsplines/page2.asp

Here is an article on a variant.
http://www.gamedev.net/reference/articles/article1370.asp
Title: Re: looking for reasonable Object3d net data
Post by: EgonOlsen on February 15, 2010, 08:39:44 pm
Robombs sends every 30ms if possible. I've never noticed a problem with entities moving in directions in which they shouldn't unless the lag is really bad. All the bots are running on a separate client too, which uses the same time interval to synchronize with the server and the other clients (including the local one) and that works fine... ???
Title: Re: looking for reasonable Object3d net data
Post by: .jayderyu on February 15, 2010, 09:53:06 pm
I passed on deadreckoning myself :P, but it is a per project and game play style. I don't think Robombs would need it. Since blowing people up are done with stationary objects. Where as shooting people with bullets or missiles would be a different story. :) Since I don't know his game. I'm only suggesting to go with standard practices in regards to highly shooting orientated games.
Title: Re: looking for reasonable Object3d net data
Post by: Disastorm on February 15, 2010, 10:40:55 pm
Robombs sends every 30ms if possible. I've never noticed a problem with entities moving in directions in which they shouldn't unless the lag is really bad. All the bots are running on a separate client too, which uses the same time interval to synchronize with the server and the other clients (including the local one) and that works fine... ???
Well I don't mean my objects move in the wrong direction but you can see like stuttering/rubber band type thing (very small, but noticeable) if an object is say for example running in changing circles/curves (not sure if its a problem in a constant circle) as opposed to a straight line.  That site jayderu linked, the first 2 choices on there are basically what I have tried (kind of combination of the two, i send the points each time and then use the velocity in between to keep the object moving in the same direction).  However, that site basically says they both suck and to use cubic splines.  Before that, though, I'm just gonna try to send the positions faster than 50 ms, since u said u do 30ms and thats almost double as fast as 50ms.