Beginner Questions about Spaceship Simulation

L o
Posts: 1
Joined: Tue Oct 27, 2009 6:08 pm

Beginner Questions about Spaceship Simulation

Post by L o »

Hi,

First of all apologize my easy questions. I am just beginning to learn the bullet engine, and hope this is the right forum to post such questions.

I am writing a game with a spaceship, which will fly on planets without air pressure. Thus, the accelleration is linear. The ship starts to accelerate when the user presses a key and stops when the maximum is reached.

How can I simulate this in bullet?

I can build up the btRigidBody for the ship. But which subclass of btCollisionShape will I need to store the vertices in?

Then, how do I accelerate? I found a function "void applyForce (const btVector3 &force, const btVector3 &rel_pos)".
- Is this the best function? Or do you know a better function?
- How often do I need to call it? Only once when the acceleration starts, and then once the acceleration shall be stopped?
- What is meant with the parameters? I mean: Why is one parameter not enough? What is rel_pos needed for?

Thanks for your answers on advance :)

Greets,
Lo
edouard
Posts: 8
Joined: Fri Sep 25, 2009 2:08 pm

Re: Beginner Questions about Spaceship Simulation

Post by edouard »

Hi,
Then, how do I accelerate? I found a function "void applyForce (const btVector3 &force, const btVector3 &rel_pos)".
- Is this the best function? Or do you know a better function?
applyImpulse would be a better choice since it's force apllied over a certain laps of time
- How often do I need to call it? Only once when the acceleration starts, and then once the acceleration shall be stopped?
You call it every frame or substep depending of your implementation. Don't forget to multiply your force by the time of your frame
- What is meant with the parameters? I mean: Why is one parameter not enough? What is rel_pos needed for?
The first parameter is the direction and magnitude of the impulse/force that you want to apply. The second parameter is where in the local coordinate of the object you want to apply this force. In your case if you only want to apply this force to the center of the object you should use applyCentralImpulse.

I hope it helps you a bit