dumbo2007
Crazy about real time sims
I thought I was getting quite good with co-ordinate transformation....but nopes, stuck again!
This time I am trying to set a velocity. So first lets define the frames.
I am using a vessel as a base positioned at Brighton Beach, which I call the base vessel.
The DG is attached to it or detached as needed depending on whether collision is needed. When the DG is attached to the base, I control its position based on what Bullet is giving me. This includes when the DG takes off from the pad at Brighton.
After the DG rises to a certain height above the surface, I detach it from the base vessel and let Orbiter take control. However I want to transfer the last reported linear velocity by Bullet to Orbiter. Otherwise immediately after detachment, the DG will have 0 velocity till the Orbiter Engine kicks in and accelerates it.
Now for the code :
First problem, I do get a nearly smooth transition after I set the velocity using above. But there is a slight sideways velocity added. I dont understand why.
I can probably live with it, and maybe somehow compensate for it, but it should not happen. Its very noticeable and the deflection increases with the amount of linear velocity that is set. If I do not set anything then its fine. Which makes me think that somehow I am not converting the linear velocity with respect to the base vessel to the correct vector to set/add to vs.rvel.
Second problem, I printed out the reference body in vs.rbody . Its the Moon, which is correct as the Moon is the nearest gravity reference. Yet I can set vs.rvel to a velocity which is with respect to the base vessel. It should accept relative velocities only with respect to the Moon ! (meaning I should be required to convert the velocity vector). But if I do that using :
I end up somewhere in orbit, high above the Moon !
This time I am trying to set a velocity. So first lets define the frames.
I am using a vessel as a base positioned at Brighton Beach, which I call the base vessel.
The DG is attached to it or detached as needed depending on whether collision is needed. When the DG is attached to the base, I control its position based on what Bullet is giving me. This includes when the DG takes off from the pad at Brighton.
After the DG rises to a certain height above the surface, I detach it from the base vessel and let Orbiter take control. However I want to transfer the last reported linear velocity by Bullet to Orbiter. Otherwise immediately after detachment, the DG will have 0 velocity till the Orbiter Engine kicks in and accelerates it.
Now for the code :
Code:
btVector3 linearVel = rbCollider->getLinearVelocity(); //velocity from Bullet in base frame
VECTOR3 rdirBaseLinearVel = _V(linearVel.x(), linearVel.y(), linearVel.z());
VESSELSTATUS2 vs;
memset(&vs, 0, sizeof(VESSELSTATUS2));
vs.version = 2;
vAttached->GetStatusEx(&vs);
vs.rvel = rdirBaseLinearVel ;
vAttached->DefSetStateEx(&vs);
First problem, I do get a nearly smooth transition after I set the velocity using above. But there is a slight sideways velocity added. I dont understand why.
I can probably live with it, and maybe somehow compensate for it, but it should not happen. Its very noticeable and the deflection increases with the amount of linear velocity that is set. If I do not set anything then its fine. Which makes me think that somehow I am not converting the linear velocity with respect to the base vessel to the correct vector to set/add to vs.rvel.
Second problem, I printed out the reference body in vs.rbody . Its the Moon, which is correct as the Moon is the nearest gravity reference. Yet I can set vs.rvel to a velocity which is with respect to the base vessel. It should accept relative velocities only with respect to the Moon ! (meaning I should be required to convert the velocity vector). But if I do that using :
Code:
baseVessel->Local2Rel(rdirBaseLinearVel, rdirMoonLinearVel);
vs.rvel = rdirMoonLinearVel;
I end up somewhere in orbit, high above the Moon !
Last edited: