public void Awake()
 {
     skeletonController = FindObjectOfType(typeof(RUISSkeletonController)) as RUISSkeletonController;
     pointTracker = GetComponent<RUISPointTracker>();
     skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
     ResetProgress();
 }
Esempio n. 2
0
    //


    void Awake()
    {
        fistClosedSignalTimestampBuffer = new float[fistClosedSignalLimit];
        fistOpenSignalTimestampBuffer   = new float[fistOpenSignalLimit];
        ruisSkeletonManager             = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
        skeletonWand        = GetComponent <RUISSkeletonWand>();
        handClosed          = false;
        gestureWasTriggered = false;

        if (leftOrRightFist == fistSide.InferFromName)
        {
            if (skeletonWand.wandStart.ToString().IndexOf("Right") != -1)
            {
                leftOrRightFist = fistSide.RightFist;
            }
            if (skeletonWand.wandStart.ToString().IndexOf("Left") != -1)
            {
                leftOrRightFist = fistSide.LeftFist;
            }
        }
        //add
        gunParticles  = GetComponent <ParticleSystem> ();
        gunLine       = GetComponent <LineRenderer> ();
        gunAudio      = GetComponent <AudioSource> ();
        gunLight      = GetComponent <Light> ();
        shootableMask = LayerMask.GetMask("Environment");
        //
    }
 public void Awake()
 {
     skeletonController = FindObjectOfType(typeof(RUISSkeletonController)) as RUISSkeletonController;
     pointTracker       = GetComponent <RUISPointTracker>();
     skeletonManager    = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
     ResetProgress();
 }
 void Awake()
 {
     if (skeletonManager == null)
     {
         skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
     }
 }
    void Awake()
    {
        skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
        if(skeletonController != null)
            playerId = skeletonController.playerId;
        else
            Debug.LogError(   "The public variable 'Skeleton Controller' is not assigned! Using skeleton "
                            + "ID 0 as the pivot source.");

        if(gameObject.transform.parent != null)
        {
            if(gameObject.transform.parent.GetComponentInChildren<RUISKinectAndMecanimCombiner>())
                kinectAndMecanimCombinerExists = true;
        }

        capsuleCollider = GetComponent<CapsuleCollider>();
        if(capsuleCollider == null)
            Debug.LogError("GameObject " + gameObject.name + " must have a CapsuleCollider!");
        defaultColliderHeight = capsuleCollider.height;
        defaultColliderPosition = transform.localPosition;

        positionKalman = new KalmanFilter();
        positionKalman.initialize(3,3);
        positionKalman.skipIdenticalMeasurements = true;
    }
Esempio n. 6
0
 void Awake()
 {
     if (skeletonManager == null)
     {
         skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
     }
 }
Esempio n. 7
0
    void Awake()
    {
        skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
        if (skeletonController != null)
        {
            playerId = skeletonController.playerId;
        }
        else
        {
            Debug.LogError("The public variable 'Skeleton Controller' is not assigned! Using skeleton "
                           + "#0 as the torso position source.");
        }

        if (gameObject.transform.parent != null)
        {
            if (gameObject.transform.parent.GetComponentInChildren <RUISKinectAndMecanimCombiner>())
            {
                kinectAndMecanimCombinerExists = true;
            }
        }

        capsuleCollider         = GetComponent <CapsuleCollider>();
        defaultColliderHeight   = capsuleCollider.height;
        defaultColliderPosition = transform.localPosition;

        positionKalman = new KalmanFilter();
        positionKalman.initialize(3, 3);
        positionKalman.skipIdenticalMeasurements = true;
    }
Esempio n. 8
0
 void Awake()
 {
     inputManager        = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;
     skeletonManager     = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
     stabilizingCollider = GetComponentInChildren <RUISCharacterStabilizingCollider>();
     lastJumpTime        = 0;
 }
Esempio n. 9
0
    //TODO ADD MINIMUM CONFIDENCE TO UPDATE!


    void Awake()
    {
        skeletonManager       = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
        cachedAverageSpeed    = new CachedAverageSpeed(ref points);
        cachedMaxVelocity     = new CachedMaxVelocity(ref points);
        cachedAverageVelocity = new CachedAverageVelocity(ref points);
    }
Esempio n. 10
0
    public void Start()
    {
        switch (compass)
        {
        case CompassSource.Kinect:
            if (!skeletonManager)
            {
                skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
            }
            if (!skeletonManager)
            {
                Debug.LogError("RUISSkeletonManager script is missing from this scene!");
            }
            break;

        case CompassSource.PSMove:
            inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;
            if (!inputManager)
            {
                Debug.LogError("RUISInputManager script is missing from this scene!");
            }
            break;
        }

        if (driftingSensor == DriftingRotation.InputTransform && !driftingTransform)
        {
            Debug.LogError("driftingTransform is none, you need to set it from the inspector!");
        }

        oculusCamController = FindObjectOfType(typeof(OVRCameraController)) as OVRCameraController;
    }
    void Awake()
    {
        inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;
        skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
        stabilizingCollider = GetComponentInChildren<RUISCharacterStabilizingCollider>();
		lastJumpTime = 0;
		skeletonController = gameObject.GetComponentInChildren<RUISSkeletonController>();
    }
 void Start()
 {
     skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
     if (!skeletonManager)
     {
         Debug.LogError("Could not find skeletonManager.");
     }
     debugPosition = GameObject.Find("handMovementAngleIndicator").transform.position;
 }
Esempio n. 13
0
    public void retry()
    {
        //Camera_inv.SetActive(false);
        ConfirmationModal.SetActive(false);
        HandInPosition = false;
        Eraser.SetActive(true);
        pitcher.Play("New State");
        gc = gameObject.GetComponent <GameController>();
        RUISSkeletonController[] kinectPlayer1 = kinectPlayer.GetComponentsInChildren <RUISSkeletonController>();
        kinectPlayer1[0].updateRootPosition = true;

        if (skeletonManager == null)
        {
            skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
            if (!skeletonManager)
            {
                Debug.Log("The scene is missing " + typeof(RUISSkeletonManager) + " script!");
            }
        }
        danceTaichi.SetActive(false);
        danceUnityChan.SetActive(false);
        Camera.transform.position = new Vector3(35f, 31.83f, 450.62f);
        //indicator.SetActive(true);
        //Camera.transform.Translate(0f, 0.83f,0 - 10.62f
        vector     = new Vector3(0, 0, 0);
        vectortest = new Vector3(0, 0, 0);
        positionIndicator.SetActive(true);

        score = 0;
        UpdateScore();
        InGame = false;
        MainPanel.SetActive(false);
        pausa.SetActive(false);
        ResultPanel.SetActive(false);
        ParametersPanel.SetActive(true);
        movimientoLateral = false;
        force             = 20;

        /*if(_angleMinLeft == 0){
         *
         *              _angleMinLeft = 25;
         *      }
         *      if(_angleLeft == 0){
         *
         *              _angleLeft = 25;
         *      }*/
        if (_range_game == 0)
        {
            _range_game = 25;
        }
        results           = ResultPanel.GetComponent <PutDataResults>();
        lanzamiento       = 0;
        movimientoLateral = true;
        //results = FindObjectOfType<PutDataResults> ();
        //Button btn = boton.GetComponent<Button> ();
        //btn.onClick.AddListener(StartGame);
    }
 public void Awake()
 {
     skeletonController = FindObjectOfType(typeof(RUISSkeletonController)) as RUISSkeletonController;
     skeletonManager    = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
     hand = GameObject.FindGameObjectWithTag("hand");
     neck = GameObject.FindGameObjectWithTag("neck");
     head = GameObject.FindGameObjectWithTag("head");
     MagicFactory.AddMagic("throw", 0);
     magic = MagicFactory.GetMagic("throw");
     scale = CalculateDistance();
 }
	public void Awake()
	{
		skeletonController = FindObjectOfType(typeof(RUISSkeletonController)) as RUISSkeletonController;
		skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
		hand = GameObject.FindGameObjectWithTag ("hand");
		shoulder = GameObject.FindGameObjectWithTag ("Shoulder");
		head = GameObject.FindGameObjectWithTag ("head");
		MagicFactory.AddMagic ("throw", 0);
		magic = MagicFactory.GetMagic ("throw");
		scale = CalculateDistance ();
	}
	void Awake()
	{
		fistClosedSignalTimestampBuffer = new float[fistClosedSignalLimit];
		fistOpenSignalTimestampBuffer = new float[fistOpenSignalLimit]; 
		ruisSkeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
		skeletonWand = GetComponent<RUISSkeletonWand>();
		handClosed = false;
		gestureWasTriggered = false;
		
		if(leftOrRightFist == fistSide.InferFromName) {
			if(skeletonWand.wandStart.ToString().IndexOf("Right") != -1) leftOrRightFist = fistSide.RightFist;
			if(skeletonWand.wandStart.ToString().IndexOf("Left") != -1) leftOrRightFist = fistSide.LeftFist;
		}
	}
