Programming Languages
What is VRML?
VRML stands for Virtual Reality Modeling Language. VRML is a specification for displaying 3-dimensional objects on the World Wide Web. We can think of it as the 3-D equivalent of HTML. Files written in VRML have a ".wrl" extension (short for world). To view these files, one need a VRML browser or a VRML plug-in to a Web browser.
VRML produces a hyperspace , a 3-dimensional space that appears on your display screen. And you can figuratively move within this space. That is, as you press keys to turn left, right, up or down, or go forwards or backwards, the images on your screen will change to give the impression that you are moving through a real space.
Tips
Navigation
Most VRML browsers support multiple modes of navigation. One method is POINT (or LOOK), which allows users to click on objects that they wish to navigate to. However, this disables linkable objects. Other modes include FLY, SPIN, SLIDE, etc.
Perhaps the easiest way for novices to navigate VRML is to use WALK mode. Unlike other modes that may leave the user wandering hopelessly upside-down, or jetting off into space, WALK always keeps your viewpoint upright, looking parallel to the horizon.
To navigate in WALK mode, click and drag your pointer (mouse, trackball, pen, etc) in the VRML display area -- being careful not to click on an object unless you wish to link to a new URL. Dragging upwards will generally move your viewpoint forward; dragging downwards will move you back. Dragging left or right, will swing your viewpoint left and right.
Get lost in WALK mode:
If you get lost in WALK mode - keep turning left... eventually you'll turn to face the main part of the model.
Colors
Use colors whenever possible. Only use textures when absolutely necessary, they slow down traveling in your world.
Small Worlds
Keep your worlds small, as its harder for the user to navigate with the world still downloading.
Inlining of objects
Inline the objects that you are animating, or that are not part of the scene.
LOD nodes
Use LOD nodes if your world is large in size, and you want the user to navigate the world even when its downloading.
Differences between VRML 1 & 2
Animation, JAVA behaviors, JavaScript, and sound are the differences between VRML 1 & 2. You should try to use whatever you can to make your site move!
BspTree Node
The BspTree is a preferment technique to reduce the amount of geometry passed to the rendering engine. Game Engines are typically based on some BspTree's logic. The BspTree is introduced as a native implemented VRML 2.0 node, other browser can display the model by using a PROTO implementation of the node.
A BSP tree allows us to make a world just about as big as we want without it slowing down the computer. To use a BSP tree think in terms of having your world cut up into a grid of tiles. Each tile can be thought of as a world in it self. So long as you put all your objects in a tile and don't have them overlap into any other tile it is easy to make big fast worlds. A BSP node is not a standard VRML97 node however it will be compatible with any VRML97 browser, you just wont get any speed performance gained unless you use a browser like Blaxxun Contact. Although this BSP Node was developed by Blaxxun for contact, BSP trees have been commonly used in computer games for some time that require large areas.
Are Spheres Faster than IndexedFaceSets?
Because I did low level programming in DirectX 3D before i ever new about VRML It never entered my mind that there would be any difference in the speed between a Sphere node and a IndexedFaceSet node in VRML. The reason I thought this was because when I programmed in Direct X there was no such thing as a function that would render a sphere only functions to render triangles. So it seemed only natural to assume that any shape that was more complex than a triangle had to be at some stage broken down into triangles.
Also your hear of video card performance being measured in triangles per second. If you press F7 in contact to see the performance info displayed at the bottom of your browser in the message bar you will see readouts of triangles regardless of what the shape is, be it a IndexedFaceSet or just a single Sphere.
Later I have wondered of the possibilities of the VRML 3d engine some how being able to take advantage of triangles being arranged in special case patterns such as spheres but I thought if this was the case I did not think there would be much to be gained.
Speeding Things Up Using Matrices
To my understanding VRML transform nodes have to keep being set up or at least watched by the 3d engine because all transform nodes can be potentially animated. Since setting up transform nodes are expensive on CPU processing power this is wasteful for objects that never need to be animated. One theoretical solution is to make each object in an IndexedFaceSet and position the coordinates where they are wanted globally so as to avoid any need for Transformations. This would in practice probably be awkward to do and could result in huge amounts of download time because there would be no downloaded data ever reused to make other objects. The solution here is to use the vrmlscript VrmlMatrix class to transform all your obj ects to where they are wanted just like you would when using a Transform node but the difference is its only done once when the world initializes.
How to build DOOM VRML worlds your self
Worlds for the DOOM II Game from ID-software are stored in a format that is convertible to VRML. In addition there are shareware and freeware tools available for editing and creating worlds for DOOM. First you need to have DOOM II.
Get a free DOOM WAD Editor and construct your own DOOM WAD-Worlds. WAD Files and editing programs can be found on the Internet by searching for sites via keywords like "wad", "doom".
Convert the WAD File to VRML using the Doom2Wrl program.
Doom 2 wrl was created by Ken Russel, SGI. We used a modified version for converting to the proper multi-user coordinate scale, the source is available as zip-file. (Microsoft Visual C and JPEG Library required for compilation.)
For tuned performance the generated VRML code can be BSP-Tree optimized for blaxxun Contact.
The source of Doom2Vrml could be further enhanced to support things, monsters, teleporters and so on. Currently only some doors can be opened with a click.
General
Look at your world through all monitors. If you have any friends with larger or smaller monitors, ask them to look at the scene.
Look at your world through different VRML browsers.
Reduce and simplify geometry.
Remove unneeded faces.
Use instancing (DEF once USE many Times).
Don't disable backface culling (solid FALSE) if it is not totally necessary.
General for blaxxun Contact 3D (but may also be true for other browsers)
Specify visibilityLimit in NavigationInfo for better z-range adoption and for more culled geometry.
Many Text Nodes are expensive, an alternative are textures representing text.
Few IndexedFaceSet's with many faces are more preferment than many single face.
IndexedFaceSets with few or only a single face.
If the plug-in is embedded into a frame set any animations like animated GIF's in the other frame may slowdown the 3D operation.
Flat shading can be forced with the default value for creaseAngle 0 and normalPerVertex FALSE.
For unlit materials use Material {diffuseColor 0 0 0 emissiveColoryourColorHere } The specularColor is already black by default. Prescale textures to a power of 2.
Specific to the blaxxun Contact 3D Direct 3D Version
If using many rectangles each with a different texture, try to combine several textures in one image, and adapt texture coordinates.
Color per vertex doesn't work in Direct3D Ramp Driver ("high speed"), in RGB/Hardware mode color per vertex Shapes are unlit.
Shapes with more than 1024 (hardware) / 2020 vertices (software) or color per face requires some extra preprocessing.
Animating vertex attributes (e.g. coordinates) of shapes works fastest up to the limit of 1024/2020 vertices try GIF Textures instead of JPEG's for Ramp Driver prefer modeling with convex polygons instead of generating an equivalent set of triangles.
Specific to OpenGL
If the model is targeted to run on a software only OpenGL platform or OpenGL hardware without texture acceleration:
- Limit the amount of textures.
- Prescale textures to a power of 2.
- Use colors per face or color per vertex to add surface detail.
Other considerations
The "software only" rendering speed depends largely on the size of the rendering window. A VRML World could be presented using several viewing choices like:
- A small VRML window embedded in a HTML page.
- A full screen VRML link for users preferring full screen viewing or using hardware acceleration.
- Fixed size windows or fixed size embeds (without %) are limiting the user to resize the rendering area. Other elements on the HTML-Page like animated-gif's may slowdown the VRML browser.
- Another aspect is how the scene is decomposed for downloading. blaxxun Contact 3D starts the loading of Inlines and other nodes with URL fields in the order the children of Group nodes are specified, walking into the deeper levels first. Inlines in currently not traversed parts (e.g. non-active children of a Switch/LOD node etc.) are loaded if needed. In Internet Explorer Contact 3D starts the download of such in-active children if no other download activity is pending. For LOD nodes with direct Inline child nodes, Contact 3D will display the lower LOD-Level if the Inline is not loaded yet. BspTree nodes are traversed by default in front to back order with respect to the viewer.
- Contact 3D currently does not unload nodes from memory. A script using node.addChildren/removeChildren Browser.createVrmlFromString could be used to perform scene memory management. A node is being deleted if no other reference exists to the node.
Specific to blaxxun Contact 3D vrmlscript/JavaScript interpreter speed
Minimize the number of eventOut's generated change an eventOut only if the value really changed (less redraw)
Original
x = 0; if (t>0.5) x=t; event = x; Better x = 0; if (t>0.5) { x=event=t; else if (x != 0) event = x; |
Change an MF Event once at the end of the script and not individual elements in the body of a loop if applicable expensive calculations could be moved out of inner loops an initialize() script function can be used to set the startup state.
|
|||