コード例 #1
0
    public bool IsDribbling(float timestamp, bool mirrored)
    {
        if (!InsideControlRadius())
        {
            return(false);
        }
        ContactModule contact = GetContactModule();

        if (contact == null)
        {
            return(false);
        }
        ContactModule.Sensor left  = contact.GetSensor(Data.Source.Bones[LeftHand].Name);
        ContactModule.Sensor right = contact.GetSensor(Data.Source.Bones[RightHand].Name);
        if (left == null || right == null)
        {
            return(false);
        }
        //Check holding contacts
        if (left.GetContact(timestamp, mirrored) == 1f && right.GetContact(timestamp, mirrored) == 1f)
        {
            return(false);
        }
        //Check dribble contact
        if (left.GetContact(timestamp, mirrored) == 1f ^ right.GetContact(timestamp, mirrored) == 1f)
        {
            return(true);
        }
        //Check if contact happened before and happens again after within the future and past window
        float window   = 1f;
        Frame previous = contact.GetPreviousContactFrame(Data.GetFrame(timestamp), mirrored, left, right);

        if (previous == null || previous.Timestamp < timestamp - window)
        {
            return(false);
        }
        Frame next = contact.GetNextContactFrame(Data.GetFrame(timestamp), mirrored, left, right);

        if (next != null && next.Timestamp - timestamp <= window)
        {
            return(left.GetContact(next.Timestamp, mirrored) == 1f ^ right.GetContact(next.Timestamp, mirrored) == 1f);
        }
        return(false);

        bool InsideControlRadius()
        {
            RootModule root = GetRootModule();

            if (root == null)
            {
                return(false);
            }
            return(Vector3.Distance(root.GetRootPosition(timestamp, mirrored).ZeroY(), GetBallPosition(timestamp, mirrored).ZeroY()) <= GetControlRadius());
        }
    }
コード例 #2
0
    public bool LeaveHand(float timestamp, bool mirrored)
    {
        ContactModule contact = GetContactModule();

        if (contact == null)
        {
            return(false);
        }
        float shootPeriod = 1.0f;

        ContactModule.Sensor left  = contact.GetSensor(Data.Source.Bones[LeftHand].Name);
        ContactModule.Sensor right = contact.GetSensor(Data.Source.Bones[RightHand].Name);
        Frame next     = contact.GetNextContactEnd(Data.GetFrame(timestamp), mirrored, left, right);
        Frame previous = contact.GetPreviousContactEnd(Data.GetFrame(timestamp), mirrored, left, right);

        if (next != null && next.Timestamp - timestamp <= shootPeriod)
        {
            return(true);
        }
        if (left.GetContact(timestamp, mirrored) == 0f && right.GetContact(timestamp, mirrored) == 0f &&
            previous != null && timestamp - previous.Timestamp <= shootPeriod)
        {
            return(true);
        }
        return(false);
    }
コード例 #3
0
    public bool IsHolding(float timestamp, bool mirrored)
    {
        ContactModule contact = GetContactModule();

        if (contact == null)
        {
            return(false);
        }
        ContactModule.Sensor left  = contact.GetSensor(Data.Source.Bones[LeftHand].Name);
        ContactModule.Sensor right = contact.GetSensor(Data.Source.Bones[RightHand].Name);
        if (left == null || right == null)
        {
            return(false);
        }
        return(left.GetContact(timestamp, mirrored) == 1f && right.GetContact(timestamp, mirrored) == 1f);
    }
コード例 #4
0
    private float ContactPower(float timestamp, bool mirrored)
    {
        ContactModule contact = GetContactModule();

        if (contact == null)
        {
            return(0f);
        }
        ContactModule.Sensor left  = contact.GetSensor(Data.Source.Bones[LeftHand].Name);
        ContactModule.Sensor right = contact.GetSensor(Data.Source.Bones[RightHand].Name);
        if (left == null || right == null)
        {
            return(0f);
        }
        SmoothingWindow = SmoothingWindow == null?Data.GetTimeWindow(MotionEditor.GetInstance().PastWindow + MotionEditor.GetInstance().FutureWindow, 1f) : SmoothingWindow;

        SmoothingContacts = SmoothingContacts.Validate(SmoothingWindow.Length);
        for (int i = 0; i < SmoothingContacts.Length; i++)
        {
            SmoothingContacts[i] = left.GetContact(timestamp + SmoothingWindow[i], mirrored) + right.GetContact(timestamp + SmoothingWindow[i], mirrored);
        }
        return(SmoothingContacts.Gaussian());
    }