Areas


Topics

j3d.org

Advanced Techniques

  1. How can I put a hole through an object?
  2. How do I make two objects collide?
  3. How do I draw 2D lines on top of the Canvas3D?
  4. How do I render terrain files like DEM/IGES in Java3D?
  5. How do I render avatars and realistic humanoids in Java3D?
  6. How do I do Non-Photorealistic Rendering (NPR) in Java 3D?
  7. How do I write Inverse Kinematics calculations in Java3D?
  8. Why are Java Timers/WakeupOnElapsedTime so inaccurate?
  9. Is there a particle systems library for Java3D?

Return to the main FAQ page for more questions and answers.

 

1. How can I put a hole through an object?

This technique is usually termed Constructive Solid Geometry and you most often see it used in 3D modelling programs and ray tracing software. There is a good reason for this - it is extremely slow to do (at least as far as realtime systems are concerned).

There are various techniques to do this, but you will probably need to do a lot of pre-processing or building of extra geometry and it is not something that can be dealt with as a simple problem.

Find some links here....

 

2. How do I make two objects collide?

Java3D does not natively support an object to object collision system. The closest it gets is a notification of when two objects have already collided. What you probably want is something to stop them colliding before it happens.

j3d.org holds a wide collection of information on the subject and you should have a read through the following items:

 

3. How do I draw 2D lines on top of the Canvas3D?

The most simple way to do this is to override the preSwap() method on the Canvas3D and then put in a call to getGraphics2D. This will return you a graphics context to do drawing with. However......

Taking this approach will lead to extreme losses in performance. For some reason the Graphics2D.flush() method takes exceedingly long times to complete. Even on high end machines this has reduced 100fps animations to 3fps.

The best alternative is to use one of the overlay systems currently in development. One of these systems will be making it into the j3d.org Code Repository in the near future, once it settles down a little bit. For the moment, we suggest you look in the java3d-interest list archives for June 2001 for a number of different code solutions that were posted to the list.

 

4. How do I render terrain files like DEM/IGES in Java3D?

You will need to use one of the file loaders available to read in the file to Java3D's structure. You can find a list of the supported loaders here on our Loaders Page. If your file format is not there, then you will have to either write one yourself or do a format conversion using a tool such as Keith Rule's Crossroads software (or the earlier WCVT2POV).

 

5. How do I render avatars and realistic humanoids in Java3D?

In whatever way you like! Really, this is up to you to decide as every application has very different needs. If you need to do some more interesting tasks like skinning/bones based animation, then take a look at one of our the reader contributed Bones demo code.

Our code repository contains a renderer-independent implementation of the ISO Humanoid Animation Specification (ISO/IEC IS 19774). There are no bindings direct to Java3D at this stage, though it should be relatively easy to add one.

You may also want to look at the IK question as well.

 

6. How do I do Non-Photorealistic Rendering (NPR) in Java 3D?

The simple answer is that with the current Java 3D release, it is not possible as we don't have access to any of the low-level rendering mechanisms. However, that has not stopped some adventurous souls giving it a try. We have an example line renderer tutorial available as a basis.

 

7. How do I write Inverse Kinematics calculations in Java3D?

This is a discussion that is very much up in the air at the moment. The J3D community has not come down along any particular "best path" for this. However, we are working on it

Various members of the community have suggested the following articles should be considered useful guide to get you going.

  • Bill Baxter's lecture slide set from Uni North Carolina.
  • Chris Welman's PhD thesis It discusses methods for implementing an ik system, but there isnt any source to go with. The referenced file is an FTP link to a PostScript document.
  • Simple 1D Jacobian (PDF) implementation provided by Fred Klingener of Brock Engineering.

 

8. Why are Java Timers/WakeupOnElapsedTime so inaccurate?

This has to do with the way that timers are implemented in the underlying platform. For unix-based operating systems, timers are not an issue. These are seen on Microsoft platforms. These timers use a system timer which is very inaccurate. Although Windows provides a very accurate multimedia timer, that timer only provides information based on the time from when the machine last booted, rather than standard epoch time required by the Java system. Hence, on Windows you get wildly unpredictable results.

Based on anecdotal evidence appearing on various lists and boards you can expect the following accuracy: Win9x 100ms, WinME 50ms, WinNT/2K/XP 10ms. There is no known work-around for this that does not involve the use of native code. There is a lot of discussions in the JavaGame JSR to fix this problem and provide some high-resolution timer, but you can't honestly expect to see anything for a couple of years yet.

For more information on the various platforms, Fred Klingener has started assembling a page of notes that is worthwhile having a read over.

 

9. Is there a particle systems library for Java3D?

There is no implementation provided with Java3D. A number of different implementations from simple to commercial products are available, as well as tutorials. Please look through the sites page for a list of possible options.