Expressions

Expressions are pseudo-code instructions which allow to perform simple mathematical operations on various source of data. Data can come from PPAttributes, Channels, Ramp nodes... Expressions can be used in the ChannelOperator and Set Bone Behaviors or in the Expression Trigger in Triggers. The syntax for the expression is:

[Operand1] [operator] [Operand2] where [operator] and [Operand2] are optionals.

Expresion results are only of type float or vector3.

Expression with exponential values, such as 1e5 or 10.3e-6 will be interpreted as channels, please avoid using exponential notations.

Operands

Available operands are:

Constant a constant float or vector3 value: 0.5, 1, <<1., 2., 3.>>...
Golaem Attribute

Golaem Attribute, which can be accessed via two keywords : 

  • this.attribute.anAttributeName : looks for a CrowdField per entity attribute, or an Entity Type attribute, with "anAttributeName" name.
  • this.sharedAttribute.aSharedAttributeName : looks for a shared CrowdField (not per entity) attribute, named "aSharedAttributeName"
PPAttribute a float of vector3 PPAttribute name: particleId, mass, position (for more information about how to use ppAttributes, see ppAttributes Handling).
Python Expression any Python expression which returns a float value: getCurrentTime(). The Python expression can contain special tags such as #pid#, #ps#, #gid# or #tid# to interact with particles, or ##innerExpression## to use a Channel or a Golaem Attribute (see Technical Documentation).
MEL Expression any MEL expression which returns a float value: getCurrentTime(). The MEL expression can contain special tags such as #pid#, #ps#, #gid# or #tid# to interact with particles, or ##innerExpression## to use a Channel or a Golaem Attribute (see Technical Documentation).
Channel a Channel name in the form entityName.(behaviorName).channelName.(componentName). Several entityNames are available:
  • this to specify the current Entity running this Expression: this.beMotionShape1.motionId.
  • master to specify the current Master Entity (when using a Master-Slave Behavior) : master.beMotionShape1.isRunning
  • closestEntity to specify the closest Entity to the current Entity running this Expression: closestEntity.position.
  • closestEntityOfTypeX to specify the closest Entity of Entity Type X to the current Entity running this Expression: closestEntityOfType2.scale.
  • entityX to specify a specific Entity of Id X: entity5001.beGotoShape1.isRunning.

The complete list of Chanels and other examples of valid Channel Names can be found here.

closestEntity and closestEntityOfTypeX will be evaluated each frame.

Note that compound entityNames are possible by using enclosing inner expression with ##, such as in the expression 

entity##this.attribute.aTargetId##.position 

Only one level of inner expression is handled, whereas several inner expressions can be used sequentially. Therefore using nested inner expressions will yield to undetermined behavior. In that case one must chain several expression (potentially via channel operators)

 

Ramp

a Crowd Ramp identifier which is connected to the Crowd node which allows to use Expressions: #ramp0# which will correspond to the Crowd Ramp node connected at slot [0] in the Crowd node:

Operators

Available operators are +, -, *, /, %

Expression Examples

Here are a couple of examples of valid Expressions:

  • 2.5
  • <<1.2, 2.4, 3.6>> * 2
  • FloatPPAttr + 0.1
  • FloatPPAttr % 100
  • VectorPPAttr - << 1, 0, 0 >>
  • VectorPPAttr * 2
  • VectorPPAttr[x] / FloatPPAttr
  • PythonCommand(#tid#) + FloatGlmAttr
  • MELCommand(#eid#) - VectorPPAttr[y]
  • this.beMotionShape1.currentRatio * 100
  • this.bonePosition.LeftArm
  • this.bonePosition.LeftArm[z] + this.bonePosition.RightArm[z]
  • this.boneOrientation.RightArm * <<2., 0., 1.5>>
  • this.renderingTypeId + FloatPPAttr
  • closestEntityOfType2.beLocomotionShape1.linearVelocity / 2
  • entity5001.paintedColor + <<1., 0., 0.>>
  • #ramp1# * 180
  • this.attribute.anAttributeName
  • master.sharedAttribute.aMasterAttributeName
  • entity##this.attribute.aTargetId##.position