Hey, I'm pretty new to Java3D and what I want to do is have the ability for a player in my 3D FPS game be able to throw a ball at a given angle and given speed and then for the ball to bounce realistically off of the ground and the walls and eventually come to a stop.

I have no idea where to begin with this but I know I'm going to need some physics and collision detection in there.

Does anyone have any resources I could refer to for help with carrying out this task? Perhaps you know someone who has done it before with a guide on a website somewhere? I've tried googling but havn't really found much useful.

You could try JOODE, it does all that kinda stuff for you. Docs a bit flimsy but it works the same as ODE (which has better documentation), plenty of test cases though in the repository. I could do with a user to force me to write some tutorials Have a look at the game physics forum.

Runesketch: an Online CCG built on Google App Engine where players draw their cards and trade. Fight, draw or trade yourself to success.

OK I think this might be more complicated than I initially thought, so I've decided to start with a simple ball bouncing up and down in the center of the scene.

Putting the physics to one side for a moment, what would be the best way to animate such a bouncing ball? The first method that comes to mind is to simply calculate the ball's position every 5ms (say) based on the principles of physics in such a scenario (in this case mainly gravity), and every 5ms draw the ball in its new position. I don't really know much about animation in Java3D at the moment so would this be an OK method? If not, what better methods are there?

The 'animation' of a moving ball is usually (if not always) done by calcuting the ball's new position every frame and drawing it at the appropriate position. I don't know anything about Java3D, but I'm pretty sure you wouldn't need anything special like a PositionInterpolator that you mentioned.

Judging from your questions, you seem quite new to game programming in general (please forgive me if I'm wrong). Might I suggest to start with simple 2D games first? Implementing a small packman game would teach you most of the basics you'd also need for 3D and can be done in less than a week's time. Any 3d shooter would certainly cost you months or more likely years to finish, depending on how much you start with.

You'd be suprised how incredibly complicated physics-systems can be, something like ODE (or the java port/rewrite JOODE) cost a number of people a few years to write. I'm not trying to discourage you though, but in this case it might be more educational and rewarding to start small.

You're right when you say I'm new to game programming! Unfortunately I don't have the time to study 2D game programming as I'm doing this work as part of a project at university (with the deadline approaching quicker than I would like )

I understand the basic principle you have described for creating a simple falling ball but I can't figure out how to animate this in Java3D. Please see Code for Episode 1 at the following link:

I had to create my own Behavior class; pretty simple once you know how, doh!

Now I can start to think about having the ball fall from the sky and bounce in 1 dimension (Y-axis) to a stop. This of course means thinking about collision detection.

I noticed one of the wakeup criteria is WakeupOnCollisionEntry - does anyone know if this can be used in this situation? So that the ball would fall and once it detected a collision with the ground the falling (downward) behavior would halt and the new upward behavior would begin...

Use WakeupOnElapsedFrames(0) to run flat out and get a callback every frame. Use System.currentTimeMillis or System.nanoSomething to calculate the elapsed time between frames. Use this time with the physics. Ball position can be calculated as

Don't think you can use WakeupOnCollisionEntry since you want to detect collision before collision. You can use the picking package for collision detection. Although any real collision detection would be complicated for a newbie.

For a simple bouncing ball you could just check the bally and set velocity sign.

Well, I wouldn't say that collision detection is necessarily too complicated for a NOB depending on their mathmatical knowledge (for instance, 3 variable calculus is much more complex then collision detection). Anyways, here is a good site that goes through how collision detection and avoidance works in java 3d

Oh gosh, with moving balls you use basic vector maths. You do not check every frame, it's just not the "proper" way to do it ... you basically rotate the line by the movement vector (using the UVN rotation system, then it's all easy from there. Check if the point of collision is within the movement of the circle - this will check to see if the circle moved through the line.

Then transform your line into a fat line, the circles into points, and do a simple check to see whether the points are within the fat line; so pm me if I don't provide you with a solution within 36 hours of this post.

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