Physics library for collision detection?

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
KlausN
Gnoblar
Posts: 3
Joined: Fri Feb 05, 2010 10:30 am

Physics library for collision detection?

Post by KlausN »

Hi,

Recently I started experimenting with Ogre, and I build a small application with a guy walking over a terrain, and I added some mesh structures like arcs, and cubes to the landscape.
Next thing I would like to do would be to implement some collision detection between the character and these meshes.

Before thinking any further I would like to ask what the pros and cons are between doing this directly with Ogre or using a physics engine (like for example bullet). For now I'm really only interested in doing collision detection (and no physics simulation) so is there any point in using a physics engine? If I would choose to do things directly with Ogre, would it be difficult to port everything to a physics engine, if I ever made up my mind?

Thank you

Klaus

If this has been asked in a post, thank you for providing me with the link.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Physics library for collision detection?

Post by jacmoe »

I stated my opinion in this topic:
http://www.ogre3d.org/forums/viewtopic. ... 26&start=0

Conclusion: use a physics library.
Unless you are very dedicated, and primarily interested in [s]banging your head against a brick wall[/s] learning. :wink:
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
Shockeye
Gremlin
Posts: 154
Joined: Mon Nov 24, 2008 10:34 am
Location: 'Straya
x 1

Re: Physics library for collision detection?

Post by Shockeye »

For now I'm really only interested in doing collision detection (and no physics simulation) so is there any point in using a physics engine?
Bullet (and I think most other physics engines) is set up so that if you only need collision detection, you just include that part of the library. So you don't have to wear the overhead of simulation if you don't need it. So why reinvent (and debug ) the wheel?
KlausN
Gnoblar
Posts: 3
Joined: Fri Feb 05, 2010 10:30 am

Re: Physics library for collision detection?

Post by KlausN »

Thanks to both of you for your answers.

One of the reasons that speak against a physics engine is that there is no rpm-package for my linux distribution, and there seems to be a general rule that compiling never runs out of the box and one spends at least two evenings setting up things ... :?

O.k., o.k., I will start downloading now... ;-)

Bye

Klaus
jjp
Silver Sponsor
Silver Sponsor
Posts: 597
Joined: Sun Jan 07, 2007 11:55 pm
Location: Cologne, Germany
Contact:

Re: Physics library for collision detection?

Post by jjp »

KlausN wrote:one spends at least two evenings setting up things ... :?
Which is probably no time at all, compared to what writing your own engine would take :D
Enough is never enough.
User avatar
Shockeye
Gremlin
Posts: 154
Joined: Mon Nov 24, 2008 10:34 am
Location: 'Straya
x 1

Re: Physics library for collision detection?

Post by Shockeye »

I've only built Bullet in a Windows environment, but I've found it to be the most painless to build of any open source library I've ever used. Its never given me any hassles at all. Just click BUILD, step back and wait. :)
I don't know what it would be like under Linux, but I imagine it would be just as good.
ecoumans
Kobold
Posts: 39
Joined: Mon Sep 12, 2005 10:07 am
Location: San Francisco
x 4
Contact:

Re: Physics library for collision detection?

Post by ecoumans »

