Saving materials with physics

It tests out fine, everything is great. Thanks randomtask.

To be honest, I don't truly understand the thing with the default Materials…



They are static, but you can do things like this:



Material.RUBBER.setDensity(9.5E-19f);



Also, out of my absolute ignorance about physic engines and jMEPhysics, I don't know why all those comparisons between materials are needed. Why a material is not just a structure with some properties? Why do we need particular material vs. material matching?



If I create a material, how does it behave on contacts with defualt materials?



Thank you guys,

I'll give it a shot (but don't guarantee accuracy)…


They are static, but you can do things like this:

Material.RUBBER.setDensity(9.5E-19f);

Because the materials are static there is only one copy of it in memory, but they aren't final so you can still change their attributes/values. Anybody know otherwise?

Also, out of my absolute ignorance about physic engines and jMEPhysics, I don't know why all those comparisons between materials are needed. Why a material is not just a structure with some properties? Why do we need particular material vs. material matching?

I beleive the reason for defining material pairs is because materials interact differently among other materials. If you have a collision between a rubber material and an ice material, which material do you use? The definition between the pair defines whats happens.

If I create a material, how does it behave on contacts with defualt materials?

This depends, if you define the relationship between you material and the default one, it will use that. But if you don't define a relationship between them, it will pick one, depending on which object is generating the contact info.

I expect irrisor or someone else can get my answers straightened out if I've told you wrong.
nymon said:

They are static, but you can do things like this:

Material.RUBBER.setDensity(9.5E-19f);

Because the materials are static there is only one copy of it in memory, but they aren't final so you can still change their attributes/values. Anybody know otherwise?

Overall that's correct. Aside the word final: The fields where the materials are kept are static and final. But this does not mean that these materials are immutable! It would be possible to create an extra class for immutable materials, but I thought it wouldn't be worth it. These materials defined in the Material class itself are just for convenience anyway. If someone likes to alter them - why not?

nymon said:

If I create a material, how does it behave on contacts with defualt materials?

This depends, if you define the relationship between you material and the default one, it will use that. But if you don't define a relationship between them, it will pick one, depending on which object is generating the contact info.

Somewhat, yes. More precise: if you do not define any contact info for behavior of an exact material pair there are three fall back possibilities: 1. your material has information for contact with an unknown (null) material or 2. the other material has such a default info or 3. both have this info - in the last case the information is merged (actual mathematical operations vary - see material callback).