//public GameObject[] generate_rbState_Objects_1;
    //public GameObject[] generate_ControllerGameobject_Objects_1;



    // Use this for initialization
    void Start()
    {
        // If the user didn't explicitly associate a client, find a suitable default.
        if (this.StreamingClient == null)
        {
            this.StreamingClient = OptitrackStreamingClient.FindDefaultClient();

            // If we still couldn't find one, disable this component.
            if (this.StreamingClient == null)
            {
                Debug.LogError(GetType().FullName + ": Streaming client not set, and no " + typeof(OptitrackStreamingClient).FullName + " components found in scene; disabling this component.", this);
                this.enabled = false;
                return;
            }
        }

        calibrationData = new CalibrationProcessData();

        if (calibrateMethod == CalibrationLoadMethod.LOADFILE)
        {
            calibrationData.loadMatrixFromFile();
            dataInitiate = true;
        }

        else if (calibrateMethod == CalibrationLoadMethod.CALIBRATION)
        {
            print("Press C for calibration");
        }
    }
    void Start()
    {
        // If the user didn't explicitly associate a client, find a suitable default.
        if (this.StreamingClient == null)
        {
            this.StreamingClient = OptitrackStreamingClient.FindDefaultClient();

            // If we still couldn't find one, disable this component.
            if (this.StreamingClient == null)
            {
                Debug.LogError(GetType().FullName + ": Streaming client not set, and no " + typeof(OptitrackStreamingClient).FullName + " components found in scene; disabling this component.", this);
                this.enabled = false;
                return;
            }
        }

        this.StreamingClient.RegisterSkeleton(this, this.SkeletonAssetName);

        // Create a lookup from Mecanim anatomy bone names to OptiTrack streaming bone names.
        CacheBoneNameMap(this.StreamingClient.BoneNamingConvention, this.SkeletonAssetName);

        // Retrieve the OptiTrack skeleton definition.
        m_skeletonDef = this.StreamingClient.GetSkeletonDefinitionByName(this.SkeletonAssetName);

        if (m_skeletonDef == null)
        {
            Debug.LogError(GetType().FullName + ": Could not find skeleton definition with the name \"" + this.SkeletonAssetName + "\"", this);
            this.enabled = false;
            return;
        }

        // Create a hierarchy of GameObjects that will receive the skeletal pose data.
        string rootObjectName = "OptiTrack Skeleton - " + this.SkeletonAssetName;

        m_rootObject = new GameObject(rootObjectName);

        m_boneObjectMap = new Dictionary <Int32, GameObject>(m_skeletonDef.Bones.Count);

        for (int boneDefIdx = 0; boneDefIdx < m_skeletonDef.Bones.Count; ++boneDefIdx)
        {
            OptitrackSkeletonDefinition.BoneDefinition boneDef = m_skeletonDef.Bones[boneDefIdx];

            GameObject boneObject = new GameObject(boneDef.Name);
            boneObject.transform.parent        = boneDef.ParentId == 0 ? m_rootObject.transform : m_boneObjectMap[boneDef.ParentId].transform;
            boneObject.transform.localPosition = boneDef.Offset;
            m_boneObjectMap[boneDef.Id]        = boneObject;
        }

        // Hook up retargeting between those GameObjects and the destination Avatar.
        MecanimSetup(rootObjectName);

        // Can't re-parent this until after Mecanim setup, or else Mecanim gets confused.
        m_rootObject.transform.parent        = this.StreamingClient.transform;
        m_rootObject.transform.localPosition = Vector3.zero;
        m_rootObject.transform.localRotation = Quaternion.identity;
    }
