void Update()
        {
            if (sending)
            {
                switch (ubitrackEvent)
                {
                case UbitrackEventType.Push:
                {
                    SimplePosition3D simplePos3D = new SimplePosition3D();
                    Vector3          output      = Vector3.zero;
                    UbiMeasurementUtils.coordsysemChange(sendPos, ref output);
                    simplePos3D.x         = output.x;
                    simplePos3D.y         = output.y;
                    simplePos3D.z         = output.z;
                    simplePos3D.timestamp = UbiMeasurementUtils.getUbitrackTimeStamp();
                    m_poseReciever.receivePosition3D(simplePos3D);
                    if (once)
                    {
                        this.enabled = false;
                    }
                    break;
                }

                case UbitrackEventType.Pull:
                default:
                    break;
                }
            }
        }
Esempio n. 2
0
        void FixedUpdate()
        {
            if (ubitrackEvent == UbitrackEventType.Pull && UseTriggerToPull)
            {
                return;
            }

            m_pose = null;

            switch (ubitrackEvent)
            {
            case UbitrackEventType.Pull: {
                ulong lastTimestamp = UbiMeasurementUtils.getUbitrackTimeStamp();
                if (m_posePull.getPose(m_simplePose, lastTimestamp))
                {
                    m_pose = UbiMeasurementUtils.ubitrackToUnity(m_simplePose);
                }
                break;
            }

            case UbitrackEventType.Push: {
                m_pose = m_poseReceiver.getData();
                break;
            }

            default:
                break;
            }


            //Debug.Log ("m_simplePose: " + m_simplePose);
            processData();
        }
Esempio n. 3
0
        protected void processData()
        {
            if (m_pose != null)
            {
                UbiUnityUtils.setGameObjectPose(relative, gameObject, m_pose.data());

                if (m_lastData != null)
                {
                    Vector3 posDiff  = m_pose.data().pos - m_lastData.data().pos;
                    ulong   timeDiff = m_pose.time() - m_lastData.time();

                    float timeDiffSeconds = (float)timeDiff * 1E-9f;

                    m_meanPosVelocity = posDiff.magnitude / timeDiffSeconds;
                }

                m_lastData = m_pose;

                triggerPull(m_pose.time());
            }


            if (m_lastData != null)
            {
                ulong timeDiff             = UbiMeasurementUtils.getUbitrackTimeStamp() - m_lastData.time();
                float timeDiffMilliSeconds = (float)timeDiff * 1E-6f;
                m_timeout = timeDiffMilliSeconds > TimeoutInMilliSeconds;
            }
        }
Esempio n. 4
0
        void Update()
        {
            if (sending)
            {
                switch (ubitrackEvent)
                {
                case UbitrackEventType.Push:
                {
                    SimplePosition2D simplePos2D = new SimplePosition2D();
                    simplePos2D.x         = sendPos2D.x;
                    simplePos2D.y         = sendPos2D.y;
                    simplePos2D.timestamp = UbiMeasurementUtils.getUbitrackTimeStamp();
                    m_poseReciever.receivePosition2D(simplePos2D);
                    if (once)
                    {
                        this.enabled = false;
                    }
                    break;
                }

                case UbitrackEventType.Pull:
                default:
                    break;
                }
            }
        }
Esempio n. 5
0
        void FixedUpdate()
        {
            switch (ubitrackEvent)
            {
            case UbitrackEventType.Pull:
            {
                ulong lastTimestamp = UbiMeasurementUtils.getUbitrackTimeStamp();
                if (m_position3DListPull.getPositionList3D(m_simplePosition3DList, lastTimestamp))
                {
                    m_data = UbiMeasurementUtils.ubitrackToUnity(m_simplePosition3DList);
                }
                break;
            }

            case UbitrackEventType.Push:
            {
                Measurement <List <Vector3> > tmp = m_listReceiver.getData();
                if (tmp != null)
                {
                    m_data = tmp;
                }
                break;
            }

            default:
                break;
            }
        }
