looking for reasonable Object3d net data

Started by .jayderyu, February 06, 2010, 02:28:18 PM

Previous topic - Next topic

.jayderyu

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.

EgonOlsen

#1
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

I'm not saying that this is the best way, but it seems to work reasonable well.

.jayderyu

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.

Disastorm

Quote from: 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

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?)  ?

EgonOlsen


Disastorm

What is it you send? send Transformed Center and then on other client you set Center ?

.jayderyu

he listed the source code, but I in short i'm using this

This is my only message that I send for gameplay action.

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;
}


Disastorm

#7
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?

.jayderyu


sender

SimpleVector p = object.getTransformedCenter();
action.x = p.x;
action.y = p.y;
action.z = p.z;


reciever

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);




EgonOlsen

I don't use getTransformedCenter, i'm using getTransformation().

Disastorm

i think u mean getTranslation? thanks, that sounds like a good idea.

EgonOlsen

Yes, getTranslation of course.  Typing on Android's virtual keyboard makes you write funny things sometimes.

Disastorm

#12
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 )?

.jayderyu

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

EgonOlsen

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