Ejemplo n.º 3
0
    void Start()
    {
        // If the user didn't explicitly associate a client, find a suitable default.
        if (this.StreamingClient == null)
        {
            this.StreamingClient = OptitrackStreamingClient.FindDefaultClient();

            // If we still couldn't find one, disable this component.
            if (this.StreamingClient == null)
            {
                Debug.LogError(GetType().FullName + ": Streaming client not set, and no " + typeof(OptitrackStreamingClient).FullName + " components found in scene; disabling this component.", this);
                this.enabled = false;
                return;
            }
        }

        if (UnityEngine.XR.XRDevice.isPresent)
        {
            string vrDeviceFamily = UnityEngine.XR.XRDevice.family;
            string vrDeviceModel  = UnityEngine.XR.XRDevice.model;
            bool   isOculusDevice = String.Equals(vrDeviceFamily, "oculus", StringComparison.CurrentCultureIgnoreCase);

            if (isOculusDevice)
            {
                if (TryDisableOvrPositionTracking() == false)
                {
                    Debug.LogError(GetType().FullName + ": Detected Oculus HMD (\"" + vrDeviceModel + "\", but could not disable OVR position tracking.", this);
                }
                else
                {
                    Debug.Log(GetType().FullName + ": Successfully disabled position tracking for HMD \"" + vrDeviceModel + "\".", this);
                }
            }
            else
            {
                Debug.LogWarning(GetType().FullName + ": Unrecognized HMD type (\"" + vrDeviceFamily + "\", \"" + vrDeviceModel + "\").", this);
            }
        }
        else
        {
            Debug.LogWarning(GetType().FullName + ": No VRDevice present.", this);
        }

        // Cache a reference to the gameobject containing the HMD Camera.
        Camera hmdCamera = this.GetComponentInChildren <Camera>();

        if (hmdCamera == null)
        {
            Debug.LogError(GetType().FullName + ": Couldn't locate HMD-driven Camera component in children.", this);
        }
        else
        {
            m_hmdCameraObject = hmdCamera.gameObject;
        }
    }
    void Start()
    {
        // If the user didn't explicitly associate a client, find a suitable default.
        if (this.StreamingClient == null)
        {
            this.StreamingClient = OptitrackStreamingClient.FindDefaultClient();

            // If we still couldn't find one, disable this component.
            if (this.StreamingClient == null)
            {
                Debug.LogError(GetType().FullName + ": Streaming client not set, and no " + typeof(OptitrackStreamingClient).FullName + " components found in scene; disabling this component.", this);
                this.enabled = false;
                return;
            }
        }
    }
Ejemplo n.º 5
0
    void Start()
    {
        if (useOptitrack)
        {
            // If the user didn't explicitly associate a client, find a suitable default.
            if (this.StreamingClient == null)
            {
                this.StreamingClient = OptitrackStreamingClient.FindDefaultClient();

                // If we still couldn't find one, disable this component.
                if (this.StreamingClient == null)
                {
                    Debug.LogError(GetType().FullName + ": Streaming client not set, and no " + typeof(OptitrackStreamingClient).FullName + " components found in scene; disabling this component.", this);
                    this.enabled = false;
                    return;
                }
            }
        }

        if (UnityEngine.VR.VRDevice.isPresent)
        {
            string vrDeviceFamily = UnityEngine.VR.VRSettings.loadedDeviceName;
            string vrDeviceModel  = UnityEngine.VR.VRDevice.model;
            bool   isOpenVR       = String.Equals(vrDeviceFamily, "OpenVR", StringComparison.CurrentCultureIgnoreCase);

            if (isOpenVR)
            {
                Debug.Log(GetType().FullName + ": found OpenVR headset\"" + vrDeviceModel + "\".", this);
            }
            else
            {
                Debug.LogWarning(GetType().FullName + ": Unsupported HMD type (\"" + vrDeviceFamily + "\", \"" + vrDeviceModel + "\").", this);
            }
        }
        else
        {
            Debug.LogWarning(GetType().FullName + ": No VRDevice present.", this);
        }

        // Cache a reference to the gameobject containing the HMD Camera.
        Camera hmdCamera = this.GetComponentInChildren <Camera>();

        if (hmdCamera == null)
        {
            Debug.LogError(GetType().FullName + ": Couldn't locate HMD-driven Camera component in children.", this);
        }
    }
