Community Forum
ANVEL Licensing Options

Collision Detection

  • Any suggestions on how would I go about detecting my vehicle has collided with an object such as the Hale Bale?

  • So depending on what you are trying to do there are a few ways to approach this.

    --- If you don't care about the performance so much or you only care about looking at just a few of objects(such as your example of 1 vehicle and 1 hay bale), through the external API you can directly get the AABB(Axis-Aligned Bounding Box) Center, the AABB Extends(from the ODE Physical Object) and absolute positions of your objects and calculate when the bounding boxes intersect. This is much more doable if you do not need to run in real time.

    An example of a way to get these values using this method looks like:

    #Create Vehicle
    vehicle = anv.CreateObject("Generic 4x4", "Vehicle", 0, Point3(0,0,0), Euler(0, 0, 0), True)
    #Get physics object for the vehicle body
    vehBody = anv.GetPhysicsObject(
    # Get the AABB properties of body
    aabbExtents = anv.GetProperty(vehBody, 'AABB Extents')
    aabbCenter = anv.GetProperty(vehBody, 'AABB Center')
    # do things

    ---If you want to handle more objects potentially colliding and/or performance is important, you will need to write a plugin.

  • I'm working on a Bump sensor plugin, i was looking at the ICollisionObject and wasn't sure if there was anyway to get a callback from the physics engine whenever my sensor collided with something.

    The scenario I imagined was a vehicle hitting a hay bale. I don't necessarily need to know who collided with the sensor (although it would be nice), only that it collided.

    However, I can't seem to figure out how to assaign a CollisionHandler to the Sensor. Any suggestions on how to get started?

  • Any suggestions on doing this a plugin? I'm kind of stuck on this one.

  • @chudson, we're sizing this effort internally and will get back with you when we have a better idea what it'll take. We really appreciate your patience and your use of ANVEL thus far!

  • @ANVEL-Team Thanks, Any luck yet in figuring out if this is possible?

  • @chudson said in Collision Detection:

    @ANVEL-Team Thanks, Any luck yet in figuring out if this is possible?

    @chudson, thanks again for your patience. We took a look into this issue, and although it's not as straightforward as we hoped, this info might help you out with your plugin development:

    Right now there is not a more convenient method for getting a collision other than directly detecting collisions from ODE. If you refer to the ODEPhysics.h, you can see that there is a listener that you can use to detect any and every collision in the Simulation:

    /* ODE Collision Listener                                               */
    enum CollisionHandlingResult
        kRejected = 0, //this is an invalid collision that should not be handled
        kHandled = 1,  //this is a valid collision that has been handled
        kUnhandled = 2, //this is a valid collision, but has not been handled
        kHandledAndAcceptNoMoreCollisions //this is a valid handled collision, but do not use anymore
    /// A Listener for ODE Collisions
    /// Gets notified when any ODE collision happens
    class ODECollisionListener
        //returns true if it is handled
        virtual CollisionHandlingResult HandleCollision(ODEContactInfo& contact)=0;

    If you are able to wait a bit, for the ANVEL 2.5 release this November, we are planning to abstract and more readily expose some of this core functionality, as well as make it able to detect specific collisions.

    The ANVEL Team