Пример #1
0
    public static Mesh Deserialize(Holoscanner.Proto.Message msg)
    {
        Mesh m = new Mesh();

        // FIXME
        return(m);
    }
Пример #2
0
 public IEnumerator SendPosition()
 {
     while (true)
     {
         if (gameOver)
         {
             break;
         }
         if (anchorSet)
         {
             Holoscanner.Proto.Message msg = new Holoscanner.Proto.Message();
             msg.Type = Holoscanner.Proto.Message.Types.Type.CLIENT_POSITION;
             Transform t = GameObject.Find("SpatialMapping").transform;
             Vector3   t_pos = t.InverseTransformPoint(GameObject.Find("Main Camera").transform.position);
             Vector3   axis; float angle;
             GameObject.Find("Main Camera").transform.rotation.ToAngleAxis(out angle, out axis);
             axis = t.InverseTransformDirection(axis);
             Quaternion t_ori = Quaternion.AngleAxis(angle, axis);
             msg.ClientPosition            = new Proto.ClientPosition();
             msg.ClientPosition.Position   = new Proto.Vec3D();
             msg.ClientPosition.Rotation   = new Proto.Vec4D();
             msg.ClientPosition.Position.X = t_pos.x;
             msg.ClientPosition.Position.Y = t_pos.y;
             msg.ClientPosition.Position.Z = t_pos.z;
             msg.ClientPosition.Rotation.X = t_ori.x;
             msg.ClientPosition.Rotation.Y = t_ori.y;
             msg.ClientPosition.Rotation.Z = t_ori.z;
             msg.ClientPosition.Rotation.W = t_ori.w;
             NetworkCommunication.Instance.SendData(Google.Protobuf.MessageExtensions.ToByteArray(msg));
         }
         yield return(new WaitForSecondsRealtime(0.05f));
     }
 }
Пример #3
0
 public void SendTargetRequest()
 {
     Holoscanner.Proto.Message msg = new Holoscanner.Proto.Message();
     msg.Type = Holoscanner.Proto.Message.Types.Type.GAME_STATE_REQUEST;
     Debug.Log("Sending request...");
     NetworkCommunication.Instance.SendData(Google.Protobuf.MessageExtensions.ToByteArray(msg));
 }
Пример #4
0
 public void SendTargetFoundMessage(uint targetid)
 {
     Holoscanner.Proto.Message msg = new Holoscanner.Proto.Message();
     msg.Type     = Holoscanner.Proto.Message.Types.Type.TARGET_FOUND;
     msg.TargetId = targetid;
     Debug.Log("Sending target found");
     NetworkCommunication.Instance.SendData(Google.Protobuf.MessageExtensions.ToByteArray(msg));
 }
Пример #5
0
        public void StartGameRequest()
        {
            //request that the server starts the game and sends out targets to everyone.
            //server should only send out targets once it has received the start game request from all the joined clients. in the future we can fix it so that it doesn't start until it has received this from 3 clients

            //for now, just request state. but change this in future:

            Holoscanner.Proto.Message msg = new Holoscanner.Proto.Message();
            msg.Type = Holoscanner.Proto.Message.Types.Type.CLIENT_READY;
            Debug.Log("Sending start-game request...");
            NetworkCommunication.Instance.SendData(Google.Protobuf.MessageExtensions.ToByteArray(msg));
        }
Пример #6
0
    public static byte[] Serialize(Mesh mesh, Quaternion q, Vector3 v, uint id, bool islast, bool isfirst)
    {
        IEnumerable <Holoscanner.Proto.Vec3D> vertices = mesh.vertices.Select(x => {
            Holoscanner.Proto.Vec3D ret = new Holoscanner.Proto.Vec3D();
            ret.X = x.x;
            ret.Y = x.y;
            ret.Z = x.z;
            return(ret);
        });

        Holoscanner.Proto.Message msg = new Holoscanner.Proto.Message();
        msg.Type = Holoscanner.Proto.Message.Types.Type.MESH;
        msg.Mesh = new Holoscanner.Proto.Mesh();

        msg.Mesh.Vertices.Add(vertices);
        msg.Mesh.Triangles.Add(mesh.triangles);
        msg.Mesh.CamPosition   = new Holoscanner.Proto.Vec3D();
        msg.Mesh.CamPosition.X = v.x;
        msg.Mesh.CamPosition.Y = v.y;
        msg.Mesh.CamPosition.Z = v.z;
        msg.Mesh.CamRotation   = new Holoscanner.Proto.Vec4D();
        msg.Mesh.CamRotation.X = q.x;
        msg.Mesh.CamRotation.Y = q.y;
        msg.Mesh.CamRotation.Z = q.z;
        msg.Mesh.CamRotation.W = q.w;

        // FIXME - Fill in fields properly -------------------------------------------------------
#if !UNITY_EDITOR
        //msg.DeviceId = Windows.System.Profile.HardwareIdentification.getPackageSpecificToken().Id;
#else
        //msg.DeviceId = 0;
#endif
        msg.Mesh.Timestamp = (ulong)(System.DateTime.UtcNow - new System.DateTime(1970, 1, 1)).TotalMilliseconds;
        msg.Mesh.MeshId    = id;
        msg.Mesh.IsLast    = islast;
        msg.Mesh.IsFirst   = isfirst;
        //msg.Mesh.CamPosition;
        // end FIXME -----------------------------------------------------------------------------
        return(Google.Protobuf.MessageExtensions.ToByteArray(msg));
    }
Пример #7
0
 public static byte[] DataRequest()
 {
     Holoscanner.Proto.Message msg = new Holoscanner.Proto.Message();
     msg.Type = Holoscanner.Proto.Message.Types.Type.GAME_STATE_REQUEST;
     return(Google.Protobuf.MessageExtensions.ToByteArray(msg));
 }