class for accessing Kinect methods
Inheritance: MonoBehaviour
示例#1
0
 private void Start()
 {
     this.kin = GetComponent<KUInterface>();
     this._feet = new List<Vector3>();
     this.sizeCount = 0;
     this._isInitialized = false;
 }
示例#2
0
 private void Start()
 {
     this.kin            = GetComponent <KUInterface>();
     this._feet          = new List <Vector3>();
     this.sizeCount      = 0;
     this._isInitialized = false;
 }
示例#3
0
 private void Start()
 {
     GameObject kinectContainer = GameObject.FindWithTag("Kinect");
     if (kinectContainer != null)
     {
         this.isInitialized = true;
         this.kin = kinectContainer.GetComponent<KUInterface>();
     }
 }
示例#4
0
 private void SetUpKinect()
 {
     GameObject kinectContainer = GameObject.FindWithTag(KinectTag);
     if (kinectContainer != null)
     {
         KMonitor km = kinectContainer.GetComponent<KMonitor>();
         if (km.IsInitialized)
             this.kin = kinectContainer.GetComponent<KUInterface>();
     }
 }
示例#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;
    }
示例#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);
     }
 }
示例#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;
    }
示例#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;
    }
示例#11
0
    private void SetUpKinect()
    {
        GameObject kinectContainer = GameObject.FindWithTag(KinectTag);

        if (kinectContainer != null)
        {
            KMonitor km = kinectContainer.GetComponent <KMonitor>();
            if (km.IsInitialized)
            {
                this.kin = kinectContainer.GetComponent <KUInterface>();
            }
        }
    }
示例#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;
    }
示例#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;
    }
示例#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);
    }
示例#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);
    }
示例#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);
    }
示例#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);
    }
示例#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);
    }
示例#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);
    }
示例#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);
    }
示例#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);
    }
示例#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);
    }
示例#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;
    }
示例#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;
    }
示例#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;
    }
示例#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;
    }
示例#27
0
 // Use this for initialization
 void Start()
 {
     debugMode = Config.handMouseControl;
     easyMode  = Config.easyMode;
     Kinect    = (KUInterface)FindObjectOfType(typeof(KUInterface));
 }