collision detection

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

collision detection

Postby programmer2008 » Mon Oct 06, 2008 12:48 pm

i am looking for function in newton that help me when to bodys collide return true
for example

Code: Select all
if (testcollision(body1,body2)==true){
//do anything
}
programmer2008
 
Posts: 5
Joined: Sun Oct 05, 2008 2:15 am

Re: collision detection

Postby Gianluca » Thu Oct 09, 2008 2:24 am

Gianluca
 
Posts: 53
Joined: Fri Nov 11, 2005 4:37 am
Location: Rome - Italy

Re: collision detection

Postby programmer2008 » Thu Oct 09, 2008 4:14 am

thank you
can you please give me simple example

because it have to many parametars
programmer2008
 
Posts: 5
Joined: Sun Oct 05, 2008 2:15 am

Re: collision detection

Postby Gianluca » Thu Oct 09, 2008 4:42 am

This is my function that use NewtonCollisionCollide for checking contacts:
Code: Select all
bool checkContacts( NewtonWorld* world, NewtonBody* obj1, NewtonBody* obj2 ) {
   const int maxsize = 4;
   float contacts[3*maxsize];
   float normals[3*maxsize];
   float penetra[3*maxsize];

   dMatrix t1, t2;
   NewtonBodyGetMatrix( obj1, &t1[0][0] );
   NewtonBodyGetMatrix( obj2, &t2[0][0] );
   NewtonWorld* nworld = world->getNewtonWorld();

   if ( NewtonCollisionCollide( nworld, maxsize, NewtonBodyGetCollision(obj1), &t1[0][0], NewtonBodyGetCollistion(obj2), &t2[0][0], contacts, normals, penetra ) != 0 ) {
      return true;
   } else {
      return false;
   }
}
Gianluca
 
Posts: 53
Joined: Fri Nov 11, 2005 4:37 am
Location: Rome - Italy

Re: collision detection

Postby programmer2008 » Fri Oct 10, 2008 3:38 pm

thank you
programmer2008
 
Posts: 5
Joined: Sun Oct 05, 2008 2:15 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 5 guests