Collisions, Physics, ect

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
freegadgets
Posts: 10
Joined: Sat Dec 04, 2004 6:37 pm
Location: Canada

Collisions, Physics, ect

Post by freegadgets »

Hello everyone, I'm the guy who wrote the physics, A.I., and camera control system for Space Madness which is currently featured on the main page as screenshot of the month. I plan to release a playable demo soon. I'm still somewhat new to this engine and I have a few questions that only an expert will be able to help me with.

First, how would I go about collision checking a mesh against a mesh? Second, is it possible to get the exact point at which the collision occurred? The reason I ask is that I'm considering writing a physics engine to be used with Irrlicht and I was hoping to use Irrlicht's collision checking if possible. Any help would be greatly appreciated.
zola
Posts: 52
Joined: Thu Jul 15, 2004 2:31 pm
Location: switzerland
Contact:

Post by zola »

Hi freegadgets

Because the collision checking of Irrlicht is somewhat slow I use the collision primitives of the physic engine currently ODE but I think Newton GD has surpassed ODE by now ;)

Anyway, typically it is not such a good idea to let meshes collide with each other because it tends to be a very slow operation. So You might consider to have a hierarchical collision system where the mesh against mesh test is a very special case that only happens occasionally.

You might take a look at the new collision system of Newtwon Game Dynamics. Their system is very stabel and easy to use and provides many primitives aswell as TriangleMesh and ConvexHull collisions. One drawback at the moment is that the Trainglemeshes are only static, but the convexhull feature is a fair compromise (if not better).

If You absolutely need to test moving meshes against each other then OPCODE might be worth considering.

Writing Your own physic engine is very ambitious. I strongly recommend to take a look at the available collisionlibraries this should take away a fair part of the complexity You're bound to face.

Here are some links to project that provide and/or use collision libs

http://www.newtondynamics.com/ (has its own)
http://www.ode.org (uses OPCODE)
http://photoneffect.com/coldet/ (very easy for meshes)
http://www.codercorner.com/Opcode.htm (for meshes)

Good luck

Tom
freegadgets
Posts: 10
Joined: Sat Dec 04, 2004 6:37 pm
Location: Canada

Thanks Tom

Post by freegadgets »

Thanks, I tried Newton but it seems to only work properly for cubes and spheres. Longer rectangle shaped objects occasionally fall through the ground. Fast collision detection will be the hardest part. Part of the problem is that Irrlicht doesn’t allow hidden objects to be used for collisions, or shadows for that matter. We should be able to use a 1000 polygon model for the graphic, and a 40 polygon model for the collisions and shadows. Shadows are completely unusable at present, to use them you would have to have all your models very low poly-count and that would be ugly.

I’ll go ahead and work on a physics engine anyway, it won’t be ready for some time because I’m going back to school soon. Hopefully Irrlicht will have the features I need when I’m ready. If anyone knows how to get the collision point for collisions between meshes let me know. Even if it’s slow at present, I could still use it for testing, Thanks.

http://www.AlternateRelativity.com
freegadgets
Posts: 10
Joined: Sat Dec 04, 2004 6:37 pm
Location: Canada

Try the demo

Post by freegadgets »

Guest

Post by Guest »

I do not know were you got the idea that Newton only support boxes and sphere.
Newton support cones, cylinders, close toroid, capsules, ellipses, general convex hulls, and compound of convex primitives. For static collision trees polygonal soups and user define collision.
In addition it also supports nom uniform scaling of any convex geometry at run time. This feature can be used for tunneling prevention, and creating non-conventional shapes like elliptical and slated cylinders of cones.

Perhaps you want to take a look at this before emiting that kind of opinion

Image

http://newton.delphigl.de/
zola
Posts: 52
Joined: Thu Jul 15, 2004 2:31 pm
Location: switzerland
Contact:

Post by zola »

Cool demo Brent

Looking at the code would surely be interesting, do You mind to share it?

Cheers

Tom
Guest

Post by Guest »

I am just an user of Irrlicht with Newton, the code is not mine I just found it browsing at the Newton site. I think that particular one is written on Delphi Pascal. But there are may others instructional ones with source on the same page.
The Newton SDK comes with plenty of demos in C++ that shows how to used the collision.
Another thing is that if you are making your own physics engine, you can use the collision part of the Newton engine as a separate collision system.
That will give you a jump-start with your physics engine until you get yours up and working.

The other point is that Newton is not the only free engine that supports convex hull and other primitives, Tokamak also support them even thought it is not as stable as Newton, but it is faster.
freegadgets
Posts: 10
Joined: Sat Dec 04, 2004 6:37 pm
Location: Canada

8)

Post by freegadgets »

Thanks Guest, I looked at some reviews of the various physics engines out there and overall I'd say Newton seems to be the favorite. I made a little demo a while ago using Newton and Irrlicht. You had to use the arrow keys to roll a ball around up and down hills. I was very impressed by Newton until I tried to make a car game this it. The car's collision was based on a rectangular box and it ran fast enough but every once and a while the car would sink through the ground... Maybe I'll give Newton another shot now that I'm more experienced with Irrlicht.

Zola, the code's a bit of a mess I'm afraid. I was new to Irrlicht at the time I started it so I don't think it would be very helpful. If I wanted to make a complete game out of it I would probably start from scratch and organize it better...
RLG not logged

Post by RLG not logged »

I'd say that AI was pretty darn impressive, no matter how messy the code.
I'm starting on building my own game now, after messing with different things here and there, I'm finally going to start on the basics of a structure. I think lookin at ur AI code might be really helpful to me :P haha. But yeah, I'm still not sure what physics to use. I'm pretty sure on using Newton, but it doesnt seem too clear on how to get it implemented without 8 million lines of code to shoot a cube into the air haha.
Post Reply