Category:Physics Material Section

From Newton Wiki
Jump to: navigation, search

Newton material settings are based on real world values and always set in pairs.


NewtonMaterialSetDefaultCollidable - Sets information, weither a material pair can collide. 
NewtonMaterialSetDefaultElasticity - Sets default elasticity of collision between materials (coefficients of restitution) - https://en.wikipedia.org/wiki/Coefficient_of_restitution 
NewtonMaterialSetDefaultFriction - Sets default static and dynamic / kinetic / sliding friction 
NewtonMaterialSetDefaultSoftness - Sets surface softness - this controls how physics engine handles penetrating contacts. 
NewtonMaterialSetSurfaceThickness - Sets surface's skin thickness 

Friction for materials can be set up using a real world table or calculator such as:  https://www.engineeringtoolbox.com/friction-coefficients-d_778.html 

Since material is assigned to a body, that would limit complex material setup on trimeshes or compound collisions where multiple materials are desired on a single shape. In such case you can use a custom material setup can be implemented in following way:

NewtonContactsProcess callback sends you the contact "joint" object pointer which you can iterate using (NewtonContactJointGetContactCount, NewtonContactJointGetFirstContact, NewtonContactJointGetNextContact).

* To determine which part of compound collision, you can use NewtonMaterialGetBodyCollidingShape function, that will give you individual piece of compound collision that collided. On that you can make another call to NewtonCollisionGetUserData to get collision shape's user data. 
* To determine which part of trimesh collided, you can use NewtonMaterialGetContactFaceAttribute, that will give you the faceid / faceAttribute that you specified while building the trimesh - function NewtonTreeCollisionAddFace. 

With material contact functions you can then control individual customized collision contact response, this are:

NewtonMaterialSetContactSoftness
NewtonMaterialSetContactThickness
NewtonMaterialSetContactElasticity
NewtonMaterialSetContactFrictionState
NewtonMaterialSetContactFrictionCoef
NewtonMaterialSetContactNormalAcceleration
NewtonMaterialSetContactNormalDirection
NewtonMaterialSetContactPosition
NewtonMaterialSetContactTangentFriction
NewtonMaterialSetContactTangentAcceleration
NewtonMaterialContactRotateTangentDirections
NewtonMaterialGetContactPruningTolerance
NewtonMaterialSetContactPruningTolerance