rigid body moving relatively to another

NevilClavain
Posts: 3
Joined: Wed Dec 11, 2013 11:29 am

rigid body moving relatively to another

Post by NevilClavain »

Hi

I'm a new Bullet user, so please excuse my noobishness :? .
I'm coding a space simulator with my homegrown rendering engine and I rely on Bullet to manage all movements and interactions.

I have real-sized procedural planets with seamless landings, and when the player's vessel is approaching a planet's ground, I need the vessel's movements
to be relative to the planet, knowing that :
- planets are following an orbit around another celestial object (star or another planet)
- there's a rotation around north pole/south pole planet axis (day/night alternance)

In addition of it I need a correct collisions detection between vessel body meshe and the planet ground meshe.

In simple terms, a instant t1 I need to "say" to bullet that the movements/speed of rigid body A is "relative" to another moving rigid body B (vessel landing
on planet), and at later instant t2 I need to "say" to bullet that the movements/speed of rigid body A is now standalone and detached from body B
(vessel lift off and leaving planet to space).

In Bullet documentation I did'nt found any feature for this (Maybe by activating a Generic 6 Dof Constraint ????)
Was someone confronted to a similar problem?

Any help/advice will be appreciated
Thanks in advance,

Nevil

PS : I'm using Bullet 2.82
Ateocinico
Posts: 12
Joined: Sat Jun 29, 2013 5:55 pm

Re: rigid body moving relatively to another

Post by Ateocinico »

The btRigidBody class has two member functions: getLinearVelocity and getAngularVelocity. Both return the linear velocity and angular velocity respectively as btVector3 objects. That's all what is needed.
NevilClavain
Posts: 3
Joined: Wed Dec 11, 2013 11:29 am

Re: rigid body moving relatively to another

Post by NevilClavain »

Ateocinico wrote:The btRigidBody class has two member functions: getLinearVelocity and getAngularVelocity. Both return the linear velocity and angular velocity respectively as btVector3 objects. That's all what is needed.
What I deduct from your reply is that the idea is to call such accessors on my "planet" body to retrieve planet velocities and add results to my "vessel" body velocities by successives calls getLinearVelocity/getAngularVelocity and then setLinearVelocity/setAngularVelocity on my "vessel" body, am I right ?

thanks,

Nev
Ateocinico
Posts: 12
Joined: Sat Jun 29, 2013 5:55 pm

Re: rigid body moving relatively to another

Post by Ateocinico »

You need to apply some classical mechanics. It's simply vector arithmetic. If you are not fond of it, you should approach some one that works it for you in paper with some 3D sketches. In principle you take the point of interest on the planet's surface, compute its velocity and subtract it from the rocket's velocity. Then you have the velocity of the rocket as if the point over the planet's surface is still.
NevilClavain
Posts: 3
Joined: Wed Dec 11, 2013 11:29 am

Re: rigid body moving relatively to another

Post by NevilClavain »

Ateocinico wrote:You need to apply some classical mechanics. It's simply vector arithmetic.
Yeah this is what I understood. Will try it ASAP. Thx for the tip :)