Esempio n. 17
0
    public void Awake()
    {
        rotationFilter = new KalmanFilteredRotation();
        rotationFilter.skipIdenticalMeasurements = true;
        rotationFilter.rotationNoiseCovariance   = rotationNoiseCovariance;

        bodyTrackingDeviceID = (int)bodyTrackingDevice;
        RUISGestureRecognizer[] gestureRecognizerScripts = GetComponents <RUISGestureRecognizer>();

        foreach (RUISGestureRecognizer script in gestureRecognizerScripts)
        {
            if (script.ToString() != gestureSelectionScriptName)
            {
                script.enabled = false;
            }
            else
            {
                gestureRecognizer = script;
            }
        }

        if (!skeletonManager)
        {
            skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
        }

        selectionVisualizers = new Texture2D[8];
        for (int i = 0; i < amountOfSelectionVisualizerImages; i++)
        {
            selectionVisualizers[i] = Resources.Load("RUIS/Graphics/Selection/visualizer" + (i + 1)) as Texture2D;
        }

        displayManager = FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager;

        if (!gestureRecognizer)
        {
            Debug.LogWarning(typeof(RUISGestureRecognizer) + " component was not found for wand '" + name + "'."
                             + "Add it if you want to use gesture-based selection.");
        }

        wandSelector = GetComponent <RUISWandSelector>();
        if (!wandSelector)
        {
            Debug.LogError(typeof(RUISWandSelector) + " component was not found for wand '" + name + "'."
                           + "Add it if you want to use gesture-based selection. Disabling wand.");
            this.enabled = false;
        }

        PlayerLost();
    }
Esempio n. 18
0
    void Awake()
    {
        if (skeletonManager == null)
        {
            skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
        }

        followMoveController = false;

        jointInitialRotations = new Dictionary <Transform, Quaternion>();
        jointInitialDistances = new Dictionary <KeyValuePair <Transform, Transform>, float>();

        positionKalman = new KalmanFilter();
        positionKalman.initialize(3, 3);
    }
    public void Awake()
    {
		rotationFilter = new KalmanFilteredRotation();
		rotationFilter.skipIdenticalMeasurements = true;
		rotationFilter.rotationNoiseCovariance = rotationNoiseCovariance;
		
		bodyTrackingDeviceID = (int)bodyTrackingDevice;
		RUISGestureRecognizer[] gestureRecognizerScripts = GetComponents<RUISGestureRecognizer>();
		
		foreach(RUISGestureRecognizer script in gestureRecognizerScripts) 
		{
			if(script.ToString() != gestureSelectionScriptName) 
				script.enabled = false;
			else 
				gestureRecognizer = script;
		}
		
        if (!skeletonManager)
        {
            skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
        }

        selectionVisualizers = new Texture2D[8];
        for (int i = 0; i < amountOfSelectionVisualizerImages; i++)
        {
            selectionVisualizers[i] = Resources.Load("RUIS/Graphics/Selection/visualizer" + (i + 1)) as Texture2D;
        }

        displayManager = FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager;

        if (!gestureRecognizer)
        {
			Debug.LogWarning(  typeof(RUISGestureRecognizer) + " component was not found for wand '" + name + "'."
			                 + "Add it if you want to use gesture-based selection.");
        }

        wandSelector = GetComponent<RUISWandSelector>();
		if(!wandSelector)
		{
			Debug.LogError(  typeof(RUISWandSelector) + " component was not found for wand '" + name + "'."
			               + "Add it if you want to use gesture-based selection. Disabling wand.");
			this.enabled = false;
		}

        PlayerLost();
    }
    void Start()
    {
        if (skeletonManager == null)
        {
            skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
            if (!skeletonManager)
            {
                Debug.Log("The scene is missing " + typeof(RUISSkeletonManager) + " script!");
            }
        }

        character = GetComponent <RielesCharacter>();

        skeletonPosition = transform.localPosition;

        //timeBetweenKnees = normalTimeBetweenKnees;
        move = Vector3.zero;
    }
    void Awake()
    {
        fistClosedSignalTimestampBuffer = new float[fistClosedSignalLimit];
        fistOpenSignalTimestampBuffer   = new float[fistOpenSignalLimit];
        ruisSkeletonManager             = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
        skeletonWand = GetComponent <RUISSkeletonWand>();
        handClosed   = false;

        if (leftOrRightFist == fistSide.InferFromName)
        {
            if (skeletonWand.wandStart.ToString().IndexOf("Right") != -1)
            {
                leftOrRightFist = fistSide.RightFist;
            }
            if (skeletonWand.wandStart.ToString().IndexOf("Left") != -1)
            {
                leftOrRightFist = fistSide.LeftFist;
            }
        }
    }
	void Awake () 
	{
        skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
		
		if(gameObject.transform.parent != null)
		{
			if(gameObject.transform.parent.GetComponentInChildren<RUISKinectAndMecanimCombiner>())
				kinectAndMecanimCombinerExists = true;
		}

        capsuleCollider = GetComponent<CapsuleCollider>();
		if(capsuleCollider == null)
			Debug.LogError("GameObject " + gameObject.name + " must have a CapsuleCollider!");
        defaultColliderHeight = capsuleCollider.height;
        defaultColliderPosition = transform.localPosition;
		
		positionKalman = new KalmanFilter();
		positionKalman.initialize(3,3);
		positionKalman.skipIdenticalMeasurements = true;
	}
Esempio n. 23
0
    // end // Head/Body turn gesture

    void Awake()
    {
        characterController = GetComponent <RUISCharacterController>();
        jumpGesture         = GetComponentInChildren <RUISJumpGestureRecognizer>();

        //moveWrapper = FindObjectOfType(typeof(PSMoveWrapper)) as PSMoveWrapper;
        bimanualSwingingRecognizer = FindObjectOfType(typeof(RUISBimanualSwingingRecognizer)) as RUISBimanualSwingingRecognizer;         // TODO: Shouldn't probably check whole scene
        coordinateSystem           = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
        skeletonManager            = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;

        try
        {
            Input.GetAxis("Sprint");
        }
        catch (UnityException)
        {
            Debug.LogWarning("'Sprint' not defined in Unity Input settings");
        }

        try
        {
            Input.GetAxis("Turn");
        }
        catch (UnityException)
        {
            Debug.LogWarning("'Turn' not defined in Unity Input settings");
        }

        try
        {
            Input.GetAxis("Jump");
        }
        catch (UnityException)
        {
            Debug.LogWarning("'Jump' not defined in Unity Input settings");
        }
    }
Esempio n. 24
0
    public void Awake()
    {
        if (!skeletonManager)
        {
            skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
        }

        selectionVisualizers = new Texture2D[8];
        for (int i = 0; i < amountOfSelectionVisualizerImages; i++)
        {
            selectionVisualizers[i] = Resources.Load("RUIS/Graphics/Selection/visualizer" + (i + 1)) as Texture2D;
        }

        displayManager = FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager;

        if (!gestureRecognizer)
        {
            Debug.LogWarning("Please set a gesture recognizer for wand: " + name + " if you want to use gestures.");
        }

        wandSelector = GetComponent <RUISWandSelector>();

        PlayerLost();
    }
Esempio n. 25
0
    public void Awake()
    {
        if (!skeletonManager)
        {
            skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
        }

        selectionVisualizers = new Texture2D[8];
        for (int i = 0; i < amountOfSelectionVisualizerImages; i++)
        {
            selectionVisualizers[i] = Resources.Load("RUIS/Graphics/Selection/visualizer" + (i + 1)) as Texture2D;
        }

        displayManager = FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager;

        if (!gestureRecognizer)
        {
            Debug.LogWarning("Please set a gesture recognizer for wand: " + name + " if you want to use gestures.");
        }

        wandSelector = GetComponent<RUISWandSelector>();

        PlayerLost();
    }
