class for accessing Kinect methods
Inheritance: MonoBehaviour
Beispiel #1
0
 private void Start()
 {
     this.kin = GetComponent<KUInterface>();
     this._feet = new List<Vector3>();
     this.sizeCount = 0;
     this._isInitialized = false;
 }
Beispiel #2
0
 private void Start()
 {
     this.kin            = GetComponent <KUInterface>();
     this._feet          = new List <Vector3>();
     this.sizeCount      = 0;
     this._isInitialized = false;
 }
Beispiel #3
0
 private void Start()
 {
     GameObject kinectContainer = GameObject.FindWithTag("Kinect");
     if (kinectContainer != null)
     {
         this.isInitialized = true;
         this.kin = kinectContainer.GetComponent<KUInterface>();
     }
 }
 private void SetUpKinect()
 {
     GameObject kinectContainer = GameObject.FindWithTag(KinectTag);
     if (kinectContainer != null)
     {
         KMonitor km = kinectContainer.GetComponent<KMonitor>();
         if (km.IsInitialized)
             this.kin = kinectContainer.GetComponent<KUInterface>();
     }
 }
Beispiel #5
0
    public static bool StartKinect(KUInterface kin)
    {
        if (kin == null) return false;

        bool val = false;
        if (kin.GetJointPos(KinectWrapper.Joints.HEAD).z > 30)
            val = true;

        return val;
    }
Beispiel #6
0
    // Use this for initialization
    void Start()
    {
        GameObject kinectContainer = GameObject.FindWithTag("Kinect");

        if (kinectContainer != null)
        {
            kin           = kinectContainer.GetComponent <KUInterface>();
            isInitialized = true;
        }
    }
 // Use this for initialization
 void Start()
 {
     //SceneManager.LoadScene(0);
     timer = 0;
     limit = 1.5f;
     countdown_text.SetActive(false);
     DontDestroyOnLoad(audio_song);
     gameStarting = false;
     Kinect       = (KUInterface)FindObjectOfType(typeof(KUInterface));
     DontDestroyOnLoad(Kinect);
 }
 void Awake()
 {
     if (instance == null)
     {
         DontDestroyOnLoad(transform.gameObject);
         instance = this;
     }
     else
     {
         Destroy(transform.gameObject);
     }
 }
Beispiel #9
0
    public static bool KinectLeft(KUInterface kin)
    {
        if (kin == null) return false;

        bool val = false;
        Vector3 leftWrist = kin.GetJointPos(KinectWrapper.Joints.WRIST_LEFT);
        Vector3 leftElbow = kin.GetJointPos(KinectWrapper.Joints.ELBOW_LEFT);

        if (Math.Abs(leftWrist.x - leftElbow.x) > Vector3.Distance(leftWrist, leftElbow) * 0.9)
            val = true;

        return val;
    }
Beispiel #10
0
    public static bool KinectRight(KUInterface kin)
    {
        if (kin == null) return false;

        bool val = false;
        Vector3 rightWrist = kin.GetJointPos(KinectWrapper.Joints.WRIST_RIGHT);
        Vector3 rightElbow = kin.GetJointPos(KinectWrapper.Joints.ELBOW_RIGHT);

        if (Math.Abs(rightWrist.x - rightElbow.x) > Vector3.Distance(rightWrist, rightElbow) * 0.9)
            val = true;

        return val;
    }
    private void SetUpKinect()
    {
        GameObject kinectContainer = GameObject.FindWithTag(KinectTag);

        if (kinectContainer != null)
        {
            KMonitor km = kinectContainer.GetComponent <KMonitor>();
            if (km.IsInitialized)
            {
                this.kin = kinectContainer.GetComponent <KUInterface>();
            }
        }
    }
Beispiel #12
0
    public static bool KinectLeft(KUInterface kin)
    {
        if (kin == null) return false;

        bool val = false;
        Vector3 shoulderCenter = kin.GetJointPos(KinectWrapper.Joints.SHOULDER_CENTER);
        Vector3 hipCenter = kin.GetJointPos(KinectWrapper.Joints.HIP_CENTER);

        Vector3 upperBody = shoulderCenter - hipCenter;
        if (upperBody.normalized.x < -0.15)
            val = true;

        return val;
    }
Beispiel #13
0
    public static bool KinectBack(KUInterface kin)
    {
        if (kin == null) return false;

        bool val = false;
        Vector3 rightAnkle = kin.GetJointPos(KinectWrapper.Joints.ANKLE_RIGHT);
        Vector3 leftAnkle = kin.GetJointPos(KinectWrapper.Joints.ANKLE_LEFT);
        Vector3 leftFoot = kin.GetJointPos(KinectWrapper.Joints.FOOT_LEFT);

        if (leftAnkle.z - rightAnkle.z < -Vector3.Distance(leftAnkle, leftFoot))
        {
            val = true;
        }

        return val;
    }
Beispiel #14
0
    public static bool StartKinect(KUInterface kin)
    {
        if (kin == null)
        {
            return(false);
        }

        bool val = false;

        if (kin.GetJointPos(KinectWrapper.Joints.HEAD).z > 30)
        {
            val = true;
        }

        return(val);
    }
