Page 1 of 2

beastie - Header only collision detection library for Ogre

Posted: Wed Jul 14, 2010 11:28 am
by betajaen
Image

Crivvens! What is Beastie?

Beastie is a C++ based simplified collision detection library for the Ogre3D
graphics engine, and it is neatly packaged in a single header, beastie.h.

"Beastie" should be always pronounced in a Glaswegian accent.

It only detects collisions and does not respond to them as you would typically
encounter in a more fully featured physics engine or more advanced collision
library.

However the detections are accurate and are optimised, building some response
code on top of beastie shouldn't be to difficult, an example of some of this
is in the "beastie.example.cpp" test application that can be found at the beastie
Git repository.

Beastie only uses Ogre as a dependency, and is developed with Ogre 1.7 in mind;
but should work with any 1.x version.

Beastie is released under the MIT licence.

Gessa Download!

Beastie only comes in one file "beastie.h", alternatively a complete Sample may be downloaded.

Beastie is hosted and versioned by GitHub.

Further Documentation and information can be found there.

Awayan'boilyirheid

Beastie is very simple to use, and requires the minimal amount of code to setup.

For example; this is how you would raycasting:

Code: Select all

beastie::collision_tree tree = OGRE_NEW collision_tree();

tree->createNode("tudorhouse.mesh", Ogre::Vector3(0,550,0);
ray_query result;
line ln(Ogre::Vector3(0,25000,0), Ogre::Vector3(0,-1,0), 25000);
tree->intersect(ln, result);

Additionally Beastie comes with an example application, using the OgreBites sample
framework.

The example is a self-installing-when-compiled Ogre Sample. Simply compile the Sample
(in the visual studio directory) and it will copy itself and self-install it self into your Ogre
Samples folder. Run the SampleBrowser application and you'll find "Beastie Example" under
the "Collision Detection" section

Smashin-intit

Beastie will be worked upon the future. My rough To-do list is as follows:

- Bug fixes.
- Box v.s. Box and Plane intersection.
- Further optimisation of raycasting.
- Jacmoe has convinced me to incorporate the works of Paul Nettle; more specifically the
ellipsoid character controller.

Re: beastie - Header only collision detection library for Og

Posted: Wed Jul 14, 2010 11:38 am
by mkultra333
Sounds really interesting. Can it handle collisions against any arbitrary mesh or disjointed triangle soup? (Not that I really need collisions against disjointed triangle soups, I'm just curious.) Can you do a mesh-mesh collisions?

Re: beastie - Header only collision detection library for Og

Posted: Wed Jul 14, 2010 11:40 am
by boyamer
Very nice project,can't wait to give a look to it.

Nice work betajaen

Re: beastie - Header only collision detection library for Og

Posted: Wed Jul 14, 2010 11:42 am
by betajaen
mkultra333 wrote:Sounds really interesting. Can it handle collisions against any arbitrary mesh or disjointed triangle soup? (Not that I really need collisions against disjointed triangle soups, I'm just curious.) Can you do a mesh-mesh collisions?
Nope; No mesh v.s. mesh collisions, I'm afraid. It would be too difficult to implement and very slow to run.

It's more rays v.s. meshes/boxes/planes at the moment.

Re: beastie - Header only collision detection library for Og

Posted: Wed Jul 14, 2010 12:17 pm
by Xavyiy
Very nice betajaen =)

I think this little library will be a really useful for a wide range of people, specially people who is starting in 3D programing and even experienced users that wants a simple, but robust, collision detection library for little demos!

Re: beastie - Header only collision detection library for Og

Posted: Wed Jul 14, 2010 12:37 pm
by AshMcConnell
LOL @ Awayan'boilyirheid

Looks great, should be useful to a lot of people!

All the best,
Ash

Re: beastie - Header only collision detection library for Og

Posted: Wed Jul 14, 2010 1:01 pm
by sinbad
Is there anything betajaen can't fit into a single header file? ;)

Nice work mate.

Re: beastie - Header only collision detection library for Og

Posted: Wed Jul 14, 2010 1:53 pm
by Klaim
Seems a useful tool for not-needing-physic-lib projects! :D

Re: beastie - Header only collision detection library for Og

Posted: Wed Jul 14, 2010 2:22 pm
by jacmoe
Like I said to Betajaen earlier: this is great! :)

Since OgreOpcode does do soup versus soup collision detection, maybe the two could be combined?

Re: beastie - Header only collision detection library for Og

Posted: Wed Jul 14, 2010 2:59 pm
by betajaen
I'm probably going to leave mesh v.s. mesh collisions to last. It is possible, but I'm really concerned about performance. I mean PhysX is based upon OpCode, but it doesn't do mesh v.s. mesh collisions.

What I may do is do allow very simple convex/concave hull collisions with vertices less than 16, but I want to do OBB boxes and that character controller first.

Re: beastie - Header only collision detection library for Og

Posted: Wed Jul 14, 2010 3:18 pm
by Ruud v A
One question:
betajaen wrote: "Beastie" should be always pronounced in a Glaswegian accent.
How is that? I am a non-native speaker so an example would be appreciated :)

