From: andy Date: Fri, 8 Apr 2005 20:46:43 +0000 (+0000) Subject: Export "rollspeed-ms" and "caster-angle-deg" properties for gear X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7eb194b3f8bf4280c994fcea0edf177f6a92cff4;p=flightgear.git Export "rollspeed-ms" and "caster-angle-deg" properties for gear objects. Josh Babcock wanted these for the B-29 model so he can properly animate the gear. --- diff --git a/src/FDM/YASim/Gear.cpp b/src/FDM/YASim/Gear.cpp index d56a519a0..c8439aa7d 100644 --- a/src/FDM/YASim/Gear.cpp +++ b/src/FDM/YASim/Gear.cpp @@ -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; diff --git a/src/FDM/YASim/Gear.hpp b/src/FDM/YASim/Gear.hpp index a042d26e5..6b0301fe1 100644 --- a/src/FDM/YASim/Gear.hpp +++ b/src/FDM/YASim/Gear.hpp @@ -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 diff --git a/src/FDM/YASim/YASim.cxx b/src/FDM/YASim/YASim.cxx index d6c2236b4..cd5e0dd6b 100644 --- a/src/FDM/YASim/YASim.cxx +++ b/src/FDM/YASim/YASim.cxx @@ -24,6 +24,8 @@ #include "YASim.hxx" +#include // 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();