Client with streamed entities do not set their geometry

All things HTML5 or text based engines, or really any web based engines.
Post Reply
robaldred
Posts: 64
Joined: Tue Aug 27, 2013 5:54 pm

Client with streamed entities do not set their geometry

Post 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
User avatar
coolbloke1324
Posts: 181
Joined: Mon Jan 23, 2012 5:20 pm

Re: Client with streamed entities do not set their geometry

Post 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
CEO & Lead Developer
Irrelon Software Limited
http://www.isogenicengine.com
robaldred
Posts: 64
Joined: Tue Aug 27, 2013 5:54 pm

Re: Client with streamed entities do not set their geometry

Post 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
Post Reply

Return to “HTML5/Web Engines”