Pablo Fernandez
Pablo Fernandez

Reputation: 287870

Where do I start to write/use a 3D physics simulation engine?

I need to write a very simple 3D physics simulator in Java, cube and spheres bumping into each other, not much more. I've never did anything like that, where should I start? Any documentation on how it is done? any libraries I could re-use?

Upvotes: 2

Views: 6026

Answers (8)

bm212
bm212

Reputation: 1439

A nice java physics library is jmephysics (http://www.jmonkeyengine.com/jmeforum/index.php?topic=6459); it is quite easy to use and sits on top of ODE (http://www.ode.org/) and jmonkeyengine (http://www.jmonkeyengine.com) which gives you a scenegraph (http://en.wikipedia.org/wiki/Scene_graph), again something that you'll need for anything beyond a very simple 3d application.

I haven't used it for some time though, and see that they haven't released since late 2007 so not sure how active the community is now.

Upvotes: 1

Ed James
Ed James

Reputation: 10572

NeHe's lesson 39 is a good starting point, it's in C++ but the theory is pretty easy to understand.

Upvotes: 1

Nick Van Brunt
Nick Van Brunt

Reputation: 15494

Check out bulletphysics. bulletphysics.com is the forum or check out the project on Sourceforge.

Upvotes: 0

Mez
Mez

Reputation: 2857

If you want to do this from scratch, meaning coding your own physics engine, you'll have to know the ins and outs of the math behind to accomplish this. If you have a fairly good math background you'll have a headstart otherwise a steep learning curve is ahead.

You can start on this community forum to gather information on how things are done: gamedev.net

Ofcourse you could use an opensource engine like Ogre if you don't want to code your own.

Upvotes: 0

mP.
mP.

Reputation: 18266

If you all you need to simulate is spheres/circles and cubes then all you need is a bit of Vector math.

Eg to simulate a simple pool game each ball (sphere) would have a position, 3d linear velocity and 3d linear acceleration vector. Your simulation would involve many little frames which continually updates each and every ball. If two or more balls collide you simply sum the vectors and calculate the new velocities for all balls. If a ball hits a wall for instance all that is required is to flip the sign of the ball to have it bounce back...

Upvotes: 0

Joonas Pulakka
Joonas Pulakka

Reputation: 36577

How about first defining a class for physical object? It has position, velocity, mass and maybe subclasses with other features like shape, elasticity etc.

Then create an universe (class) where to place these physical objects. Sounds like fun :)

Upvotes: 0

TofuBeer
TofuBeer

Reputation: 61536

Physics for Game Programmers By Grant Palmer (not Java)

Phys2D (Java code)

Upvotes: 7

Swanand
Swanand

Reputation: 12426

Assuming you want to get started on how to do it, best way to start is with a Pen and Paper. Start defining focal points of your app (like the entities sphere, cube etc, rules like gravity, collision etc, decide hierarchy of objects etc..)

If you know how to do this, and want a primer on the technology side, Swing is a good option to make UIs in Java.

Also take a look here: http://www.myphysicslab.com/

Upvotes: 1

Related Questions