Charles wrote:Hi Julio,
One question about the compound collider : How can i get the
sub-colliders' shapeID that are in contact? For now i can only get the shapeID of the compound collider itself from the collision callback.
Basically, i want use different materials of one compound collider, but the Unity Plugin doesn't support this for now, so i want use shapeID to distinguish the parts of one compound collider as the Newton Wiki says:
http://www.newtondynamics.com/wiki/index.php/ShapeID
You can do and use this, yes:
In contact callback - do:
b1 := NewtonJointGetBody0(contact);
b2 := NewtonJointGetBody1(contact);
Then when looping thru contacts (NewtonContactJointGetContactCount, NewtonContactJointGetFirstContact, NewtonContactJointGetNextContact)
NewtonMaterialGetContactPositionAndNormal(material, nil, @ContactLocation, @ContactNormal);
Then you get the collision shapes of each body / or body compound via:
Collision_Primary:= NewtonMaterialGetBodyCollidingShape(material, b1);
Collision_Secondary := NewtonMaterialGetBodyCollidingShape(material, b2);
This logic doesn't need special checking if it's compound or not, it works regardless, then you can use NewtonCollisionGetUserData on the shapeid and so on..
I use this to build compound shapes, where particular parts do not collide (for example, a truck shape collides with everything, but rear part of truck does not collide with trailers so that they can be hooked up) - it works very well!