abhishekvp / cesium-lg

Liquid Galaxy GSoC 2016 Project: Enabling Cesium for Liquid Galaxy
5 stars 3 forks source link

update: protobuf using signed ints for camera pose. #38

Open alfski opened 8 years ago

alfski commented 8 years ago

server.js:

    UDPserver.on('message', function(message, remote) {

        var viewsync = String(message).split(',');

        var s = new CesiumSync();
        s.msgtype = 2;
        s.lat = Math.round(parseFloat(viewsync[1]) * 10e5);
        s.lon = Math.round(parseFloat(viewsync[2]) * 10e5);
        s.alt = Math.round(parseFloat(viewsync[3]) * 100);
        s.heading = Math.round(util.toRadians(parseFloat(viewsync[4])) * 10e4);
        s.pitch = Math.round(util.toRadians((parseFloat(viewsync[5]) - 90)) * 10e4);
        s.roll = Math.round(util.toRadians(parseFloat(viewsync[6])) * 10e3);

        var thisSync = s.toBuffer();

        if (thisSync != lastGESync) {
                lastGESync = thisSync;

                for (var i in wsClients) {
                    wsClients[i].send(thisSync);
                }

            // UDPclient.send(thisSync,0,thisSync.length,CONFIG.CesiumSyncPort,CONFIG.CesiumSyncHost);
        }
    });

cesiumsync.proto:

message CesiumSync {
    required int32 msgtype = 1;
    optional sint32 lon = 2;
    optional sint32 lat = 3;
    optional sint32 alt = 4;
    optional sint32 heading = 5; 
    optional sint32 pitch = 6;
    optional sint32 roll = 7;
    optional bool lighting = 8;
}

updates to Slave-Client.html:

function handleGECam(camVals) {

            var px = camVals.lon / 10e5,
                py = camVals.lat / 10e5,
                pz = camVals.alt / 100,
                heading = camVals.heading / 10e4,
                pitch = camVals.pitch / 10e4,
                roll = camVals.roll / 10e3;
...
alfski commented 8 years ago

my check for changes isn't really good enough... some stuff if slipping thru.

in server.js use this instead:

       ...
    s.roll = Math.round(util.toRadians(parseFloat(viewsync[6])) * 10e3);

    var syncString = s.lat+','+s.lon+','+s.alt+','+s.heading+','+s.pitch+','+s.roll;

    if (syncString != lastGESyncString) {
        lastGESyncString = syncString;
        var msg = s.toBuffer();

        for (var i in wsClients) {
            wsClients[i].send(msg);
        }
        ...
abhishekvp commented 8 years ago

I am working on this issue, now that we have a single handler for both Cesium Master and GE. But using the sint32 in the .proto file gives this error on Cesium Master: Uncaught Error: Illegal value for Message.Field .CesiumSync.lon of type sint32: number (not an integer)

The Server(Node Relay) exits with a similar error when GE is used : Error: Illegal value for [object Object] of type sint32: number (not an integer) at Error (native)