Author Topic: looking for reasonable Object3d net data  (Read 12356 times)

Offline .jayderyu

  • long
  • ***
  • Posts: 116
    • View Profile
looking for reasonable Object3d net data
« 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: looking for reasonable Object3d net data
« Reply #1 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.
« Last Edit: February 06, 2010, 08:23:19 pm by EgonOlsen »

Offline .jayderyu

  • long
  • ***
  • Posts: 116
    • View Profile
Re: looking for reasonable Object3d net data
« Reply #2 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.

Offline Disastorm

  • long
  • ***
  • Posts: 161
    • View Profile
Re: looking for reasonable Object3d net data
« Reply #3 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

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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: looking for reasonable Object3d net data
« Reply #4 on: February 11, 2010, 09:01:33 pm »
Yes, it requires less bandwidth this way.

Offline Disastorm

  • long
  • ***
  • Posts: 161
    • View Profile
Re: looking for reasonable Object3d net data
« Reply #5 on: February 12, 2010, 06:22:46 am »
What is it you send? send Transformed Center and then on other client you set Center ?

Offline .jayderyu

  • long
  • ***
  • Posts: 116
    • View Profile
Re: looking for reasonable Object3d net data
« Reply #6 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;
}

Offline Disastorm

  • long
  • ***
  • Posts: 161
    • View Profile
Re: looking for reasonable Object3d net data
« Reply #7 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?
« Last Edit: February 13, 2010, 03:34:42 am by Disastorm »

Offline .jayderyu

  • long
  • ***
  • Posts: 116
    • View Profile
Re: looking for reasonable Object3d net data
« Reply #8 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);



Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: looking for reasonable Object3d net data
« Reply #9 on: February 13, 2010, 09:37:23 am »
I don't use getTransformedCenter, i'm using getTransformation().

Offline Disastorm

  • long
  • ***
  • Posts: 161
    • View Profile
Re: looking for reasonable Object3d net data
« Reply #10 on: February 14, 2010, 07:42:22 am »
i think u mean getTranslation? thanks, that sounds like a good idea.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: looking for reasonable Object3d net data
« Reply #11 on: February 14, 2010, 10:16:13 am »
Yes, getTranslation of course.  Typing on Android's virtual keyboard makes you write funny things sometimes.

Offline Disastorm

  • long
  • ***
  • Posts: 161
    • View Profile
Re: looking for reasonable Object3d net data
« Reply #12 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 )?
« Last Edit: February 15, 2010, 08:09:19 am by Disastorm »

Offline .jayderyu

  • long
  • ***
  • Posts: 116
    • View Profile
Re: looking for reasonable Object3d net data
« Reply #13 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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: looking for reasonable Object3d net data
« Reply #14 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... ???