I'm finally at the point where I'm feel secure enough with Java3D to start creating my physics engine.

(I went to gamedev.net and almost shot myself to head due the fact that every 14-year-old is creating a mmorpg.)

For now, I start with flat grid-landscape where I drop items. My attempt is to implements Newtons 3 first laws of dynamics.

1. Object in uniform motion keeps its velocity if no force affects it. Same with objects with velocity of 0.

2. Acceleration is directly porpotional to the sum of new forces divided by mass.

3. If object excerts force on another object, equal force is excerted back.

I believe these all can be done with the simple collision detection thingies provided by Java3D.

One thing I need to know is though, how do I handle objects moving on rough ground? Should I put all the objects "glide" on top of the surface and just give the illusion that they are gliding/moving on it?

How do I implement multiple forces on one object? Lets say I take my cube up to 20 pixels high and drop it from there, but also give it initial velocity with a bearing of 45 degrees. While the gravity would be certainly moving it downwards, how does I set movement with the vi in 45 degrees. I believe I need to calculate the relative velocity. Isn't that correct?

I have thought about the code in following way:

interface PhysicalConstants-mass-distance-time(I'm not sure about this)-velocity-acceleration-force

Now this interface would be the core of any object, whether it is geometry or model.

Could someone who has little knowledge in physics to revieve the list as I wrote it at my (soon to be girl)friends party when others were doing drugs and performing pre-marriatal sex. If I'm missing some basic element please tell me.

Newtons laws describe the physics of a point mass. Luckily, points can never collide and cannot spin. That nice for computation. Ah, and they live in continous time!

Real-world objects have a finite volume and an orientation and therefor have inertia. For a sphere with equally distributed mass, this can be a number. Generally it is a tensor. Welcome to the world of tensor algebra.

So add at least two properties to your interface:

- inertia (Matrix3f) - spin (Vector3f)

The critical point is to calculate the forces!! There are constant ones like

1

G=newVector3f(0f,-9.81f,0f)

and easy-to calculate ones like air-resistance

1

draw=newVector3f(0f,0f, v*v)

(all in their resp. coordinate systems, of course).

And there are the complex ones resulting from object interaction. As long as your objects are elastic spheres, that not a very big problem (if you can determing EXACTLY where the spheres collide) e.g. in a billiard game.

But if you have interconnected object (a swinging bridge, a skeleton) - don't do it at home. There are specialists necessary to deal with. People who know how to do the integration.

If you need to be real physical, you have to observe conservation of energy - which turns out to be very hard when doing numerics.....

Basically, there are 3 laws, .... but....

Ok, now lets talk about dissipative forces like friction, elasticity,.....

first you have to find the result of all forces on your object (if they apply on the same point), just sum up all your forces vectors and use this to find the acceleration. (F=ma, you divide your force vector by mass and you find acceleration, but it's a vector).

Now you need to integrate this over time. For this step, you need an accurate timer and the difference of time between your current frame and the last one (delta_time). Multiply your acceleration vector by this delta_time and add this new vector to your object velocity. Now take this freshly updated velocity vector and multiply it by delta_time. Add this vector to your object position and you get the updated object position. This is the Euler integrator which is not THAT accurate but still good for simple stuff.

There's some code in the middle of the article that performs this integration, you should be able to understand it, it's C. For advanced motion, you'll have to read some docs about torque and momentum. (Chris Hecker series are a good start : http://www.d6.com/users/checker/dynamics.htm)

BTW anyone tried building the project on a windows system? I managed to build the ODE C code fine after having to edit source code to make it work with VS.net, but the javaforode stuff is not compiling.

I can get the .java files to compile into the bin directory, but the "make jni" stuff is failing - obviously since it was written for linux/unix.

Anyone have any ideas?

PS: Make is suppose to make compiling easier?? My god what a horrendous mess of a a setup. Its almost as if the designers WANTED it to be a mess...

--More than likely I have offended you with the above post. Don't feel bad, we are often upset by things we are too damned stupid to understand.

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