I'm starting a new game project, and there will be lots of balls in this game.
My desire is to have all the balls in this game to behave in almost a comic fashion, "disney-style" if you understand what that means.
So, each ball can move around on a terrain simply by rolling, and it can bounce too if it goes off a hill or cliff.
Ok, here are basic things that these balls need to do:
- I want the appearence of the ball to be "deflated" a bit, so it's almost never a perfect sphere. For instance, if it's rolling on the ground then the area that touches the ground is flattened a bit…just like car tires would be.
- Also, if the ball is stationary on the ground, then it's only deflated at the bottom. But if it's moving fast in some direction, then the ball should be deflated a bit in the opposite traveling direction.
- I need "realistic" bouncing, just like if the balls were rubber.
- Good collision detection.
So, what's the way to go in jME for this kind of behaviour?
I don't know a damn thing about most of what yer asking for but as far as the deformations of the ball goes I'd handle that in a 3D modeling app just like animations for a "normal" player charactor. 3DS MAX, for example, has many free form deformation tools which can be animated. I'd use those to get all the "poses" you want - flattened way down at high speed, moderately flattened for normal speed, bottom only for stopped, etc. Then use the regular animation capabilities in jME to switch between those.
Do you plan on having the balls be textured? I wonder if it might be easier to simply "pose" the balls, and then animate the textures for a rolling effect - rather than trying to "roll" the ball. I'm sure someone much smarter than I will tell you if that's a horrible idea. Was just thinking that with a deformed ball you couldn't just rotate it over the terrain as it would tumble end over end rather than roll.
That idea for the deformations sounds good, to me, too.
Regarding the physics, I'd use 'normal' spheres for the balls. Make them bouncy and have a look if this already fits your needs. Deformable bodies are not supported in many physics engines. And they are really costly. So I can't recommend to implement something for them…
Nice idea! I think you would have to write your own physics stuff.
When the ball moves, you have one form of energy: movement energy. You can squeeze the ball along the acceleration vector. Maybe you can add a spring effect to that to make it look more fluid-like.
When the ball hits the ground and gets squeezed together, you have two forms of energy: movement energy and the potential energy stored in the ball deformation. So squeezing the ball against the ground removes movement energy and stores energy as deformation energy in the ball that gets releazed when it gets unsqueezed. Check out pendulums and mass spring force systems in the physics book of your choice.
btw. the book "Physics for game developers" is quite good
I remember a playing a game where you rolled around as a blob and painted stuff. They used shaders to deform the mesh based on movement like you want.
Great replies all! This will surely help me
Also, if you want to be cheap, you can have the physics representation of the ball be perfectly round, even if the actual ball isn't!
That would be one way of doing it, unless it would be noticeable in gameplay.