+void Model::updateGround(State* s)
+{
+ float dummy[3];
+ _ground_cb->getGroundPlane(s->pos, _global_ground, dummy);
+
+ int i;
+ // The landing gear
+ for(i=0; i<_gears.size(); i++) {
+ Gear* g = (Gear*)_gears.get(i);
+
+ // Get the point of ground contact
+ float pos[3], cmpr[3];
+ g->getPosition(pos);
+ g->getCompression(cmpr);
+
+ Math::mul3(g->getCompressFraction(), cmpr, cmpr);
+ Math::add3(cmpr, pos, pos);
+ // Transform the local coordinates of the contact point to
+ // global coordinates.
+ double pt[3];
+ s->posLocalToGlobal(pos, pt);
+
+ // Ask for the ground plane in the global coordinate system
+ double global_ground[4];
+ float global_vel[3];
+ const SGMaterial* material;
+ _ground_cb->getGroundPlane(pt, global_ground, global_vel, &material);
+ g->setGlobalGround(global_ground, global_vel, pt[0], pt[1], material);
+ }
+
+ for(i=0; i<_hitches.size(); i++) {
+ Hitch* h = (Hitch*)_hitches.get(i);
+
+ // Get the point of interest
+ float pos[3];
+ h->getPosition(pos);
+
+ // Transform the local coordinates of the contact point to
+ // global coordinates.
+ double pt[3];
+ s->posLocalToGlobal(pos, pt);
+
+ // Ask for the ground plane in the global coordinate system
+ double global_ground[4];
+ float global_vel[3];
+ _ground_cb->getGroundPlane(pt, global_ground, global_vel);
+ h->setGlobalGround(global_ground, global_vel);
+ }
+
+ for(i=0; i<_rotorgear.getRotors()->size(); i++) {
+ Rotor* r = (Rotor*)_rotorgear.getRotors()->get(i);
+ r->findGroundEffectAltitude(_ground_cb,s);
+ }
+
+ // The arrester hook
+ if(_hook) {
+ double pt[3];
+ _hook->getTipGlobalPosition(s, pt);
+ double global_ground[4];
+ _ground_cb->getGroundPlane(pt, global_ground, dummy);
+ _hook->setGlobalGround(global_ground);
+ }
+
+ // The launchbar/holdback
+ if(_launchbar) {
+ double pt[3];
+ _launchbar->getTipGlobalPosition(s, pt);
+ double global_ground[4];
+ _ground_cb->getGroundPlane(pt, global_ground, dummy);
+ _launchbar->setGlobalGround(global_ground);
+ }
+}
+