Flex-VR Content Structuralization (Building Configurable 3D Web Applications with Flex-VR) Part 2

Communication Commands

The following commands are used to enable communication between VR-Beans in a virtual scene.

Call The Call command may be used to call methods of the same VR-Bean or other VR-Beans, enabling synchronous communication between VR-Beans. The target parameter specifies the target VR-Bean(s). This may be a single VR-Bean, a list of VR-Beans, or a category of VR-Beans. If the target parameter is omitted, the this value is used by default, which means that the method will be called in the same VR-Bean. The method parameter provides the name of the method to call and the actual values of the method parameters. VR-BML uses explicit naming of parameters in method calls, which results in more self-documenting code. Finally, the wait parameter specifies whether execution of the current VR-BML thread should be suspended until the execution of the method finishes or not. If wait is true, the next VR-BML command will be executed when the method execution finishes; if wait is false, execution of next VR-BML commands continues while the method is being executed. Example of use:

tmpe113-80_thumb_thumb


Publish The Publish command enables definition of a public value—either as a constant or as an expression using variables and events coming from a component. The Publish command is useful for creating objects that control the virtual scene. For example, a scale slider may be created and its scale value may be published using the Publish command. Whenever the setting of the slider changes, the public value is automatically changed. The public value is not created directly from the component’s event but it is recalculated by using expression specified in the value parameter. Names of VRML/X3D events in expressions are denoted starting with the tilde sign (“~”). The public parameter specifies the name of the public value.

Example of use of the Publish command:

tmpe113-81_thumb[2]

Assign The Assign command may be used to directly assign a public value to an event controlling a particular component of the VR-Bean. For example, a public value object_scale can be assigned to the set_scale event of components of all presentation objects. In this way, by changing the public value, the scale of all presentation objects in the scene can be changed.

The Assign command is similar to the ROUTE statement in VRML/X3D standards, with the main difference that ROUTEs must be established from the source to all receiving objects, which—in the case of a dynamically composed virtual scene— are not known at the design time.

Example of use:

tmpe113-82_thumb[2]

Link The Link command enables attaching events coming from VR-Bean components to method calls in the same or other VR-Beans. Since Beh-VR scenes are configured dynamically, the list of target VR-Bean objects may not be known at the design time. Therefore the Link command enables specifying in the target parameter either a list of concrete VR-Beans or a list of categories. If target is empty, the current VR-Bean is used by default.

The Link command has the following parameters:

•    comp—is the name of the component which is the source of events,

•    event—is the name of the event activating the method,

•    target—represents the list of target VR-Beans or the list of target VR-Bean categories—if not specified, the current VR-Bean is used,

•    method—specifies the name and the parameters of the method called.

Example of use of the Link command:

tmpe113-83_thumb[2]

Component Management Commands

The following commands are used to manage components representing VR-Beans in a virtual scene.

Load The Load command enables loading components into the Beh-VR scene. The uri parameter provides location of the component—this may be a remote object accessed by the HTTP protocol, an object from the local file system, or an object retrieved from a database. The comp parameter specifies the name that will be assigned to the newly loaded component. The active parameter specifies whether the component should be automatically activated after loading or should stay as inactive until it is activated with the Activate command. Example of use:

tmpe113-84_thumb[2]

Activate The Activate command activates or deactivates a component that has been loaded (using the Load command) into the Beh-VR scene. Because the loading process may include content generation, transmission over the network and parsing, it may take relatively long time. Therefore, to allow Beh-VR applications to switch on and switch off particular components in an efficient way, the Activate command may be used. Example of use:

tmpe113-85_thumb[2]

SetPosition The SetPosition command is used to position a component in the 3D space. The command has three parameters: comp, value and relative. The comp parameter specifies the name of the component to be positioned. The value parameter provides the new position of the component, while the relative parameter indicates whether the new position is absolute or relative to the current position. Example of use:

tmpe113-86_thumb[2]

SetScale The SetScale command permits setting a new scale factor to a component. The command has three parameters: comp, value and relative with the meaning similar as in the SetPosition command.

SetOrientation The SetOrientation command enables rotation of an object in the three-dimensional space. The comp parameter specifies the name of the component to be rotated. The axis and angle parameters specify the axis and angle by which the component should be rotated.

GetPosition The GetPosition command enables retrieval of the current position of a component in the scene. The position is assigned to a variable whose name is provided in the var parameter.

GetScale The GetScale command enables retrieval of the current scale of the component.

