Пример #1
0
    public override ComponentSeries DerivedExtractSeries(TimeSeries global, float timestamp, bool mirrored)
    {
        ContactSeries instance = new ContactSeries(global, GetNames());

        for (int i = 0; i < instance.Samples.Length; i++)
        {
            instance.Values[i] = GetContacts(timestamp + instance.Samples[i].Timestamp, mirrored);
        }
        return(instance);
    }
Пример #2
0
            public Container(MotionEditor editor, float timestamp)
            {
                editor.LoadFrame(timestamp);

                Asset = editor.GetAsset();
                Frame = editor.GetCurrentFrame();

                TimeSeries    = editor.GetTimeSeries();
                RootSeries    = (RootSeries)Asset.GetModule <RootModule>().ExtractSeries(TimeSeries, timestamp, editor.Mirror);
                StyleSeries   = (StyleSeries)Asset.GetModule <StyleModule>().ExtractSeries(TimeSeries, timestamp, editor.Mirror);
                ContactSeries = (ContactSeries)Asset.GetModule <ContactModule>().ExtractSeries(TimeSeries, timestamp, editor.Mirror);
                PhaseSeries   = (PhaseSeries)Asset.GetModule <PhaseModule>().ExtractSeries(TimeSeries, timestamp, editor.Mirror);

                Root            = editor.GetActor().transform.GetWorldMatrix(true);
                ActorPosture    = editor.GetActor().GetBoneTransformations();
                ActorVelocities = editor.GetActor().GetBoneVelocities();
            }
    protected override void Setup()
    {
        Collider   = GetComponent <CapsuleCollider>();
        Controller = new Controller(PlayerID);

        GenerativeModel = GetComponent <GenerativeControl>();

        Controller.Logic    stand           = Controller.AddLogic("Stand", () => Controller.QueryLeftJoystickVector().magnitude < 0.25f);
        Controller.Function standControl    = Controller.AddFunction("StandControl", (x) => TimeSeries.GetControl((int)x, 0.5f, 0.1f, 1f));
        Controller.Function standCorrection = Controller.AddFunction("StandCorrection", (x) => TimeSeries.GetCorrection((int)x, 0.1f, 1f, 0f));

        Controller.Logic    move           = Controller.AddLogic("Move", () => !stand.Query() && !Controller.GetButton(Controller.Button.Y));
        Controller.Function moveControl    = Controller.AddFunction("MoveControl", (x) => TimeSeries.GetControl((int)x, 0.5f, 0.1f, 1f));
        Controller.Function moveCorrection = Controller.AddFunction("MoveCorrection", (x) => TimeSeries.GetCorrection((int)x, 0.1f, 1f, 0f));

        Controller.Logic    hold           = Controller.AddLogic("Hold", () => Controller.GetButton(Controller.Button.B));
        Controller.Function holdControl    = Controller.AddFunction("HoldControl", (x) => TimeSeries.GetControl((int)x, hold.Query() ? 0.5f : 1f, 0.1f, 1f));
        Controller.Function holdCorrection = Controller.AddFunction("HoldCorrection", (x) => TimeSeries.GetCorrection((int)x, hold.Query() ? 0.1f : 0f, 1f, 0f));

        Controller.Logic    shoot           = Controller.AddLogic("Shoot", () => Carrier && Controller.GetButton(Controller.Button.Y));
        Controller.Function shootControl    = Controller.AddFunction("ShootControl", (x) => TimeSeries.GetControl((int)x, shoot.Query() ? 0.5f : 1f, 0.1f, 1f));
        Controller.Function shootCorrection = Controller.AddFunction("ShootCorrection", (x) => TimeSeries.GetCorrection((int)x, shoot.Query() ? 0.1f : 0f, 1f, 0f));

        Controller.Logic    dribble           = Controller.AddLogic("Dribble", () => Carrier && !hold.Query() && !shoot.Query());
        Controller.Function dribbleControl    = Controller.AddFunction("DribbleControl", (x) => TimeSeries.GetControl((int)x, hold.Query() || shoot.Query() ? 0.5f : 1f, 0.1f, 1f));
        Controller.Function dribbleCorrection = Controller.AddFunction("DribbleCorrection", (x) => TimeSeries.GetCorrection((int)x, hold.Query() || shoot.Query() ? 0.1f : 0f, 1f, 0f));

        Controller.Logic sprint = Controller.AddLogic("Sprint", () => move.Query() && Controller.QueryLeftJoystickVector().y > 0.25f);

        Controller.Logic spin = Controller.AddLogic("Spin", () => move.Query() && Controller.QueryButtonController() != 0f);

        Controller.Logic horizontalControl = Controller.AddLogic("HorizontalControl", () =>
                                                                 !Carrier && hold.Query() ||
                                                                 Carrier && !spin.Query() && Controller.QueryRightJoystickVector().magnitude > 0.1f
                                                                 );
        Controller.Logic heightControl = Controller.AddLogic("HeightControl", () =>
                                                             !Carrier && hold.Query() ||
                                                             Carrier && Controller.QueryDPadController().z != 0f ||
                                                             Carrier && hold.Query() && horizontalControl.Query()
                                                             );
        Controller.Logic speedControl = Controller.AddLogic("SpeedControl", () =>
                                                            !Carrier && hold.Query() ||
                                                            Carrier && dribble.Query() && DribbleSeries.Pivots[TimeSeries.Pivot].y > HeightDribbleThreshold ||
                                                            Carrier && dribble.Query() && DribbleSeries.Momentums[TimeSeries.Pivot].y < SpeedDribbleThreshold
                                                            );

        Controller.Function phaseStability = Controller.AddFunction("PhaseStability", (x) => TimeSeries.GetCorrection((int)x,
                                                                                                                      1f,
                                                                                                                      0.9f,
                                                                                                                      0.1f
                                                                                                                      ));

        Controller.Logic rootControl = Controller.AddLogic("RootControl", () => true);

        Controller.Function rootPositionControl = Controller.AddFunction("RootPositionControl", (x) => TimeSeries.GetControl((int)x,
                                                                                                                             rootControl.Query() ? 0.25f : 0f,
                                                                                                                             0.1f,
                                                                                                                             1f
                                                                                                                             ));

        Controller.Function rootPositionCorrection = Controller.AddFunction("RootPositionCorrection", (x) => TimeSeries.GetCorrection((int)x,
                                                                                                                                      rootControl.Query() ? 0.25f : 1f,
                                                                                                                                      1f,
                                                                                                                                      0f
                                                                                                                                      ));

        Controller.Function rootRotationControl = Controller.AddFunction("RootRotationControl", (x) => TimeSeries.GetControl((int)x,
                                                                                                                             rootControl.Query() ? 0.5f : 0f,
                                                                                                                             0.1f,
                                                                                                                             1f
                                                                                                                             ));

        Controller.Function rootRotationCorrection = Controller.AddFunction("RootRotationCorrection", (x) => TimeSeries.GetCorrection((int)x,
                                                                                                                                      rootControl.Query() ? 0.25f : 1f,
                                                                                                                                      1f,
                                                                                                                                      0f
                                                                                                                                      ));

        Controller.Function rootVelocityControl = Controller.AddFunction("RootVelocityControl", (x) => TimeSeries.GetControl((int)x,
                                                                                                                             rootControl.Query() ? 0.75f : 0f,
                                                                                                                             0.1f,
                                                                                                                             1f
                                                                                                                             ));

        Controller.Function rootVelocityCorrection = Controller.AddFunction("RootVelocityCorrection", (x) => TimeSeries.GetCorrection((int)x,
                                                                                                                                      rootControl.Query() ? 0.25f : 1f,
                                                                                                                                      1f,
                                                                                                                                      0f
                                                                                                                                      ));

        Controller.Function ballHorizontalControl = Controller.AddFunction("BallHorizontalControl", (x) => TimeSeries.GetControl((int)x,
                                                                                                                                 horizontalControl.Query() ? 0.2f : 0f,
                                                                                                                                 0f,
                                                                                                                                 0.5f
                                                                                                                                 ));

        Controller.Function ballHorizontalCorrection = Controller.AddFunction("BallHorizontalCorrection", (x) => TimeSeries.GetCorrection(
                                                                                  (int)x, horizontalControl.Query() ? 0.2f : 1f,
                                                                                  0.5f,
                                                                                  0f
                                                                                  ));

        Controller.Function ballHeightControl = Controller.AddFunction("BallHeightControl", (x) => TimeSeries.GetControl(
                                                                           (int)x, heightControl.Query() ? 0.1f : 0f,
                                                                           0f,
                                                                           0.5f
                                                                           ));

        Controller.Function ballHeightCorrection = Controller.AddFunction("BallHeightCorrection", (x) => TimeSeries.GetCorrection(
                                                                              (int)x, heightControl.Query() ? 0.1f : 1f,
                                                                              0.5f,
                                                                              0f
                                                                              ));

        Controller.Function ballSpeedControl = Controller.AddFunction("BallSpeedControl", (x) => TimeSeries.GetControl(
                                                                          (int)x, speedControl.Query() ? 0.1f : 0f,
                                                                          0f,
                                                                          0.5f
                                                                          ));

        Controller.Function ballSpeedCorrection = Controller.AddFunction("BallSpeedCorrection", (x) => TimeSeries.GetCorrection(
                                                                             (int)x, speedControl.Query() ? 0.1f : 1f,
                                                                             0.5f,
                                                                             0f
                                                                             ));

        TimeSeries    = new TimeSeries(6, 6, 1f, 1f, 5);
        RootSeries    = new RootSeries(TimeSeries, transform);
        DribbleSeries = new DribbleSeries(TimeSeries, 2.5f, Ball.transform, Actor, RootSeries, null, null);
        StyleSeries   = new StyleSeries(TimeSeries, new string[] { "Stand", "Move", "Dribble", "Hold", "Shoot" }, new float[] { 1f, 0f, 1f, 0f, 0f });
        ContactSeries = new ContactSeries(TimeSeries, "Left Foot", "Right Foot", "Left Hand", "Right Hand", "Ball");
        PhaseSeries   = new PhaseSeries(TimeSeries, "Left Foot", "Right Foot", "Left Hand", "Right Hand", "Ball");

        BodyIK      = UltimateIK.BuildModel(Actor.FindTransform("Player 01:Hips"), Actor.GetBoneTransforms("Player 01:LeftFoot", "Player 01:RightFoot", "Player 01:LeftBallAux", "Player 01:RightBallAux"));
        LeftFootIK  = UltimateIK.BuildModel(Actor.FindTransform("Player 01:LeftUpLeg"), Actor.GetBoneTransforms("Player 01:LeftFoot"));
        RightFootIK = UltimateIK.BuildModel(Actor.FindTransform("Player 01:RightUpLeg"), Actor.GetBoneTransforms("Player 01:RightFoot"));
        LeftHandIK  = UltimateIK.BuildModel(Actor.FindTransform("Player 01:LeftArm"), Actor.GetBoneTransforms("Player 01:LeftBallAux"));
        RightHandIK = UltimateIK.BuildModel(Actor.FindTransform("Player 01:RightArm"), Actor.GetBoneTransforms("Player 01:RightBallAux"));
        HeadIK      = UltimateIK.BuildModel(Actor.FindTransform("Player 01:Neck"), Actor.GetBoneTransforms("Player 01:Head"));

        RootSeries.DrawGUI    = DrawGUI;
        StyleSeries.DrawGUI   = DrawGUI;
        DribbleSeries.DrawGUI = DrawGUI;
        ContactSeries.DrawGUI = DrawGUI;
        PhaseSeries.DrawGUI   = DrawGUI;
        GetComponent <ExpertActivation>().Draw = DrawGUI;
        RootSeries.DrawScene    = DrawDebug;
        StyleSeries.DrawScene   = DrawDebug;
        DribbleSeries.DrawScene = DrawDebug;
        ContactSeries.DrawScene = DrawDebug;
        PhaseSeries.DrawScene   = DrawDebug;
    }
