Stream Room System questions.

Post your help queries and engine programming questions here

Stream Room System questions.

Postby craigbett » Fri Aug 05, 2016 12:18 pm

So I'v been messing around with the Stream Room System, but its not working quite the way I expected.
It is creating the correct entities when I join the room. The way I have the scenes set up is (server side) :
Code: Select all
      var self = this;

      self.mainScene = new IgeScene2d()
         .id('mainScene')
         .translateTo(0, 0, 0)
         .streamRoomId('room1')
         .streamMode(1)
         .compositeStream(true);

      self.backScene = new IgeScene2d()
         .id('backScene')
         .depth(0)
         .mount(self.mainScene);

      self.foreScene = new IgeScene2d()
         .id('foreScene')
         .depth(2)
         .mount(self.mainScene);

      self.objectLayer = new IgeTileMap2d()
         .id('objectLayer')
         .translateTo( 0, 0, 0)
         .depth(1)
         .gridSize(64,64)
         .tileWidth(32)
         .tileHeight(32)
         .mount(self.mainScene);

      self.mainView = new IgeViewport()
         .id('mainView')
         .autoSize(true)
         .scene(self.mainScene)
         .mount(ige);

      ige.addComponent(IgeTiledComponent).tiled.loadJson( map, function ( layerArray, layersById ) {
         var i, j;
         for (i = 0; i < layerArray.length; i++) {
            switch (layerArray[i].type){
               case 'tilelayer':
                  layerArray[i]
                     .translateTo( 16, 16, 0 )
                     .tileWidth(32)
                     .tileHeight(32)
                     .mount(self.backScene);
                  break;
               case 'objectgroup':
                  for (j = 0; j < layerArray[i].objects.length; j++) {
                     var obj = layerArray[i].objects[j];
                     new IgeEntityBox2d()
                        .translateTo( obj.x + (obj.width / 2) , obj.y + (obj.height / 2) , 0)
                        .width(obj.width)
                        .height(obj.height)
                        .drawBounds(true)
                        .mount(self.objectLayer)
                        .box2dBody({
                           type: 'static',
                           allowSleep: true,
                           fixtures: [{
                              shape: {
                                 type: 'rectangle'
                              }
                           }]
                        });
                  }
                  break;
               default:
                  console.log(layerArray[i]);
                  break;
            }
         }

      });


client side:
Code: Select all
      var self = this;

      ige.network.request('joinRoom', {roomId: 'room1'}, function (cmd, result) {
         if (result.success) {
            self.log('success! you\'re in the room');
         }
      });

      // Create the scene
      self.mainScene = new IgeScene2d()
         .id('mainScene')
         .translateTo(0, 0, 0)
         .drawBounds(false)
         .drawBoundsData(false);

      // Create the main viewport
      self.mainView = new IgeViewport()
         .id('mainView')
         .autoSize(true)
         .drawBounds(true)
         .scene(self.mainScene)
         .mount(ige);


This is what it looks like in the editor:
Image

as you can see the client side has none of the texture/map/tile data. Is that not how the stream room system works? Do I have to find some other way to load/sync it. I've tried loading the map data clientside, but the stream system seem to cancel it out.
craigbett
 
Posts: 10
Joined: Fri Feb 28, 2014 5:28 am

Re: Stream Room System questions.

Postby rob » Fri Aug 05, 2016 1:15 pm

Hi ya,

If I remember correctly, streaming works if you create a new class from a base class and then use that on the client-side to init things like tile graphics. I cannot see anywhere in your code where you tell the engine what tile graphics to use so it would effectively be blank.

The graphics are never set server-side so what you would do (I think) is create a new class that will represent your tile map. In that class init, check if you are on the client and if so, set your tile graphics texture. On the server, init that tile map class and stream it.

What this will do is tell the server to issue a command to the client to create the instance client-side. When it creates it client-side the init method in the class kicks in and uses the correct texture to display graphics.

That said, I actually have no idea if streaming tile maps works... it's been quite some time since I looked at it. Is there an example that deals with this?
CEO & Lead Developer
Irrelon Software Limited
http://www.isogenicengine.com
User avatar
rob
Site Admin
 
Posts: 316
Joined: Tue Oct 22, 2013 5:08 pm

Re: Stream Room System questions.

Postby rob » Fri Aug 05, 2016 1:18 pm

Oh, and I see you set drawBounds to true on the server-side. I don't think that will stream to clients. By default I think only transforms stream to clients. Try setting drawBounds on the client-side via your JS console.
CEO & Lead Developer
Irrelon Software Limited
http://www.isogenicengine.com
User avatar
rob
Site Admin
 
Posts: 316
Joined: Tue Oct 22, 2013 5:08 pm

Re: Stream Room System questions.

Postby craigbett » Sat Aug 06, 2016 3:09 am

Ok well I got something working, the only issue I have now is that when I use camera.trackTranslate() the background scenes move wildly when I move the character.

When using the sream room method this is what I see when I move:
http://i.imgur.com/8muzrZJ.gifv

vs just using the .streamMode(1) on the player entity.
http://i.imgur.com/bLrZXUr.gifv

Is this a bug or am I missing something?

what I'm doing is creating the scenes in the init func when creating the main scene and assigning client/server vars there.
Code: Select all
var WorldMap = IgeScene2d.extend({
    classId: 'WorldMap',

    init: function () {

        var self = this;

        IgeScene2d.prototype.init.call(this);

        self.objectScene = new IgeScene2d()
            .id('objectScene')
            .translateTo( 0, 0, 0)
            .depth(1)
            .translateTo( 0, 0, 0)
            .mount(self);

        if ( ige.isClient ){
           
        self.backScene = new IgeScene2d()
            .id('backScene')
            .translateTo( 0, 0, 0)
            .depth(0)
            .mount(self);

            ige.addComponent(IgeTiledComponent).tiled.loadJson( map, function ( layerArray, layersById ) {
                var i;
                for (i = 0; i < layerArray.length; i++) {
                    switch (layerArray[i].type) {
                        case 'tilelayer':
                            layerArray[i]
                                .translateTo(0, 0, 0)
                                .tileWidth(32)
                                .tileHeight(32)
                                .mount(self.backScene);
                            break;
                    }
                }
            });
        }

        if ( ige.isServer ) {
            self.objectScene
                .streamRoomId('room1')
                .streamMode(1)
                .compositeStream(true);
        }

    },

    destroy: function () {
        // Call the super class
        IgeScene2d.prototype.destroy.call(this);
    }
});

if (typeof(module) !== 'undefined' && typeof(module.exports) !== 'undefined') { module.exports = WorldMap; }
craigbett
 
Posts: 10
Joined: Fri Feb 28, 2014 5:28 am


Return to Help & Questions

Who is online

Users browsing this forum: No registered users and 1 guest
cron