Exemplo n.º 1
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();
        }
 public override void receivePositionList3D(SimplePositionList3D position3dList)
 {
     lock (thisLock)
     {
         m_data = UbiMeasurementUtils.ubitrackToUnity(position3dList);
     }
 }
Exemplo n.º 3
0
 public override void receivePose(SimplePose newPose)
 {
     lock (thisLock)
     {
         m_pose = UbiMeasurementUtils.ubitrackToUnity(newPose);
     }
 }
Exemplo n.º 4
0
 public override void receiveErrorPosition3D(SimpleErrorPosition3D position3d)
 {
     lock (thisLock)
     {
         m_data = UbiMeasurementUtils.ubitrackToUnity(position3d);
     }
 }
Exemplo 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;
            }
        }
Exemplo n.º 6
0
        public void applyProjectionMatrix(ulong givenTimestamp, float screenWidth, float screenHeight)
        {
            Debug.Log("Trying to pull with timestamp " + givenTimestamp);
            SimpleMatrix3x3 matrix = new SimpleMatrix3x3();

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

                projectionMatrix = CameraUtils.constructProjectionMatrix3x3(intrinsics.data(), screenWidth, screenHeight, 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");
            }
        }
Exemplo n.º 7
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");
            }
        }
 public override void receiveMatrix3x4(SimpleMatrix3x4 newMatrix)
 {
     lock (thisLock)
     {
         m_matrix = UbiMeasurementUtils.ubitrackToUnity(newMatrix);
     }
 }
Exemplo n.º 9
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());
            }
        }
Exemplo n.º 10
0
 public override void receivePosition3D(SimplePosition3D newPosition)
 {
     lock (thisLock)
     {
         m_position = UbiMeasurementUtils.ubitrackToUnity(newPosition);
     }
 }
Exemplo n.º 11
0
 public override void pullNow(ulong lastTimestamp)
 {
     if (m_posePull.getPose(m_simplePose, lastTimestamp))
     {
         m_pose = UbiMeasurementUtils.ubitrackToUnity(m_simplePose);
     }
     processData();
 }
        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;
            }
        }
Exemplo n.º 13
0
        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;
            }
        }