Collision detection is like 90% of a typical physics (rigid body) library. So it does make sense to use a physics library even just for collision detection.
For Bullet it is just a matter to use btCollisionWorld instead of btDiscreteDynamicsWorld (and don't link against BulletDynamics, but just BulletCollision and LinearMath)

Please check Bullet 2.76, it comes with updated cmake files, that should build easily under Windows, Mac and Linux. We don't have a cmake option yet to only build the collision detection bits, but I'll make sure to add such option.
http://bulletphysics.org/Bullet/phpBB3/ ... =18&t=4779

Thanks,
Erwin
KlausN
Gnoblar
Posts: 3
Joined: Fri Feb 05, 2010 10:30 am

Re: Physics library for collision detection?

Post by KlausN »

I think I will try to use bullet directly. There are nice rpm-packages.
I have tried during several evenings to compile the OgreBullet library, but I did not succeed at all...

Thank you

Klaus
robot ogre
Gnoblar
Posts: 4
Joined: Thu Mar 04, 2010 10:54 am

Re: Physics library for collision detection?

Post by robot ogre »

I have some general questions about Ogre and Physics libraries:

Part I =====================================================

A. Let's say I have a static scene, with no terrain or moving objects.
B. I wish to make a human player walk around in this scene, and correctly collide with solid objects in the scene. (The player is represented by a capsule)

I see that there are Ogre bindings or helper libraries for various physics engines. Most game "levels" are constructed in 3D modeling programs, and consist of many meshes, containing thousands of complex non-primitive polygons. This presents two major issues:

1. A given physics engine must be fed all of a "level's" polygon data.
2. Some algorithm must decide which meshes in the level should be tested for collision against the player capsule. Testing every mesh each iteration would be very slow.


Questions:

1. How does one feed his "level" data to a given physics engine? The admittedly few tutorial examples I have seen go no farther than: "Make a box at X,Y,Z".
Video game levels are complex collections of non-standard shapes. One convenient way to handle this data is through Ogre's .scene (DotScene) format. One purpose of an Ogre binding to a physics engine might be the sending of Ogre level data into the physics engine.

For example, I would love a physics engine binding that simply accepted a .scene file, or SceneManager object. Do any of the physics engines do something like this? If not, how does one feed his level data into the physics engine? The only other solution that comes to mind would be this: The individual game developer would have to parse his own scene file, and send the contents of each .mesh file into the physics engine.

2. I assume all major physics engines will figure out which meshes to test for collision in a given iteration, without the game developer having to write extra code. Is this correct? Furthermore, is it necessary to use an Octree Scene?

Part II =====================================================

I am attempting to choose a physics engine for my Ogre-rendered game.

Information:

1. We are making static non-terrain levels in 3ds Max.
To get the level data into Ogre for rendering, we are currently using OgreMax, which converts the level data into a .scene file, which looks up individual .mesh files. We could instead use oFusion if needed.

2. The gameplay involves humanoid players running about and shooting each other. While we will not need gravity guns, physics puzzles, or Crysis-like wizardry, we may need the occasional grenade to bounce off of geometry.

3. Given the above two points, which physics engine would be the easiest to implement?
Workflow: 3ds Max->Ogre


Part III =====================================================


Using a physics engine with no Ogre binding at all:

It also occurs to me that since Ogre is just a rendering engine, perhaps no Ogre binding is needed at all.

- One could export his level data from his 3D editing program directly into a format that the physics engine needs.
- One's game code would exist separately from all rendering code, and only notify Ogre when an item's position changes. For example, move player X's mesh to (x, y, z).
- This could get complicated:
- If one had many items affected by physics, like particles in an explosion, the programmer would have to somehow bind each Ogre mesh to a corresponding game object and physics object, collect "changed" events, and only move altered meshes.
- Artists would have to maintain two export formats from their 3D modeling programs.
- There would be no visual debugger to see the low-poly version of the game level.

Edit: I am currently awaiting my Nvidia Developer account approval. PhysX/NxOgre may provide a relatively painless way to convert and feed game "level" data into PhysX.
User avatar
tod
Troll
Posts: 1394
Joined: Wed Aug 02, 2006 9:41 am
Location: Bucharest
x 94
Contact:

Re: Physics library for collision detection?

Post by tod »

[Warning!] Take this with a grain of salt, as I have just begun to study physics engines, and I only worked a little with Newton.

Part 1
A1. You just feed the vertex data to the physics engine. If this is to much for the engine to handle you will need to reduce in some way the vertex count you feed to the engine. You also use a specialized collision shape, for Newton you have height map collision, tree collision, etc. You will also probably want to define some simple shapes for characters for example, like a cylinder, or maybe a very rough shape if you really need it, like a stick figure made out of boxes :roll:
A2. You have some way to decide which bodies collide, in Newton there are some IDs you set for each body.

Part 2
A1. You are worrying to much, if your graphics world and physics world share the same origin it should be easy to pass the vertex positions to the physics engine.
A2. As I've heard, not tested though, if you don't have RTS style number of players, you should be OK, performance wise.
A3. I'm trying to use Newton. Information it's pretty scarce, forum helps somehow. I was looking over the Ogre Bullet forum and it seems pretty much the same to me. No real advice here.

Part 3
- Do you really need particle collision? :p
- Binding an ogre mesh to a physics body is, like, the whole point of physics. Basically you have a physics body that the engine moves to 3,3,3 and you do a set position for your Ogre entity to 3,3,3.
- Newton has a way to display physics data. I bet the others have also.
Post Reply