Until now I have simulated the "hovering" by low friction - which works well for developing the steering - but is not what i want.
I am working with my hovercraft (collision box) and 9.81 gravity. As far as i have worked out it should be possible to just apply an counter-force to the gravity.
To do it, I compute the 4 corner-points of my hovercraft, calculate the distance to the floor (which is only a simple plane at the moment) and generate a counterforce for each corner.
i am doing this in tickcallback (prestep)
Code: Select all
// corner = (0,-1,0) and so on for each corner
btVector3 world_corner;
world_corner = trans(corner); // get corner in world space
float altitude = wcorner.y(); // just get the height of the corner in worldspace
if( altitude < 1.0f ) // treshold in which counter-force is applied
{
btVector3 force(0,-(9.81f*player.weigth),0); // make "anti-gravity", weigth = ~290kg, so max anti-grav = 2900N .. ?
float diff = (altitude-1.0f); // compute relative
force *= diff;
btVector3 trg = corner;
trg.rotate(tt.getAxis(),tt.getAngle()); // transform to object space, tt = getRotation from worldtransform
body->applyImpulse(force*timestep,trg); // apply to rigid body corner
}
I think it is because of the applied torque which brings down the opposite edge again and so on.
Is my approach generally wrong or do i need any special value for AngularFactor ..? As far as i can imagine the torques on each corner should eliminate themselfs and only the strongest should survive.
Any help would be highly apprecated
...also how can i prevent the body from ever touching the ground .. infinite anti-grav .. do i need to handle gravity myself for that?