GetOrientation The GetOrientation command enables retrieval of the current cumulative orientation of the component in space in the axis-angle form.

Send The Send command enables sending events to a component. The comp parameter specifies the name of the component to which the event should be sent. The event parameter specifies the name of the event, and the value parameter specifies the value of the event to be sent. The optional index parameter may be used for multiple-value event types. Example of use of the Send command:

tmpe113-87_thumb[2]

Read The Read command enables retrieving the current value of an output field of a component. The names of the component and the event are provided in the comp and event parameters, respectively. The var parameter specifies the name of the variable that will hold the retrieved value. Example of use:

tmpe113-88_thumb[2]

Unload The Unload command is complementary to the Load command and causes removal of the object from Beh-VR scene (regardless whether the component is currently active or not).

Animation Commands

The following commands can be used to animate VR-Bean objects in a virtual scene.

MoveTo Using the MoveTo command it is possible to move a component from its current location to a new location. The comp parameter specifies the component to be animated. The position and relative parameters provide the target location. The time parameter specifies how long (in milliseconds) the animation should last. Finally, the wait parameter specifies whether execution of the current VR-BML thread should be suspended until the animation finishes or not. Example of use:

tmpe113-89_thumb[2]

RotateTo The RotateTo command permits rotating a component through an animation. The comp parameter specifies the name of the component. The axis and angle parameters specify how the component should be rotated. The meaning of the relative, time and wait parameters is analogous to the corresponding parameters in the MoveTo command.

ScaleTo The ScaleTo command is an animation command that enables changing the scale factor of a component. The command has five parameters: comp, value, relative, time, and wait (cf. MoveTo command).

Sensor Commands

Sensor commands enable adding interactivity to virtual scenes by allowing users to move, rotate or touch-activate components. These commands correspond to basic sensors available in the VRML/X3D standards.

PlaneSensor The PlaneSensor command enables a component to be moved by a user on a two-dimensional plane. The name of the component is provided in the comp parameter. The orientation parameter provides the orientation of the two-dimensional plane in space. The active parameter specifies whether the plane sensor should be activated or deactivated.

Example of use:

tmpe113-90_thumb[2]

SphereSensor The SphereSensor command enables a user to rotate a component in space. The comp parameter specifies the component which can be rotated. The active parameter specifies whether the sphere sensor should be activated or deactivated. Example of use:

tmpe113-91_thumb[2]

CylinderSensor The CylinderSensor command enables a user to rotate a component in space around an axis. The comp parameter specifies the component. The orientation parameter provides the orientation of the rotation axis in space. The active parameter specifies whether the sensor should be activated or deactivated. Example of use:

tmpe113-92_thumb[2]

TouchSensor The TouchSensor command enables to activate a component as a touch sensitive element. The comp parameter provides the name of the component to become a touch sensor. The method parameter specifies the method invocation, which should be executed when the component is touched. The active parameter specifies whether the touch sensor should be activated or deactivated. Example of use of the TouchSensor:

tmpe113-93_thumb[2]

VR-BML Expressions

The VR-BML scripts may use expressions in values of command parameters in a similar way as the X-VRML language (Chap. 4). Expressions provide a powerful way of parameterization of commands, verifying complex conditions, and calculating values. Expressions are enclosed in brackets “ { } ” and are evaluated before the command execution. The expression evaluator enables use of numerical, geometrical, Boolean, string, and list operators. In addition, an extensible library of functions is available.

The VR-BML expressions enable use of variables, public values and environment properties. Similarly as in many programming languages, a variable is simply a named value. In the VR-BML language, variables are local—they are visible only inside a single VR-Bean. Multiple VR-Bean objects can have variables with the same name and possibly different values. Variables are static (but not constant). One command may set a value of a variable, and other commands may read and change this value.

A public value is a named expression that is visible to all VR-Beans (Sect. 5.4.2). A public value may be a constant or it may be an expression based on environment properties, values of variables from the VR-Bean that has published this value, and values of events generated by the scene components in the same VR-Bean (e.g., the translation_changed event in VRML/X3D).

Flex-VR content model: hierarchy of presentation spaces

Fig. 5.4 Flex-VR content model: hierarchy of presentation spaces

An environment property is a named value that cannot be changed by a script. It may be either a static system value or a dynamic value set by the Beh-VR environment. An example of an environment property is TIME, which can be used as a value in expressions indicating the number of milliseconds passed from the beginning of the current virtual scene simulation.

Next post:

Previous post: