Site hosted by Angelfire.com: Build your free website today!
 


22.2 VRML Export and VRML Applet - Part 2
 
Previous   Table of Contents   Home   Next

LAYOUT, LIGHTWAVE LAYOUT PROGRAM

Note that you are using the LAYOUT program not the MODELER program in this tutorial. Load Layout and do a 'File->Load Object...'. Load your reduced-polygon object.


LAYOUT, POSITIONING THE CAMERA

The Blaxxun Applet will need to have the camera positioned so it points at your object. If the camera is too close, you will see nothing, or the closer parts of your object will be sliced away. You MUST position your lens far enough back that this doesn't occur.

When you are positioning your camera, try bringing the camera in as close as you can until it chops your object, then back up from there. You can zoom in later by modifying the VRML code.

Select as the viewport type from the drop-down menu.

Click on the 'Move' tool or press the 't' key. Use the left mouse button to position the camera to the left, right, in or out. Use the right mouse button to position the camera up or down.

You can also position the camera by selecting as the viewport type.

In that case, select 'Move'. Back away with the ',' key or closer with the '.' key (as in Modeler).

Make sure the camera is the thing which is selected by clicking on or pressing SHIFT-C

Click on the blue up-arrow to move the camera in and out. When using applets, it's best not to move the camera sideways, or rotate it, just straight up and down or in and out. That makes it simpler for the applet to do the math which renders the object.

Press to set the camera angle changes, or press RETURN.

IMPORTANT - Blaxxun has a problem. If you move the camera too close, it will chop your object like a knife cut the front off; and, if you move the camera too close, you'll see nothing but a black screen.

The problem seems to be worse with shorter/squatter objects than tall objects.

Therefore, back your camera away from your object.

I'll show you how to manipulate the code so you can zoom closer by editing the VRML code, instead. However, you should try moving the camera as close as possible until it starts clipping the image. When it occurs, it will look like someone cut off the front part of your object with a knife.


LAYOUT, ADDING LIGHTS

Create a 'Distant Light' by choosing the drop-down menu.

Choose 'Add Distant Light'. You will be using Distant Lights because Blaxxun supports them well.

IMPORTANT - Don't use 'Spot Lights' because the Blaxxun Applet doesn't support them correctly.

Name the light 'RightLight'.


Move the light to the front-right of your scene by selecting from the 'Tools' section or pressing 't' (like in Modeler).

Click on the blue up-arrow and drag forward or backward with your mouse to move the light. Click on the red arrow and move the mouse left or right to move the light sideways.


Next, you will have to (press the 'y' key as in Modeler) the light.

Click on the red circle and drag your mouse sideways and the light will rotate. Point the arrow at your object. The light should be at approximately a 45 degree angle to your object. You'll see the light change on the object as you move it.


Press 'p' to bring up the 'Light Properties' window. Put 30 in the Light Intensity box and press the RETURN key.


The VRML export module forces a 100% intensity when you export the VRML, but this will help you see what it might look like. 25% - 30% is usually good for the RightLight.

Press to set the RightLight angles and movement, or press RETURN.

Create another 'Distant Light' and name it 'LeftLight', position it to the lower-left of your scene. Rotate it at about a 45 degree angle, pointing it at your object at its upper-right.

Press 'p' to bring up the 'Light Properties' window. Put 80 in the Light Intensity box and press RETURN. 80% - 100% is usually good for the LeftLight (depending on how far away the light source is, and how big your object is).

Don't take a long time getting the lighting correct, as no intensity values are passed once you save it as a VRML. At that time you'll have to experiment with the VRML values until you get the same sort of lighting effects. Setting light values now just helps you determine what you'll want later.

Press to set the LeftLight angles and movement, or press RETURN.

And, finally, create a third distant light and call it 'BackLight'. Position it so it's at the top-right when in 'Top' viewport type (behind your object) and angle it at about a 45 degree angle pointing towards your object.

Press 'p' to bring up the 'Light Properties' window. Put 25 in the Light Intensity box and press RETURN. 25% - 30% is usually good for the BackLight.

Press to set the BackLight angles and movement, or press RETURN.

IMPORTANT - You should delete the original Distant Light' (Layout calls it 'Light').

Otherwise, more than three light definitions will appear in your VRML file, which will be confusing for you and might overlight the scene.

