|
Written by CR Team
|
|
Wednesday, 02 September 2009 16:50 |
|
What is the most efficient way to create rigid bodies for collision in a game ?
The most common question in mind when you start out creating a game level would be the right way to create collision volumes around your 3d models in the scene. Lets have a look...
Why should you create one ?Well..
- You might have a complicated model with uneven surface(you don't wanna kill your physics engine, making it compute the bounding volume for collision)
- Passing the entire scene to the physics engine to calculate a bounding collision container might strangle it !
- Easy to get the collision reports when 2 rigid bodies are involved in collision are of simple shape...
Two things to consider here would be if the 3d model in your world is dynamic or static...
If the mesh/3d model is static, divide the whole mesh into smaller pieces of collision volumes. Some example here . Just get the model into the engine and run a loop to make these named bounding volumes to proxy type of #box.
If its dynamic then its slightly a different ball game ! Let us discuss these based on the type of 3d models that you might wish to make dynamic and interactive and bounce around in your game.
- Chair, table , bottles,bins, cans, cars on road : good to make such models static, but then you might want the 3d character to interact with it, The best approach would be to make use of a box bounding volume or proxy. Box proxy would be the easiest to compute for the physics engine...
- 3D Characters: Best choice would be capsule bounding volume. Why not use the other one's ?..
- sphere ? : Nope, taking into consideration that the diameter of the sphere would be the length of your character, imagine getting through doors or narrow spaces. Would not be possible would it ? ( Unless all openings in your game are made of fortress doors )
- Box/square ? : same reason as the sphere
- Rectangle ? : Would be a good choice, but imagine the character in a room and has somehow reached the corner where the walls meet, turning him around without back tracking wuld be rather jerky. Also if you are in a open area, the chances of character hitting a slightly non-smooth edge on the terrain and tripping is a high possibility.
- Capsule ? : Found this one to be most suitable, its a mix of rectangle and sphere, suites well for most cases ! Would solve most of the problems associated with box/rectangle volume !
More info on volumes can be also found here
When it come to Director, create the capsule in your 3d application and then export it to w3d. Create a cocave dynamic shape out of the capsule suing the concave proxy template api's.
|