How to create a RigidDynamic / Shape of a cylinder

Hello people!

I have a couple of questions …

1. How can I create the rigidDynamic / shape of a cylinder? to create a barrel for example.

2. As I can do to make rigidDynamic have different behaviors to the floor or collide with between them, simulating for example a block of iron or a wooden box, a sphere of low weight leather and stuff like that?
I’ve looked at the interface of RigidDynamic and only see that you can adjust the mass and the documentation I could not find anything about this.

regards and Thanks.

Hi

1. Cylinder aren´t possible (yet) in PhysX 3.x - in the 2.x versions there was a method for it.

Hard way and “exactly” shapes:
You can create an convex mesh - you need to cook the mesh from the infos you got.
Or a static mesh of course. Depended what you want to archiev.
[In your case, you need to pass the triangle data and stuff from the Ogre mesh to your convex cooker]

Easy way using simple shapes:
(The collision meshs are not accurate, thus its not recommended if you need “exact” results)
-> Build your cylinder with some PxShapes which uses PxBoxGeometry, and PxSphereGeometry, or PxCapsuleGeometry -
or use 2 PxShapes [PxSpehere] wich is at the bottom and the top of the barrel.
Simple, but inaccurate.

One hint:
Just imagine a 1000kg rock and a 0.01kg feather falls from 100 meter high.
Which one will be the first hitting the ground?

• Answer. They hits the ground almost at the same time.
Thats the behaviour of gravity. If you want to have “more realistic” physics, like
the feather would take much longer than the rock to fall down on the ground, you need
to add forces to simulate “air friction” (dont know if this is the english word for it.)

I dont know if you can scale the gravity for each PxActor, if so, this is an alternative.
(Not needed for my projects yet)

There is also another setting for PxRigidDynamics:

setAngularDamping
setAngularVelocity
setCMassLocalPose
setLinearDamping
setLinearVelocity

which might be worth to mention if you testing the behaviour of PxActors.

Hi,
I’ve done some testing with the instructions you gave me and I have observed several things:

1. As for what to add force to counteract gravity and simulate an object that weighs less than another, I used the function

You asks as you spend a minimum PxVec3 (indicating which axis you want to occur the force).
The second parameter that can be passed is a PxForceMode.
I have noticed that if I spend a PxForceMode::eIMPULSE or PxForceMode::eFORCE nothing happens. I.e visually none force is applied to object although put very high values.

With PxForceMode::eACCELERATION or PxForceMode::eVELOCITY_CHANGE If changes are observed, being with “::eAcceleration” with the best results I got. But are “unstable and unexpected” results because the same values ​​they behave in different ways.
Ie Putting -9.8 gravity force and adding a 9.0 eg the object falls to the ground (very slowly as you would expect) but sometimes when it bounces, the object moves up indefinitely.
I have tried many trying to find appropriate values ​​but the behavior is always hard to predict and that could cause a bug in some situation.

I’ve looked at the API and the interface PxSceneDesc to see if there any function that would allow changing the influence of gravity to an object only, while others are still in the initial severity, but found nothing. Surely there is no function to do that.

1. With respect to the types of materials to simulate wood, iron, etc… the first and second parameters that are passed to the function createMaterial (StaticFriction, DynamicFriction, restitution) does not seem to affect naked eye to the form of the object react to a collision.

Only the value “restitution” is the one that seems to affect the object, causing it to bounce more or less in a collision.

1. As for what to create a “convex mesh”, I think I’m gonna have to start early to learn how it works. I’ll see these days and if I have a rare thing, I send you a message.

Greetings and thanks.

Hi,
sorry I dont have much time to answer.

you should also test setLinearDamping.
Add force to your actor can cause some undesired effects of course.
But its just a test, you also could set the kinematic flag for your actor and calculate the gravity by your own.

I dont know how you add the force to your actor, but when its on the ground - ( or the gravity is smaler than -9.8 you add 9.0 to it - of course it would move upwards.

You also could limit your velocity - but you are only testing the PxActor. There are many ways to reach the goal.

-> Friction handles when your actors are on the ground, and you try to push them / add force to them.
Those with high friction values are stoping faster / or wont move with smaller forces.
When 2 actors collides, they should react correctly. (Depending of their mass of course)

You definatly should look into the PhysXGuide and the samples from the sdk.
There are some hints how you deal corretly with cooking meshs or using triggershapes / or use custom gravity. Or look into the sample with the submarine - its “moving delay velocity” is interesting.

Ok. Thanks