Beispiel #15
0
    public static bool KinectHeadRightTilt(KUInterface kin)
    {
        if (kin == null)
        {
            return(false);
        }

        bool    val  = false;
        Vector3 neck = kin.GetJointPos(KinectWrapper.Joints.HEAD) - kin.GetJointPos(KinectWrapper.Joints.SHOULDER_CENTER);

        if (neck.normalized.x > 0.15)
        {
            val = true;
        }

        return(val);
    }
Beispiel #16
0
    public static bool KinectRight(KUInterface kin)
    {
        if (kin == null)
        {
            return(false);
        }

        bool    val        = false;
        Vector3 rightWrist = kin.GetJointPos(KinectWrapper.Joints.WRIST_RIGHT);
        Vector3 rightElbow = kin.GetJointPos(KinectWrapper.Joints.ELBOW_RIGHT);

        if (Math.Abs(rightWrist.x - rightElbow.x) > Vector3.Distance(rightWrist, rightElbow) * 0.9)
        {
            val = true;
        }

        return(val);
    }
Beispiel #17
0
    public static bool KinectLeft(KUInterface kin)
    {
        if (kin == null)
        {
            return(false);
        }

        bool    val       = false;
        Vector3 leftWrist = kin.GetJointPos(KinectWrapper.Joints.WRIST_LEFT);
        Vector3 leftElbow = kin.GetJointPos(KinectWrapper.Joints.ELBOW_LEFT);

        if (Math.Abs(leftWrist.x - leftElbow.x) > Vector3.Distance(leftWrist, leftElbow) * 0.9)
        {
            val = true;
        }

        return(val);
    }
Beispiel #18
0
    public static bool KinectBack(KUInterface kin)
    {
        if (kin == null)
        {
            return(false);
        }

        bool    val        = false;
        Vector3 rightAnkle = kin.GetJointPos(KinectWrapper.Joints.ANKLE_RIGHT);
        Vector3 leftAnkle  = kin.GetJointPos(KinectWrapper.Joints.ANKLE_LEFT);
        Vector3 leftFoot   = kin.GetJointPos(KinectWrapper.Joints.FOOT_LEFT);

        if (leftAnkle.z - rightAnkle.z < -Vector3.Distance(leftAnkle, leftFoot))
        {
            val = true;
        }

        return(val);
    }
Beispiel #19
0
    public static bool KinectFly(KUInterface kin)
    {
        if (kin == null)
        {
            return(false);
        }

        bool    val           = false;
        Vector3 leftLowerArm  = kin.GetJointPos(KinectWrapper.Joints.WRIST_LEFT) - kin.GetJointPos(KinectWrapper.Joints.ELBOW_LEFT);
        Vector3 rightLowerArm = kin.GetJointPos(KinectWrapper.Joints.WRIST_RIGHT) - kin.GetJointPos(KinectWrapper.Joints.ELBOW_RIGHT);
        Vector3 leftHand      = kin.GetJointPos(KinectWrapper.Joints.HAND_LEFT);
        Vector3 head          = kin.GetJointPos(KinectWrapper.Joints.HEAD);

        if (leftLowerArm.normalized.y > 0.9 && rightLowerArm.normalized.y < -0.9 && leftHand.y > head.y)
        {
            val = true;
        }

        return(val);
    }
Beispiel #20
0
    public static bool KinectLeft(KUInterface kin)
    {
        if (kin == null)
        {
            return(false);
        }

        bool    val            = false;
        Vector3 shoulderCenter = kin.GetJointPos(KinectWrapper.Joints.SHOULDER_CENTER);
        Vector3 hipCenter      = kin.GetJointPos(KinectWrapper.Joints.HIP_CENTER);

        Vector3 upperBody = shoulderCenter - hipCenter;

        if (upperBody.normalized.x < -0.15)
        {
            val = true;
        }

        return(val);
    }
Beispiel #21
0
    public static bool KinectCrouch(KUInterface kin)
    {
        if (kin == null)
        {
            return(false);
        }

        bool    val          = false;
        Vector3 lowerLeftLeg = kin.GetJointPos(KinectWrapper.Joints.ANKLE_LEFT) - kin.GetJointPos(KinectWrapper.Joints.KNEE_LEFT);
        Vector3 upperLeftLeg = kin.GetJointPos(KinectWrapper.Joints.HIP_LEFT) - kin.GetJointPos(KinectWrapper.Joints.KNEE_LEFT);

        Vector3 lowerRightLeg = kin.GetJointPos(KinectWrapper.Joints.ANKLE_RIGHT) - kin.GetJointPos(KinectWrapper.Joints.KNEE_RIGHT);
        Vector3 upperRighLeg  = kin.GetJointPos(KinectWrapper.Joints.HIP_RIGHT) - kin.GetJointPos(KinectWrapper.Joints.KNEE_RIGHT);

        if (Vector3.Angle(lowerLeftLeg, upperLeftLeg) < crouchAngle && Vector3.Angle(lowerRightLeg, upperRighLeg) < crouchAngle)
        {
            val = true;
        }

        return(val);
    }
