Example #1
0
    // receive WebVR data from browser.
    public void WebVRData(string jsonString)
    {
        VRData data = VRData.CreateFromJSON(jsonString);

        // left projection matrix
        clp = numbersToMatrix(data.leftProjectionMatrix);

        // left view matrix
        clv = numbersToMatrix(data.leftViewMatrix);

        // right projection matrix
        crp = numbersToMatrix(data.rightProjectionMatrix);

        // right view matrix
        crv = numbersToMatrix(data.rightViewMatrix);

        // sit stand matrix
        if (data.sitStand.Length > 0)
        {
            sitStand = numbersToMatrix(data.sitStand);
        }

        // controllers
        if (data.controllers.Length > 0)
        {
            foreach (Controller control in data.controllers)
            {
                Vector3    position = new Vector3(control.position [0], control.position [1], control.position [2]);
                Quaternion rotation = new Quaternion(control.orientation [0], control.orientation [1], control.orientation [2], control.orientation [3]);

                Quaternion sitStandRotation = Quaternion.LookRotation(
                    sitStand.GetColumn(2),
                    sitStand.GetColumn(1)
                    );
                Vector3    p = sitStand.MultiplyPoint(position);
                Quaternion r = sitStandRotation * rotation;

                if (control.hand == "left")
                {
                    lhp = p;
                    lhr = r;
                }
                if (control.hand == "right")
                {
                    rhp = p;
                    rhr = r;
                }
            }
        }
    }
        public ClientScreen(string name, string id, ServerConnectionVR serverConnectionVR, ServerConnection serverConnection, string currentSessionId, BleHeartHandler bleHeartHandler, BleBikeHandler bleBikeHandler)
        {
            InitializeComponent();

            this.name = name;
            this.id   = id;

            this.serverConnectionVR = serverConnectionVR;
            this.jsonPacketBuilder  = new JsonPacketBuilder();
            this.serverConnection   = serverConnection;

            this.pageConversion  = new PageConversion();
            this.bleHeartHandler = bleHeartHandler;
            this.bleBikeHandler  = bleBikeHandler;

            this.runningVrData = new VRData();
            this.runningVrData.currentSessionId = currentSessionId;

            InitializeDefaultEvents();
            ToggleControls(false);
            StartWorker();
        }