Esempio n. 26
0
    void Awake()
    {
        skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;

        if (gameObject.transform.parent != null)
        {
            if (gameObject.transform.parent.GetComponentInChildren <RUISKinectAndMecanimCombiner>())
            {
                kinectAndMecanimCombinerExists = true;
            }
        }

        capsuleCollider = GetComponent <CapsuleCollider>();
        if (capsuleCollider == null)
        {
            Debug.LogError("GameObject " + gameObject.name + " must have a CapsuleCollider!");
        }
        defaultColliderHeight   = capsuleCollider.height;
        defaultColliderPosition = transform.localPosition;

        positionKalman = new KalmanFilter();
        positionKalman.initialize(3, 3);
        positionKalman.skipIdenticalMeasurements = true;
    }
    private float UpdateBoneScaling(Transform boneToScale, Transform comparisonBone, RUISSkeletonManager.JointData boneToScaleTracker, RUISSkeletonManager.JointData comparisonBoneTracker, float cumulativeScale)
    {
        float modelBoneLength = 1;
		float playerBoneLength = Vector3.Distance(boneToScaleTracker.position, comparisonBoneTracker.position);
		float newScale = 1;
		float thickness = 1;
		float parentBoneThickness = 1;
		float extremityTweaker = 1;
		float skewedScaleTweak = 1;

		if(boneToScale && comparisonBone)
			modelBoneLength = jointInitialDistances[new KeyValuePair<Transform, Transform>(boneToScale, comparisonBone)];

		if(!boneToScale)
			return cumulativeScale;

		newScale = playerBoneLength / modelBoneLength / cumulativeScale;
		
		
		switch(boneToScaleTracker.jointID)
		{
			case RUISSkeletonManager.Joint.LeftHip:       thickness = leftLegThickness;  break;
			case RUISSkeletonManager.Joint.RightHip:      thickness = rightLegThickness; break;
			case RUISSkeletonManager.Joint.LeftShoulder:  thickness = leftArmThickness;  break;
			case RUISSkeletonManager.Joint.RightShoulder: thickness = rightArmThickness; break;
			case RUISSkeletonManager.Joint.LeftKnee:      thickness = leftLegThickness;  extremityTweaker = shinLengthRatio; break;
			case RUISSkeletonManager.Joint.RightKnee:     thickness = rightLegThickness; extremityTweaker = shinLengthRatio; break;
			case RUISSkeletonManager.Joint.LeftElbow:     thickness = leftArmThickness;  extremityTweaker = forearmLengthRatio; break;
			case RUISSkeletonManager.Joint.RightElbow:    thickness = rightArmThickness; extremityTweaker = forearmLengthRatio; break;
		}

		if(scaleBoneLengthOnly)
		{
			bool isExtremityJoint =  (    boneToScaleTracker.jointID == RUISSkeletonManager.Joint.LeftElbow || boneToScaleTracker.jointID == RUISSkeletonManager.Joint.RightElbow
									   || boneToScaleTracker.jointID == RUISSkeletonManager.Joint.LeftKnee  || boneToScaleTracker.jointID == RUISSkeletonManager.Joint.RightKnee );

			if(isExtremityJoint && boneToScale.parent && comparisonBone)
			{
				float jointAngle = Vector3.Angle(boneToScale.position - comparisonBone.position, boneToScale.parent.position - boneToScale.position);
				float cosAngle = Mathf.Cos(Mathf.Deg2Rad * jointAngle);
				float sinAngle = Mathf.Sin(Mathf.Deg2Rad * jointAngle);
				switch(boneLengthAxis)
				{
					case RUISAxis.X: parentBoneThickness = boneToScale.parent.localScale.y; break;
					case RUISAxis.Y: parentBoneThickness = boneToScale.parent.localScale.z; break;
					case RUISAxis.Z: parentBoneThickness = boneToScale.parent.localScale.x; break;
				}

				newScale = ( playerBoneLength / modelBoneLength ); // / ( cumulativeScale * cosAngle * cosAngle + parentBoneThickness * sinAngle * sinAngle );
				thickness = Mathf.Pow (thickness, sinAngle * sinAngle); //cosAngle * cosAngle + sinAngle * sinAngle * thickness;
				skewedScaleTweak = 1 / ( cumulativeScale * cosAngle * cosAngle + parentBoneThickness * sinAngle * sinAngle );
			}

			switch(boneLengthAxis)
			{
				case RUISAxis.X:
					boneToScale.localScale = Vector3.MoveTowards(boneToScale.localScale, new Vector3(newScale, thickness, thickness), maxScaleFactor * Time.deltaTime);
					boneToScale.localScale = new Vector3(boneToScale.localScale.x, thickness, thickness);
					break;
				case RUISAxis.Y:
					boneToScale.localScale = Vector3.MoveTowards(boneToScale.localScale, new Vector3(thickness, newScale, thickness), maxScaleFactor * Time.deltaTime);
					boneToScale.localScale = new Vector3(thickness, boneToScale.localScale.y, thickness);
					break;
				case RUISAxis.Z:
					boneToScale.localScale = Vector3.MoveTowards(boneToScale.localScale, new Vector3(thickness, thickness, newScale), maxScaleFactor * Time.deltaTime);
					boneToScale.localScale = new Vector3(thickness, thickness, boneToScale.localScale.z);
					break;
			}

			if(isExtremityJoint)
			{
				// Save untweaked scales
				switch(boneToScaleTracker.jointID)
				{
					case RUISSkeletonManager.Joint.LeftKnee:  
						unalteredLeftShinScale     = boneToScale.localScale;
						break;
					case RUISSkeletonManager.Joint.RightKnee:   
						unalteredRightShinScale    = boneToScale.localScale;
						break;
					case RUISSkeletonManager.Joint.LeftElbow:   
						unalteredLeftForearmScale  = boneToScale.localScale;
						break;
					case RUISSkeletonManager.Joint.RightElbow: 
						unalteredRightForearmScale = boneToScale.localScale;
						break;
				}

				// Apply bone length tweaks
				switch(boneLengthAxis)
				{
					case RUISAxis.X:
						boneToScale.localScale = new Vector3(extremityTweaker * skewedScaleTweak * boneToScale.localScale.x, thickness, thickness);
						break;
					case RUISAxis.Y:
						boneToScale.localScale = new Vector3(thickness, extremityTweaker * skewedScaleTweak * boneToScale.localScale.y, thickness);
						break;
					case RUISAxis.Z:
						boneToScale.localScale = new Vector3(thickness, thickness, extremityTweaker * skewedScaleTweak * boneToScale.localScale.z);
						break;
				}
			}
		}
		else
			boneToScale.localScale = extremityTweaker * Vector3.MoveTowards(boneToScale.localScale, new Vector3(newScale, newScale, newScale), maxScaleFactor * Time.deltaTime);

		switch(boneLengthAxis)
		{
			case RUISAxis.X: return boneToScale.localScale.x;
			case RUISAxis.Y: return boneToScale.localScale.y;
			case RUISAxis.Z: return boneToScale.localScale.z;
		}
		return boneToScale.localScale.x;
    }
    private void ForceUpdatePosition(ref Transform transformToUpdate, RUISSkeletonManager.JointData jointToGet, int jointID, float deltaT)
    {
        if (transformToUpdate == null)
			return;

		if(jointID == 2 || jointID == 3) // HACK: for now saving performance by not filtering hips
			transformToUpdate.position = transform.TransformPoint(jointToGet.position - skeletonPosition);
		else
		{

			measuredPos [0] = jointToGet.position.x;
			measuredPos [1] = jointToGet.position.y;
			measuredPos [2] = jointToGet.position.z;

			fourJointsKalman[jointID].setR (deltaT * fourJointsNoiseCovariance);
			fourJointsKalman[jointID].predict ();
			fourJointsKalman[jointID].update (measuredPos);
			pos = fourJointsKalman[jointID].getState ();

			fourJointPositions[jointID].Set((float)pos [0], (float)pos [1], (float)pos [2]);

			transformToUpdate.position = transform.TransformPoint(fourJointPositions[jointID] - skeletonPosition);
		}
//		transformToUpdate.position = transform.TransformPoint(jointToGet.position - skeletonPosition);
    }
	private void UpdateTransform(ref Transform transformToUpdate, RUISSkeletonManager.JointData jointToGet, float maxAngularVelocity)
    {
        if (transformToUpdate == null)
		{
			return;
		}

        if (updateJointPositions && jointToGet.positionConfidence >= minimumConfidenceToUpdate)
        {
            transformToUpdate.localPosition = jointToGet.position - skeletonPosition;
        }

        if (updateJointRotations && jointToGet.rotationConfidence >= minimumConfidenceToUpdate)
        {
            if (useHierarchicalModel)
            {
                Quaternion newRotation = transform.rotation * jointToGet.rotation *
                    (jointInitialRotations.ContainsKey(transformToUpdate) ? jointInitialRotations[transformToUpdate] : Quaternion.identity);
				transformToUpdate.rotation = Quaternion.RotateTowards(transformToUpdate.rotation, newRotation, maxAngularVelocity);
            }
            else
            {
				transformToUpdate.localRotation = Quaternion.RotateTowards(transformToUpdate.localRotation, jointToGet.rotation, maxAngularVelocity);
            }
        }
    }
    void Start()
    {
		
		if (skeletonManager == null)
		{
			skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
			if (!skeletonManager)
				Debug.LogError("The scene is missing " + typeof(RUISSkeletonManager) + " script!");
		}

		// Disable features that are only available for Kinect2 or custom motion tracker
		if (bodyTrackingDevice == bodyTrackingDeviceType.Kinect1) 
		{
			fistCurlFingers = false;
			trackThumbs = false;
			trackWrist  = false;
			trackAnkle  = false;
			rotateWristFromElbow = false;
		}

        if (useHierarchicalModel)
        {
            //fix all shoulder and hip rotations to match the default kinect rotations
            rightShoulder.rotation = FindFixingRotation(rightShoulder.position, rightElbow.position, transform.right) * rightShoulder.rotation;
            leftShoulder.rotation = FindFixingRotation(leftShoulder.position, leftElbow.position, -transform.right) * leftShoulder.rotation;
            rightHip.rotation = FindFixingRotation(rightHip.position, rightFoot.position, -transform.up) * rightHip.rotation;
            leftHip.rotation = FindFixingRotation(leftHip.position, leftFoot.position, -transform.up) * leftHip.rotation;

			Vector3 scaler = new Vector3(1/transform.lossyScale.x, 1/transform.lossyScale.y, 1/transform.lossyScale.z);
			Vector3 assumedRootPos = Vector3.Scale((rightShoulder.position + leftShoulder.position + leftHip.position + rightHip.position) / 4, scaler); 
															// (1/transform.lossyScale.x, 1/transform.lossyScale.y, 1/transform.lossyScale.z)
			Vector3 realRootPos = Vector3.Scale(torso.position, scaler);

			Vector3 torsoUp = head.position - torso.position;
			torsoUp.Normalize();
			torsoOffset = Vector3.Dot(realRootPos - assumedRootPos, torsoUp);
			//torsoOffset = (realRootPos - assumedRootPos).y;

            if (neck)
            {
                neckOriginalLocalPosition = neck.localPosition;
				if(neck.parent)
				{
					chest = neck.parent;
					if(chest == torso)
					{
						Debug.Log(	typeof(RUISSkeletonController) + ": Hierarchical model stored in GameObject " + this.name 
						          + " does not have enough joints between neck and torso for Hips Vertical Tweaker to work.");
						chest = null;
					}
					chestOriginalLocalPosition = chest.localPosition;
				}
            }
        }

        SaveInitialRotation(root);
        SaveInitialRotation(head);
        SaveInitialRotation(torso);
        SaveInitialRotation(rightShoulder);
        SaveInitialRotation(rightElbow);
        SaveInitialRotation(rightHand);
        SaveInitialRotation(leftShoulder);
        SaveInitialRotation(leftElbow);
        SaveInitialRotation(leftHand);
        SaveInitialRotation(rightHip);
        SaveInitialRotation(rightKnee);
        SaveInitialRotation(rightFoot);
        SaveInitialRotation(leftHip);
        SaveInitialRotation(leftKnee);
        SaveInitialRotation(leftFoot);

		SaveInitialRotation(leftThumb);
		SaveInitialRotation(rightThumb);

		saveInitialFingerRotations();
		
        SaveInitialDistance(rightShoulder, rightElbow);
        SaveInitialDistance(rightElbow, rightHand);
        SaveInitialDistance(leftShoulder, leftElbow);
        SaveInitialDistance(leftElbow, leftHand);

        SaveInitialDistance(rightHip, rightKnee);
        SaveInitialDistance(rightKnee, rightFoot);
        SaveInitialDistance(leftHip, leftKnee);
        SaveInitialDistance(leftKnee, leftFoot);

        SaveInitialDistance(torso, head);

        SaveInitialDistance(rightShoulder, leftShoulder);
        SaveInitialDistance(rightHip, leftHip);

		
		if (rightElbow)
			unalteredRightForearmScale = rightElbow.localScale;
		
		if (leftElbow)
			unalteredLeftForearmScale = leftElbow.localScale;
		
		if(rightKnee)
			unalteredRightShinScale = rightKnee.localScale;
		
		if(leftKnee)
			unalteredLeftShinScale = leftKnee.localScale;

		// Finger clench rotations: these depend on your animation rig
		// Also see method handleFingersCurling() and its clenchedRotationThumbTM_corrected and clenchedRotationThumbIP_corrected
		// variables, if you are not tracking thumbs with Kinect 2. They also depend on your animation rig.
		switch(boneLengthAxis)
		{
		case RUISAxis.X:
			// Thumb phalange rotations when hand is clenched to a fist
			clenchedRotationThumbTM = Quaternion.Euler (45, 0, 0); 
			clenchedRotationThumbMCP = Quaternion.Euler (0, 0, -25 );
			clenchedRotationThumbIP = Quaternion.Euler (0, 0, -80);
			// Phalange rotations of other fingers when hand is clenched to a fist
			clenchedRotationMCP = Quaternion.Euler (0, 0, -45);
			clenchedRotationPIP = Quaternion.Euler (0, 0, -100);
			clenchedRotationDIP = Quaternion.Euler (0, 0, -70);
			break;
		case RUISAxis.Y:
			// Thumb phalange rotations when hand is clenched to a fist
			clenchedRotationThumbTM = Quaternion.Euler (0, 0, 0); 
			clenchedRotationThumbMCP = Quaternion.Euler (0, 0, 0);
			clenchedRotationThumbIP = Quaternion.Euler (0, 0, 80);
			// Phalange rotations of other fingers when hand is clenched to a fist
			clenchedRotationMCP = Quaternion.Euler (45, 0, 0);
			clenchedRotationPIP = Quaternion.Euler (100, 0, 0);
			clenchedRotationDIP = Quaternion.Euler (70, 0, 0);
			break;
		case RUISAxis.Z: // TODO: Not yet tested with a real rig
			// Thumb phalange rotations when hand is clenched to a fist
			clenchedRotationThumbTM = Quaternion.Euler (45, 0, 0); 
			clenchedRotationThumbMCP = Quaternion.Euler (0, 0, -25 );
			clenchedRotationThumbIP = Quaternion.Euler (0, 0, -80);
			// Phalange rotations of other fingers when hand is clenched to a fist
			clenchedRotationMCP = Quaternion.Euler (0, -45, 0);
			clenchedRotationPIP = Quaternion.Euler (0, -100, 0);
			clenchedRotationDIP = Quaternion.Euler (0, -70, 0);
			break;
		}

		if(inputManager)
		{
			if(gameObject.transform.parent != null)
			{
				characterController = gameObject.transform.parent.GetComponent<RUISCharacterController>();
				if(characterController != null)
				{
					if(		characterController.characterPivotType == RUISCharacterController.CharacterPivotType.MoveController
						&&	inputManager.enablePSMove																			)
					{
						followMoveController = true;
						followMoveID = characterController.moveControllerId;
//						if(		 gameObject.GetComponent<RUISKinectAndMecanimCombiner>() == null 
//							||	!gameObject.GetComponent<RUISKinectAndMecanimCombiner>().enabled )
							Debug.LogWarning(	"Using PS Move controller #" + characterController.moveControllerId + " as a source "
						                 	 +	"for avatar root position of " + gameObject.name + ", because PS Move is enabled"
											 +	"and the PS Move controller has been assigned as a "
											 +	"Character Pivot in " + gameObject.name + "'s parent GameObject");
					}

					if(!inputManager.enableKinect && !inputManager.enableKinect2 && !followMoveController)
					{
						
						if(OVRManager.display != null && OVRManager.display.isPresent)
						{
							followOculusController = true;
							Debug.LogWarning(	"Using Oculus Rift HMD as a Character Pivot for " + gameObject.name
							                 +	", because Kinects are disabled and an Oculus Rift was detected.");
						}
					}
				}
			}
		}

		
		try
		{
			if(OVRManager.capiHmd != null)
				ovrHmdVersion = OVRManager.capiHmd.GetDesc().Type;
		}
		catch(UnityException e)
		{
			Debug.LogError(e);
		}

		if(oculusRotatesHead && (OVRManager.display == null || !OVRManager.display.isPresent))
		   oculusRotatesHead = false;

		// HACK for filtering Kinect 2 arm rotations
		skeletonManager.skeletons [bodyTrackingDeviceID, playerId].filterRotations = filterRotations;
		skeletonManager.skeletons [bodyTrackingDeviceID, playerId].rotationNoiseCovariance = rotationNoiseCovariance;
		for(int i=0; i < skeletonManager.skeletons [bodyTrackingDeviceID, playerId].filterRot.Length; ++i)
		{
			if(skeletonManager.skeletons [bodyTrackingDeviceID, playerId].filterRot[i] != null)
				skeletonManager.skeletons [bodyTrackingDeviceID, playerId].filterRot[i].rotationNoiseCovariance = rotationNoiseCovariance;
		}
		skeletonManager.skeletons [bodyTrackingDeviceID, playerId].thumbZRotationOffset = thumbZRotationOffset;
    }
