Where do I set the materials and coefficients for response?

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Spankenstein
Posts: 249
Joined: Wed Nov 17, 2010 1:49 pm

Where do I set the materials and coefficients for response?

Post by Spankenstein »

Where should I dynamically set the materials, restitution coefficients and friction coefficients for the correct collision response between two objects?

Is there a particular method I should overload? Does the 'MaterialManager' class come into play?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Where do I set the materials and coefficients for respon

Post by Norbo »

The kinetic friction, static friction, and bounciness of the two objects are blended using the MaterialManager.MaterialBlender. This defaults to the MaterialManager.DefaultMaterialBlender function which multiplies the values together. The MaterialManager.MaterialBlender delegate can be changed.

For special cases between certain materials, the MaterialBlender.MaterialInteractions can be used. This is a dictionary which associates material pairs with arbitrary MaterialBlender delegates. If a pair is defined in the dictionary, the custom delegate will be used instead of the catch-all MaterialManager.MaterialBlender.
Spankenstein
Posts: 249
Joined: Wed Nov 17, 2010 1:49 pm

Re: Where do I set the materials and coefficients for respon

Post by Spankenstein »

EDIT:

I think I've got it now :)

Code: Select all

            MaterialBlender woodOnWood = delegate(Material a, Material b, out InteractionProperties properties)
            {
                properties.Bounciness = a.Bounciness;
                properties.KineticFriction = 0.25f;
                properties.StaticFriction = 0.5f;
            };

            Material wood = new Material();
            wood.Bounciness = 0.603f; 

            MaterialManager.MaterialInteractions.Add(new MaterialPair(wood, wood), woodOnWood);
Post Reply