Пример #4
0
    protected override void Setup()
    {
        Collider   = GetComponent <CapsuleCollider>();
        Controller = new Controller(1);

        Controller.Logic    idle            = Controller.AddLogic("Idle", () => Controller.QueryLeftJoystickVector().magnitude < 0.1f);
        Controller.Function idleControl     = Controller.AddFunction("IdleControl", (x) => TimeSeries.GetControl((int)x, ActionBias, 0.1f, ControlStrength));
        Controller.Function idleCorrection  = Controller.AddFunction("IdleCorrection", (x) => TimeSeries.GetCorrection((int)x, CorrectionBias, CorrectionStrength, 0f));
        Controller.Logic    move            = Controller.AddLogic("Move", () => !idle.Query());
        Controller.Function moveControl     = Controller.AddFunction("MoveControl", (x) => TimeSeries.GetControl((int)x, ActionBias, 0.1f, ControlStrength));
        Controller.Function moveCorrection  = Controller.AddFunction("MoveCorrection", (x) => TimeSeries.GetCorrection((int)x, CorrectionBias, CorrectionStrength, 0f));
        Controller.Logic    speed           = Controller.AddLogic("Speed", () => true);
        Controller.Function speedControl    = Controller.AddFunction("SpeedControl", (x) => TimeSeries.GetControl((int)x, ActionBias, 0.1f, ControlStrength));
        Controller.Function speedCorrection = Controller.AddFunction("SpeedCorrection", (x) => TimeSeries.GetCorrection((int)x, CorrectionBias, CorrectionStrength, 0f));

        Controller.Logic sprint = Controller.AddLogic("Sprint", () => move.Query() && Controller.QueryLeftJoystickVector().y > 0.25f);

        Controller.Function rootPositionControl = Controller.AddFunction("RootPositionControl", (x) => TimeSeries.GetControl((int)x,
                                                                                                                             PositionBias,
                                                                                                                             0.1f,
                                                                                                                             ControlStrength
                                                                                                                             ));
        Controller.Function rootPositionCorrection = Controller.AddFunction("RootPositionCorrection", (x) => TimeSeries.GetCorrection((int)x,
                                                                                                                                      CorrectionBias,
                                                                                                                                      CorrectionStrength,
                                                                                                                                      0f
                                                                                                                                      ));
        Controller.Function rootRotationControl = Controller.AddFunction("RootRotationControl", (x) => TimeSeries.GetControl((int)x,
                                                                                                                             RotationBias,
                                                                                                                             0.1f,
                                                                                                                             ControlStrength
                                                                                                                             ));
        Controller.Function rootRotationCorrection = Controller.AddFunction("RootRotationCorrection", (x) => TimeSeries.GetCorrection((int)x,
                                                                                                                                      CorrectionBias,
                                                                                                                                      CorrectionStrength,
                                                                                                                                      0f
                                                                                                                                      ));
        Controller.Function rootVelocityControl = Controller.AddFunction("RootVelocityControl", (x) => TimeSeries.GetControl((int)x,
                                                                                                                             VelocityBias,
                                                                                                                             0.1f,
                                                                                                                             ControlStrength
                                                                                                                             ));
        Controller.Function rootVelocityCorrection = Controller.AddFunction("RootVelocityCorrection", (x) => TimeSeries.GetCorrection((int)x,
                                                                                                                                      CorrectionBias,
                                                                                                                                      CorrectionStrength,
                                                                                                                                      0f
                                                                                                                                      ));

        Controller.Function phaseStability = Controller.AddFunction("PhaseStability", (x) => TimeSeries.GetCorrection((int)x,
                                                                                                                      2f,
                                                                                                                      1f,
                                                                                                                      0.5f
                                                                                                                      ));

        TimeSeries    = new TimeSeries(6, 6, 1f, 1f, 5);
        RootSeries    = new RootSeries(TimeSeries, transform);
        StyleSeries   = new StyleSeries(TimeSeries, new string[] { "Idle", "Move", "Speed" }, new float[] { 1f, 0f, 0f });
        ContactSeries = new ContactSeries(TimeSeries, "Left Hand", "Right Hand", "Left Foot", "Right Foot");
        PhaseSeries   = new PhaseSeries(TimeSeries, "Left Hand", "Right Hand", "Left Foot", "Right Foot");

        LeftHandIK  = UltimateIK.BuildModel(Actor.FindTransform("LeftForeArm"), Actor.GetBoneTransforms("LeftHandSite"));
        RightHandIK = UltimateIK.BuildModel(Actor.FindTransform("RightForeArm"), Actor.GetBoneTransforms("RightHandSite"));
        LeftFootIK  = UltimateIK.BuildModel(Actor.FindTransform("LeftLeg"), Actor.GetBoneTransforms("LeftFootSite"));
        RightFootIK = UltimateIK.BuildModel(Actor.FindTransform("RightLeg"), Actor.GetBoneTransforms("RightFootSite"));

        RootSeries.DrawGUI    = DrawGUI;
        StyleSeries.DrawGUI   = DrawGUI;
        ContactSeries.DrawGUI = DrawGUI;
        PhaseSeries.DrawGUI   = DrawGUI;
        GetComponent <ExpertActivation>().Draw = DrawGUI;
        RootSeries.DrawScene    = DrawDebug;
        StyleSeries.DrawScene   = DrawDebug;
        ContactSeries.DrawScene = DrawDebug;
        PhaseSeries.DrawScene   = DrawDebug;
    }