Esempio n. 31
0
    void Start()
    {
        inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;
        if(		!inputManager
            &&  (	headPositionInput == HeadPositionSource.PSMove
                 || headRotationInput == HeadRotationSource.PSMove
                 || (externalDriftCorrection && compass == CompassSource.PSMove)))
            Debug.LogError("RUISInputManager script is missing from this scene!");

        if(inputManager && !inputManager.enablePSMove)
        {
            if(headPositionInput == HeadPositionSource.PSMove)
                Debug.LogError(	"Your settings indicate that you want to use PS Move for position "
                                 +	"tracking, but you have not enabled it from InputManager.");
            if(headRotationInput == HeadRotationSource.PSMove)
                Debug.LogError(	"Your settings indicate that you want to use PS Move for rotation "
                                 +	"tracking, but you have not enabled it from InputManager.");
            if(externalDriftCorrection && compass == CompassSource.PSMove)
                Debug.LogError(	"Your settings indicate that you want to use PS Move for yaw drift "
                                 +	"correction, but you have not enabled it from InputManager.");
        }

        if (!skeletonManager)
            skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
        if(		!skeletonManager
            &&  (	headPositionInput == HeadPositionSource.Kinect
                 || (headRotationInput == HeadRotationSource.Kinect && !useOculusRiftRotation)
                 || (externalDriftCorrection && compass == CompassSource.Kinect)))
        {
            Debug.LogError("RUISSkeletonManager script is missing from this scene!");
        }

        if(inputManager && !inputManager.enableRazerHydra)
        {
            if(headPositionInput == HeadPositionSource.RazerHydra)
                Debug.LogError(		"Your settings indicate that you want to use Razer Hydra for "
                                +	"position tracking, but you have disabled Razer Hydra from RUIS "
                                +	"InputManager.");
            if(headRotationInput == HeadRotationSource.RazerHydra)
                Debug.LogError(		"Your settings indicate that you want to use Razer Hydra for "
                                +	"rotation tracking, but you have disabled Razer Hydra from RUIS "
                                +	"InputManager.");
            if(externalDriftCorrection && compass == CompassSource.RazerHydra)
                Debug.LogError(		"Your settings indicate that you want to use Razer Hydra for "
                                +	"yaw drift correction, but you have disabled Razer Hydra from RUIS "
                                +	"InputManager.");
        }

        if(headPositionInput == HeadPositionSource.InputTransform && !positionInput)
            Debug.LogError("Position tracker's Input Transform is none, you need to set it in Unity inspector!");

        if(headRotationInput == HeadRotationSource.InputTransform && !rotationInput && !useOculusRiftRotation)
            Debug.LogError("Rotation tracker's Input Transform is none, you need to set it in Unity inspector!");

        if(headPositionInput == HeadPositionSource.Kinect && positionJoint == RUISSkeletonManager.Joint.None)
            Debug.LogError(	 "Your settings indicate that you want to track position with a "
                           + "Kinect joint, but you have left its value to None in Unity inspector!");

        if(		headRotationInput == HeadRotationSource.Kinect && rotationJoint == RUISSkeletonManager.Joint.None
            &&	!useOculusRiftRotation																			 )
            Debug.LogError(	 "Your settings indicate that you want to track rotation with a "
                           + "Kinect joint, but you have left its value to None in Unity inspector!");

        if(		externalDriftCorrection && compass == CompassSource.Kinect && compassJoint == RUISSkeletonManager.Joint.None
            &&  !compassIsPositionTracker && (useOculusRiftRotation || headRotationInput == HeadRotationSource.InputTransform))
            Debug.LogError(	 "Your settings indicate that you want to do yaw drift correction with a "
                           + "Kinect joint, but you have left its value to None in Unity inspector!");

        if(		externalDriftCorrection && compass == CompassSource.InputTransform && !compassTransform
            &&  !compassIsPositionTracker && (useOculusRiftRotation || headRotationInput == HeadRotationSource.InputTransform))
            Debug.LogError("Yaw drift corrector's Input Transform is none, you need to set it in Unity inspector!");

        if(externalDriftCorrection && compassIsPositionTracker && headPositionInput == HeadPositionSource.None)
            Debug.LogError(		"Position Tracker is set to None, but in 'Yaw Drift Correction' you have enabled "
                            +	"'Use Position Tracker'!");

        if(isRazerBaseMobile && (	headPositionInput == HeadPositionSource.RazerHydra
                                 || headRotationInput == HeadRotationSource.RazerHydra
                                 || compass == CompassSource.RazerHydra				  ))
        {
            if(mobileRazerBase == RazerHydraBase.InputTransform && hydraBaseInput == null)
                Debug.LogError(	 "Your settings indicate that you want to track Razer Hydra base station with a "
                               + "custom Input Transform, but you have left its value to None in Unity inspector!");
            if(mobileRazerBase == RazerHydraBase.Kinect && hydraBaseJoint == RUISSkeletonManager.Joint.None)
                Debug.LogError(	 "Your settings indicate that you want to track Razer Hydra base station with a "
                               + "Kinect joint, but you have left its value to None in Unity inspector!");
        }

        if(oculusCamController && Application.isEditor)
            Debug.Log("OVRCameraController script detected in a child object of this " + gameObject.name
                    + " object. Using Oculus Rift as a Rotation Tracker. You can access other rotation "
                    + "trackers when you remove the OVRCameraController component from the child object(s).");

        //		if(useOculusRiftRotation && inputManager)
        //		{
        //			if(		(inputManager.enableKinect 		&& headPositionInput == HeadPositionSource.Kinect)
        //				||	(inputManager.enableRazerHydra 	&& headPositionInput == HeadPositionSource.RazerHydra)
        //				||	(inputManager.enablePSMove 		&& headPositionInput == HeadPositionSource.PSMove)
        //				||	headPositionInput == HeadPositionSource.InputTransform								  )
        //			{
        //				oculusCamController.SetNeckPosition(Vector3.zero);
        //				oculusCamController.SetEyeCenterPosition(Vector3.zero);
        //				Debug.Log(	"Head position tracker found, setting NeckPosition and EyeCenterPosition to zero from "
        //						  + "OVRCameraController.");
        //			}
        //		}
    }
    private void ForceUpdatePosition(ref Transform transformToUpdate, RUISSkeletonManager.JointData jointToGet)
    {
        if (transformToUpdate == null) return;

        transformToUpdate.position = transform.TransformPoint(jointToGet.position - skeletonPosition);//transform.position + transform.rotation * (jointToGet.position - skeletonPosition);
    }
    private float UpdateBoneScaling(Transform boneToScale, Transform comparisonBone, RUISSkeletonManager.JointData boneToScaleTracker, RUISSkeletonManager.JointData comparisonBoneTracker, float cumulativeScale)
    {
        float modelBoneLength = jointInitialDistances[new KeyValuePair<Transform, Transform>(boneToScale, comparisonBone)];
        float playerBoneLength = Vector3.Distance(boneToScaleTracker.position, comparisonBoneTracker.position);
        float newScale = playerBoneLength / modelBoneLength / cumulativeScale;

        boneToScale.localScale = Vector3.MoveTowards(boneToScale.localScale, new Vector3(newScale, newScale, newScale), maxScaleFactor * Time.deltaTime);

        return boneToScale.localScale.x;
    }
    void Start()
    {
        Vector3 initialLocalScale = transform.localScale;

        skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;

        skeletonController = GetComponent <RUISSkeletonController>();
        //		if (	!inputManager.enableKinect && !inputManager.enableKinect2
        //		    &&  (skeletonController.bodyTrackingDevice != RUISSkeletonController.bodyTrackingDeviceType.GenericMotionTracker))
        if (skeletonController != null && (skeletonController.followHmdPosition || inputManager == null ||
                                           (skeletonController.followMoveController &&
                                            ((skeletonController.bodyTrackingDeviceID == RUISSkeletonManager.kinect1SensorID && !inputManager.enableKinect) ||
                                             (skeletonController.bodyTrackingDeviceID == RUISSkeletonManager.kinect2SensorID && !inputManager.enableKinect2)))))
        {
            // Without the below if-clause the legs will twist with PS Move head tracker (when Move is enabled but Kinect is not)
            //if(!inputManager.enablePSMove)
            torsoBlendWeight    = 1;
            headBlendWeight     = 1;
            rightArmBlendWeight = 1;
            leftArmBlendWeight  = 1;
            rightLegBlendWeight = 1;
            leftLegBlendWeight  = 1;
//			forceArmStartPosition = false;
//			forceLegStartPosition = false;
        }

        if (!childrenInstantiated)
        {
            childrenInstantiated = true;

            kinectGameObject                      = Instantiate(gameObject, transform.position, transform.rotation) as GameObject;
            kinectGameObject.name                 = name + "Kinect";
            kinectGameObject.transform.parent     = transform.parent;
            kinectGameObject.transform.localScale = initialLocalScale;
            //kinectGameObject.GetComponent<RUISKinectAndMecanimCombiner>().childrenInstantiated = true;
            Destroy(kinectGameObject.GetComponent <RUISKinectAndMecanimCombiner>());
            Destroy(kinectGameObject.GetComponent <Animator>());
            Destroy(kinectGameObject.GetComponent <RUISCharacterAnimationController>());
            foreach (Collider collider in kinectGameObject.GetComponentsInChildren <Collider>())
            {
                Destroy(collider);
            }
            foreach (Renderer meshRenderer in kinectGameObject.GetComponentsInChildren <Renderer>())
            {
                Destroy(meshRenderer);
            }


            mecanimGameObject                      = Instantiate(gameObject, transform.position, transform.rotation) as GameObject;
            mecanimGameObject.name                 = name + "Mecanim";
            mecanimGameObject.transform.parent     = transform.parent;
            mecanimGameObject.transform.localScale = initialLocalScale;
            Destroy(mecanimGameObject.GetComponent <RUISKinectAndMecanimCombiner>());
            Destroy(mecanimGameObject.GetComponent <RUISCharacterAnimationController>());

            Destroy(mecanimGameObject.GetComponent <RUISSkeletonController>());
            foreach (Collider collider in mecanimGameObject.GetComponentsInChildren <Collider>())
            {
                Destroy(collider);
            }
            foreach (Renderer meshRenderer in mecanimGameObject.GetComponentsInChildren <Renderer>())
            {
                Destroy(meshRenderer);
            }


            Destroy(GetComponent <RUISSkeletonController>());
            Destroy(GetComponent <Animator>());
            GetComponent <RUISCharacterAnimationController>().animator = mecanimGameObject.GetComponent <Animator>();

            skeletonController = kinectGameObject.GetComponent <RUISSkeletonController>();
            mecanimAnimator    = mecanimGameObject.GetComponent <Animator>();

            if (!skeletonController)
            {
                Debug.LogError("Script " + typeof(RUISSkeletonController) + " is not found by " + this.GetType().Name + "!");
            }

            torsoIsRoot = skeletonController.root == skeletonController.torso;

            Transform kinectRootBone  = skeletonController.root;
            Transform mecanimRootBone = FindBone(mecanimAnimator.transform, kinectRootBone.name);
            Transform blendedRootBone = FindBone(transform, kinectRootBone.name);
            skeletonRoot = new BoneTriplet(kinectRootBone, mecanimRootBone, blendedRootBone, BodypartClassification.Root);

            if (torsoIsRoot)
            {
                torsoRoot = skeletonRoot;
                AddChildren(ref torsoRoot, BodypartClassification.Torso);
            }
            else
            {
                AddChildren(ref skeletonRoot, BodypartClassification.Root);
            }
        }
    }
 public void Awake()
 {
     skeletonController = FindObjectOfType(typeof(RUISSkeletonController)) as RUISSkeletonController;
     pointTrackerLeftHand = leftHandWithPointTracker.GetComponent<RUISPointTracker>();
     pointTrackerRightHand = rightHandWithPointTracker.GetComponent<RUISPointTracker>();
     skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
     ResetProgress();
 }
    void Start()
	{
		Vector3 initialLocalScale = transform.localScale;
		skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
		
		skeletonController = GetComponent<RUISSkeletonController>();
		//		if (	!inputManager.enableKinect && !inputManager.enableKinect2 
		//		    &&  (skeletonController.bodyTrackingDevice != RUISSkeletonController.bodyTrackingDeviceType.GenericMotionTracker))
		if(skeletonController != null && (   skeletonController.followOculusController || inputManager == null
		                                  || (	   skeletonController.followMoveController 
		    									&& (   (skeletonController.bodyTrackingDeviceID == RUISSkeletonManager.kinect1SensorID && !inputManager.enableKinect )
		    										|| (skeletonController.bodyTrackingDeviceID == RUISSkeletonManager.kinect2SensorID && !inputManager.enableKinect2)))))
		{
			// Without the below if-clause the legs will twist with PS Move head tracker (when Move is enabled but Kinect is not)
			//if(!inputManager.enablePSMove)
			torsoBlendWeight = 1;
			headBlendWeight = 1;		
			rightArmBlendWeight = 1;
			leftArmBlendWeight = 1;
			rightLegBlendWeight = 1;
			leftLegBlendWeight = 1;
//			forceArmStartPosition = false;
//			forceLegStartPosition = false;
		}

        if (!childrenInstantiated)
        {
            childrenInstantiated = true;

            kinectGameObject = Instantiate(gameObject, transform.position, transform.rotation) as GameObject;
            kinectGameObject.name = name + "Kinect";
			kinectGameObject.transform.parent = transform.parent;
			kinectGameObject.transform.localScale = initialLocalScale;
            //kinectGameObject.GetComponent<RUISKinectAndMecanimCombiner>().childrenInstantiated = true;
            Destroy(kinectGameObject.GetComponent<RUISKinectAndMecanimCombiner>());
            Destroy(kinectGameObject.GetComponent<Animator>());
            Destroy(kinectGameObject.GetComponent<RUISCharacterAnimationController>());
            foreach (Collider collider in kinectGameObject.GetComponentsInChildren<Collider>())
            {
                Destroy(collider);
            }
            foreach (Renderer meshRenderer in kinectGameObject.GetComponentsInChildren<Renderer>())
            {
                Destroy(meshRenderer);
            }


            mecanimGameObject = Instantiate(gameObject, transform.position, transform.rotation) as GameObject;
            mecanimGameObject.name = name + "Mecanim";
            mecanimGameObject.transform.parent = transform.parent;
			mecanimGameObject.transform.localScale = initialLocalScale;
            Destroy(mecanimGameObject.GetComponent<RUISKinectAndMecanimCombiner>());
            Destroy(mecanimGameObject.GetComponent<RUISCharacterAnimationController>());

            Destroy(mecanimGameObject.GetComponent<RUISSkeletonController>());
            foreach (Collider collider in mecanimGameObject.GetComponentsInChildren<Collider>())
            {
                Destroy(collider);
            }
            foreach (Renderer meshRenderer in mecanimGameObject.GetComponentsInChildren<Renderer>())
            {
                Destroy(meshRenderer);
            }


            Destroy(GetComponent<RUISSkeletonController>());
            Destroy(GetComponent<Animator>());
            GetComponent<RUISCharacterAnimationController>().animator = mecanimGameObject.GetComponent<Animator>();

            skeletonController = kinectGameObject.GetComponent<RUISSkeletonController>();
            mecanimAnimator = mecanimGameObject.GetComponent<Animator>();

			if(!skeletonController)
				Debug.LogError("Script " + typeof(RUISSkeletonController) + " is not found by " + this.GetType().Name + "!");

            torsoIsRoot = skeletonController.root == skeletonController.torso;

            Transform kinectRootBone = skeletonController.root;
            Transform mecanimRootBone = FindBone(mecanimAnimator.transform, kinectRootBone.name);
            Transform blendedRootBone = FindBone(transform, kinectRootBone.name);
            skeletonRoot = new BoneTriplet(kinectRootBone, mecanimRootBone, blendedRootBone, BodypartClassification.Root);

            if (torsoIsRoot)
            {
                torsoRoot = skeletonRoot;
                AddChildren(ref torsoRoot, BodypartClassification.Torso);
            }
            else
            {
                AddChildren(ref skeletonRoot, BodypartClassification.Root);
            }
        }
    }
