]> git.mxchange.org Git - flightgear.git/commitdiff
Export "rollspeed-ms" and "caster-angle-deg" properties for gear
authorandy <andy>
Fri, 8 Apr 2005 20:46:43 +0000 (20:46 +0000)
committerandy <andy>
Fri, 8 Apr 2005 20:46:43 +0000 (20:46 +0000)
objects.  Josh Babcock wanted these for the B-29 model so he can
properly animate the gear.

src/FDM/YASim/Gear.cpp
src/FDM/YASim/Gear.hpp
src/FDM/YASim/YASim.cxx

index d56a519a046386498d8e5440773840ba1ea91285..c8439aa7d6d8bbb8c16afcbfcc65a1eb9c9d5e3c 100644 (file)
@@ -230,10 +230,6 @@ void Gear::calcForce(RigidBody* body, State *s, float* v, float* rot)
     _wow = (fmag - damp) * -Math::dot3(cmpr, ground);
     Math::mul3(-_wow, ground, _force);
 
-    // Castering gear feel no force in the ground plane
-    if(_castering)
-       return;
-
     // Wheels are funky.  Split the velocity along the ground plane
     // into rolling and skidding components.  Assuming small angles,
     // we generate "forward" and "left" unit vectors (the compression
@@ -272,6 +268,15 @@ void Gear::calcForce(RigidBody* body, State *s, float* v, float* rot)
     float vskid  = Math::dot3(cv, skid);
     float wgt = Math::dot3(_force, gup); // force into the ground
 
+    if(_castering) {
+        _rollSpeed = Math::sqrt(vsteer*vsteer + vskid*vskid);
+        _casterAngle = Math::atan2(vskid, vsteer);
+        return;
+    } else {
+        _rollSpeed = vsteer;
+        _casterAngle = 0;
+    }
+
     float fsteer = _brake * calcFriction(wgt, vsteer);
     float fskid  = calcFriction(wgt, vskid);
     if(vsteer > 0) fsteer = -fsteer;
index a042d26e57ab9dd47d26321fb108369105d27503..6b0301fe1767bd94f5d261ae53d51257156afb34 100644 (file)
@@ -52,6 +52,8 @@ public:
     float getRotation();
     float getExtension();
     bool getCastering();
+    float getCasterAngle() { return _casterAngle; }
+    float getRollSpeed() { return _rollSpeed; }
 
     // Takes a velocity of the aircraft relative to ground, a rotation
     // vector, and a ground plane (all specified in local coordinates)
@@ -84,6 +86,8 @@ private:
     float _frac;
     double _global_ground[4];
     float _global_vel[3];
+    float _casterAngle;
+    float _rollSpeed;
 };
 
 }; // namespace yasim
index d6c2236b4e5485eb50be3a08cbe6f020085e05b6..cd5e0dd6b464b56fa36aee572399726623bcffb9 100644 (file)
@@ -24,6 +24,8 @@
 
 #include "YASim.hxx"
 
+#include <fenv.h> // SIGFPE DEBUG
+
 using namespace yasim;
 
 static const float YASIM_PI = 3.14159265358979323846;
@@ -459,6 +461,8 @@ void YASim::copyFromYASim()
        node->setBoolValue("has-brake", g->getBrake() != 0);
        node->setBoolValue("wow", g->getCompressFraction() != 0);
        node->setFloatValue("compression-norm", g->getCompressFraction());
+        node->setFloatValue("caster-angle-deg", g->getCasterAngle() * RAD2DEG);
+        node->setFloatValue("rollspeed-ms", g->getRollSpeed());
     }
 
     Hook* h = airplane->getHook();