NumberExpression

Trait NumberExpression 

Source
pub trait NumberExpression: Sized + Into<Expression> {
    // Provided methods
    fn as_expr(self) -> Expression { ... }
    fn equals(self, other: impl Into<Expression>) -> Expression { ... }
    fn not_equal(self, other: impl Into<Expression>) -> Expression { ... }
    fn lt(self, other: impl Into<Expression>) -> Expression { ... }
    fn ge(self, other: impl Into<Expression>) -> Expression { ... }
    fn gt(self, other: impl Into<Expression>) -> Expression { ... }
    fn le(self, other: impl Into<Expression>) -> Expression { ... }
    fn add(self, other: impl Into<Expression>) -> Expression { ... }
    fn subtract(self, other: impl Into<Expression>) -> Expression { ... }
    fn multiply(self, other: impl Into<Expression>) -> Expression { ... }
    fn divide(self, other: impl Into<Expression>) -> Expression { ... }
    fn modulus(self, other: impl Into<Expression>) -> Expression { ... }
}

Provided Methods§

Source

fn as_expr(self) -> Expression

Source

fn equals(self, other: impl Into<Expression>) -> Expression

Examples found in repository?
examples/third_person.rs (line 826)
729fn create_action_graph() -> AnimGraph {
730    let resources = init_res([
731        SKELETON,
732        SITTING_CLIP,
733        TURN_AND_SIT_CLIP,
734        POINTING_FORWARD_CLIP,
735        UPPER_BODY_MASK,
736    ]);
737
738    let parameters = vec![
739        init(
740            "fade_out",
741            InitialParameterValue::Event(FADE_OUT_EVENT.into()),
742        ),
743        init("turn_and_sit", false),
744        init("sit", InitialParameterValue::Event(SIT_EVENT.into())),
745        init("point_of_interest", InitialParameterValue::Vector([0.0; 3])),
746        init("enable_point_of_interest", false),
747        init(
748            "poi_cooldown",
749            InitialParameterValue::Event(COOLDOWN_EVENT.into()),
750        ),
751    ];
752
753    const COOLDOWN_EVENT: &str = "cooldown";
754    const FADE_OUT_EVENT: &str = "fade_out";
755    const SIT_EVENT: &str = "sit";
756
757    const POINTED_EVENT: &str = "pointed";
758
759    let pointing_cooldown = endpoint(tree([
760        reference_pose(),
761        state_event(COOLDOWN_EVENT, true, EventEmit::Entry),
762        alias("bounce_back", blend_in(ALPHA_ZERO, Seconds(5.0))),
763    ]));
764
765    let off_pose = endpoint(tree([
766        reference_pose(),
767        alias(
768            "poi_offset",
769            transform_offset("Hips", bind_parameter("point_of_interest")),
770        ),
771    ]));
772
773    const EMIT_ON_ENTER: EventEmit = EventEmit::Or(FlowState::Entering, FlowState::Entered);
774
775    let sitting_pose = endpoint(tree([
776        animation_pose(SITTING_CLIP),
777        state_event(ACTION_EVENT, true, EMIT_ON_ENTER),
778    ]));
779    let turn_and_sit_pose = endpoint(tree([
780        animation_pose(TURN_AND_SIT_CLIP),
781        state_event(ACTION_EVENT, true, EMIT_ON_ENTER),
782    ]));
783    let pointing_forward = endpoint(tree([
784        animation_pose(POINTING_FORWARD_CLIP),
785        remaining_event(
786            bind_route("animation_pose"),
787            POINTED_EVENT,
788            true,
789            TRANSITION_DURATION,
790            EventEmit::Never,
791        ),
792        state_event(UPPER_BODY_ACTION_EVENT, true, EMIT_ON_ENTER),
793    ]));
794    use QueryType::*;
795
796    const POINTING_STATE: &str = "Pointing";
797    const COOLDOWN_STATE: &str = "Cooldown";
798    let idling = state_machine(
799        "Idle",
800        [
801            state(OFF_STATE).with_branch(off_pose).with_transitions([
802                bind_route::<f32>("bounce_back")
803                    .not_equal(1.0)
804                    .immediate_transition(COOLDOWN_STATE),
805                bind_parameter::<bool>("enable_point_of_interest")
806                    .and(contains_inclusive(
807                        (0.4, 1.5),
808                        bind_route::<[f32; 3]>("poi_offset").projection(Projection::Length),
809                    ))
810                    .and(
811                        bind_route::<[f32; 3]>("poi_offset")
812                            .projection(Projection::Back)
813                            .gt(0.1),
814                    )
815                    .transition(POINTING_STATE, FADE_OUT_DURATION),
816            ]),
817            state(POINTING_STATE)
818                .with_branch(pointing_forward)
819                .with_transitions([bind_parameter::<bool>("enable_point_of_interest")
820                    .not()
821                    .or(event_is(POINTED_EVENT, QueryType::Active))
822                    .transition(COOLDOWN_STATE, FADE_OUT_DURATION * 2.0)]),
823            state(COOLDOWN_STATE)
824                .with_branch(pointing_cooldown)
825                .with_transitions([bind_route::<f32>("bounce_back")
826                    .equals(1.0)
827                    .immediate_transition(OFF_STATE)]),
828        ],
829    );
830
831    const OFF_STATE: &str = "Off";
832    const TURN_AND_SIT_STATE: &str = "Turn and sit";
833    const SITTING_STATE: &str = "Sitting";
834
835    let root = state_machine(
836        "Root",
837        [
838            state(OFF_STATE)
839                .with_branch(submachine("Idle"))
840                .with_transitions([
841                    event_is(FADE_OUT_EVENT, Exited)
842                        .and(event_is(SIT_EVENT, Active))
843                        .transition(SITTING_STATE, TRANSITION_DURATION),
844                    event_is(FADE_OUT_EVENT, Exited)
845                        .and(bind_parameter::<bool>("turn_and_sit"))
846                        .transition(TURN_AND_SIT_STATE, TRANSITION_DURATION),
847                ]),
848            state(SITTING_STATE)
849                .with_branch(sitting_pose)
850                .with_global_condition(
851                    event_is(FADE_OUT_EVENT, Exited).and(event_is(SIT_EVENT, Active)),
852                )
853                .with_transitions([event_is(SIT_EVENT, Exited)
854                    .as_expr()
855                    .transition(OFF_STATE, FADE_OUT_DURATION)]),
856            state(TURN_AND_SIT_STATE)
857                .with_branch(turn_and_sit_pose)
858                .with_global_condition(
859                    event_is(FADE_OUT_EVENT, Exited).and(bind_parameter::<bool>("turn_and_sit")),
860                )
861                .with_transitions([
862                    event_is(FADE_OUT_EVENT, Active)
863                        .as_expr()
864                        .transition(OFF_STATE, FADE_OUT_DURATION),
865                    event_is(SIT_EVENT, Active)
866                        .as_expr()
867                        .transition(SITTING_STATE, TRANSITION_DURATION),
868                ]),
869        ],
870    );
871
872    AnimGraph {
873        resources,
874        parameters,
875        state_machines: vec![root, idling],
876        ..Default::default()
877    }
878}
Source