Ejemplo n.º 6
0
    /*
     *  Method called at start of game
     */
    void Start()
    {
        // If the user didn't explicitly associate a client, find a suitable default.
        if (this.StreamingClient == null)
        {
            this.StreamingClient = OptitrackStreamingClient.FindDefaultClient();

            // If we still couldn't find one, disable this component.
            if (this.StreamingClient == null)
            {
                Debug.LogError(GetType().FullName + ": Streaming client not set, and no " + typeof(OptitrackStreamingClient).FullName + " components found in scene; disabling this component.", this);
                this.enabled = false;
                return;
            }
        }

        #region Initialize variables

        count   = 0;                   //frame number
        prevPos = Experiment.cuestart; //initialize previous positons to cue starting position

        //initialize cue velocities
        cueVelocity  = new Vector3(0f, 0f, 0f);
        VelocityList = new List <Vector3>();
        for (int i = 0; i < Experiment.numVelocitiesAverage; i++)
        {
            VelocityList.Add(cueVelocity);
        }

        //initialize IDs and positions of optitrack markers placed on the pool table
        corner1ID = -1; corner2ID = -1; corner3ID = -1;
        C1        = new List <Vector3>(); C2 = new List <Vector3>(); C3 = new List <Vector3>();

        //get IDs and positions of optitrack markers
        backID1 = -1; backID2 = -2; frontID1 = -3; frontID2 = -4;
        Oback1  = new Vector3(); Oback2 = new Vector3(); Ofront1 = new Vector3(); Ofront2 = new Vector3();
        if (Experiment.experiment == 0 && markerIDs)
        {
            getCalMarkerId();
        }

        test = true; //for calibration

        #endregion
    }
Ejemplo n.º 7
0
    void Start()
    {
        //sets the reference time
        zeroTime.m_ticks = 0;

        // null client, find default
        if (this.StreamingClient == null)
        {
            this.StreamingClient = OptitrackStreamingClient.FindDefaultClient();

            // disable if no client found
            if (this.StreamingClient == null)
            {
                Debug.LogError(GetType().FullName + ": No streaming clients found, disabling CustomRigidBody", this);
                this.enabled = false;
                return;
            }
        }
    }
Ejemplo n.º 8
0
 // Start is called before the first frame update
 void Start()
 {
     if (StreamingClient == null)
     {
         StreamingClient = OptitrackStreamingClient.FindDefaultClient();
         // If we still couldn't find one, disable this component.
         if (StreamingClient == null)
         {
             Debug.LogError(GetType().FullName + ": Streaming client not set, and no " + typeof(OptitrackStreamingClient).FullName + " components found in scene; disabling this component.", this);
             this.enabled = false;
             return;
         }
     }
     InitGO("shoulder1", ref goShoulder1);
     InitGO("shoulder2", ref goShoulder2);
     InitGO("forearm", ref goForearm);
     InitGO("hand", ref goHand);
     InitGO("indexfinger", ref goIndexfinger);
     InitGO("hmd", ref goHmd);
     InitGO("upperarm", ref goUpperarm);
 }
Ejemplo n.º 9
0
    void Start()
    {
        // If the user didn't explicitly associate a client, find a suitable default.
        if (this.StreamingClient == null)
        {
            this.StreamingClient = OptitrackStreamingClient.FindDefaultClient();

            // If we still couldn't find one, disable this component.
            if (this.StreamingClient == null)
            {
                //Debug.LogError(GetType().FullName + ": Streaming client not set, and no " + typeof(OptitrackStreamingClient).FullName + " components found in scene; disabling this component.", this);
                this.enabled = false;
                return;
            }
        }

        calibrationScript = GameObject.Find("Client - OptiTrack").GetComponent <OptitrackCalibration>();


        //Initialize Photos
        obeject1.gameObject.SetActive(false);
        obeject2.gameObject.SetActive(false);
        obeject3.gameObject.SetActive(false);
        obeject4.gameObject.SetActive(false);
        object5.gameObject.SetActive(false);
        object6.gameObject.SetActive(false);
        object7.gameObject.SetActive(false);
        object8.gameObject.SetActive(false);
        object_text.gameObject.SetActive(false);


        //Initialize Music
        music_play = false;
        music1.gameObject.SetActive(false);
        music2.gameObject.SetActive(false);
        music3.gameObject.SetActive(false);
        m_text1.gameObject.SetActive(false);
        m_text2.gameObject.SetActive(false);
        m_text3.gameObject.SetActive(false);
    }