simulating underwater space

Dmitriy

11-05-2012 14:28:01

I have the body in space. This space must be underwater world. There are must be Archimed's force that influence to body. I wrote:

body->addLocalForce(0,body->getMass()*9.8,0);

Body is not falling it stays in the air i.e underwater.
I need to move it by forces and torques now. When I add forces or torques, they give velocity to my body, but the body is never stops now. That because of there is no friction in the space. How can I add friction to the space? Is it possible or is there any solution? For now i think to add forces of friction by the hands, by body->addForce(), but it seems to me is not the best way.

betajaen

11-05-2012 21:13:57

Forces are the correct way to do it, but your math isn't.

Just turn off scene gravity, and use volumes to detect when the body is underwater, then apply a gravity/buoyancy force to it each frame.

Dmitriy

12-05-2012 02:25:34

Maybe you mean gravity + buoyance force?

Ok and then body will move up or down, without adding other forces. And when I apply any forces to it, I just need to apply friction force vector that has inverse direction to velocity vector until velocity is 0, right?

There is a small trouble with velocity vector that I found in debug mode.
Before I apply torque to my body everything is ok- velocity vector directed in the right way. But I apply torque to body then it rotates and when I apply force to it velocity vector directed in the same way that it was beforŅƒ. I tried addForce and addLocalForce methods. I think it because of that center of mass is not rotate's. What i should to do?

I add screenshots before and after apply torque
BEFORE

AFTER

betajaen

12-05-2012 20:26:44

It may be worth asking on a PhysX forum, as this is pure PhysX code really. Best not mention NxOgre, otherwise they'll ask you to post here.

I do remember making an anti-gravity body once, if I remember correctly, the trick was to use the correct impulse type, with the correct mass and time, with the gravity flag turned off for that Actor.

It may even be in the the tutorials;

https://github.com/betajaen/nxogretutor ... ild/source