fn not_equal(self, other: impl Into<Expression>) -> Expression

Examples found in repository?
examples/third_person.rs (line 803)
729fn create_action_graph() -> AnimGraph {
730    let resources = init_res([
731        SKELETON,
732        SITTING_CLIP,
733        TURN_AND_SIT_CLIP,
734        POINTING_FORWARD_CLIP,
735        UPPER_BODY_MASK,
736    ]);
737
738    let parameters = vec![
739        init(
740            "fade_out",
741            InitialParameterValue::Event(FADE_OUT_EVENT.into()),
742        ),
743        init("turn_and_sit", false),
744        init("sit", InitialParameterValue::Event(SIT_EVENT.into())),
745        init("point_of_interest", InitialParameterValue::Vector([0.0; 3])),
746        init("enable_point_of_interest", false),
747        init(
748            "poi_cooldown",
749            InitialParameterValue::Event(COOLDOWN_EVENT.into()),
750        ),
751    ];
752
753    const COOLDOWN_EVENT: &str = "cooldown";
754    const FADE_OUT_EVENT: &str = "fade_out";
755    const SIT_EVENT: &str = "sit";
756
757    const POINTED_EVENT: &str = "pointed";
758
759    let pointing_cooldown = endpoint(tree([
760        reference_pose(),
761        state_event(COOLDOWN_EVENT, true, EventEmit::Entry),
762        alias("bounce_back", blend_in(ALPHA_ZERO, Seconds(5.0))),
763    ]));
764
765    let off_pose = endpoint(tree([
766        reference_pose(),
767        alias(
768            "poi_offset",
769            transform_offset("Hips", bind_parameter("point_of_interest")),
770        ),
771    ]));
772
773    const EMIT_ON_ENTER: EventEmit = EventEmit::Or(FlowState::Entering, FlowState::Entered);
774
775    let sitting_pose = endpoint(tree([
776        animation_pose(SITTING_CLIP),
777        state_event(ACTION_EVENT, true, EMIT_ON_ENTER),
778    ]));
779    let turn_and_sit_pose = endpoint(tree([
780        animation_pose(TURN_AND_SIT_CLIP),
781        state_event(ACTION_EVENT, true, EMIT_ON_ENTER),
782    ]));
783    let pointing_forward = endpoint(tree([
784        animation_pose(POINTING_FORWARD_CLIP),
785        remaining_event(
786            bind_route("animation_pose"),
787            POINTED_EVENT,
788            true,
789            TRANSITION_DURATION,
790            EventEmit::Never,
791        ),
792        state_event(UPPER_BODY_ACTION_EVENT, true, EMIT_ON_ENTER),
793    ]));
794    use QueryType::*;
795
796    const POINTING_STATE: &str = "Pointing";
797    const COOLDOWN_STATE: &str = "Cooldown";
798    let idling = state_machine(
799        "Idle",
800        [
801            state(OFF_STATE).with_branch(off_pose).with_transitions([
802                bind_route::<f32>("bounce_back")
803                    .not_equal(1.0)
804                    .immediate_transition(COOLDOWN_STATE),
805                bind_parameter::<bool>("enable_point_of_interest")
806                    .and(contains_inclusive(
807                        (0.4, 1.5),
808                        bind_route::<[f32; 3]>("poi_offset").projection(Projection::Length),
809                    ))
810                    .and(
811                        bind_route::<[f32; 3]>("poi_offset")
812                            .projection(Projection::Back)
813                            .gt(0.1),
814                    )
815                    .transition(POINTING_STATE, FADE_OUT_DURATION),
816            ]),
817            state(POINTING_STATE)
818                .with_branch(pointing_forward)
819                .with_transitions([bind_parameter::<bool>("enable_point_of_interest")
820                    .not()
821                    .or(event_is(POINTED_EVENT, QueryType::Active))
822                    .transition(COOLDOWN_STATE, FADE_OUT_DURATION * 2.0)]),
823            state(COOLDOWN_STATE)
824                .with_branch(pointing_cooldown)
825                .with_transitions([bind_route::<f32>("bounce_back")
826                    .equals(1.0)
827                    .immediate_transition(OFF_STATE)]),
828        ],
829    );
830
831    const OFF_STATE: &str = "Off";
832    const TURN_AND_SIT_STATE: &str = "Turn and sit";
833    const SITTING_STATE: &str = "Sitting";
834
835    let root = state_machine(
836        "Root",
837        [
838            state(OFF_STATE)
839                .with_branch(submachine("Idle"))
840                .with_transitions([
841                    event_is(FADE_OUT_EVENT, Exited)
842                        .and(event_is(SIT_EVENT, Active))
843                        .transition(SITTING_STATE, TRANSITION_DURATION),
844                    event_is(FADE_OUT_EVENT, Exited)
845                        .and(bind_parameter::<bool>("turn_and_sit"))
846                        .transition(TURN_AND_SIT_STATE, TRANSITION_DURATION),
847                ]),
848            state(SITTING_STATE)
849                .with_branch(sitting_pose)
850                .with_global_condition(
851                    event_is(FADE_OUT_EVENT, Exited).and(event_is(SIT_EVENT, Active)),
852                )
853                .with_transitions([event_is(SIT_EVENT, Exited)
854                    .as_expr()
855                    .transition(OFF_STATE, FADE_OUT_DURATION)]),
856            state(TURN_AND_SIT_STATE)
857                .with_branch(turn_and_sit_pose)
858                .with_global_condition(
859                    event_is(FADE_OUT_EVENT, Exited).and(bind_parameter::<bool>("turn_and_sit")),
860                )
861                .with_transitions([
862                    event_is(FADE_OUT_EVENT, Active)
863                        .as_expr()
864                        .transition(OFF_STATE, FADE_OUT_DURATION),
865                    event_is(SIT_EVENT, Active)
866                        .as_expr()
867                        .transition(SITTING_STATE, TRANSITION_DURATION),
868                ]),
869        ],
870    );
871
872    AnimGraph {
873        resources,
874        parameters,
875        state_machines: vec![root, idling],
876        ..Default::default()
877    }
878}
Source

fn lt(self, other: impl Into<Expression>) -> Expression

Source

fn ge(self, other: impl Into<Expression>) -> Expression

Examples found in repository?
examples/compiler_global.rs (line 17)
12    fn construct_data() -> AnimGraph {
13        fn global_number(name: &str) -> Expression {
14            Expression::CompilerGlobal(name.to_owned())
15        }
16
17        let condition = bind_parameter::<f32>("a").ge(global_number(ALMOST_PI));
18        let endpoint = endpoint(state_event(TEST_EVENT, condition, EventEmit::Always));
19
20        let machines = [state_machine("Root", [state("StateA").with(endpoint, [])])];
21
22        AnimGraph {
23            state_machines: machines.into(),
24            ..Default::default()
25        }
26    }
Source

fn gt(self, other: impl Into<Expression>) -> Expression

Source

fn le(self, other: impl Into<Expression>) -> Expression

Source

fn add(self, other: impl Into<Expression>) -> Expression

Source

fn subtract(self, other: impl Into<Expression>) -> Expression

Source

fn multiply(self, other: impl Into<Expression>) -> Expression

Source

fn divide(self, other: impl Into<Expression>) -> Expression

Source

fn modulus(self, other: impl Into<Expression>) -> Expression

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§