How to use materials?

matches81

03-01-2008 15:29:29

Hi there!

I've recently started working with NxOgre and I've got a small app up and running where you can shove a ball around. Problem is: I'm missing friction. There is a class called NxMaterial where I could set things like dynamic friction and static friction, which sounds exactly like what I wanted to have. However, I don't see how to use those materials.

Also, it would be great if someone could furthermore point me to how the final friction (between 2 materials) is calculated.

Any help appreciated.

betajaen

03-01-2008 16:52:55

Remember most of the classes in PhysX are wrapped in NxOgre, they all use the same pattern. The same name minus the Nx prefix.

Material* myMaterial = mScene->createMaterial("myMaterialName");
myMaterial->setDynamicFriction(0.75f);

mActor->createActor(...., "mass: 10, material: myMaterialName");

matches81

03-01-2008 17:57:44

so I have to have the material created when creating the actor and pass it in as part of the string parameter? is there no way to apply a material to an existing actor?

betajaen

03-01-2008 18:37:36

Yeah. You can.

You need to iterate through each Shape in the Actor, and set the material to it. (Which reminds me the code above is slightly wrong, the material needs to be in the ShapeParams not the ActorParams).

matches81

03-01-2008 22:12:15

Great! Thx. I'll give that a try tomorrow.