FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Collision help

 
Post new topic   Reply to topic     Forum Index -> Blaze
View previous topic :: View next topic  
Author Message
mike



Joined: 28 Dec 2008
Posts: 34

PostPosted: Sun Mar 22, 2009 8:33 pm    Post subject: Collision help Reply with quote

I can't quite figure out how to tell what object hit what.

For blaze 1.0 all I used was poly2poly to tell if the object hit another object.

What would I have to use for blaze 2.0? Do I have to do something with the contact class?
Back to top
View user's profile Send private message
zzzzrrr



Joined: 17 Feb 2007
Posts: 139
Location: Washington, DC

PostPosted: Mon Mar 23, 2009 12:55 pm    Post subject: Re: Collision help Reply with quote

mike wrote:
I can't quite figure out how to tell what object hit what.


Take a look at the ContactListener in the testbed; it's a very good example of how to use collision callbacks.

In fact, if you select 'draw contacts' in the demo and then then run the pyramid test, you should see some interesting results.
Back to top
View user's profile Send private message
mike



Joined: 28 Dec 2008
Posts: 34

PostPosted: Tue Mar 24, 2009 8:13 pm    Post subject: Reply with quote

Im still confused on what I have to actually look for.

I checked out the contactlistener.d and i looked at test.d. I cant figure out how you added the contactpoint.

Like I don't understand add(bzContactPoint point).

Im just really confused on this. Sad
Back to top
View user's profile Send private message
zzzzrrr



Joined: 17 Feb 2007
Posts: 139
Location: Washington, DC

PostPosted: Tue Mar 24, 2009 8:44 pm    Post subject: Contact Listener Reply with quote

When a collision event occurs in Blaze, it registers a callback if you've created a contact listener in your application. For example, you should create a class like this in your program:

Code:

class MyContactListener : bzContactListener
{
    void add(bzContactPoint point)
    {
        // handle add point
    }
 
    void persist(bzContactPoint point)
    {
        // handle persist point
    }
 
   void remove(bzContactPoint point)
    {
        // handle remove point
    }
 
    void Result(bzContactResult point)
    {
        // handle results
    }
};

See the abstract class bzContactListener in bzWorldCallbacks.d for more details.... Also look in bzContact.d for bzContactPoint.

You can create a new instance your contact listener by doing this:
Code:

// Create your listener
auto listener = new MyContactListener;
// Register your contact listener with world
world.contactListener = listener;


Whenever a collision occurs, it will "call back" to 'listener', and you can handle the results accordingly.

Hope this helps.... You can also check out the Box2D wiki for good info.
Back to top
View user's profile Send private message
mike



Joined: 28 Dec 2008
Posts: 34

PostPosted: Wed Mar 25, 2009 2:45 pm    Post subject: Reply with quote

Wow that is really simple. I kept thinking it was more complex than just that.

Thanks for the help again. Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Blaze All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group