ConvexHull not colliding

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

ConvexHull not colliding

Postby nathanf534 » Thu Jul 15, 2010 5:25 pm

I have 2 convex hulls, and I can't get them to collide. I am assuming I created the hull with incorrect values, but Im not sure. I am using Irrlicht. Here is where I create the hull collision

Code: Select all
void PhysicsManager::addHullCollisionBody(IMeshSceneNode* node){//creates the HullCollisionBody
   NewtonCollision* collision =NewtonCreateConvexHull(nWorld,4,(const float*)(node->getMesh()->getMeshBuffer(0)->getVertices()),12,0,0,NULL);
   NewtonBody* body=NewtonCreateBody(nWorld,collision);
   cout<<"body:"<<body<<endl;
   UserData* userData = new UserData;
   cout<<"userData:"<<userData<<endl;
   userData->node=node;
   userData->physicsManager=this;
   userData->body=body;
   NewtonBodySetUserData(body,userData);
   NewtonBodySetForceAndTorqueCallback(body,ApplyForceAndTorqueEvent);
   NewtonBodySetTransformCallback(body,callbackTransform);
   matrix4 mat=node->getAbsoluteTransformation();
   NewtonBodySetMatrix(body, &mat.M[0]);
   NewtonBodySetMassMatrix(body,1,1,1,1);
   node->setID((int)((void*)userData));
}


and these are my 2 callbacks
Code: Select all
void _cdecl ApplyForceAndTorqueEvent (const NewtonBody* body,float matrix,int x){
   float torque[3];
   float force[3];
   PhysicsManager::UserData* data=(PhysicsManager::UserData*)NewtonBodyGetUserData(body);
   data->addForce.getAs4Values(force);
   data->addTorque.getAs4Values(torque);
   NewtonBodyAddTorque (body,torque);
   NewtonBodyAddForce (body,force);
   NewtonBodySetAutoSleep(body,0);
}
void _cdecl callbackTransform( const NewtonBody* body, const float* matrix,int x){
   matrix4 mat;
   mat.setM(matrix);
   PhysicsManager::UserData* data = (PhysicsManager::UserData*)NewtonBodyGetUserData(body);
   if (data->node){
      data->node->setPosition(mat.getTranslation());
      data->node->setRotation(mat.getRotationDegrees());
   }
}
nathanf534
 
Posts: 19
Joined: Sun Jul 11, 2010 9:01 am

Re: ConvexHull not colliding

Postby JernejL » Fri Jul 16, 2010 5:10 am

You gave insufficient information on the problem, I suggest you implement a debug renderer to visualise the world and shapes you created and post a few screenshots.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: ConvexHull not colliding

Postby nathanf534 » Sat Jul 17, 2010 10:05 am

ok, here is a screenshot of the hull collision... it is just a triangle.
Image
nathanf534
 
Posts: 19
Joined: Sun Jul 11, 2010 9:01 am

Re: ConvexHull not colliding

Postby nathanf534 » Sat Jul 17, 2010 10:14 am

by changing the second parameter of NewtonCreateConvexHull from 4 to 2000, it works perfectly. What exactly does that second parameter do? I just figured out 2000 by guess and check, and anything above that made my program crash.

here is the picture with the 2nd parameter at 2000
Image
nathanf534
 
Posts: 19
Joined: Sun Jul 11, 2010 9:01 am

Re: ConvexHull not colliding

Postby Julio Jerez » Sat Jul 17, 2010 11:40 am

It is not a random value it is the number of veritices in the vertex list.
from where you get 4 and 2000 figure? you should pass the exact number of vertices in the mesh

hopefully when the new editor comes on line, thes confusion will go away, because those model will be put together visually.
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: ConvexHull not colliding

Postby nathanf534 » Sat Jul 17, 2010 11:56 am

it is the number of veritices in the vertex list.


well that would have been helpful to know, all the wiki says is

dFloat count - number of consecutive points to follow (must be at least 4).


which just made me confused... it could have just said number of vertices.

Anyway, thanks for the help. :)
nathanf534
 
Posts: 19
Joined: Sun Jul 11, 2010 9:01 am

Re: ConvexHull not colliding

Postby JernejL » Sun Jul 18, 2010 8:32 am

It is number of vertices / points, it says it.. and it builds a convex hull to wrap around the vertex cloud that you send it.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: ConvexHull not colliding

Postby Stucuk » Sun Jul 18, 2010 9:40 am

If your supplying it vertex's and a parameter is called "Count" then no matter what the description is you should know it means the amount of whatever your giving the procedure. I have updated the WIKI page.

dFloat count - number of points/vertices sent in vertexCloud (must be at least 4).
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: ConvexHull not colliding

Postby Aldeminor » Sat Jul 31, 2010 10:59 am

How to visualize result of NewtonCreateConvexHull?
Aldeminor
 
Posts: 31
Joined: Tue Jun 29, 2010 6:37 am

Re: ConvexHull not colliding

Postby Julio Jerez » Sat Jul 31, 2010 11:52 am

use debug display
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: ConvexHull not colliding

Postby Aldeminor » Sat Jul 31, 2010 12:37 pm

How can I see that window if I'm using wrapper betwen Newton double-precision dll and C#?
Aldeminor
 
Posts: 31
Joined: Tue Jun 29, 2010 6:37 am

Re: ConvexHull not colliding

Postby Julio Jerez » Sat Jul 31, 2010 2:37 pm

the debug display are funstion of the engine, you wrapre need to support then,
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: ConvexHull not colliding

Postby Stucuk » Sat Jul 31, 2010 4:49 pm

Debug display has to be implemented on the application that renders the scene. Newton doesn't render anything to your application. The SDK Demos have a debug display implemented.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 44 guests