View Full Version : Detecting edge of mesh/maps??
wazoo
12-18-2004, 09:11 PM
Hi everyone,
I'm prototyping an idea I've been mulling over the past few days, and my only "stumbling" block at the moment is how to detect the edge of a mesh that I create in 3DS MAx (or whatever).
I want to roll a ball around on a level, then detect when/if it falls off the edge.
The ball mesh I'm not having a problem with, as I know the current ball's vector (position) and I can fake a radius.
But what about my actual level that I want to roll the ball on? And what happens when I want to perhaps use a spiral surface or an un-rectangular mesh?
I'm not asking for direct source code, just for ideas on where to look next on how to implement this. :)
I've been searching through some forums, but can't seem to find anything "clear-cut"..
thanks anyone/everyone for suggestions..
You haven't told us much about what you want to do when the ball reaches an edge, so this suggestion may not be satisfactory for your specific application. But, I would suggest that instead of trying to determine the edge, you try to determine the altitude (Y or Z component, depending on your conventions) of the level mesh at the horizontal location of the ball. For physics calculations, you will also need to determine the surface normal of the mesh at the ball's location. You should be able to derive the surface normal from the plane equation of whichever mesh polygon the ball is resting on in any given frame.
If you need more detail, please ask.
--milo
http://www.starshatter.com
Wayward
12-20-2004, 02:37 AM
I want to roll a ball around on a level, then detect when/if it falls off the edge.
...
I'm not asking for direct source code, just for ideas on where to look next on how to implement this.It sounds like what you're looking for is sphere-to-mesh collision detection, which you could find in an existing collision detection library:
ColDet (http://photoneffect.com/coldet/) - Free 3D collision detection library at The Photon Effect.
Cullide (http://www.cs.unc.edu/~geom/collide/index.shtml) by Team Gamma.
FreeSolid (http://www.win.tue.nl/~gino/solid/) "is a library for collision detection of three-dimensional objects undergoing rigid motion and deformation."
QuickCD (http://www.ams.sunysb.edu/~jklosow/quickcd/QuickCD.html) "is a general-purpose collision detection library, capable of performing fast and exact collision detection on highly complex models."
OPCODE (http://www.codercorner.com/Opcode.htm) "is a new small collision detection library."
Or a physics engine with built-in collision (I can't be sure all these engines will have the right kind of collision you need):
ODE (http://ode.org/) - The Open Dynamics Engine.
Newton Game Dynamics (http://www.physicsengine.com/)
Tokamak Game Physics (http://www.tokamakphysics.com/)
NovadeX Physics SDK (http://www.novodex.com/)
Or use a language or game-making system which provides simple collision functions:
Blitz3D (http://www.blitzbasic.com/Products/blitz3d.php)
Or roll your own (not recommended):
Introduction to Collision Detection (http://www.stanford.edu/~jgao/collision-detection.html) at Stanford.
Simple Intersection Tests For Games (http://www.gamasutra.com/features/19991018/Gomez_1.htm) at Gamasutra (requires free registration).
Applewood
12-20-2004, 08:33 AM
I can confirm that Tokamak will do what you need and is scarily easy to setup. Can't beat the price of zero dollars either - even for a commercial title.
Do a search (locally on tokamak site or google) for "adam dawes" and he's written up a handful of tuts for utter newbies to tokamak - they were invaluable to me. His first example does exactly what you're looking for.
wazoo
12-20-2004, 12:38 PM
thanks guys.
Yeah a sphere-to-mesh is pretty much exactly what I'm looking for.
My only other thought was that as long as the ball was on the level, the collision detection should be returning some kind of a true value. Once I steer it off the edge, I'm hoping the test will return a false value..
thanks guys!
vBulletin v3.6.0, Copyright ©2000-2008, Jelsoft Enterprises Ltd.