Exemplo n.º 1
0
    private ShadowTransform[] BlendController(
        ShadowController controller,
        ShadowTransform[] input,
        Slider weight,
        FilterList <string> filter = null)
    {
        if (weight.IsMin == true)
        {
            return(input);
        }

        // Update the target controller from that blend
        if (filter == null)
        {
            controller.Decode(input);
        }
        else
        {
            controller.Decode(input, filter);
        }
        controller.ControlledUpdate();
        ShadowTransform[] result
            = controller.Encode(this.NewTransformArray());

        return(BlendSystem.Blend(
                   this.NewTransformArray(),
                   new BlendPair(input, weight.Inverse),
                   new BlendPair(result, weight.Value)));
    }
Exemplo n.º 2
0
    void Update()
    {
        UpdateCoordinates();
        UpdateInterpolation();

        // Project the idle controller onto the headLook controller
        // each frame, since the headLook controller calculates a full
        // offset each frame from the base pose to the gazing pose
        headlookController.Decode(
            this.dummyController.Encode(
                this.NewTransformArray()));
        this.headlookController.ControlledUpdate();

        ShadowTransform[] dummy =
            dummyController.Encode(this.NewTransformArray());
        ShadowTransform[] headLook =
            this.headlookController.Encode(this.NewTransformArray());

        ShadowTransform[] blend = BlendSystem.Blend(
            this.NewTransformArray(),
            new BlendPair(headLook, interp),
            new BlendPair(dummy, 1.0f - interp));

        Shadow.ReadShadowData(blend, transform.GetChild(0), this);
    }
Exemplo n.º 3
0
    // Update is usually where we do the blending and fading
    void Update()
    {
        this.UpdateCoordinates();
        this.UpdateInterpolation();

        // Project the idle controller onto the reach controller
        // each frame, except for the hierarchy beginning with the
        // LeftArm joint, otherwise the reach control would be
        // overwritten each frame
        this.reachController.Decode(
            this.dummyController.Encode(
                this.NewTransformArray()),
            new Blacklist <string>("LeftArm"));
        this.reachController.ControlledUpdate();

        ShadowTransform[] dummy =
            this.dummyController.Encode(this.NewTransformArray());
        ShadowTransform[] reach =
            this.reachController.Encode(this.NewTransformArray());

        ShadowTransform[] blend =
            BlendSystem.Blend(
                this.NewTransformArray(),
                new BlendPair(reach, interp),
                new BlendPair(dummy, 1.0f - interp));

        Shadow.ReadShadowData(blend, transform.GetChild(0), this);
    }
    private ShadowTransform[] BlendRagdoll(ShadowTransform[] input)
    {
        if (this.dWeight.IsMin == true)
        {
            this.ragdoll.Decode(
                input,
                new Blacklist <string>("LeftUpLeg", "RightUpLeg"));
        }
        this.ragdoll.ControlledUpdate();
        ShadowTransform[] result
            = this.ragdoll.Encode(this.ragdollPose);

        return(BlendSystem.Blend(
                   this.NewTransformArray(),
                   new BlendPair(input, this.dWeight.Inverse),
                   new BlendPair(result, this.dWeight.Value)));
    }
Exemplo n.º 5
0
    void Update()
    {
        this.weight.Tick(Time.deltaTime);

        // Move the root position of each shadow to match the display model
        this.UpdateCoordinates();

        // Update the lean controller and write its shadow into the buffer
        this.lean.ControlledUpdate();
        this.lean.Encode(this.buffer1);

        // Update the anim controller and write its shadow into the buffer
        this.anim.ControlledUpdate();
        this.anim.Encode(this.buffer2, new Whitelist <string>("Spine1"));

        // Optionally, uncomment this to see the weight value
        // Debug.Log(weight);

        // Play an animation when we press T
        if (Input.GetKeyDown(KeyCode.T) == true)
        {
            this.anim.AnimPlay("dismissing_gesture");
            this.weight.ToMin();
        }

        // Fade out the animation controller if we're finished
        if (anim.IsPlaying() == false)
        {
            this.weight.ToMax();
        }

        // Blend the two controllers using the weight value
        BlendSystem.Blend(
            this.buffer1,
            new BlendPair(this.buffer1, this.weight.Value),
            new BlendPair(this.buffer2, this.weight.Inverse));

        // Write the shadow buffer to the display model, starting at the hips
        Shadow.ReadShadowData(
            this.buffer1,
            this.transform.GetChild(0),
            this);
    }
Exemplo n.º 6
0
    private ShadowTransform[] BlendLegsAndSitting()
    {
        // Update the leg controller
        this.locomotion.ControlledUpdate();
        ShadowTransform[] legs =
            this.locomotion.Encode(this.NewTransformArray());

        // If we don't need to blend the gesture controller, don't bother
        if (sWeight.IsMin == true)
        {
            return(legs);
        }

        this.sitting.ControlledUpdate();
        ShadowTransform[] sitBody =
            this.sitting.Encode(this.NewTransformArray());

        return(BlendSystem.Blend(
                   this.NewTransformArray(),
                   new BlendPair(legs, sWeight.Inverse),
                   new BlendPair(sitBody, sWeight.Value)));
    }
Exemplo n.º 7
0
 // Update is called once per frame
 void Update()
 {
     this.weight.Tick(Time.deltaTime);
     this.UpdateCoordinates();
     this.lean.ControlledUpdate();
     this.lean.Encode(this.buffer1);
     this.anim.ControlledUpdate();
     this.anim.Encode(this.buffer2, new Whitelist <string>("Spine1"));
     if (Input.GetKeyDown(KeyCode.T) == true)
     {
         this.anim.AnimPlay("dismissing_gesture");
         this.weight.ToMax();
     }
     if (anim.IsPlaying() == false)
     {
         this.weight.ToMin();
     }
     BlendSystem.Blend(this.buffer1,
                       new BlendPair(this.buffer1, this.weight.Value),
                       new BlendPair(this.buffer2, this.weight.Inverse));
     Shadow.ReadShadowData(this.buffer1, this.transform.GetChild(0), this);
 }