To delete the 'Distant Light' which Layout calls 'Light', (after you've created your own three lights), choose at the bottom of the screen and from the dropdown menu above that button choose the light called 'Light'.

From the drop-down choose 'Clear Selected Items'. It will ask if you wish to remove the light from the scene. Click 'YES'.


LAYOUT, RENDER THE SCENE

After you've added the three 'Distant Lights', from the 'Top' viewport type it should look something like this.




Press 'F9' to render the scene. It will most likely be washed-out and will be too high contrast. The reason is that the light sources are each set to 50%. You will be setting the real values once you are in VRML. Since the VRML Export Module ignores the intensity settings, it's useless to set them now.






Once you have it looking a bit like you want it, save the scene with 'File->Save->Save Scene As...' and give it a scene name.


LAYOUT, EXPORTING SCENE AS VRML FILE

Finally, do a 'File->Export->Export Scene as VRML97'

Turn off 'Use Prototypes'. Turn on 'Embed Objects'. Turn on 'Lowercase Filenames'.




Select the 'Environment' tab. Ensure that 'Headlight' is not checked. Click Output.wrl and choose an output .WRL filename.


Click 'OK'.


Notice that the VRML file was not written until you clicked OK on the last requester.


LAYOUT, EDITING THE VRML FILE

You will now be editing the exported VRML file. A VRML file is just a cleverly disguised plain text file.

Open WordPad or a text editing program and do 'File->Open'.

Browse to the .WRL file that you just wrote and load it into the text editor.

Use the scroll gadget to move to the end of the text, and you'll find a line which begins with two ## signs.

From that section onward, you will be modifying a bit of code. This will allow the object to rotate on its own. If you didn't do that, there would be little reason to have a 3D applet, as the picture in the applet window would just look like any other non-moving JPG image.


LAYOUT, VRML CODE AS IT COMES FROM LIGHTWAVE

The end of the VRML code that comes from LightWave's Layout VRML Export module should look something like this:

<...................CODE BEGINS AFTER THIS...................>

## DEF vrml3_Sense SphereSensor { enabled TRUE }
] } # _ObjXForm End
,
DEF vrml3_ClickDetect TouchSensor { enabled TRUE }
] } # end of vrml3_XForm
DEF vrml3_Turner OrientationInterpolator {
key [
0.0000, 1.0000,]
keyValue [
0.0000 -1.0000 0.0000 0.0017,
0.0000 -0.9984 0.0000 6.2832,
]
}
DEF vrml3_Clock TimeSensor {
startTime -1
loop FALSE stopTime 0
cycleInterval 0.3333
}
,
DEF RightLight DirectionalLight {
color 0.3000 0.3000 0.3000
direction -0.7445 0.0506 -0.6657
intensity 1.3000
on TRUE
}
,
DEF LeftLight DirectionalLight {
color 0.8000 0.8000 0.8000
direction 0.7094 -0.0192 -0.7045
intensity 1.3000
on TRUE
}
,
DEF BackLight DirectionalLight {
color 0.3000 0.3000 0.3000
direction -0.7059 0.0000 0.7083
intensity 1.3000
on TRUE
}
,
DEF MasterFrame_Clock TimeSensor {
startTime 0
loop TRUE stopTime 0
cycleInterval 0.0000
}
,
] }
}
ROUTE vrml3_Clock.fraction_changed TO vrml3_Turner.set_fraction
ROUTE vrml3_Turner.value_changed TO vrml3_XForm.set_rotation
ROUTE vrml3_ClickDetect.touchTime TO vrml3_Clock.startTime
<..................CODE ENDS BEFORE THIS..................>


They've ALMOST got it working.

There are a few changes that have to be made, though, before it will rotate nicely.

First, you must change: DEF vrml3_Turner OrientationInterpolator {
key [
0.0000, 1.0000,]
keyValue [
0.0000 -1.0000 0.0000 0.0017,
0.0000 -0.9984 0.0000 6.2832,
]
}


LAYOUT, CODE THAT MAKES IT ROTATE

So that the key and keyValues are correct for a full rotation:

DEF vrml3_Turner OrientationInterpolator {
key [ 0, .25, .5, .75, 1.0 ]
keyValue [
0 1 0 0 ,
0 1 0 -1.570796,
0 1 0 -3.141593,
0 1 0 -4.712389,
0 1 0 -6.283185
]
}


Second, you must change:

DEF vrml3_Clock TimeSensor {
startTime -1
loop FALSE stopTime 0
cycleInterval 0.3333
}


LAYOUT, CODE THAT CORRECTS THE SPEED OF ROTATION

... to loop is TRUE, (not FALSE) and the cycleInterval to 7.0, not 0.3333:

DEF vrml3_Clock TimeSensor {
startTime -1
loop TRUE stopTime 0
cycleInterval 7.0
}


