예제 #1
0
	// Use this for initialization
	void Start () {
		kinect = devOrEmu.getKinect();
		players = new Kinect.NuiSkeletonTrackingState[Kinect.Constants.NuiSkeletonCount];
		trackedPlayers = new int[Kinect.Constants.NuiSkeletonMaxTracked];
		trackedPlayers[0] = -1;
		trackedPlayers[1] = -1;
		bonePos = new Vector3[2,(int)Kinect.NuiSkeletonPositionIndex.Count];
		rawBonePos = new Vector3[2,(int)Kinect.NuiSkeletonPositionIndex.Count];
		boneVel = new Vector3[2,(int)Kinect.NuiSkeletonPositionIndex.Count];
		
		boneState = new Kinect.NuiSkeletonPositionTrackingState[2,(int)Kinect.NuiSkeletonPositionIndex.Count];
		boneLocalOrientation = new Quaternion[2, (int)Kinect.NuiSkeletonPositionIndex.Count];
		boneAbsoluteOrientation = new Quaternion[2, (int)Kinect.NuiSkeletonPositionIndex.Count];
		
		//create the transform matrix that converts from kinect-space to world-space
		Matrix4x4 trans = new Matrix4x4();
		trans.SetTRS( new Vector3(-kinect.getKinectCenter().x,
		                          kinect.getSensorHeight()-kinect.getKinectCenter().y,
		                          -kinect.getKinectCenter().z),
		             Quaternion.identity, Vector3.one );
		Matrix4x4 rot = new Matrix4x4();
		Quaternion quat = new Quaternion();
		double theta = Mathf.Atan((kinect.getLookAt().y+kinect.getKinectCenter().y-kinect.getSensorHeight()) / (kinect.getLookAt().z + kinect.getKinectCenter().z));
		float kinectAngle = (float)(theta * (180 / Mathf.PI));
		quat.eulerAngles = new Vector3(-kinectAngle, 0, 0);
		rot.SetTRS( Vector3.zero, quat, Vector3.one);

		//final transform matrix offsets the rotation of the kinect, then translates to a new center
		kinectToWorld = flipMatrix*trans*rot;
	}
예제 #2
0
    // Use this for initialization
    void Start()
    {
        kinect            = devOrEmu.getKinect();
        players           = new Kinect.NuiSkeletonTrackingState[Kinect.Constants.NuiSkeletonCount];
        trackedPlayers    = new int[Kinect.Constants.NuiSkeletonMaxTracked];
        trackedPlayers[0] = -1;
        trackedPlayers[1] = -1;
        bonePos           = new Vector3[2, (int)Kinect.NuiSkeletonPositionIndex.Count];
        rawBonePos        = new Vector3[2, (int)Kinect.NuiSkeletonPositionIndex.Count];
        boneVel           = new Vector3[2, (int)Kinect.NuiSkeletonPositionIndex.Count];

        boneState               = new Kinect.NuiSkeletonPositionTrackingState[2, (int)Kinect.NuiSkeletonPositionIndex.Count];
        boneLocalOrientation    = new Quaternion[2, (int)Kinect.NuiSkeletonPositionIndex.Count];
        boneAbsoluteOrientation = new Quaternion[2, (int)Kinect.NuiSkeletonPositionIndex.Count];

        //create the transform matrix that converts from kinect-space to world-space
        Matrix4x4 trans = new Matrix4x4();

        trans.SetTRS(new Vector3(-kinect.getKinectCenter().x,
                                 kinect.getSensorHeight() - kinect.getKinectCenter().y,
                                 -kinect.getKinectCenter().z),
                     Quaternion.identity, Vector3.one);
        Matrix4x4  rot         = new Matrix4x4();
        Quaternion quat        = new Quaternion();
        double     theta       = Mathf.Atan((kinect.getLookAt().y + kinect.getKinectCenter().y - kinect.getSensorHeight()) / (kinect.getLookAt().z + kinect.getKinectCenter().z));
        float      kinectAngle = (float)(theta * (180 / Mathf.PI));

        quat.eulerAngles = new Vector3(-kinectAngle, 0, 0);
        rot.SetTRS(Vector3.zero, quat, Vector3.one);

        //final transform matrix offsets the rotation of the kinect, then translates to a new center
        kinectToWorld = flipMatrix * trans * rot;
    }
예제 #3
0
    // Use this for initialization

    void Start()
    {
        kinect   = devOrEmu.getKinect();
        sw       = new SkeletonWrapper();
        skeleton = GameObject.Find("SkeletonWrapper");
        StartCoroutine("WaveSegments");
    }
예제 #4
0
 // Use this for initialization
 void Start()
 {
     kinect             = devOrEmu.getKinect();
     lastPlayerDetected = false;
     text.text          = "No Player Detected";
     text.color         = Color.red;
 }
using UnityEngine;