Esempio n. 37
0
	void Start()
	{
		// Get information about Oculus Rift version and if it is connected
		ovrManager = FindObjectOfType<OVRManager>();
		bool isRiftConnected = false;
		//		#if UNITY_EDITOR
		//		if(UnityEditorInternal.InternalEditorUtility.HasPro())
		//		#endif
		{
			try
			{
				if(OVRManager.capiHmd != null)
					ovrHmdVersion = OVRManager.capiHmd.GetDesc().Type;
				if(OVRManager.display != null)
				{
					isRiftConnected = OVRManager.display.isPresent;
					
					if(coordinateSystem && coordinateSystem.applyToRootCoordinates && headPositionInput == HeadPositionSource.OculusDK2)
					{
						OVRManager.display.RecenteredPose += RecenterPoseWarning;
					}	
				}
			}
			catch(UnityException e)
			{
				Debug.LogError(e);
			}
		}
		
		if(headPositionInput == HeadPositionSource.OculusDK2)
		{
			if(!isRiftConnected) 
			{
				headPositionInput = HeadPositionSource.None;
				this.transform.localPosition = defaultPosition;
			}
			else 
			{
				OculusCounterPoseOffset();
				if(coordinateSystem && coordinateSystem.applyToRootCoordinates)
					this.localRotation = coordinateSystem.GetOculusCameraYRotation();
			}
		}
		
		if(headPositionInput == HeadPositionSource.Kinect1) {
			kinectSensorID = RUISSkeletonManager.kinect1SensorID;
		}
		if(headPositionInput == HeadPositionSource.Kinect2) {
			kinectSensorID = RUISSkeletonManager.kinect2SensorID;
		}
		
		inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;
		if(		!inputManager
		   &&  (	headPositionInput == HeadPositionSource.PSMove
		     || headRotationInput == HeadRotationSource.PSMove
		     || (externalDriftCorrection && compass == CompassSource.PSMove)))
			Debug.LogError("RUISInputManager script is missing from this scene!");
		
		if(inputManager && !inputManager.enablePSMove)
		{
			if(headPositionInput == HeadPositionSource.PSMove)
				Debug.LogError(	"Your " + typeof(RUISTracker) + " settings indicate that you want to use PS Move for position "
				               +	"tracking, but you have not enabled it from InputManager.");
			if(headRotationInput == HeadRotationSource.PSMove)
				Debug.LogError(	"Your " + typeof(RUISTracker) + " settings indicate that you want to use PS Move for rotation "
				               +	"tracking, but you have not enabled it from InputManager.");
			if(externalDriftCorrection && compass == CompassSource.PSMove)
				Debug.LogError(	"Your " + typeof(RUISTracker) + " settings indicate that you want to use PS Move for yaw drift "
				               +	"correction, but you have not enabled it from InputManager.");
		}
		
		if (!skeletonManager)
			skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
		if(		!skeletonManager
		   &&  (	headPositionInput == HeadPositionSource.Kinect1
		     || headPositionInput == HeadPositionSource.Kinect2
		     || (!useOculusRiftRotation && (headRotationInput == HeadRotationSource.Kinect1 || headRotationInput == HeadRotationSource.Kinect2))
		     || (externalDriftCorrection && (compass == CompassSource.Kinect1 || compass == CompassSource.Kinect2))))
		{
			Debug.LogError("RUISSkeletonManager script is missing from this scene!");
		}
		
		if(inputManager && !inputManager.enableRazerHydra)
		{
			if(headPositionInput == HeadPositionSource.RazerHydra)
				Debug.LogWarning(	"Your " + typeof(RUISTracker) + " settings indicate that you want to use Razer Hydra for "
				                 +	"position tracking, but you have disabled Razer Hydra from RUIS "
				                 +	"InputManager.");
			if(headRotationInput == HeadRotationSource.RazerHydra)
				Debug.LogWarning(	"Your " + typeof(RUISTracker) + " settings indicate that you want to use Razer Hydra for "
				                 +	"rotation tracking, but you have disabled Razer Hydra from RUIS "
				                 +	"InputManager.");
			if(externalDriftCorrection && compass == CompassSource.RazerHydra)
				Debug.LogWarning(	"Your " + typeof(RUISTracker) + " settings indicate that you want to use Razer Hydra for "
				                 +	"yaw drift correction, but you have disabled Razer Hydra from RUIS "
				                 +	"InputManager.");
		}
		
		if(headPositionInput == HeadPositionSource.InputTransform && !positionInput)
			Debug.LogError("Position tracker's Input Transform is none, you need to set it in Unity inspector!");
		
		if(headRotationInput == HeadRotationSource.InputTransform && !rotationInput && !useOculusRiftRotation)
			Debug.LogError("Rotation tracker's Input Transform is none, you need to set it in Unity inspector!");
		
		if(headPositionInput == HeadPositionSource.Kinect1 && positionJoint == RUISSkeletonManager.Joint.None)
			Debug.LogError(	 "Your " + typeof(RUISTracker) + " settings indicate that you want to track position with a "
			               + "Kinect joint, but you have left its value to None in Unity inspector!");
		
		if(		headRotationInput == HeadRotationSource.Kinect1 && rotationJoint == RUISSkeletonManager.Joint.None
		   &&	!useOculusRiftRotation																
		   )
			Debug.LogError(	 "Your " + typeof(RUISTracker) + " settings indicate that you want to track rotation with a "
			               + "Kinect joint, but you have left its value to None in Unity inspector!");
		
		if(		externalDriftCorrection && compass == CompassSource.Kinect1 && compassJoint == RUISSkeletonManager.Joint.None
		   &&  !compassIsPositionTracker && (useOculusRiftRotation || headRotationInput == HeadRotationSource.InputTransform))
			Debug.LogError(	 "Your " + typeof(RUISTracker) + " settings indicate that you want to do yaw drift correction with a "
			               + "Kinect joint, but you have left its value to None in Unity inspector!");
		
		if(headPositionInput == HeadPositionSource.Kinect2 && positionJoint == RUISSkeletonManager.Joint.None)
			Debug.LogError(	 "Your " + typeof(RUISTracker) + " settings indicate that you want to track position with a "
			               + "Kinect2 joint, but you have left its value to None in Unity inspector!");
		
		if(		headRotationInput == HeadRotationSource.Kinect2 && rotationJoint == RUISSkeletonManager.Joint.None
		   &&	!useOculusRiftRotation																	
		   )
			Debug.LogError(	 "Your " + typeof(RUISTracker) + " settings indicate that you want to track rotation with a "
			               + "Kinect2 joint, but you have left its value to None in Unity inspector!");
		
		if(		externalDriftCorrection && compass == CompassSource.Kinect2 && compassJoint == RUISSkeletonManager.Joint.None
		   &&  !compassIsPositionTracker && (useOculusRiftRotation || headRotationInput == HeadRotationSource.InputTransform))
			Debug.LogError(	 "Your " + typeof(RUISTracker) + " settings indicate that you want to do yaw drift correction with a "
			               + "Kinect2 joint, but you have left its value to None in Unity inspector!");
		
		if(		externalDriftCorrection && compass == CompassSource.InputTransform && !compassTransform 
		   &&  !compassIsPositionTracker && (useOculusRiftRotation || headRotationInput == HeadRotationSource.InputTransform))
			Debug.LogError("Yaw drift corrector's Input Transform is none, you need to set it in Unity inspector!");
		
		if(externalDriftCorrection && compassIsPositionTracker && headPositionInput == HeadPositionSource.None)
			Debug.LogError(		"Position Tracker is set to None, but in 'Yaw Drift Correction' you have enabled "
			               +	"'Use Position Tracker'!");
		
		if(isRazerBaseMobile && (	headPositionInput == HeadPositionSource.RazerHydra
		                         || headRotationInput == HeadRotationSource.RazerHydra
		                         || compass == CompassSource.RazerHydra				  ))
		{
			if(mobileRazerBase == RazerHydraBase.InputTransform && hydraBaseInput == null)
				Debug.LogError(	 "Your " + typeof(RUISTracker) + " settings indicate that you want to track Razer Hydra base station with a "
				               + "custom Input Transform, but you have left its value to None in Unity inspector!");
			if(mobileRazerBase == RazerHydraBase.Kinect1 && hydraBaseJoint == RUISSkeletonManager.Joint.None)
				Debug.LogError(	 "Your " + typeof(RUISTracker) + " settings indicate that you want to track Razer Hydra base station with a "
				               + "Kinect joint, but you have left its value to None in Unity inspector!");
		}
		
		if(useOculusRiftRotation && headPositionInput != HeadPositionSource.OculusDK2 && ovrCameraRig != null)
		{
			DisableOculusPositionalTracking();
			
			// OVR manager is not necessarily initialized, so lets do the above disabling later as well
			StartCoroutine(DelayedDisableOculusPositionalTracking());
			
			Debug.Log(  typeof(RUISTracker) + ": Position Tracker is " + headPositionInput + " and " + typeof(OVRCameraRig)
			          + " found in a child gameObject, turning off Oculus Rift position tracking altogether. If you do not "
			          + "want this, then remove the " + typeof(OVRCameraRig) + " component from the child object(s).");
		}
		
		if(ovrCameraRig && Application.isEditor)
			Debug.Log(typeof(OVRCameraRig) + " script detected in a child object of this " + gameObject.name
			          + " object. Using Oculus Rift as a Rotation Tracker. You can access other rotation "
			          + "trackers when you remove the " + typeof(OVRCameraRig) + " component from the child object(s).");
		
		//		if(useOculusRiftRotation && inputManager)
		//		{
		//			if(		(inputManager.enableKinect 		&& headPositionInput == HeadPositionSource.Kinect)
		//				||	(inputManager.enableRazerHydra 	&& headPositionInput == HeadPositionSource.RazerHydra)
		//				||	(inputManager.enablePSMove 		&& headPositionInput == HeadPositionSource.PSMove)
		//				||	headPositionInput == HeadPositionSource.InputTransform								  )
		//			{
		//				oculusCamController.SetNeckPosition(Vector3.zero);
		//				oculusCamController.SetEyeCenterPosition(Vector3.zero);
		//				Debug.Log(	"Head position tracker found, setting NeckPosition and EyeCenterPosition to zero from "
		//						  + "OVRManager.");
		//			}
		//		}
	}
