|
|
|
Making Active Worlds
|
Active Worlds uses RenderWare 2.0 as its rendering engine. Building RenderWare objects can be a daunting task, since there is no front-end mechanism for building objects specifically for RenderWare. However, once you get the basic concepts under your belt you'll see that most objects can be created quickly and easily. This section is intended to make it easier to create suitable 3D objects for Active Worlds environments by outlining:
We recommend strongly that you read the book "Learning 3D Programming on the PC" by Richard Ferraro, published by Addison-Wesley. This book is based on RenderWare exclusively, and is essential for anyone who wants to use RenderWare in any way. We will assume you have this book and have read at least the most relevant parts of it. Reading the entire book would take a good while, and much of the material is only suitable for programmers, but before trying to create RenderWare objects you should at least read the highlights of the section on the Renderware Script Language and understand the basics of 3D rendering such as polygons, textures (and UV mapping), lighting, etc.. Ferraro's book is specific to RenderWare 1.4, and Active Worlds uses RenderWare 2.0, so we will discuss some of the differences in 2.0--but they are minimal for our purposes.
There are two basic ways to make RenderWare objects. The simplest approach for a basic object is to just type into the RWX file with a text editor. The other way to create objects is to import them from programs such as Caligari's TrueSpace or Autodesk's 3D Studio. We'll see that for simple objects the best approach is to just use a text editor, especially if you have AlphaWorld's base objects to draw on as an example. You should use a text editor to review RWX files even when you import objects, and in fact it is often necessary to "tweak" imported objects at least slightly.
Text editors such as Windows' Notepad or programmers' editors are crude tools for making 3D objects, but they have very important advantages. The biggest advantage to making objects this way is that you have complete control; the big drawback is that it's difficult to make complex objects. But since complex objects don't render easily, the text editor is by-and-large the tool of choice for making models.
You can also design Active Worlds objects using high-end visual design tools such as Autodesks's 3D Studio and Caligari's TrueSpace. This method is especially suitable for making complex objects such as avatars. You design the object, save it, and then run one of Criterion's converters to create an RWX file from your design. Currently the only converters are from VRML objects, TrueSpace, 3D Studio, and Autocad's DXF format (which will not preserve textures).
Once you have completed the conversion, you will need to take a look at your new object in a text editor and touch it up while viewing in a world or in RenderWare's RWVIEW program or RWXLOOK/RWXMOD.
When designing objects with high-end visual tools, keep in mind that they are not designed to create optimized objects that will render quickly. You should work to make sure your objects are centered, and that they contain as few polygons as possible. Our scope here doesn't include instructions for using these visual tools.
There are some basic rules for developing objects to build a world. To make an environment in which people will enjoy the depth of experience and overall speed of rendering, we suggest you keep these concepts in mind:
Let's make a few objects so you can get your feet wet with the concepts. First we'll use a text editor to create a simple panel, then we'll use Caligari's TrueSpace to create a more complex object and convert it to RenderWare format.
Before you make your first RenderWare object, get a few pieces of paper and a couple of sharp pencils. Then open a text editor (not a word processor, they insert control codes).
Step 1: Create a Clump Skeleton
First let's make a very simple object, a four meter panel. The first thing we do is type in the basic commands to the RenderWare scripting language to create a "clump:"
modelbegin clumpbegin #Here's where all clump information goes. clumpend modelend
Of course, the comment (which always starts with "#") can be replaced by your own comment, and can go anywhere in the file, either on its own line or to the right of a scripting command. As in programming, we suggest you only create comments where they are useful -- too many comments will clutter the file and also adversely affect the load time of the model.
Step 2: Add vertices
Now let's add the vertices for the panel. At this point it is best to make a rudimentary sketch on paper, showing the vertices and their order, possibly something like this:
Since the panel has no depth, all z coordinates are 0. Height and depth are both four meters - since the entire height of the panel will be above ground level, y coordinates vary from 0 to 4, where x coordinates vary from -2 to 2 in order to center the object in the x plane.
Now we'll add the vertices to our skeleton:
#Simple four meter panel..PAN4TEST.RWX modelbegin clumpbegin vertex -.2 .4 0 #top left vertex .2 .4 0 #top right vertex .2 0 0 #bottom right vertex -.2 0 0 #bottom left clumpend modelend
All Active Worlds building objects should be centered around 0X 0Z and the bottom edge of their bounding box should be at 0Y. This model will conform to those standards. The object has no depth, so all Z coordinates are 0. X coordinates are equidistant from 0 and Y coordinates start at 0. Note that vertex coordinates are scaled by ten-each 1 unit is equal to 10 meters (one cell) in Active Worlds.
Step 3: Make Polygons
Now to make our polygons we add two quad commands: Since we declared our vertices in clockwise order this is simple:
#Simple four meter panel..PAN4TEST.RWX
modelbegin clumpbegin vertex -.2 .4 0 #top left vertex .2 .4 0 #top right vertex .2 0 0 #bottom right vertex -.2 0 0 #bottom left quad 1 2 3 4 #back side quad 4 3 2 1 #front side clumpend modelend
Step 4: Add Color & Surface Values
Now we're almost there already, but we want to add both color and surface properties and a bitmap texture. Let's say we're using a gray stone surface texture. We want the "flat" version of the model, which Active Worlds shows before the texture has been downloaded, to look similar to the textured version. So we use these values:
color .6 .6 .6 #red, green blue surface .5 .3 0 #ambient, diffusion, shininess
To get color and surface values right for AlphaWorld's lighting, you really have to play with them and test them within an Active Worlds environment.
Step 5: Add UV Values
Now we have to add UV values to our vertices to make sure the texture is oriented as we want. In general, it makes sense to "wrap" textures twice or more in a four meter square. Wrapping them too loosely creates objects in which you can see pixels from too far away. What we're basically doing is wrapping 128 pixels of bitmap across four meters of space. But before we double the UV values let's look at a one-to-one map:
vertex -.2 .4 0 UV 0 0 #top left vertex .2 .4 0 UV 1 0 #top right vertex .2 0 0 UV 1 1 #bottom right vertex -.2 0 0 UV 0 1 #bottom left
We assume some knowledge of what UV is about already, but basically the Y coordinate goes from 0 at the top to 1 at the bottom of the bitmap, X goes from 0 (left) to 1 (right). This maps the bitmap rightside up on the square polygon. But we want two copies of the bitmap, so we'll double all the UV values.
Step 6: Add a Texture and Texturemode
While we're at it, let's add a bitmap texture, with a texturemode so that the bitmap looks good from all angles. We'll use texturemode foreshorten because even though it slows rendering, it makes textured objects look much much better when you're not facing them head-on. We'll also use lit because we want our objects to use the lighting in Active Worlds, showing shadow on one side and lighter color on the other. For objects that face upward or downward, the lit parameter isn't necessary and should be omitted to speed rendering. But for objects with vertical faces, we'll use lit despite the cost, so that we can make things look more realistic. Here is our finished RWX file:
# Simple four meter panel..PAN4TEST.RWX modelbegin clumpbegin vertex -.2 .4 0 UV 0 0 #top left vertex .2 .4 0 UV 2 0 #top right vertex .2 0 0 UV 2 2 #bottom right vertex -.2 0 0 UV 0 2 #bottom left color .6 .6 .6 #red, green blue surface .5 .3 0 #ambient, diffuse, specular texturemodes lit foreshorten quad 1 2 3 4 #back side quad 4 3 2 1 #front side clumpend modelend
The bitmaps used in objects should be "seamless," that is, the right-hand edge should meet with the left-hand edge smoothly, and similarly the bottom and top should meet continuously. Then if we want to make a matching panel that is 8 meters x 8 meters, we just double the UV values (to multiples of 4 in this case). This way we can make a suite of panels that all meet smoothly and look as if they were carved out of one piece of stone, wood, or whatever.
8x8 and 4x4 panels with seamless UV mapping--
PP03L.RWX (left) and PP03.RWX (right)
Besides quad, the main commands for creating polygons to make up objects are triangle and polygon. For special purposes, there are also higher-level commands such as cone, cylinder, cube, hemisphere, and sphere. Keep in mind when you use these higher-level commands that although they may look simpler in the RWX file, they can create large numbers of polygons.
If you have access to a C compiler and the RenderWare engine, you may want to create and/or change objects programmatically. There are commands in the RenderWare library which are accessible from programs that do not have equivalents in the scripting language. For instance, you could create a hemispherical object using the HEMISPHERE script command, but you must use a program to create UV values for each vertex that will wrap a texture properly around the hemisphere:
RwSphericalTexturizeClump(sphereclump);
globetexture=RwGetNamedTexture("test.bmp");
RwForAllPolygonsInClumpPointer(sphereclump,
(RwPolygon3dFuncPointer)RwSetPolygonTexture,
globetexture);
It is time-consuming to write programs just to generate objects, but occasionally there is a need for a really spectacular object to draw attention. Even with general building objects, if an object is to be rendered many times by many people, any time you can afford to spend with it to get it right is well spent.
One of the factors that causes the greatest slowdown in Active Worlds rendering performance is Z buffering. Z buffering is used by RenderWare to render objects that intersect, or that come close enough to intersecting that the engine can't tell that they don't intersect.
One of the most important things to avoid is intersection with the ground plane. You should design your objects to terminate at 0 on the Y axis to avoid this. Since the ground is usually slightly below this point, this will avoid having RenderWare render the ground and other objects much more slowly through Z buffering.
Animations are costly to make and costly to render, but they add a lot to the environment. Choose carefully which animations to support, and try to keep them minimal.
There are two methods of rendering animations in Active Worlds: Active Worlds supports the standard RenderWare animation technique of "stacking" bitmaps in a "filmstrip" texture. This method provides more control in environments where user construction is allowed, since only the named texture is used. It also allows you to control what surfaces of an object are animated. Another animation option is the animate command, which does not allow as tight control over where the animation is used, but allows much greater control over timing and ordering of frames.
To use a "filmstrip" bitmap, you create a bitmap that contains all the frames of your animation "stacked" vertically. For instance, a 4-frame animation is 128 pixels wide and 512 pixels high. This texture is applied to a polygon within the RWX file with the texture command, just as if it were a non-animated bitmap texture. The main drawback to this approach is that the frame rate and order cannot be controlled as with the animate command.
You can achieve greatest control over animations using Active Worlds-specific commands. Animations can be running or stopped, and looping or non-looping. Animations default to running and looping as with the filmstrip technique, but can be stopped or made non-looping. You can use triggers to change an animation's state in various ways. See "Object Actions" in the client help file for more details about triggers before proceeding here if you haven't looked at it yet.
Animate has six parameters: object name, animation name, image count, frame count, frame rate, and an optional list of frames which determines the playing sequence:
Examples:
To assign a simple seven frame animation called "boggle" with a frame rate of 250 ms to an object, click on the object while using the Active Worlds client and enter this in the action field:
animate me boggle 7 7 250
To animate a figure jumping up and down, you only need to create images for the jump up, and then you can use them again for the trip down. Say you have 5 frames total from the bottom to the top of the jump. You'd get a jump up and down like this:
animate me jump 5 9 300 1 2 3 4 5 4 3 2 1
This next animation uses the same image sequence, but repeats frames to simulate a pause at the top of the jump:
animate me jump 5 11 300 1 2 3 4 5 5 5 4 3 2 1
Some additional commands have been added to supplement the animate command:
Examples:
This action creates a situation where an object's animation changes frame every time the objects is bumped into (or walked through if the object is non-solid and the user isn't holding down SHIFT.)
bump frame +1
This creates an animated object that doesn't start showing animation until bumped.
create animate me wow 10 10 300, astop; bump astart on
To expand this so that the animation starts when a hidden bump panel is touched, change the command on the animated object to:
create name s, animate me wow 10 10 300, astop
And for the trigger wall's action use:
create visible off, solid off; bump frame astart screen off
To create three figures in a row that jump up and down, on the first figure use:
create animate me jump 5 9 300 1 2 3 4 5 4 3 2 1, astop; bump astart; adone astart fig2
On the second figure use:
create name fig2, animate me jump 5 9 300 1 2 3 4 5 4 3 2 1, astop; adone astart fig3
And on the third figure use:
create name fig3, animate me jump 5 9 300 1 2 3 4 5 4 3 2 1, astop
When the first figure is bumped, it jumps up and down. Then the second one jumps up and down, then the third one.
Creating and testing animations can take a lot of time and patience, as well as some building skill. At times you may need to leave the scene and come back, or even quit the client and restart it altogether, for animations to work properly. Also bear in mind that once a texture is associated with a certain mask, it is cached and you must restart the client to change it.