Beispiel #22
0
    public static bool KinectJump(KUInterface kin)
    {
        if (kin == null)
        {
            return(false);
        }

        bool val = false;

        Vector3 lowerLeftLeg = kin.GetJointPos(KinectWrapper.Joints.ANKLE_LEFT) - kin.GetJointPos(KinectWrapper.Joints.KNEE_LEFT);

        Vector3 lowerRightLeg = kin.GetJointPos(KinectWrapper.Joints.ANKLE_RIGHT) - kin.GetJointPos(KinectWrapper.Joints.KNEE_RIGHT);
        Vector3 upperRighLeg  = kin.GetJointPos(KinectWrapper.Joints.HIP_RIGHT) - kin.GetJointPos(KinectWrapper.Joints.KNEE_RIGHT);

        if (Vector3.Angle(lowerRightLeg, upperRighLeg) < jumpKneeAngle &&
            kin.GetJointPos(KinectWrapper.Joints.ANKLE_RIGHT).y - kin.GetJointPos(KinectWrapper.Joints.ANKLE_LEFT).y > Vector3.Magnitude(lowerLeftLeg) * 0.6)
        {
            val = true;
        }

        return(val);
    }
Beispiel #23
0
    public static bool KinectFly(KUInterface kin)
    {
        if (kin == null) return false;

        bool val = false;
        Vector3 leftLowerArm = kin.GetJointPos(KinectWrapper.Joints.WRIST_LEFT) - kin.GetJointPos(KinectWrapper.Joints.ELBOW_LEFT);
        Vector3 rightLowerArm = kin.GetJointPos(KinectWrapper.Joints.WRIST_RIGHT) - kin.GetJointPos(KinectWrapper.Joints.ELBOW_RIGHT);
        Vector3 leftHand = kin.GetJointPos(KinectWrapper.Joints.HAND_LEFT);
        Vector3 head = kin.GetJointPos(KinectWrapper.Joints.HEAD);

        if (leftLowerArm.normalized.y > 0.9 && rightLowerArm.normalized.y < -0.9 && leftHand.y > head.y)
            val = true;

        return val;
    }
Beispiel #24
0
    public static bool KinectHeadRightTilt(KUInterface kin)
    {
        if (kin == null) return false;

        bool val = false;
        Vector3 neck = kin.GetJointPos(KinectWrapper.Joints.HEAD) - kin.GetJointPos(KinectWrapper.Joints.SHOULDER_CENTER);

        if (neck.normalized.x > 0.15)
            val = true;

        return val;
    }
Beispiel #25
0
    public static bool KinectJump(KUInterface kin)
    {
        if (kin == null) return false;

        bool val = false;

        Vector3 lowerLeftLeg = kin.GetJointPos(KinectWrapper.Joints.ANKLE_LEFT) - kin.GetJointPos(KinectWrapper.Joints.KNEE_LEFT);

        Vector3 lowerRightLeg = kin.GetJointPos(KinectWrapper.Joints.ANKLE_RIGHT) - kin.GetJointPos(KinectWrapper.Joints.KNEE_RIGHT);
        Vector3 upperRighLeg = kin.GetJointPos(KinectWrapper.Joints.HIP_RIGHT) - kin.GetJointPos(KinectWrapper.Joints.KNEE_RIGHT);

        if (Vector3.Angle(lowerRightLeg, upperRighLeg) < jumpKneeAngle
             && kin.GetJointPos(KinectWrapper.Joints.ANKLE_RIGHT).y - kin.GetJointPos(KinectWrapper.Joints.ANKLE_LEFT).y > Vector3.Magnitude(lowerLeftLeg) * 0.6)
            val = true;

        return val;
    }
Beispiel #26
0
    public static bool KinectCrouch(KUInterface kin)
    {
        if (kin == null) return false;

        bool val = false;
        Vector3 lowerLeftLeg = kin.GetJointPos(KinectWrapper.Joints.ANKLE_LEFT) - kin.GetJointPos(KinectWrapper.Joints.KNEE_LEFT);
        Vector3 upperLeftLeg = kin.GetJointPos(KinectWrapper.Joints.HIP_LEFT) - kin.GetJointPos(KinectWrapper.Joints.KNEE_LEFT);

        Vector3 lowerRightLeg = kin.GetJointPos(KinectWrapper.Joints.ANKLE_RIGHT) - kin.GetJointPos(KinectWrapper.Joints.KNEE_RIGHT);
        Vector3 upperRighLeg = kin.GetJointPos(KinectWrapper.Joints.HIP_RIGHT) - kin.GetJointPos(KinectWrapper.Joints.KNEE_RIGHT);

        if (Vector3.Angle(lowerLeftLeg, upperLeftLeg) < crouchAngle && Vector3.Angle(lowerRightLeg, upperRighLeg) < crouchAngle)
            val = true;

        return val;
    }
Beispiel #27
0
 // Use this for initialization
 void Start()
 {
     debugMode = Config.handMouseControl;
     easyMode  = Config.easyMode;
     Kinect    = (KUInterface)FindObjectOfType(typeof(KUInterface));
 }