Пример #1
0
    void Update()
    {
        ++lostCount_;
        if (lostCount_ > 120)
        {
            MarkerManager.Remove(data_);
        }

        UpdateInterpolation();

        if (!isInitialized_)
        {
            transform.localPosition = rawPos_;
            transform.localRotation = Quaternion.AngleAxis(currentAngle_ * Mathf.Rad2Deg, Vector3.down);
            isInitialized_          = true;
        }
        else
        {
            transform.localPosition += (rawPos_ - transform.localPosition) * filter;
            var from = transform.localRotation;
            var to   = Quaternion.AngleAxis(currentAngle_ * Mathf.Rad2Deg, Vector3.down);
            if (to.eulerAngles.y - from.eulerAngles.y >= 180)
            {
                from *= Quaternion.Euler(Vector3.up * 360);
            }
            if (to.eulerAngles.y - from.eulerAngles.y <= -180)
            {
                from *= Quaternion.Euler(-Vector3.up * 360);
            }
            transform.localRotation = Quaternion.Slerp(from, to, filter);
        }
    }
Пример #2
0
    void ProcessMarkerMessage(Osc.Message msg)
    {
        var json = JSON.Parse(msg.data[0].ToString());
        var data = convertToMarkerData(json);

        int markerIndex = "/marker".Length;

        if (msg.path.IndexOf("/create") == markerIndex)
        {
            MarkerManager.Create(data);
        }
        else if (msg.path.IndexOf("/update") == markerIndex)
        {
            MarkerManager.Update(data);
        }
        else if (msg.path.IndexOf("/remove") == markerIndex)
        {
            MarkerManager.Remove(data);
        }
        else
        {
            Debug.LogWarning("unknown message: " + msg);
        }
    }