Note: This attribute is not supported in this version of Pueblo/UE.
This is an <img> field attribute which specifies a command related to VRML. This field may also be used to display 2-dimensional graphics in the sizeable graphics pane.
This syntax will probably change somewhat in future releases of Pueblo to make it more consistent. The old syntax will be supported.
There are four forms of the xch_graph attribute. The first form loads a VRML scene. The 'href' attribute specifies which scene to load. Here is an example of this form:
<img xch_graph=load href="http://www.chaco.com/vrml/room.wrl">
This form may also be used to load a 2-dimensional graphic into the graphics pane, by specifying a .jpg, .gif, or .bmp file to load. For example:
<img xch_graph=load href="http://www.chaco.com/room.gif">
The second form causes the current graphics image to be drawn before the client proceeds. It's useful after modifying a VRML node, to force the graphics module to draw what you've sent it immediately. Here is an example of this form:
<img xch_graph="draw">
The third form causes the graphics pane to be hidden:
<img xch_graph=hide>
The last form of the xch_graph command changes the value of a field in the current VRML scene by sending a "set_fieldName" event to the VRML viewer. There are two ways that you can do this:
<img xch_graph="event nodeName fieldType eventName args">
<img xch_graph="event nodeName fieldType eventName args" xch_graph_vrml="vrml code">
where the values are as follows:
|
nodeName |
is any node named by the DEF keyword. It may also may be a period-delimited qualified name, such as MySeparator.MyRotation |
|
fieldType |
is the VRML type of the field to change. Currently supported are SFRotation, SFLong, SFVec3f, and SFNode. This must correspond to the correct field type of the field to be changed. See the VRML spec for descriptions of the SFRotation, SFLong, and SFVec3f field types. Type SFNode corresponds to a single node, and is specified by either name (for an existing node to be operated upon) or VRML code (for a new node to be added). |
|
eventName |
name of the event to send. This is usually the name of the field to change, prepended by "set_". |
|
args |
arguments to the field change event. |
|
vrml code |
is actual VRML code to be used in the event. Do not precede it with the standard VRML 1.0 header, this is assumed. This code is compiled and then used by the event, such as adding it as a child node. It must compile to one top-level node. That node may have any number of children, of course. To use embedded double quotes, such as those around SFString fields, use HTML entities for the quotation marks, either '"' or '"'. Note: You should keep this code as short as possible through the use of WWWInline nodes. There is a limit of 4,000 characters for each HTML tag. |
The following table lists the currently supported events, their types, and their arguments.
Event Name |
Node Types Affected |
Event Type |
Field Affected &(comments) |
Arguments |
|
add_children |
Separator Group Switch |
SFNode |
(add a child) |
No args; VRML code should be supplied as the argument to xch_graph_vrml. See the note below regarding the types of nodes that can be added. |
|
remove_children |
Separator Group Switch |
SFNode |
(remove a child) |
Name of child to remove. See the note below regarding the types of nodes which can be added. |
|
set_center |
Transform |
SFVec3f |
center |
new center vector |
|
set_rotation |
Transform Rotation SpinGroup |
SFRotation |
rotation |
new rotation, as four floats: xAxis, yAxis, zAxis, angle |
|
set_scaleFactor |
Transform Scale |
SFVec3f |
scaleFactor |
new scale factor |
|
set_scaleOrientation |
Transform |
SFRotation |
scaleOrientation |
new orientation rotation |
|
set_translation |
Transform Translation |
SFVec3f |
translation |
new translation vector |
|
set_whichChild |
Switch |
SFLong |
whichChild (to select a child of the switch) |
number of child, zero-based. |
Note: It is only permissible to add or remove nodes which do not 'leak' state to other portions of the scene graph. The following node types can not be added or removed directly:
|
Background |
BaseColor |
Environment |
Group |
|
Coordinate3 |
Info |
FontStyle |
Material |
|
MaterialBinding |
MatrixTransform |
Normal |
NormingBinding |
|
Rotation |
Scale |
ShapeHints |
Texture2 |
|
Texture2Transform |
TextureCoordinate2 |
Transform |
Translation |
It is legal to add a leak-proof parent node with these types as children. Chaco recommended that you add or remove Separator nodes, and include all other nodes as children of the Separator node being modified.
The following code loads a 2-dimensional JPEG image into the graphics pane:
<img xch_graph=load href="http://www.chaco.com/~coyote/graf/smronny.jpg">
This example loads a 3-dimensional scene into the graphics pane:
<img xch_graph=load href="http://bradley.bradley.edu/~dware/mystars.wrl">
This example sets the current viewpoint to camera #1. It assumes the standard VRML convention that there is a Switch node called Cameras. (Note that not all VRML files have such a node.)
<img xch_graph="event Cameras SFLong set_whichChild 1">
The following adds a VRML node to a Separator node. By placing a Transform inside the new Separator, we've made it possible to manipulate the location of the contents of the WWWInline later. Fetching of the WWWInline will start immediately after adding this new sub-tree to the VRML scene.
<img xch_graph="event MyRoot SFNode add_children" xch_graph_vrml="DEF MyGreenCylinder Separator{DEF MyTransform Transform {} WWWInline {name mycylinder.wrl} AsciiText { string "It's Ralph" } }">
The following changes the rotation affecting the WWWInline child added above.
<img xch_graph="event MyRoot.MyGreenCylinder.MyTransform SFRotation set_rotation 0. 1. 1. 1.">
To send multiple lines of VRML in one "add_children" event, use HTML "encodings". The HTML encoding for a linefeed is " ", so to send the following VRML code on multiple lines, you would use a construct like this:
<img xch_graph="event AvatarRoot SFNode add_children" xch_graph_vrml="DEF MyGreenCylinder Separator {
WWWInline { name m1red.wrl.gz } }" >
Note that you may want to use xch_mode=purehtml for these multiple line VRML code fragments. See the xch_mode documentation for more information.