WeightRec* wr = new WeightRec();
wr->handle = _model.getBody()->addMass(0, pos);
- wr->surf = new Surface();
+ wr->surf = new Surface(this);
wr->surf->setPosition(pos);
wr->surf->setTotalDrag(size*size);
_model.addSurface(wr->surf);
wgt += mass;
// Make a Surface too
- Surface* s = new Surface();
+ Surface* s = new Surface(this);
s->setPosition(pos);
float sideDrag = len/wid;
- s->setXDrag(f->_cx);
+ if( isVersionOrNewer( YASIM_VERSION_32 ) ) {
+ s->setXDrag(f->_cx);
+ }
s->setYDrag(sideDrag*f->_cy);
s->setZDrag(sideDrag*f->_cz);
- s->setTotalDrag(scale*segWgt);
+ if( isVersionOrNewer( YASIM_VERSION_32 ) ) {
+ s->setTotalDrag(scale*segWgt);
+ } else {
+ s->setTotalDrag(scale*segWgt*f->_cx);
+ }
s->setInducedDrag(f->_idrag);
// FIXME: fails for fuselages aligned along the Y axis
Gear* g = gr->gear;
// Make a Surface object for the aerodynamic behavior
- Surface* s = new Surface();
+ Surface* s = new Surface(this);
gr->surf = s;
// Put the surface at the half-way point on the gear strut, give
#include "Wing.hpp"
#include "Rotor.hpp"
#include "Vector.hpp"
+#include "Version.hpp"
namespace yasim {
class Thruster;
class Hitch;
-class Airplane {
+class Airplane : public Version {
public:
Airplane();
~Airplane();
TurbineEngine.cpp
Turbulence.cpp
Wing.cpp
+ Version.cpp
)
set(SOURCES
if(eq(name, "airplane")) {
_airplane.setWeight(attrf(a, "mass") * LBS2KG);
+ if(a->hasAttribute("version")) {
+ _airplane.setVersion( a->getValue("version") );
+ }
+ if( !_airplane.isVersionOrNewer( Version::YASIM_VERSION_CURRENT ) ) {
+ SG_LOG(SG_FLIGHT,SG_ALERT, "This aircraft does not use the latest yasim configuration version.");
+ }
} else if(eq(name, "approach")) {
float spd = attrf(a, "speed") * KTS2MPS;
float alt = attrf(a, "alt", 0) * FT2M;
#undef p2
r->setInUse();
} else if(eq(name, "wing")) {
- _airplane.setWing(parseWing(a, name));
+ _airplane.setWing(parseWing(a, name, &_airplane));
} else if(eq(name, "hstab")) {
- _airplane.setTail(parseWing(a, name));
+ _airplane.setTail(parseWing(a, name, &_airplane));
} else if(eq(name, "vstab") || eq(name, "mstab")) {
- _airplane.addVStab(parseWing(a, name));
+ _airplane.addVStab(parseWing(a, name, &_airplane));
} else if(eq(name, "piston-engine")) {
parsePistonEngine(a);
} else if(eq(name, "turbine-engine")) {
}
}
-Wing* FGFDM::parseWing(XMLAttributes* a, const char* type)
+Wing* FGFDM::parseWing(XMLAttributes* a, const char* type, Version * version)
{
- Wing* w = new Wing();
+ Wing* w = new Wing(version);
float defDihed = 0;
if(eq(type, "vstab"))
namespace yasim {
class Wing;
+class Version;
// This class forms the "glue" to the FlightGear codebase. It handles
// parsing of XML airplane files, interfacing to the properties
void setOutputProperties(float dt);
Rotor* parseRotor(XMLAttributes* a, const char* name);
- Wing* parseWing(XMLAttributes* a, const char* name);
+ Wing* parseWing(XMLAttributes* a, const char* name, Version * version);
int parseAxis(const char* name);
int parseOutput(const char* name);
void parseWeight(XMLAttributes* a);
#include "Surface.hpp"
namespace yasim {
-Surface::Surface()
+Surface::Surface( Version * version ) :
+ _version(version)
{
// Start in a "sane" mode, so unset stuff doesn't freak us out
_c0 = 1;
// coordinates. Since out[] is now the force vector and is
// roughly parallel with Z, the small-angle approximation
// must change its X component.
- out[0] += incidence * out[2];
+ if( _version->isVersionOrNewer( Version::YASIM_VERSION_32 )) {
+ out[0] += incidence * out[2];
+ } else {
+ out[2] -= incidence * out[0];
+ }
// Convert back to external coordinates
Math::tmul33(_orient, out, out);
if(stallAlpha == 0)
return 1;
- if(i == 0)
- stallAlpha += _slatPos * _slatAlpha;
+ if(i == 0) {
+ if( _version->isVersionOrNewer( Version::YASIM_VERSION_32 )) {
+ stallAlpha += _slatPos * _slatAlpha;
+ } else {
+ stallAlpha += _slatAlpha;
+ }
+ }
// Beyond the stall
if(alpha > stallAlpha+_widths[i])
#ifndef _SURFACE_HPP
#define _SURFACE_HPP
+#include "Version.hpp"
+
namespace yasim {
// FIXME: need a "chord" member for calculating moments. Generic
class Surface
{
public:
- Surface();
+ Surface( Version * version );
// Position of this surface in local coords
void setPosition(float* p);
float _incidence;
float _twist;
float _inducedDrag;
+
+ Version * _version;
};
}; // namespace yasim
--- /dev/null
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "Version.hpp"
+#include <simgear/debug/logstream.hxx>
+#include <string>
+
+namespace yasim {
+void Version::setVersion( const char * version )
+{
+ const std::string v(version);
+
+ if( v == "YASIM_VERSION_ORIGINAL" ) {
+ _version = YASIM_VERSION_ORIGINAL;
+ } else if( v == "YASIM_VERSION_32" ) {
+ _version = YASIM_VERSION_32;
+ } else if( v == "YASIM_VERSION_CURRENT" ) {
+ _version = YASIM_VERSION_CURRENT;
+ } else {
+ SG_LOG(SG_FLIGHT,SG_ALERT,"unknown yasim version '" << version << "' ignored, using YASIM_VERSION_ORIGINAL");
+ }
+}
+
+} // namespace yasim
--- /dev/null
+#ifndef _VERSION_HPP
+#define _VERSION_HPP
+
+namespace yasim {
+
+class Version {
+public:
+ Version() : _version(YASIM_VERSION_ORIGINAL) {}
+ virtual ~Version() {}
+
+ typedef enum {
+ YASIM_VERSION_ORIGINAL = 0,
+ YASIM_VERSION_32,
+ YASIM_VERSION_CURRENT = YASIM_VERSION_32
+ } YASIM_VERSION;
+
+ void setVersion( const char * version );
+ bool isVersion( YASIM_VERSION version );
+ bool isVersionOrNewer( YASIM_VERSION version );
+
+private:
+ YASIM_VERSION _version;
+};
+
+inline bool Version::isVersion( YASIM_VERSION version )
+{
+ return _version == version;
+}
+
+inline bool Version::isVersionOrNewer( YASIM_VERSION version )
+{
+ return _version >= version;
+}
+
+
+}; // namespace yasim
+#endif // _WING_HPP
namespace yasim {
-Wing::Wing()
+Wing::Wing( Version * version ) :
+ _version(version)
{
_mirror = false;
_base[0] = _base[1] = _base[2] = 0;
Surface* Wing::newSurface(float* pos, float* orient, float chord,
bool flap0, bool flap1, bool slat, bool spoiler)
{
- Surface* s = new Surface();
+ Surface* s = new Surface(_version);
s->setPosition(pos);
s->setOrientation(orient);
#define _WING_HPP
#include "Vector.hpp"
+#include "Version.hpp"
namespace yasim {
// FIXME: need to handle "inverted" controls for mirrored wings.
class Wing {
public:
- Wing();
+ Wing( Version * version );
~Wing();
// Do we mirror ourselves about the XZ plane?
float _slatEnd;
float _slatAoA;
float _slatDrag;
+
+ Version * _version;
};
}; // namespace yasim