contents.gifindex.gif

pueblo00000000.gif Building TinyMUSH VRML animations

First, create a VRML room (See the Building In GozenMUSH Section for how to do that).

Next, build a VRML scene. For this tutorial, we'll use this simple VRML scene:

#VRML V1.0 ascii

Separator

{

DEF Cube_transform Transform { rotation 0 1 0 0 }

Cube { }

}

This scene consists of one cube and a 'Transform' node. The Transform node as it exists in the VRML file does nothing (because the fourth parameter after 'rotation' is 0), but using Pueblo's xch_graph <img> field, we can change this transform’s rotation field to result in an actual rotation.

To see this effect, save the VRML file, put it on a World-Wide Web server, and configure your room to point to the file's URL. (In GozenMUSH, you would do: '&vrml_url here=http://www.chaco.com/~vrmldemo/demo1.wrl').

Then, leave your demo room and re-enter it. Be sure the cube is visible. To rotate the cube, you can do this:

say <img xch_graph="event Cube_transform SFRotation set_rotation 0 1 0 .1">

This should rotate the cube slightly.

To make the cube rotate on its own, you could use this TinyMUSH code:

@create Cube Rotator

@lock cube rotator==me

drop cube rotator

&spin cube rotator=$spin:@dolist [lnum(32)]=@wait ##=@emit/noreturn <img xch_graph="event Cube_transform SFRotation set_rotation 0 1 0 [mul(0.1,##)] ">

Then type 'spin' to cause the cube to rotate by .1 radians per second for 32 seconds.

One drawback of this method of animation is that there is no synchronization between the World and the client. Here is another version of the Cube Rotator that synchronizes using <img xch_cmd> to force the client command to execute a command which causes the next <img xch_graph=event> rotation to be sent:

@create Rotation

@lock Rotation==me

&ROTATE Rotation=&angle_%0 me=[add(v(angle_%0),v(angle_inc))];@pemit/noreturn %0=<img xch_graph="event Cube_transform SFRotation set_rotation 0 1 0 [v(angle_%0)] "><img xch_cmd="rotate">

&RO Rotation=$rotate:@trig me/rotate=%#

&ANGLE_INC Rotation=-.1

The 'rotate' command starts this object's execution. The output of this command looks like this:

<img xch_graph="event Cube_transform SFRotation set_rotation 0 1 0 0.1"><img xch_cmd="rotate">

The first <img> changes the cube's rotation transform. The second one causes your Pueblo client to send another 'rotate' command on your behalf. Because the next 'rotate' command is sent after the new cube rotation is displayed, the World server stays in synch with your Pueblo client.

Also see

Pueblo VRML extensions

Adding Avatar support in VRML spaces

TinyMUSH extensions

Building TinyMUSH sound generators