Exemplo n.º 1
0
    /// <summary>
    /// Creates a new UWB objecy in the scene with address from the tag.
    /// </summary>
    /// <param name="address"></param>
    public void CreateNewUWBObject(string address)
    {
        UWBObject uwb = Instantiate(UWBObjectPrefab);

        uwb.UWBAddress      = address;
        uwb.gameObject.name = address;
        UWBObjects.Add(uwb);
    }
Exemplo n.º 2
0
    /// <summary>
    /// Calls UWBObjectManager to find an object in the scene by address. If the object is found, sends sensor data to it.
    /// </summary>
    /// <param name="data"></param>
    public void SendDataToUWBObject(SensorDataRaw data)
    {
        UWBObject obj = UWBMan.FindObjectByAddress(data.address);

        if (obj != null)
        {
            obj.ReceiveData(data);
        }
    }
Exemplo n.º 3
0
    public void UpdateSettingsFromClient(int _sender, UWBObject _target, UWBObjectData _newSettings)
    {
        _target.m_OverridePosition      = _newSettings.m_OverridePosition;
        _target.m_OverridePositionState = _newSettings.m_OverridePositionState;
        _target.allowRotation           = _newSettings.allowRotation;
        _target.m_InvertPositionState   = _newSettings.m_InvertPositionState;
        _target.m_OffsetPosition        = _newSettings.m_OffsetPosition;
        _target.position = _newSettings.position;

        _target.UpdateObjectPosition(_target.position);

        // TODO: Send this data to other clients
        ServerSend.UWBObjectDataExcludeUser(_sender, UWBObjectSerializer.instance.Serialize(_newSettings));
    }
Exemplo n.º 4
0
    public void SendUpdateToClients(UWBObject _senderObj)
    {
        UWBObjectData data = new UWBObjectData();

        data.UWBAddress              = _senderObj.UWBAddress;
        data.m_OverridePosition      = _senderObj.m_OverridePosition;
        data.m_OverridePositionState = _senderObj.m_OverridePositionState;
        data.allowRotation           = _senderObj.allowRotation;
        data.m_InvertPositionState   = _senderObj.m_InvertPositionState;
        data.m_OffsetPosition        = _senderObj.m_OffsetPosition;
        data.position = _senderObj.position;

        ServerSend.UWBObjectData(UWBObjectSerializer.instance.Serialize(data));
    }
Exemplo n.º 5
0
 void Update()
 {
     m_activeUWBObject = uwbMan.activeSelectedUWBObject;
     if (m_activeUWBObject != null)
     {
         Vector3 activePos = uwbMan.activeSelectedUWBObject.transform.position;
         Vector3 activeRot = uwbMan.activeSelectedUWBObject.transform.rotation.eulerAngles;
         activeTransformString = string.Format("Position: \n X: {0} \n Y: {1} \n Z: {2} \n\n Rotation: \n X: {3} \n Y: {4} \n Z: {5}", activePos.x, activePos.y, activePos.z, activeRot.x, activeRot.y, activeRot.z);
     }
     else
     {
         activeTransformString = "Position: \n - \n - \n - \n\n Rotation: \n - \n - \n -";
     }
     InitOverrideFields();
     activeObjectTransformDataText.text = activeTransformString;
 }
Exemplo n.º 6
0
    public void SetActiveUWBObject(GameObject targetObject)
    {
        // first, the raycast collides with the graphics collider,and that is a child of the graphics object
        //GameObject graphicsObjectRoot = targetObject.transform.parent.gameObject;
        // then we get the parent of the graphics object which holds the UWBObject script
        //UWBObject uwbObjectRoot = graphicsObjectRoot.transform.parent.gameObject.GetComponent<UWBObject>();

        UWBObject uwbObjectRoot = targetObject.transform.root.GetComponent <UWBObject>();

        if (uwbObjectRoot != null)
        {
            //UWBObjectManager.i.activeSelectedUWBObject = uwbObjectRoot;
            UWBObjectManager.i.SetActiveSelectedObject(uwbObjectRoot);
            activeTagLabel.text = uwbObjectRoot.gameObject.name;
            UWBUI.InitNewSelectedObject();
        }
    }
Exemplo n.º 7
0
    public void UpdateSettingsFromServer(UWBObject _target, UWBObjectData _newSettings)
    {
        _target.m_OverridePosition      = _newSettings.m_OverridePosition;
        _target.m_OverridePositionState = _newSettings.m_OverridePositionState;
        _target.allowRotation           = _newSettings.allowRotation;
        _target.m_InvertPositionState   = _newSettings.m_InvertPositionState;
        _target.m_OffsetPosition        = _newSettings.m_OffsetPosition;
        _target.position = _newSettings.position;

        _target.UpdateObjectPosition(_target.position);

        // TEST:
        if (UWBObjectManager.i.activeSelectedUWBObject.UWBAddress == _target.UWBAddress)
        {
            GameObject.FindObjectOfType <ActiveUWBObjectDataOutputUI>().InitNewSelectedObject();
        }
    }
Exemplo n.º 8
0
    public void SendUpdateToServer(UWBObject _senderObj)
    {
        // UWBServer_Client.ClientSend.UWBObjectData(UWBObjectSerializer.instance.Serialize(UWBObjectManager.i.activeSelectedUWBObject))

        UWBObjectData data = new UWBObjectData();

        data.UWBAddress              = _senderObj.UWBAddress;
        data.m_OverridePosition      = _senderObj.m_OverridePosition;
        data.m_OverridePositionState = _senderObj.m_OverridePositionState;
        data.allowRotation           = _senderObj.allowRotation;
        data.m_InvertPositionState   = _senderObj.m_InvertPositionState;
        data.m_OffsetPosition        = _senderObj.m_OffsetPosition;

        //data.position = new Vector3(Mathf.Abs(_senderObj.transform.position.x), Mathf.Abs(_senderObj.transform.position.y), Mathf.Abs(_senderObj.transform.position.z));
        data.position = _senderObj.position;

        print("Sending updated data to server");
        ClientSend.UWBObjectData(UWBObjectSerializer.instance.Serialize(data));
    }
Exemplo n.º 9
0
 public void SetActiveSelectedObject(UWBObject _obj)
 {
     activeSelectedUWBObject = _obj;
 }