![]() |
| Speed issues
Return to the main FAQ page for more questions and answers.
1. How do I make Java 3D run more quickly
Doug Twilleager (Doug.Twilleager@eng.sun.com) has written Performance Guides for Java3D 1.1 and 1.3 that have been posted to the j3d interest list. A copy of them are available under the Quick Fix tutorials section for Java3D 1.1 and Java3D 1.3. Sun have posted an updated version for Java3D 1.2 on their website
2. Why is Direct3D slower than OpenGL?
Edited and paraphrased explanation from a post to the Java3D interest list and also tips on how to help make things run faster.
The OpenGL implementation uses display lists, which are faster than the
Direct3D DrawPrimitive function. When you have a scene that contains a
lot of cubes or shapes that use
The Sun utility classes define the Cube as a So for ColorCube there are 6000 DrawPrimitives call. That's why it hurts performance as Philip Taylor from Microsoft mention in his email. Several optimization is consider in our next release. For D3D we may use VertexBuffer. Also we may combine shape node together. There are several things that you can do right now to improve performance.
3. What does BranchGroup.compile() do?
It is often recommended that you compile() your scene graphs. Sun's Doug Gehringer wrote up a small article explaining what compile does and how you might best make use of its capabilities. Compile is designed to optimise certain types of scenes where a lot of common information is stored. In particular MCAD data greatly benefits from this.
4. Scenes with cylinders and spheres using Sun's util classes
The default number of subdivisions for spheres and cylinders is high, leading to pretty nice looking objects, but objects with really high polygon counts. The default for cylinders is 50 in x and y, which is 5200 triangles. If you specify a lower number of subdivisions, you'll still get objects that look good, but with dramatically lower polygon counts. Try 10 for x and 1 or 2 for y. The default for sphere is 30. You can set that lower too. Alternatively, you can try out the various primitives available in the j3d.org Code Repository. This collection of Open Source code provides a larger and more controllable array of primitive items.
5. I have an XYZ Video Card. Why is it so slow?
Many video cards designed for PC systems are designed for game playing. These cards only work in fullscreen mode (for example cards based on the Voodoo chipsets). That is, they do not provide hardware accelaration for 3D graphics when it is running in a window. When this happens, the underlying rendering API defaults to a software rendered mode making it much slower. Since Java3D only operates in windowed mode (see How Do I run J3D in Fullscreen Mode) you will never have hardware accelaration with your video card. The solution is to purchase a card that supports windowed hardware accelaration. Generally, any card with full OpenGL hardware support will offer this (particularly cards based on 3DLabs chipsets eg Permedia 2 or nVidia GeForce cards). Check the video card section of this FAQ for more information about video cards.
6. How do I use BSP Trees with Java 3D?
There are no direct tutorials regarding J3D with BSP trees that we are aware of. There is a good tutorial that talks about general Java usage and BSP trees in general at http://www.geocities.com/SiliconValley/Way/7650/java.html. (There are a lot of other good tutorials here too!) As Java3D is a scene graph based API, BSP trees may not give you the performance benefits that you might expect (in some cases we have seen them and similar "optimisation" tactics cause it to run slower than normal). Internally Java3D does a lot of its own management of viewable objects. We strongly recommend you use vanilla Java3D code first to see if it is acceptable before attempting premature optimisation that may in fact degrade performance.
7. How can I stop 100% CPU utilisation?
Java3D uses 100% CPU to gain maximum performance and number of frames per second rendered. On games and many highly complex applications, that leaves no time for user code to do stuff. Unfortunately, many of Sun's utility classes are a contributor to this problem due to the behaviours they use internally. If you use any of the Interpolator classes, you're in trouble. The best way around many of these issues is to not use the utility classes provided by Sun and write your own system.
To modify the priority of all the Java 3D threads running you can use the
static
If you are using Java3D 1.3 or later, you can also use the
8. Slow picking with multiple geometries
Java3D 1.2 Allows use of multiple pieces of geometry in a single Shape3D instance. When I try to make a pick in a Shape3D with a lot of geometry, it is much slower than using a single Shape3D for each geometry. Why? Doug Gehringer from Sun suggests one way to speed up your picking may be to use slightly smaller "chunks" for your geometric data. Picking proceeds in two passes. The first pass selects Shape3D nodes that may be picked by seeing if their bounds intersect the pick volume. The second pass intersects the pick shape with the geometry to determine the shapes that were actually picked (this is assuming that you are doing GEOMETRY picking, BOUNDS picking stops at the first step). If you can divide your 25000 geometries into smaller groups, say 250 shapes with 100 geometries per shape, you may get much better performance. The speedup will depend on the spacial locality of the shapes. If you can eliminate most of the shapes on the bounds pass you can greatly increase the speed of picking. Experiment with different numbers of geometry per shape to come up with the best balance for your application.
9. Why does my mouse flicker when over the canvas?
This problem mainly occurs when there is 100% CPU utilisation (for example WakeupOnElapsedFrames(0) behavior). So far we have only seen this limited to Win32 implementations. Some problems relate to the video driver in use. For example, many laptops do not support hardware rendering by default and may need a driver update. If the driver update fails to fix the problem, then the next most common cause is that the mouse has shadows running. To turn of shadows, go to the Control Panel | Mouse and then the Pointers tab.There should be a check box at the bottom left saying "Enable pointer shadow". Make sure that this is unchecked and then hit OK to commit the changes
10. Why is J3DGraphics2D so slow?
J3DGraphics2D has a number of acknowledged, severe performance problems. Unfortunately those problems seems to related to the way Java3D and the AWT libraries handle screen updates, and there is no known fix for this. To work around this problem, Sun updating the capabilities from J3D v1.3 onwards but only with some specific functionality. See the Java3D 1.3 Performance Guide for more information. If you would like to view an alternate way of drawing 2D information over the 3D window, have a look at the answer to the question How do I draw 2D lines on top of the Canvas3D
11. How do I stop the camera jittering when I move?
Jitter occurs due to the way Java3D processes the behaviours and screen updates. The following code excerpt shows a behaviour that will cause jitter of the view as the viewplatform moves:
public void processStimulus(Enumeration criteria) {
Modify Camera View point using the object transform
Modify Object transform as in RotationInterpolator
}
To elminate jitter you can change the code to swap the order of evaluation in the processStimulus() method.
public void processStimulus(Enumeration criteria) {
Modify Object transform as in RotationInterpolator
Modify Camera View point using object transform
}
Under Java3D 1.3, you can use the new features setSchedulingInterval() and 2 separate behaviors for it to avoid jitter.
|
|
[ j3d.org Home ]
[ Java OpenGL ]
[ Aviatrix3D ]
[ Tutorials ]
[ Books ]
[ Contact Us ]
Hosted by Yumetech, Inc Last Updated: $Date: 2006/04/18 18:19:59 $ |