If you increase the cycleInterval value to 15, the rotation will slow down, if you decrease it, the rotation will speed up.

To get the three lights to not be super-saturated and high contrast you have to change the intensity values for the the three lights (it may say 1.0, or 1.33, or some other value, but that value has nothing to do with the intensity value you entered by pressing 'p' in Layout).


LAYOUT, CODE THAT CORRECTS THE LIGHTING

Change the intensity for the BackLight to .25, of the RightLight to .3 and the LeftLight to 1.1


LAYOUT, CODE THAT REMOVES NEED TO CLICK MOUSE

And, finally, remove this line:
ROUTE vrml3_ClickDetect.touchTime TO vrml3_Clock.startTime

The original thought was that the user was to click the applet to get the rotation started, and this is is neither needed, nod desired.

After you've saved the modified .WRL file, make a copy of the file as Blaxxun3d Wizard will corrupt it when it is done by compressing it. Afterwards, the very same file is no longer a plain text VRML file, but is a gZipped file which you can not use any more. Only use the copy when Blaxxun3d Wizard asks for it. And, again, make another copy before you give it to the program.

Save your WordPad file changes. If it says "You are about to save the document in a Text-Only format, which will remove all formatting. Are you sure you want to do this?" Click 'Yes'.


COMPLETED EXAMPLE OF WORKING VRML CODE

Here is the text, with changes, for this particular VRML file.


<...................CODE BEGINS AFTER THIS...................>

## DEF vrml3_Sense SphereSensor { enabled TRUE }
] } # _ObjXForm End
,
DEF vrml3_ClickDetect TouchSensor { enabled TRUE }
] } # end of vrml3_XForm
DEF vrml3_Turner OrientationInterpolator {
key [ 0, .25, .5, .75, 1.0 ]
keyValue [
0 1 0 0 ,
0 1 0 -1.570796,
0 1 0 -3.141593,
0 1 0 -4.712389,
0 1 0 -6.283185
]
}
DEF vrml3_Clock TimeSensor {
startTime -1
loop TRUE stopTime 0
cycleInterval 7.0
}
,
DEF RightLight DirectionalLight {
color 0.3000 0.3000 0.3000
direction -0.7445 0.0506 -0.6657
intensity 1.3000
on TRUE
}
,
DEF LeftLight DirectionalLight {
color 0.8000 0.8000 0.8000
direction 0.7094 -0.0192 -0.7045
intensity 1.3000
on TRUE
}
,
DEF BackLight DirectionalLight {
color 0.3000 0.3000 0.3000
direction -0.7059 0.0000 0.7083
intensity 1.3000
on TRUE
}
,
DEF MasterFrame_Clock TimeSensor {
startTime 0
loop TRUE stopTime 0
cycleInterval 0.0000
}
,
] }
}
ROUTE vrml3_Clock.fraction_changed TO vrml3_Turner.set_fraction
ROUTE vrml3_Turner.value_changed TO vrml3_XForm.set_rotation
<..................CODE ENDS BEFORE THIS..................>


VRML CODING, ELIMINATING CLOSE CAMERA PROBLEMS

A couple last modifications that may be helpful.

At the very top of a LightWave Exported VRML file is the camera definition.

