How can we build a 3D simulation of physical objects?
3D programs like Java3D use a scenegraph to render to the screen, but should the scenegraph nodes also be used to model the interactions?
Modeling Newtonian Mechanics
To model Newtonian mechanics, we need to be able to do the following things:
- Model motion
- Collision detection
- Collision response
A scenegraph can be used to model motion, the shapes that are moving could be placed under a transform group and its translation modified each frame. This would need to be coded by the programmer as the behaviors built into VRML/Java3D don't seem to be appropriate, they require start and end points which would not be known in the general case, also these behaviors are not specially good at generating accelerations. In order to calculate these we will need to hold parameters like, energy, mass, linear and angular momentum, c-of-mass, etc. along with the shape information in the node.
To prevent two objects from occupying the same volume of space, we need collision detection. Collision detection is quite difficult for arbitrary geometry arrays (not implemented in Java3D 1.1). This might also be a heavy overhead, if there are a lot of objects and we need to test for a collision between every object and every other object.
Then once we have detected the collision, we need to calculate the effect of the collision, generate new velocities, spins, etc. I have tried to calculate the formulae in the collision section, and as you can see, it get very complicated when all objects can have 6 degrees of freedom.
Non Scenegraph methodsSo, for the reasons above, although the scenegraph is normally used for rendering, it may not always be the best way to model the physics. Other possibilities are discussed in this section.
Analytical verses Numerical Methods
Should we use analytical methods or numerical methods? Analytical methods require us to solve some complex equations, and therefore require a lot of work at design time. Numerical methods involve less complex equations but more calculation is done at runtime. This is a tradeoff, in the most general case we will probably have to use numerical methods, but in more restricted cases we may be able to build a faster, more efficient, simulation by using analytical methods. So if we put more analysis at design time, we may be able to design the program to run faster.
Rigid verses deformable body interactions
There are different types of collision and it may be more efficient to choose the type of model depending on the application. For instance some applications involve perfectly elastic collisions, where all the energy of the collision is transformed back into kinetic energy, an example of this might be a simulation of snooker or pool. Other applications may involve non-elastic collisions, such as a car crash, where some of the kinetic energy may be converted into other types of energy, in some cases, for non-elastic collisions we may want to model the deformation of the objects, if so we need to model them as non-rigid bodies.
So what types of models could we use to simulate the 3D mechanics? Here are some possibilities I have thought of, I am sure there are a lot more, if you can think of other variations please let me know:
Simulation of rigid bodies
Simulation of non-rigid bodies
How do we model something that is flexible like, say, a sponge, or a biological system?
- Deformable Shapes
- Deformable Shapes using Numerical Methods
- Finite Element Method and methods using partial differential equations
- Model shapes as equations
There are APIs for rendering 3D models, such as Java3D. This document discusses ways to expand these models so that they can simulate the physical behavior of objects. This would allow people to build and exchange virtual models, with physical behaviors, without having to program the physics. This behavior could be an integral part of the object, like its geometry or appearance.
A 'Physics editor' could then be added to allow non-programmers to create solid objects which can interact in virtual worlds.
Uses of 3D mechanics
To find a way to investigate this I will go back to some possible requirements and describe what the end users would see. What I had in mind was a system where people could do the following:
- One person might build a model of a solid object in their world, and send it to a second person who could put it in a different world. This object would behave in a way dependent on the physical properties that the first person gave it. For example, if it hit another object it might fall over, it might bounce off it, or it might smash into pieces.
- One use might be education, to allow people to do virtual physics experiments. Or to build virtual engineering models such as engines.
- Another use might be for people with particular interests/hobbies to try out ideas in a virtual world. Different people could build parts of the world, when they put all these objects together in a virtual world they should interact together. An example might be a war games different people could build a fighting machine separately, then put them all together in the same virtual world and let them fight it out.
- Another application might be virtual games/sports, for example pool, golf, football, etc.
- This would not just be for multi user worlds. Individual 'authors' might want to get physical objects form other people or buy them off the shelf.
RequirementsThe requirements will depend on the application, some applications might need a very accurate simulation of the physics, other applications, such as games, may just need to look about right. Some applications may need a simulation or the physics properties in earths gravity and atmosphere. Other applications might need to model space, relativity, etc.
It seems to me that for all this to become practical would require a number of conditions:
- The physical properties and their interactions should be rigorously enough defined so that objects continue to behave as expected in viewers from different suppliers.
- These properties should be defined at a high level of abstraction, so that the viewing engine is free to optimize the low level details to allow efficient runtime performance.
It doesn't seem practical to model down to the atoms & beyond, so this must be a compromise, the physical behaviors must be simple enough to model, yet comprehensive enough to be useful in a high proportion of applications.