Hi all!
I'd like to make a little space "simulator". I'm using Ogre3D with Bullet (and btOgre), i have a world with physics (zero gravity), a space-like skybox and a spaceship.
My problem is:
How can i control the space ship's physical body(rotate,accelerate,lift,etc...) in zero gravity, without infinite moving.
Also, if the ship's body rotated and i apply CentralForce to for example the y axis to move up, it applies to the fix y axis, not the rotated one, how to fix this?
Thank you in advance, and sorry for my noob questions, but i don't know where to start :/
Greetings from Hungary!
[Help] Controlling a spaceship
-
- Posts: 168
- Joined: Tue Jan 04, 2011 11:47 pm
Re: [Help] Controlling a spaceship
Hi,
zero gravity can be set with: (I didn't use before, but should work)
About the fixed y axis problem, you can get the rotation of the object first, and multiply with the force, which essentially transform the force to the object coordinate.
Hope this helps.
zero gravity can be set with: (I didn't use before, but should work)
Code: Select all
void btRigidBody::setGravity(const btVector3& acceleration)
Hope this helps.
-
- Posts: 4
- Joined: Mon Mar 25, 2013 10:14 pm
Re: [Help] Controlling a spaceship
I've set up the gravity at the physics world initialization.
The object moving should be done by the ApplyForce or ApplyTorque or ApplyCentralFore/Impulse, or Transform function?
The object moving should be done by the ApplyForce or ApplyTorque or ApplyCentralFore/Impulse, or Transform function?
-
- Posts: 168
- Joined: Tue Jan 04, 2011 11:47 pm
Re: [Help] Controlling a spaceship
if you only need to apply force at the center of mass, then go for the applycentralforce etc. If you choose apply force, you need to specify both the force and the position on which it is applied. Really depends on your situation.
-
- Posts: 4
- Joined: Mon Mar 25, 2013 10:14 pm
Re: [Help] Controlling a spaceship
Now i figured out, how to use WorldTransform of the body, i can rotate and move it, but the moving is still on the world's axis' and not on the body's. Any idea how to solve this?
What i do to move the body:
This moves the body, but if i rotate the ship, and want to move again, it still moves on the same axis like before the rotation.
Thank you in advance for your help!
What i do to move the body:
Code: Select all
mShipBody->activate(true);
mShipBody->setWorldTransform(btTransform(mShipBody->getOrientation(),mShipBody->getCenterOfMassPosition() + btVector3(0,0,10*elapsedTime)));
Thank you in advance for your help!
-
- Posts: 168
- Joined: Tue Jan 04, 2011 11:47 pm
Re: [Help] Controlling a spaceship
As far as I can understand, you want to move in the body's coordinate, rather than world coordinate?
I think the best way to do this is to set the transformation in body's coordinate as T_body, and get current transformation of the body as T_current, and pass T_current*T_body into setWorldTransform().
I think the best way to do this is to set the transformation in body's coordinate as T_body, and get current transformation of the body as T_current, and pass T_current*T_body into setWorldTransform().
-
- Posts: 4
- Joined: Mon Mar 25, 2013 10:14 pm
Re: [Help] Controlling a spaceship
Thank you for your response, that's exactly what i want to do.
I'll try it when i get home
I'll try it when i get home