Esempio n. 38
0
    // Use this for initialization
    void Start()
    {
        //Camera_inv = GameObject.Find("Camera Panel");
        //Camera_inv.SetActive(false);
        HandInPosition = false;
        Eraser.SetActive(false);
        RUISSkeletonController[] kinectPlayer1 = kinectPlayer.GetComponentsInChildren <RUISSkeletonController>();
        if (PlaylistManager.pm == null || (PlaylistManager.pm != null && !PlaylistManager.pm.active))
        {
            ParametersPanel.SetActive(true);
            MainPanel.SetActive(false);
        }
        kinectPlayer1[0].updateRootPosition = true;
        indicatorplayer = false;
        initialposition = kinectPlayer.transform.position;

        gc = gameObject.GetComponent <GameController>();


        if (skeletonManager == null)
        {
            skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
            if (!skeletonManager)
            {
                Debug.Log("The scene is missing " + typeof(RUISSkeletonManager) + " script!");
            }
        }

        danceTaichi.SetActive(false);
        danceUnityChan.SetActive(false);
        Camera.transform.position = new Vector3(35f, 31.83f, 450.62f);
        positionIndicator.SetActive(true);
        //indicator.SetActive(true);

        //Camera.transform.position = new Vector3(0f, 31.83f,134.62f);

        vector     = new Vector3(0, 0, 0);
        vectortest = new Vector3(0, 0, 0);

        score = 0;
        UpdateScore();
        InGame = false;
        MainPanel.SetActive(false);
        pausa.SetActive(false);
        ResultPanel.SetActive(false);
        movimientoLateral = false;
        force             = 20;

        /*if(_angleMinLeft == 0){
         *
         *              _angleMinLeft = 25;
         *      }
         *      if(_angleLeft == 0){
         *
         *              _angleLeft = 25;
         *      }*/
        if (_range_game == 0)
        {
            _range_game = 25;
        }
        movimientoLateral = true;

        results = ResultPanel.GetComponent <PutDataResults>();

        //results = FindObjectOfType<PutDataResults> ();
        //Button btn = boton.GetComponent<Button> ();
        //btn.onClick.AddListener(StartGame);

        //sliderCurrentTime.onValueChanged.AddListener(delegate {SlideTime(); });
    }
    void Awake()
    {
        if (skeletonManager == null)
        {
            skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
        }

        followMoveController = false;

        jointInitialRotations = new Dictionary<Transform, Quaternion>();
        jointInitialDistances = new Dictionary<KeyValuePair<Transform, Transform>, float>();

        positionKalman = new KalmanFilter();
        positionKalman.initialize(3,3);
    }
