Page 1 of 1

Client with streamed entities do not set their geometry

Posted: Fri Aug 30, 2013 11:48 am
by robaldred
Hi,
I just wonder if this was expected.
I create an IgeEntityBox2d server side i create a box2d body that is a circle which i set .width(100) .height(100)
It then uses the geometry data to create the circle it seems, I can override with { data: { radius: xxx }} in the fixture.

So server side the entitiy is perfect.
With streamMode(1) the geometry doesn't appear to get reflected on the client so the texture is not scaled appropriately.

If i force the width() & height() for the client it's fine, but this seems like unnecessary duplication?

Thanks in advance for your help
Rob

Re: Client with streamed entities do not set their geometry

Posted: Fri Aug 30, 2013 8:33 pm
by coolbloke1324
Hey,

Yes this is definitely expected behaviour. You can either set the geometry in the shared execution section of the init method or if you are changing the geometry regularly you can set it to stream by adding the "geometry" stream section (which is not recommended unless you need it because although the stream is optimised to send data only on changes, each data section adds an extra byte to the data send every frame regardless of if data is included (has changed) or not.

Shared execution section would look like this:

Code: Select all

init: function () {
// This will be executed on both client and server
this.width(100)
    .height(100);

if (ige.isServer) {
// This will only be executed on server
}

if (!ige.isServer) {
// This will only be executed on client
}
}
If you want to add the geometry changes to the data being streamed, you set the stream sections like this:

Code: Select all

init: function () {
// Add geometry to the data being streamed
this.streamSections(['transform', 'geometry']);
}
You will notice that the transform section is added at the start, this is because you can actually turn off the transform streaming if you want to. You can also create custom data sections and there is a full doc page on this on the web site.

Currently in the dev version of the engine these sections are "built-in" to the IgeEntity class:

transform: The translation, rotation and scale
geometry: The size3d bounding data
depth: The depth sort value
layer: The layer sort value
hidden: If the entity is currently hidden or not
mount: Which parent entity the entity is mounted to

Re: Client with streamed entities do not set their geometry

Posted: Fri Aug 30, 2013 10:46 pm
by robaldred
Great post thanks.
I'll make sure I read the docs thoroughly.
I guess I should not have assumed geometry was streamed by default. I guess the more data is streamed the more bandwidth is required.

Thanks again
Rob