Esempio n. 6
0
        public void applyProjectionMatrix()
        {
            SimpleMatrix3x3 matrix = new SimpleMatrix3x3();

            if (m_matrixPull.getMatrix3x3(matrix, UbiMeasurementUtils.getUbitrackTimeStamp()))
            {
                intrinsics = UbiMeasurementUtils.ubitrackToUnity(matrix);

                projectionMatrix = CameraUtils.constructProjectionMatrix3x3(intrinsics.data(), standardWidth, standardHeight, nearClipping, farClipping);

                if (Flip_X_Y)
                {
                    Matrix4x4 rotMat = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, 0, -90), Vector3.one);
                    projectionMatrix = rotMat * projectionMatrix;
                }

                //Debug.Log(projectionMatrix);
                if (GetComponent <Camera>() != null)
                {
                    GetComponent <Camera>().projectionMatrix = projectionMatrix;
                    //Debug.Log("set projection matrix of camera");
                }
            }
            else
            {
                throw new Exception("unable to get 3x3 matrix");
            }
        }
Esempio n. 7
0
        void FixedUpdate()
        {
            m_pose = null;

            switch (ubitrackEvent)
            {
            case UbitrackEventType.Pull: {
                ulong lastTimestamp = UbiMeasurementUtils.getUbitrackTimeStamp();
                if (m_posePull.getPose(m_simplePose, lastTimestamp))
                {
                    m_pose = UbiMeasurementUtils.ubitrackToUnity(m_simplePose);
                }
                break;
            }

            case UbitrackEventType.Push: {
                m_pose = m_poseReceiver.getData();
                break;
            }

            default:
                break;
            }

            if (m_pose != null)
            {
                UbiUnityUtils.setGameObjectPose(relative, gameObject, m_pose.data());
            }
        }
Esempio n. 8
0
        public void sendButtonEvent(int eventID)
        {
            SimpleButton b = new SimpleButton();

            b.timestamp = UbiMeasurementUtils.getUbitrackTimeStamp();
            b._event    = eventID;
            m_button.receiveButton(b);
        }
        void FixedUpdate()
        {
            m_pose = null;

            switch (ubitrackEvent)
            {
            case UbitrackEventType.Pull:
            {
                ulong lastTimestamp = UbiMeasurementUtils.getUbitrackTimeStamp();

                if (m_posePull.getErrorPosition3D(m_simplePose, lastTimestamp))
                {
                    m_pose = UbiMeasurementUtils.ubitrackToUnity(m_simplePose);
                }
                break;
            }

            case UbitrackEventType.Push:
            {
                m_pose = m_poseReceiver.getData();
                break;
            }

            default:
                break;
            }

            if (m_pose != null)
            {
                if (relative == UbitrackRelativeToUnity.Local)
                {
                    gameObject.transform.localPosition = m_pose.data().position;
                }
                else
                {
                    gameObject.transform.position = m_pose.data().position;
                }
                m_lastpose = m_pose;
            }
        }
        void FixedUpdate()
        {
            m_position = null;

            switch (ubitrackEvent)
            {
            case UbitrackEventType.Pull: {
                ulong lastTimestamp = UbiMeasurementUtils.getUbitrackTimeStamp();
                if (m_positionPull.getPosition3D(m_simplePosition, lastTimestamp))
                {
                    m_position = UbiMeasurementUtils.ubitrackToUnity(m_simplePosition);
                }
                break;
            }

            case UbitrackEventType.Push: {
                m_position = m_positionReceiver.getData();
                break;
            }

            default:
                break;
            }

            if (m_position != null)
            {
                UbiUnityUtils.setGameObjectPosition(relative, gameObject, m_position.data());
                m_lastData = m_position;
            }

            if (m_lastData != null)
            {
                ulong timeDiff             = UbiMeasurementUtils.getUbitrackTimeStamp() - m_lastData.time();
                float timeDiffMilliSeconds = (float)timeDiff * 1E-6f;
                m_timeout = timeDiffMilliSeconds > TimeoutInMilliSeconds;
            }
        }