User Tools

Site Tools


formula

Description

Describes a set of operations and relationships to apply to a given property in the scene.

Parent Objects

Properties

Name Description Default Required
output A string representing the object reference of the single-valued property to be targeted with the output from the formula. None yes
operations An ordered array of operation objects to apply, to derive the output value. None yes
stage A string representing the calculation stage that this formula’s output contributes to. May be one of “multiply” or “sum”. See Details section. “sum” no

Details

The operations are given in Reverse Polish Notation (RPN) and applied in order. The output is the top-level operand remaining on the stack after applying all operations.

The operations array must contain at least one push operator and there must be at least one operand remaining on the stack at the end of the operation sequence, which will be pushed to the target channel. If the stack contains insufficient entries for a given operator, the results of that operator are undefined.

Multiple formulas may output to the same property, and if they do there must be some logic to determine how the results will be accumulated onto the property. The stage element allows a formula to specify how its output will be combined with other outputs that may target the same property. The current implementation supports a two-stage combiner. The outputs for all formulas that specify “multiply” as their stage will be multiplied together and the result multiplied by the sum of the outputs of all formulas that specify “sum” as their stage.

output = (sum1+sum2+sum3+...sumN) * multi1 * multi2 * multi3 *...*multiN

More stages may be introduced in the future to support more complex combinations of outputs.

Example

{
    "output" : "upper_leg:figures/Unimesh#upper_leg?rotation/x",
    "operations" : [
        { "op" : "push", "url" : "hips:figures/UniMesh#hips?rotation/x" },
        { "op" : "push", "url" : "hips:figures/Daphne#DaphneHeadLarge?value" },
        { "op" : "push", "val" : 1.7 },
        { "op" : "add" },
        { "op" : "mult" },
    "stage" : "multiply"
    ]
}