This code has not been maintained by me since 2001. I gave the bulk of it to j3d.org and ceased using it. If you are interested in it (it worked pretty well), it is best to get the most recent version from them.
This is a library for Java3D to place "overlays" on the screen. An overlay is text or an image that appears to be drawn on the canvas that the scene is rendered on rather than being a part of the scene. It is useful for presenting information about the scene that does not have a spatial relationship to the scene; player information in a video game is a good example.
This library was originally written by David Yazel and was posted to the Java3D listserv, I believe as a part of the game Cosm. I, Will Holcomb, have done some enhancements for use in my work. In addition to the packages posted here, any of the latest revisions are via cvs. (Anonymous cvs will be running soon.)
All of the examples on this page are placed using HTML conformant to the HTML 4.0 object tag specification. If you want to hear a minor tirade ask me sometime about what I think about having to deal with web browsers that do not render the standards correctly. The browser that has the best standards conformance that I have seen is Mozilla. These examples will work there assuming you have the Java Plug-in installed and the Java3D Libraries.
All of these files are alpha code. Any usage in production environments should be tested thoroughly. The latest version of these files are available in the nightly builds and until there is a release those are the recommended sources.
jar xvf original-overlay.jar
cd overlay
javac com/xith/java3d/overlay/*
java com.xith.java3d.testbed.OverlayTester
Overlay Demo: This is the adapted set of classes that I worked on. It is a pretty drastic set of changes and I will not try to get into all that changed. This is a simple test that resembles the original overlay demo except it is more interactive. Also the original kept the scene constantly updating (using a WakeupOnElapsedFrame) and this one only updates when there is a change, so the frames per second counter will only work in the new architecture if there is something that keeps the canvas repainting. (Well, it will work, but the only frames rendered will be the update on the counter so it will read 1 or 2.)
This demo focuses more on being interactive too. Typing should appear in the little scrolling chatbox at the bottom of the screen. Additionally there are the special keys:
F1
: Will change the color of the background on the chatbox. This causes a pause in the cube's rotation and it should not. This is a known bug.F2
: Will slowly type out a message in the chatbox and suspends user typing in the interim. This is intended for something like characters speaking in a video game.Numeric Keypad
: The elements can be positioned relative to any corner of the screen and the numeric keypad will move the chatbox accordingly. Hitting F1
and changing the chatbox color makes this more visible.Also there is a little picture of a man in the lower right corner. This should change colors when the mouse passes over. Also it will react when clicked and clicking will toggle it between two colors. You have to move off the image to see the toggling of colors.
java -jar SceneViewer.jar
I have done another test program that illustrates how to move the camera's mounted position while maintaining the transform associated with the ViewPlatform. It is using the NavigationHandlers from the j3d cvs. Because the OrbitBehavior can only be used with the ViewingPlatform class it is not possible to change the point that the camera is mounted because when you call ViewingPlatform.setViewPlatform() it does change the ViewPlatform but the ViewTransform stays at the initial position and the OrbitBehavior stays with it so it is no longer possible to move the camera.
This program does not change the camera's mounted position be changing the ViewPlatform, rather it detaches and reattaches a BranchGroup below both the ViewPlatform and the ViewTransform. The NavigationHandler behaviors and the Overlays are both attached to the ViewTransform so they stay with the camera when it moves.
The program itself is a set of spheres spiraling around in a sphere with the brightness going from 1 to 0. Different properties of how the scene is created can be altered in the intial setup dialog.