Best way to implement moving spaceships with interiors

Googolplexed
Posts: 1
Joined: Sat Apr 23, 2011 8:25 am

Best way to implement moving spaceships with interiors

Post by Googolplexed »

Right now, I've got a little project slowly getting off the ground.
It simulates space-ship combat, with the interior of the ships simulated.

My issue at the moment, is ensuring that if the ship was to accelerate, the dynamic objects inside would not be effected.

The ship itself would be controlled directly from other parts of the code, however I want to ensure that when it is rotated, all the physics objects inside are automatically synced with the movement as-well. (Think star-trek, accelerating at 100kms^-2 doesn't cause the crew to become impaled on a wall)

Whats the best way to accomplish this ?
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Re: Best way to implement moving spaceships with interiors

Post by dphil »

I'd also be interested on ideas about this. Essentially you want objects internal tot he spaceship to have a transform that is relative to the ship, such the when the ship translated, rotates, etc, the internal objects match this behaviour. This is taken into account automatically in graphics systems like Ogre with scene node hierarchies. I'm not sure about bullet, aside from manually updating transforms/motionstates of every internal object to match the ship at every step...
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Best way to implement moving spaceships with interiors

Post by Flix »

Googolplexed wrote:My issue at the moment, is ensuring that if the ship was to accelerate, the dynamic objects inside would not be effected.
I would try extending the btCompoundShape class (or maybe implementing a completely new custom class based on the btCompoundShape code), so that it can contain not only child shapes, but child rigid bodies as well (that are automatically removed/added to the world when they are attached/detached to this new compound shape).
Storing whole rigid bodies instead of just shapes is essential to preserve all their properties, so that they can be reused when the bodies are released again.
I don't think it's too easy to implement such a shape, expecially because inner bodies may have a center of mass offset that should be taken into account when doing glue/fracture operations, and because and the mass/inertia of the new compound shape should change every time in a way that is not too trivial...
I can't think of any different general approach, but maybe you can just keep another precalculated compound shape for your ship that contains all the physics objects inside it, and use it when you don't want them to move...

[Edit] Using a fixed constraint for each of the internal bodies is by far the easiest approach...