It looks great, especially the single header file! No mess, just one include and it works. I like it.

Re: beastie - Header only collision detection library for Og

Posted: Wed Jul 14, 2010 3:21 pm
by AshMcConnell
Ruud v A wrote:One question:
betajaen wrote: "Beastie" should be always pronounced in a Glaswegian accent.
How is that? I am a non-native speaker so an example would be appreciated :)

It looks great, especially the single header file! No mess, just one include and it works. I like it.
BeeeeStaaaay :D

Re: beastie - Header only collision detection library for Og

Posted: Wed Jul 14, 2010 3:32 pm
by betajaen
AshMcConnell wrote:BeeeeStaaaay :D
http://www.youtube.com/watch?v=Nrmcxa1yBec

Re: beastie - Header only collision detection library for Og

Posted: Wed Jul 14, 2010 3:51 pm
by Ruud v A
AshMcConnell wrote:BeeeeStaaaay :D
Ah, thanks!

Re: beastie - Header only collision detection library for Og

Posted: Wed Jul 14, 2010 5:59 pm
by betajaen
New commit
Changes:

- Added set origin, direction and length functions in line
- Added alternative Raycasting algorithm
The new ray casting algorithm is an adapted version Tomas Möller's "Fast Minimum Storage Ray-Triangle Intersection" which is used in Opcode and possibly PhysX.

Re: beastie - Header only collision detection library for Og

Posted: Wed Jul 14, 2010 7:09 pm
by Jabberwocky
cool stuff.

Re: beastie - Header only collision detection library for Og

Posted: Wed Jul 14, 2010 7:42 pm
by jacmoe
This is coolness! :)

Makes me resurrect OgreOpcode again...
Would be interesting to benchmark the two.

Re: beastie - Header only collision detection library for Og

Posted: Wed Jul 14, 2010 7:43 pm
by jacmoe
But first:
A character controller demo. :)

Re: beastie - Header only collision detection library for Og

Posted: Wed Jul 14, 2010 7:50 pm
by betajaen
jacmoe wrote:Would be interesting to benchmark the two.
I did some basic benchmarking.

Using the TudorDemo and in clicking in nowhere particular. I timed each ray cast, then I collected them and got an average.

The adapted Ogre raycasting code takes 45μs
The adapted Opcode/PhysX code takes 50μs

I am surprised about the second, considering how simpler the code is.

Re: beastie - Header only collision detection library for Og

Posted: Wed Jul 14, 2010 7:52 pm
by jacmoe
I don't give a lot of credits to that kind of benchmarking..

Look to the CDTestFramework which ships with Bullet, if you want good benchmarks. :)

Would be cool to throw in a Beastie example.

Re: beastie - Header only collision detection library for Og

Posted: Thu Jul 15, 2010 10:40 am
by Shadow007
Great work Betajaen ! One question though :
Looking at your code, I see that you based a 1 axis split submesh computation/splitting on the Y axis ... Is there any reason to stop there and not subdivide further, or simply cut with all 3 axes giving 8 submeshes ?

Re: beastie - Header only collision detection library for Og

Posted: Thu Jul 15, 2010 10:59 am
by betajaen
Shadow007 wrote:Looking at your code, I see that you based a 1 axis split submesh computation/splitting on the Y axis ... Is there any reason to stop there and not subdivide further, or simply cut with all 3 axes giving 8 submeshes ?
I wanted to see if it made any difference, and it does a bit.

I'm taking a different approach now and making the meshes part of the octtree directly, rather represented as whole by an AABB. That should skip over some existing code and same on some time on finding the proper mesh fragment for raycasting.

Re: beastie - Header only collision detection library for Og

Posted: Fri Jul 16, 2010 4:35 am
by kneeride
betajaen you rock!! This is very cool.

I've been reluctant to integrate a physics engine because it would have been overkill for what I need. I also thought the memory would be overkill because there needs to be 2 scene managers (1 for phsyics and 1 for ogre).

I've been using MOC for ray to mesh but I'm really hanging out for this one:

>> Box v.s. Box and Plane intersection.

Can you please also consider: Box vs Sphere :-)

Re: beastie - Header only collision detection library for Og

Posted: Fri Jul 16, 2010 7:43 am
by Matheus Martino
I think betajaen expect you to define a box around your sphere.

Re: beastie - Header only collision detection library for Og

Posted: Fri Jul 16, 2010 8:39 am
by Zonder
doing a box -> sphere check is only a matter of checking to see if a points distance from the center of the sphere is below it's radius