I have a question on Java 3D's applicability on a project I'm soon to embark upon. I need to do some physics modeling/simulation of cloths using a mass spring system (with some colision detection). Since I've yet to learn Java 3D I was thinking this might be a good time for that.

I've perused the docs a bit, and it seems it might be suitable for such a project (by using GeometryArray for instance). My question is thus, would Java 3D be suitable for such an endevaour or is it too high-level? I have also been comtemplating using JOGL, but with Java 3D all the basic stuff is taken care of (like matrix and vector classes, quaternions etc), and I can focus on the physics part.

Java3D is quick and easy for representing a 3D scene. If you're doing physics I would keep the physics implementation well away from the 3D stuff (so for example don't use Java3D to calculate when and where things have collided) and just use the physics to update the 3D scene as and when changes occur.

Physics libraries can be thought of as big black boxes...feed data in about forces and torques, out comes new positions and rotations in world coordinates. The problem is actually feeding the scenegraph with the new transforms while still maintaining a nice heirarchy for culling and all sorts of nice optimisations. Anyone have any cool special algorithms to do that ?

The counter example is Shawn Kendall at IMI, who Cosmic Racer uses a rigid physics system that is directly driven off of theJava3D scene graph structure. The advantages are as follows:

(a) Cannot get out of synch with rendered data. (Removes whole classes of potential bugs.)(b) Uses the Java3D bounding system for hirearchical bounding volumes. (Less coding, already optimized for theJ3D structures and update path, again less likely to get out of synch.)(c) Less memory usage (you arent representing your geometry twice in two diffferent ways.)

He still does his own final tri v. tri collision and penetration depth calculation.

i dont THINK Im giving away any trade secrets by revealing this much,,,

Got a question about Java and game programming? Just new to the Java Game Development Community? Try my FAQ. Its likely you'll learn something!

system that is directly driven off of the Java3D scene graph structure.

Would you mind explaining more about this? how exactly is it "driven off". You need to exachange transformation data between the physics layer and the graphics layer. (Ofcourse, if the physics and the graphics are using the same math classes, you could just pass a pointer to the tranform). But my question is still valid, how do you keep a tight scenegraph while allowing free movement ?

Cosmic Racer (as far as physics examples go) is pretty simple, but if you look at some of the videos by Artificial Stuidos and what they do with their physics, thousands of dynamic objects everywhere that can literally move from one end of the level to the next. How do you keep a clean and tight scenegraph so that the frustum culling is effecient in these cases?

...rigid physics system that is directly driven off of the Java3D scene graph structure. ...

A while back, I did some research on collision detection and briefly considered using the scene graph as the bounding volume hierarchy (BVH). [A BVH is used during a broad phase of collision detection to more quickly prune away distance objects from collision consideration. Other tighter volumes up to and including the actual geometry are typically used in the narrow phase.]. There are many ways to create a BVH depending on the application (binary trees, n-ary trees, spheres, axis aligned boxes, oriented bounding boxes, etc. Since the BVH is used for the broad phase of collision detection and my situation (a particle system) could involve many shapes, I elected to go with a separate axis aligned box BVH. This was mostly because the particles could have little or no locality coherence (they could go anywhere). I also elected to use 'subtree volume' as the cost function to determine how to build the BVH for the same reasons. If an application has a relatively static scene, then the scene graph seems like it could double as a fine BVH. It has a collision bounds at each level and already has a tree structure. Ultimately, the decision is primarly about the perfomance of the collision detection.

Ah ok, so you are using the bounding volume heirarchy to do wide area collision detection? Nice....

Why doesn't any physics engine out there at the moment do that? They all have their own weird way of dividing up the universe (im thinking Spaces for ODE) for collision detection. Looks like ive found myself something to code for a few days

But the question still remains, once that dynamic object has traveled across the scenegraph, how do you stop the bounding heirarchy severly overlapping itself...maybe some PhD student should write a dissertation about it

Ah ok, so you are using the bounding volume heirarchy to do wide area collision detection? Nice....Why doesn't any physics engine out there at the moment do that?

DP,I was trying to justify the possibility that using the scene graph as a basis for the BVH was reasonable for applications with relatively static scenes. I have no first hand knowledge that IMI did what I described (sorry if that was not clear). My physics stuff does the weird stuff (with axis-aligned bounding boxes (AABB) and a binary tree). Java3D does not reveal a BVH, so one would have to manage the volumes within the application (presumably with BoundingBox and the collision bounds) using the scene graph.

The severely overlapping volumes is a common issue in a BVH implementation. Because I selected 'minimum added volume' as the cost function to determine the 'best' tree location, the tree does need to be rebuilt occasionally if the objects are long lived.

Ah ok, so you are using the bounding volume heirarchy to do wide area collision detection? Nice.......Java3D does not reveal a BVH, so one would have to manage the volumes within the application (presumably with BoundingBox and the collision bounds) using the scene graph....

That is incorrect. Java3D does have and exposes the BVH (bounding volume heirarchy) and we use it in our traversal down to the shape level. Then at the point we added addition partitioning down to the triangle. This way we could use as much of the J3D graph as possible AND it makes it easy on the artist since most of the time the collision geometry is the same as the visual geoemtry.Another reason we did this is because you can deform the geometry in our engine, so we had to manipulate the J3D shapes. In that case you really want the visual and collision to be one in the same.

Perhaps they were confusing what you wanted with the Java3D internal BINARY tree that is used for culling.

Every node in the Java3D graph has a bounding geometry (usually a sphere for each grouping node, and a box for each Shape3D). We are using those exact bounds to traverse the graph looking for collision (we even do some caching and manipulations of those bounds). Shoot, our system even inverse transforms into local Shape3D space to do the bounds test on the Local axis aligned box (which is oriented in global space) It works great, I love it ;-).

That's very interesting- I'd always been lead to believe it was likely to be safer to keep them separate...

I think it depends on the purpose of the physics modeling. Sometimes physics modeling is used to enhance the visual experence and sometimes it's used to learn more about physics. In the first case it's probably no harm in integrating the physics quite tightly with the scenegraph, but in the other it's definately a mistake.

Also note the emerging physics cards. To be able to use them I guess its not a good idea to intertwine the physics modeling to much with Java3D.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org