#include <material.hpp>
Inheritance diagram for irr::newton::Material:
Public Member Functions | |
int | getID () |
get newton material id | |
Material (NewtonWorld *newton_world) | |
void | setCollidable (Material *material_2, float value) |
void | setCollisionCallback (Material *material_2, irr::newton::MaterialCollisionCallback *contact_callback) |
void | setElasticity (Material *material_2, float value) |
void | setFriction (Material *material_2, float static_friction, float kinetic_friction) |
void | setSoftness (Material *material_2, float value) |
~Material () |
irr::newton::Material::Material | ( | NewtonWorld * | newton_world | ) |
costrucotr. don't call this directly. use World::createMaterial() to create a new material
irr::newton::Material::~Material | ( | ) |
destructor
int irr::newton::Material::getID | ( | ) | [inline] |
get newton material id
void irr::newton::Material::setCollidable | ( | Material * | material_2, | |
float | value | |||
) |
void irr::newton::Material::setCollisionCallback | ( | Material * | material_2, | |
irr::newton::MaterialCollisionCallback * | contact_callback | |||
) |
Set material callbacks. When a body with this material colide with an other body of material_2 IrrNewt calls 3 user defined functions. The first is MaterialCollisionCallback::beginContact(), the second MaterialCollisionCallback::processContact() and the third MaterialCollisionCallback::endContact() These functions are virtual, so you can re-implement it to execute your code
From newton documentation:"When the AABB extend of the collision geometry of two bodies overlap, Newton collision system retrieves the material interaction that defines the behavior between the pair of bodies. The material interaction is collected from a database of materials, indexed by the material gruopID assigned to the bodies. If the material is tagged as non collidable, then no action is taken and the simulation continues. If the material is tagged as collidable, and a beginCallback was set for this material, then the beginCallback function is called. If the function *beginCallback* returns 0, no further action is taken for this material (this can be use to ignore the interaction under certain conditions). If the function *beginCallback* returns 1, Newton proceeds to calculate the array of contacts for the pair of colliding bodies. If the function processCallback was set, the application receives a callback for every contact found between the two colliding bodies. Here the application can perform fine grain control over the behavior of the collision system. For example, rejecting the contact, making the contact frictionless, applying special effects to the surface etc. After all contacts are processed and if the function endCallback was set, Newton calls endCallback. Here the application can collect information gathered during the contact-processing phase and provide some feedback to the player. A typical use for the material callback is to play sound effects. The application passes the address of structure in the userData along with three event function callbacks. When the function beginCallback is called by Newton, the application resets a variable say maximumImpactSpeed. Then for every call to the function processCallback, the application compares the impact speed for this contact with the value of maximumImpactSpeed, if the value is larger, then the application stores the new value along with the position, and any other quantity desired. When the application receives the call to endCallback the application plays a 3d sound based in the position and strength of the contact."
material_2 | the second material wich the function takes effects | |
contact_callback | pointer to a MaterialCollisionCallback object wich contain the methods that are called if an collision between 2 materials happen |
void irr::newton::Material::setElasticity | ( | Material * | material_2, | |
float | value | |||
) |
Set the coefficients of restitution (elasticity)
material_2 | the second material wich the function takes effects | |
value | elasticity coefficients, must be a positive value. It is recommended that value be set to a value lower or equal to 1.0 |
void irr::newton::Material::setFriction | ( | Material * | material_2, | |
float | static_friction, | |||
float | kinetic_friction | |||
) |
Set the default coefficients of friction for the material
staticFriction and kineticFriction must be positive values. kineticFriction must be lower than staticFriction. It is recommended that staticFriction and kineticFriction be set to a value lower or equal to 1.0, however because some synthetic materials can have higher than one coeficient of friction Newton allows for the coeficient of friction to be as high as 2.0.
material_2 | the second material wich the function takes effects | |
static_friction | static friction coefient | |
kinetic_friction | dynamic friction coefficient |
void irr::newton::Material::setSoftness | ( | Material * | material_2, | |
float | value | |||
) |
Set the default softness coefficients
softnessCoef must be a positive value. It is recommended that softnessCoef be set to value lower or equal to 1.0 A low value for softnessCoef will make the material soft. A typical value for softnessCoef is 0.15
material_2 | the second material wich the function takes effects | |
value | softness coefficient |