Visual style definition

General considerations

'Vstyle' are string properties of the Part, Joint, NeuroDef, and Model, modifying the appearance of the associated body elements. The system originated as a loose convention, where users can introduce custom styles to improve presentation of certain experiments. Therefore it was never very strict and only few styles are universally recognized by all Framsticks applications.

Rules:
- Vstyle value can be: empty, 'stylename' or 'stylename(arg1=value1,arg2=value2,...)
- Empty means default appearance
- Body elements can be influenced by both Model and the respective Part/Joint/NeuroDef Vstyle in a hierarchical manner (or at least could be; never used in practice)

Commonly used Model styles:
- "food" - the iconic Framsticks apple
- "manipulator" - robot hand displayed when catching and dragging Framsticks objects
- "boid" - bird model, used in 'boids.expdef'
- "mark" - location marker, used in 'mazes.expdef'
- "foram" and "reticulopodia" - see foraminifera.expdef

Commonly used Model style arguments:
- "color=0xRRGGBB" - modify the object color

The only use of the Part Vstyle in the official Framsticks apps:
- "flag" - adds the sign, as seen in the Welcome show of the Framsticks Theater


Use of visual styles in legacy applications (Framsticks GUI, Framsticks Theater)

The style definition comes from the "style" files. It defines the appearance of the OpenGL display. VisParams properties are created according to the "property:" sections in the file.

Framsticks calls user defined functions to create and update the object's visual elements during the simulation.

Each function name is built as follows: "[<element_Vstyle>_]<model_Vstyle>_<element>_<action>"

- action="build" when the visual model is first created (load or create geometry and set initial attributes)
- action="update" each time the visual model is displayed (modify geometry to reflect current position or attributes)

"<element>" refers to the kind of the element being processed (part, joint, neuron, model).
The script can access different objects depending on the kind:
1. part
can access:
- "MechPart" after calling Element.useMechPart()
- "Creature" after calling Element.useCreature()

2. joint
can access:
- "MechJoint" after calling Element.useMechJoint()
- "MechPart" after calling Element.useMechPart1() or Element.useMechPart2()
- "Creature" after calling Element.useCreature()

3. neuro
can access:
- "n" after calling Element.useNeuro()
- "Creature" after calling Element.useCreature()

4. model
can access:
- "Creature" after calling Element.useCreature()

"<element_Vstyle>" and "<model_Vstyle>" are element's and model's Vstyle fields. <element_Vstyle> is omitted when the field is empty. Empty model's Vstyle is replaced with "default". Both <element_Vstyle> and <model_Vstyle> can contain several words separated by "_". This is interpreted as a kind of subclassing, i.e. Framsticks will automatically look for the general version of the function when the specific one is not found. Example:
Assuming a part with Vstyle="green" in a model with Vstyle="food" the following functions will be tried until a match is found:
- green_food_part_...
- food_part_...
- default_part_...
So if the experiment requests visualizing some element as "green food" but the visual style only defines generic form of "food", Framsticks will automatically choose the best available visualization.
Global context>>Experiment definition>>Visual style definition