Exemplo n.º 1
0
    public void SendOSCPosition(UserData userData, int playerPart, OSCEndPoint targetEndPoint)
    {
        Vector3    pos = new Vector3();
        Quaternion rot = new Quaternion();

        if (osc.initialized)
        {
            message         = new OscMessage();
            message.address = "/PlayerData";
            message.values.Add(userData._ID);
            message.values.Add(userData._registeredRank);

            if (playerPart == 0)
            {
                pos = userData.head.transform.position - userData.calibrationPositionGap;
                rot = userData.head.transform.rotation;
            }
            if (playerPart == 1)
            {
                pos = userData.leftHand.transform.position - userData.calibrationPositionGap;
                rot = userData.leftHand.transform.rotation;
            }
            if (playerPart == 2)
            {
                pos = userData.rightHand.transform.position - userData.calibrationPositionGap;
                rot = userData.rightHand.transform.rotation;
            }

            if (gameEngine._userRole == UserRole.Server)
            {
                //pos -=  userData.calibrationPositionGap;
            }

            message.values.Add(playerPart);
            message.values.Add(pos.x);
            message.values.Add(pos.y);
            message.values.Add(pos.z);
            message.values.Add(rot.x);
            message.values.Add(rot.y);
            message.values.Add(rot.z);
            message.values.Add(rot.w);


            osc.OscPacketIO.RemoteHostName = targetEndPoint.ip;
            osc.OscPacketIO.RemotePort     = targetEndPoint.remotePort;
            osc.Send(message);
            if (gameEngine.debugMode)
            {
                Debug.Log("Sending : " + message + ", " + targetEndPoint.ip + ", " + targetEndPoint.remotePort);
            }
        }
    }
Exemplo n.º 2
0
    public void SendTimeStampData(OSCEndPoint targetEndPoint)
    {
        message         = new OscMessage();
        message.address = "/TimeStamp";

        double ts;

        if (gameEngine._userRole == UserRole.Playback)
        {
            ts = gameEngine.playbackManager.currentLine.Time / 1000;
        }
        else
        {
            ts = gameEngine.clock.GetTimeSinceSceneStart();
        }

        message.values.Add(ts.ToString());
        //message.values.Add(ts);

        osc.OscPacketIO.RemoteHostName = targetEndPoint.ip;
        osc.OscPacketIO.RemotePort     = targetEndPoint.remotePort;
        osc.Send(message);
    }
Exemplo n.º 3
0
    public void InitUserData(int ID, string playerName, string address, int localPort, GameObject pGameObject, bool isMe, bool playerNameVisible, UserRole userRole,
                             GameObject vrRigPrefab, bool useVRHeadset)
    {
        _ID = ID;

        _userRole   = userRole;
        _playerName = playerName;
        _isMe       = isMe;

        oscEndPoint            = new OSCEndPoint();
        oscEndPoint.ip         = address;
        oscEndPoint.remotePort = localPort;

        if (userRole == UserRole.Player || (!isMe && userRole == UserRole.Playback))
        {
            head      = pGameObject.transform.Find("Head").gameObject;
            leftHand  = pGameObject.transform.Find("LeftHand").gameObject;
            rightHand = pGameObject.transform.Find("RightHand").gameObject;
        }

        if (_playerName == "")
        {
            _playerName = "P" + (_registeredRank + 1);
        }

        // things that change depending on the kind of player we try to instantiate
        // PLAYER //
        if (_userRole == UserRole.Player)
        {
            if (!useVRHeadset)
            {
                Debug.Log("Not looking for Vive System");
            }

            PlaceUserPartsInScene(pGameObject, vrRigPrefab, useVRHeadset);

            if (!useVRHeadset)
            {
                SetAsDraggable(this);
            }

            pGameObject.name = "Player" + _ID.ToString();
            playerGameObject = pGameObject;
        }
        // TRACKER //
        else if (_userRole == UserRole.Tracker)
        {
            pGameObject.name = "Tracker" + _ID.ToString();
            PlaceUserPartsInScene(pGameObject, vrRigPrefab, false);
        }
        // PLAYBACK //
        else if (userRole == UserRole.Playback)
        {
            PlaceUserPartsInScene(pGameObject, vrRigPrefab, useVRHeadset);
            if (isMe)
            {
                pGameObject.name = "Playback" + _ID.ToString();
            }
            else
            {
                pGameObject.name = "PlaybackPlayer" + _ID.ToString();
            }
            playerGameObject = pGameObject;
        }
        // VIEWER //
        else
        {
            pGameObject.name = "Viewer" + _ID.ToString();
            PlaceUserPartsInScene(pGameObject, vrRigPrefab, false);
        }

        if (head != null)
        {
            headText      = head.transform.Find("Canvas").Find("Text").GetComponent <UnityEngine.UI.Text>();
            headText.text = _playerName;

            if (playerNameVisible)
            {
                headText.gameObject.SetActive(true);
            }
            else
            {
                headText.gameObject.SetActive(false);
            }
        }

        calibrationPositionGap = new Vector3();
        calibrationRotationGap = new Quaternion();
    }
Exemplo n.º 4
0
 public void SendCustomMessage(OscMessage customMessage, OSCEndPoint oscEndPoint)
 {
     osc.OscPacketIO.RemoteHostName = oscEndPoint.ip;
     osc.OscPacketIO.RemotePort     = oscEndPoint.remotePort;
     osc.Send(customMessage);
 }