Esempio n. 40
0
    public void OnEnable()
    {
        skeletonManagerGameObject = GameObject.Find("SkeletonManager");

        if (skeletonManagerGameObject != null)
        {
            RUISSkeletonManager playerManager = skeletonManagerGameObject.GetComponent <RUISSkeletonManager>();
            if (playerManager != null)
            {
                maxKinectSkeletons = playerManager.skeletonsHardwareLimit;
            }
        }

        defaultPosition = serializedObject.FindProperty("defaultPosition");
        //skeletonManager = serializedObject.FindProperty("skeletonManager");
        headPositionInput  = serializedObject.FindProperty("headPositionInput");
        headRotationInput  = serializedObject.FindProperty("headRotationInput");
        pickRotationSource = serializedObject.FindProperty("pickRotationSource");
//		resetKey = serializedObject.FindProperty("resetKey");
        positionPlayerID     = serializedObject.FindProperty("positionPlayerID");
        rotationPlayerID     = serializedObject.FindProperty("rotationPlayerID");
        positionJoint        = serializedObject.FindProperty("positionJoint");
        rotationJoint        = serializedObject.FindProperty("rotationJoint");
        positionPSMoveID     = serializedObject.FindProperty("positionPSMoveID");
        rotationPSMoveID     = serializedObject.FindProperty("rotationPSMoveID");
        positionRazerID      = serializedObject.FindProperty("positionRazerID");
        rotationRazerID      = serializedObject.FindProperty("rotationRazerID");
        positionInput        = serializedObject.FindProperty("positionInput");
        rotationInput        = serializedObject.FindProperty("rotationInput");
        positionOffsetKinect = serializedObject.FindProperty("positionOffsetKinect");
        positionOffsetPSMove = serializedObject.FindProperty("positionOffsetPSMove");
        positionOffsetHydra  = serializedObject.FindProperty("positionOffsetHydra");
//		positionOffsetOpenVR = serializedObject.FindProperty("positionOffsetOpenVR");
        rotationOffsetKinect             = serializedObject.FindProperty("rotationOffsetKinect");
        rotationOffsetPSMove             = serializedObject.FindProperty("rotationOffsetPSMove");
        rotationOffsetHydra              = serializedObject.FindProperty("rotationOffsetHydra");
        filterPositionKinect             = serializedObject.FindProperty("filterPositionKinect");
        filterPositionPSMove             = serializedObject.FindProperty("filterPositionPSMove");
        filterPositionHydra              = serializedObject.FindProperty("filterPositionHydra");
        filterPositionTransform          = serializedObject.FindProperty("filterPositionTransform");
        positionNoiseCovarianceKinect    = serializedObject.FindProperty("positionNoiseCovarianceKinect");
        positionNoiseCovariancePSMove    = serializedObject.FindProperty("positionNoiseCovariancePSMove");
        positionNoiseCovarianceHydra     = serializedObject.FindProperty("positionNoiseCovarianceHydra");
        positionNoiseCovarianceTransform = serializedObject.FindProperty("positionNoiseCovarianceTransform");
        filterRotationKinect             = serializedObject.FindProperty("filterRotationKinect");
        filterRotationPSMove             = serializedObject.FindProperty("filterRotationPSMove");
        filterRotationHydra              = serializedObject.FindProperty("filterRotationHydra");
        filterRotationTransform          = serializedObject.FindProperty("filterRotationTransform");
        rotationNoiseCovarianceKinect    = serializedObject.FindProperty("rotationNoiseCovarianceKinect");
        rotationNoiseCovariancePSMove    = serializedObject.FindProperty("rotationNoiseCovariancePSMove");
        rotationNoiseCovarianceHydra     = serializedObject.FindProperty("rotationNoiseCovarianceHydra");
        rotationNoiseCovarianceTransform = serializedObject.FindProperty("rotationNoiseCovarianceTransform");
//		mobileRazerBase = serializedObject.FindProperty("mobileRazerBase");
//		hydraBaseJoint = serializedObject.FindProperty("hydraBaseJoint");
//		hydraBaseKinectPlayerID = serializedObject.FindProperty("hydraBaseKinectPlayerID");
//		hydraBaseInput = serializedObject.FindProperty("hydraBaseInput");
//		filterHydraBasePoseKinect = serializedObject.FindProperty("filterHydraBasePoseKinect");
//		filterHydraBasePoseTransform = serializedObject.FindProperty("filterHydraBasePoseTransform");
//		inferBaseRotationFromRotationTrackerKinect = serializedObject.FindProperty("inferBaseRotationFromRotationTrackerKinect");
//		inferBaseRotationFromRotationTrackerTransform = serializedObject.FindProperty("inferBaseRotationFromRotationTrackerTransform");
//		hydraAtRotationTrackerOffset = serializedObject.FindProperty("hydraAtRotationTrackerOffset");
//		hydraBasePositionOffsetKinect = serializedObject.FindProperty("hydraBasePositionOffsetKinect");
//		hydraBaseRotationOffsetKinect = serializedObject.FindProperty("hydraBaseRotationOffsetKinect");
//		hydraBasePositionCovarianceKinect = serializedObject.FindProperty("hydraBasePositionCovarianceKinect");
//		hydraBaseRotationCovarianceKinect = serializedObject.FindProperty("hydraBaseRotationCovarianceKinect");
//		hydraBasePositionCovarianceTransform = serializedObject.FindProperty("hydraBasePositionCovarianceTransform");
//		hydraBaseRotationCovarianceTransform = serializedObject.FindProperty("hydraBaseRotationCovarianceTransform");
        externalDriftCorrection = serializedObject.FindProperty("externalDriftCorrection");
        compass = serializedObject.FindProperty("compass");
        compassIsPositionTracker     = serializedObject.FindProperty("compassIsPositionTracker");
        compassPlayerID              = serializedObject.FindProperty("compassPlayerID");
        compassJoint                 = serializedObject.FindProperty("compassJoint");
        correctOnlyWhenFacingForward = serializedObject.FindProperty("correctOnlyWhenFacingForward");
        compassPSMoveID              = serializedObject.FindProperty("compassPSMoveID");
        compassRazerID               = serializedObject.FindProperty("compassRazerID");
        compassTransform             = serializedObject.FindProperty("compassTransform");
        compassRotationOffsetKinect  = serializedObject.FindProperty("compassRotationOffsetKinect");
        compassRotationOffsetPSMove  = serializedObject.FindProperty("compassRotationOffsetPSMove");
        compassRotationOffsetHydra   = serializedObject.FindProperty("compassRotationOffsetHydra");
        driftCorrectionRateKinect    = serializedObject.FindProperty("driftCorrectionRateKinect");
        driftCorrectionRatePSMove    = serializedObject.FindProperty("driftCorrectionRatePSMove");
        driftCorrectionRateHydra     = serializedObject.FindProperty("driftCorrectionRateHydra");
        driftCorrectionRateTransform = serializedObject.FindProperty("driftCorrectionRateTransform");
        //driftNoiseCovariance = serializedObject.FindProperty("driftNoiseCovariance");
        enableVisualizers            = serializedObject.FindProperty("enableVisualizers");
        driftingDirectionVisualizer  = serializedObject.FindProperty("driftingDirectionVisualizer");
        compassDirectionVisualizer   = serializedObject.FindProperty("compassDirectionVisualizer");
        correctedDirectionVisualizer = serializedObject.FindProperty("correctedDirectionVisualizer");
        driftVisualizerPosition      = serializedObject.FindProperty("driftVisualizerPosition");
    }
Esempio n. 41
0
 // Use this for initialization
 void Start()
 {
     skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
 }
Esempio n. 42
0
    public void Start()
    {
        switch(compass)
        {
            case CompassSource.Kinect:
                if (!skeletonManager)
                {
                    skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
                }
                if(!skeletonManager)
                    Debug.LogError("RUISSkeletonManager script is missing from this scene!");
                break;
            case CompassSource.PSMove:
                inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;
                if(!inputManager)
                    Debug.LogError("RUISInputManager script is missing from this scene!");
                break;
        }

        if(driftingSensor == DriftingRotation.InputTransform && !driftingTransform)
            Debug.LogError("driftingTransform is none, you need to set it from the inspector!");

        oculusCamController = FindObjectOfType(typeof(OVRCameraController)) as OVRCameraController;
    }