DEF SCENE_ROOT_XForm Transform { children [
DEF Camera Viewpoint {
position -0.0014 0.9129 3.5723
orientation 0.0000 0.0000 0.0000 0.0000
fieldOfView 0.789582 # 45.24 deg.
description "Camera" jump FALSE
}


If you run into problems moving your camera closer to the object, where it cuts off the closest part of the object near to you, or even doesn't show the object at all, change the fieldOfView from 0.789582 to .5 or less to enlarge the image. Put a number higher then .789582 to shrink the image.

This will make the object appear to be closer. You will still have to back off with your camera until the object is completely visible, but it will make the object larger in the applet, which is all you really want anyway.

Also, if you want to adjust the camera up/down, then increase the second number in 'Position'. If you want to adjust the camera left/right increase or decrease the first number in 'Position'.

The order of the axis' after the word position are X Y Z

It's best to adjust the angle of the lens rather than the z axis, though. It won't warp the image, yet it won't envoke the chopping-off of the object.


VRML CODING, MOVING THE CAMERA

I can also move the camera in Blaxxun's 3D space by manually modifying the position values.

If you look at the lines of camera coding...

DEF Camera Viewpoint {
position -0.0014 0.9129 3.5723
orientation 0.0000 0.0000 0.0000 0.0000
fieldOfView 0.789582 # 45.24 deg.
description "Camera" jump FALSE
}


The values in the 'position' line are the X, Y and Z coordinates of the camera.

If you increase the first value (X, in this case -0.0014), the object will move to the left (camera moves to the right).

If you increase the second value (Y, in this case 0.9129), the object will move upward.

If you increase the third value (Z, in this case 3.5723), the object will look smaller.

If you decrease those values, the object will move in the opposite directions from what I just said.


VRML CODING, IF YOU GET A BLACK SCREEN

Neither the Blaxxun Wizard, or the Applet give usable error messages.

If any kind of error occurs, it will say 'Scene Error' when you run the Wizard and the .wrl file it writes will be locked (until you quit the Wizard). The .wrl file will be 0 bytes in size.

Watch for mismatched brackets if you get a scene error. When modifying code, you might be chopping out pieces of code here and there to see what part might be causing the problem. It's easy to delete one of two brackets so they no longer are a matching pair. (A common problem when programming in any language)

If the Wizard determines that no large scene error occurred, it'll write the file. You'll oftentimes find a pure black screen when you run the Applet.

Neither way of determining that an error has occurred is helpful. When it says 'scene error', you can at least be sure there's something wrong with the code. But, if it writes the module, you can't really have a clue what Blaxxun3D might not have liked.

It handles some things well. Some things that probably aren't your problem if you get a black screen:

It seems to do well with multiple surface names.

Does well with simple surface adjustments such as color, specularity, shininess, transparency, diffusion and emissiveness.

It properly handles movement of the pivot point.

It handles LightWave's 'Distant Lights' (calls them a DirectionLight).

Some things it doesn't handle well...

Other kinds of lights.

Complex scenes.

When lights are nestled inside an XForm. If LightWave puts the lights inside an XForm, delete the XForm part. The lights must look like this:

DEF RightLight DirectionalLight {
color 0.3000 0.3000 0.3000
direction -0.7445 0.0506 -0.6657
intensity 1.3000
on TRUE
}
,
DEF LeftLight DirectionalLight {
color 0.8000 0.8000 0.8000
direction 0.7094 -0.0192 -0.7045
intensity 1.3000
on TRUE
}
,
DEF BackLight DirectionalLight {
color 0.3000 0.3000 0.3000
direction -0.7059 0.0000 0.7083
intensity 1.3000
on TRUE
}
Probably the second most common problem is at the very end of the code... the part which makes it rotate. If you get an image, but it won't rotate, then the problem is probably in the code below all other code.

First, check that the cycleInterval for the Something_Clock TimeSensor is not zero. If it's zero, try 15.0000. Of course, 'Something' is not the word 'Something', but the name which precedes '_Clock TimeSensor' in your code.

Next most common problem are the last two lines which cause it to rotate.

ROUTE MasterFrame_Clock.fraction_changed TO Angle.set_fraction
ROUTE Angle.value_changed TO Deinon_Rotated_Loss02_XForm.set_rotation

In this case, where it says 'MasterFrame', that must match the name it says before _Clock TimeSensor' which I was just talking about. LightWave will oftentimes put 'MasterFrame' as the name for that.

Next, check that the name before '.set_fraction' equals whatever you called the OrientationInterpolator. If there IS no OrientationInterpolator, that's your problem. Paste in the code for the OrientationInterpolator (I always call it 'Angle').

In the second ROUTE line, make sure it also has the name of the OrienationInterpolator before '.value_changed'. In this case it should say 'Angle'.

And, finally, the name before '.set_rotation' should equal the main name of your XForm (the name you gave it when you saved it with _XForm tacked on the end of it). You can verify that you got the proper name there by looking at the beginning of the file. About a page down it will have the main DEF for the main XForm such as DEF Deinon_XForm Transform {' if I saved the .wrl file as 'Deinon'.

Be carefull you don't leave out the word XForm. Make sure you have periods where there should be periods and underscores where there should be underscores.

If they don't look like that, highlight the section in your code which contains the three lights (making sure you don't accidently delete too many brackets) and paste in these lights.

Also, since it's very picky about what it can and can't understand, yet there is no explanation anywhere about what VRML codes it can and can't handle, it's almost impossible to determine if you're far away from getting it to work, or if you're very close.

Therefore, since it's very common to get a black screen when it renders in Blaxxun3D, its generally best to start out simple and work up to the complex until it breaks.

Build it like you'd build a computer program, a little at a time, always making sure that it works each time. Just as nobody writes an intricate program without constantly testing it to see if it does what you expect it to as you go, the same should be done with a VRML in Blaxxun3D.


BLAXXUN3D WIZARD, INSTRUCTIONS

Now, you can just follow the instructions to use the Blaxxun3D Wizard.

Create a folder where all the files will go, put the copy of the .WRL file there.

In my case, I create a folder called D:\VrmlApplet

In that folder I put the file called blaxxun3d.jar, which is the applet you'll also need to upload to your site. It is found in the install folder. Do a search for it if you can't find it.

Run the 'Blaxxun3d Wizard'. Click on the 'load scene' button and select the .WRL file you just wrote and copied to that folder. It will read the file.




You might wish to increase the size on the applet that will play. This is not hard to change at a later date, as the values are just two numbers that are passed to the applet inside the HTML code; but for those who don't like modifying things, click on the 'General' tab of the Blaxxun Wizard and put 500 for the width and 375 for the height.




You could even put 640 for the width and 320 for the height, but that tends to be jerky on most people's computers.

Click the 'create' button and choose a name in that same folder for the .HTM file. Click on 'Save'.




If you did the code changes proper, you will have a rotating object. If you didn't, you'll have a still object. You can fiddle with the three light's intensity values. They point to the center of the stage (0,0,0) slightly above the ground.

If it doesn't rotate, go back to your .WRL file copy and see if the name is proper. See if the code looks changed properly. If you find the problem, copy the changes overwriting the compressed version in the folder with the .JAR file, go back to Blaxxun Wizard, again click 'Load Scene', again click on 'create' and pick the same .html file and try it again.

Following my own instructions, I created this...

Sorry, your browser doesn't support Java.

The completed version, a bit bigger, can be found Here

You copy and paste the code from the .HTML file you just wrote to where it says <applet> to where it says </applet> and paste it into your code.


Click for a Rotating 3D Version of the skull done using the Blaxxun3D Applet


VRML VIEWERS and WEB LINKS

Blaxxun Interactive

A developer of software for interactive VRML 3-D user communities. BlaxxunContact is a VRML Plug-In Viewer.

www.blaxxun.com


Cosmo Software

Cosmo Player Software - Web 3D Viewer, Authoring Tools and Resources.

www.cosmosoftware.com


3D Graphics/Virtual Reality site. "About 3D Graphcis/VR : Web3D Virtual Reality 3D Graphics games tutorials vrml;".

Frequently updated VRML site containing hundreds of updated links, a weekly chat, feature articles and interviews.

web3d.about.com


Martian Media Productions Fun Page

Martian Media Productions.

www.MartianMedia.com/fun.htm


Geometrek

VRMl games, puzzles, contests, webring, interactive multi-user worlds and games.

DeepMatrix is a Geometrek product that enables real-time multiuser interaction in 3-D environments across the Internet.

The DeepMatrix System is a multi-user VRML application. It enables several users to share a single VRML world and interact with it as it is possible with an ordinary VRML world. Users can jump between different worlds and these jumps can be triggered in any way. VRML events are distributed between the several instances of the VRML world on the different users computers. .

www.geometrek.com


ParallelGraphics

The makers of the Cortona Vrml client plug-in, vrml authoring tools, vrml screen saver, developer tools.

www.parallelgraphics.com


The VRwave Home Page

Hyperwave's 'VRwave' is the only VRML 97 browser available in complete source code, and requiring no commercial packages to run. VRwave is written largely in Java (parsing, scene graph management, and program logic). For performance reasons, rendering is performed via OpenGL.

www.iicm.edu/vrwave


Viewing VRML World with Multiple Plugins

Techniques for juggling VRML plugins for Navigator on Win95. How to select a VRML browser, how to get one, and how to use it.

hiwaay.net/~crispen/vrml


VRML 1.0 Objects,etc

Rich's Dabblings in VRML - Include's cyberspace's first Mobius Strip (and the C code which created it).

www.winwaed.com/comp/vrml2/vrml.html


VRML Dreamers

Italian VRML computer group news, projects, gallery, and newsletter.

www.lucia.it/vrml


VRML for Rocket Scientists, Astronomers, and Truck Drivers.

Site offers VRML for the beginner, intermediate and expert designer.

WDVL.com/Authoring/vrml2/index.html


VRMLSite Magazine

Spotlight on Web Based VRML Creation. VRML-related books. VRML Forums.

www.vrmlsite.com


Web3D Consortium

The home of the Web3D Consortium, this site includes the latest information on VRML and on all evolving VRML97 ISO Standard activities.

www.web3d.org


Ziggarautomatic

Parameterized VRML tower-building, in the style of Babylonian ziggurats.

www.textuality.com/zig


Previous   Table of Contents   Home   Next