YASim add surface id and export surface positions to prop tree after model compile.
This commit is contained in:
parent
dd420c6ff4
commit
021a9db9be
3 changed files with 35 additions and 0 deletions
|
@ -21,6 +21,7 @@
|
||||||
#include "Rotor.hpp"
|
#include "Rotor.hpp"
|
||||||
#include "Rotorpart.hpp"
|
#include "Rotorpart.hpp"
|
||||||
#include "Hitch.hpp"
|
#include "Hitch.hpp"
|
||||||
|
#include "Surface.hpp"
|
||||||
|
|
||||||
#include "FGFDM.hpp"
|
#include "FGFDM.hpp"
|
||||||
|
|
||||||
|
@ -118,6 +119,8 @@ Airplane* FGFDM::getAirplane()
|
||||||
|
|
||||||
void FGFDM::init()
|
void FGFDM::init()
|
||||||
{
|
{
|
||||||
|
//reset id generator, needed on simulator reset/re-init
|
||||||
|
Surface::resetIDgen();
|
||||||
_turb_magnitude_norm = fgGetNode("/environment/turbulence/magnitude-norm", true);
|
_turb_magnitude_norm = fgGetNode("/environment/turbulence/magnitude-norm", true);
|
||||||
_turb_rate_hz = fgGetNode("/environment/turbulence/rate-hz", true);
|
_turb_rate_hz = fgGetNode("/environment/turbulence/rate-hz", true);
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
|
#include <Main/fg_props.hxx>
|
||||||
#include "Math.hpp"
|
#include "Math.hpp"
|
||||||
#include "Surface.hpp"
|
#include "Surface.hpp"
|
||||||
|
|
||||||
namespace yasim {
|
namespace yasim {
|
||||||
|
int Surface::s_idGenerator = 0;
|
||||||
|
|
||||||
Surface::Surface( Version * version ) :
|
Surface::Surface( Version * version ) :
|
||||||
_version(version)
|
_version(version)
|
||||||
{
|
{
|
||||||
|
// create id for surface
|
||||||
|
_id = s_idGenerator++;
|
||||||
// Start in a "sane" mode, so unset stuff doesn't freak us out
|
// Start in a "sane" mode, so unset stuff doesn't freak us out
|
||||||
_c0 = 1;
|
_c0 = 1;
|
||||||
_cx = _cy = _cz = 1;
|
_cx = _cy = _cz = 1;
|
||||||
|
@ -30,12 +35,21 @@ Surface::Surface( Version * version ) :
|
||||||
_slatAlpha = 0;
|
_slatAlpha = 0;
|
||||||
_spoilerLift = 1;
|
_spoilerLift = 1;
|
||||||
_inducedDrag = 1;
|
_inducedDrag = 1;
|
||||||
|
_surfN = fgGetNode("/fdm/yasim/surfaces", true);
|
||||||
|
if (_surfN != 0)
|
||||||
|
_surfN = _surfN->getChild("surface", _id, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Surface::setPosition(float* p)
|
void Surface::setPosition(float* p)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i=0; i<3; i++) _pos[i] = p[i];
|
for(i=0; i<3; i++) _pos[i] = p[i];
|
||||||
|
if (_surfN != 0) {
|
||||||
|
_surfN->getNode("pos-x", true)->setFloatValue(p[0]);
|
||||||
|
_surfN->getNode("pos-y", true)->setFloatValue(p[1]);
|
||||||
|
_surfN->getNode("pos-z", true)->setFloatValue(p[2]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Surface::getPosition(float* out)
|
void Surface::getPosition(float* out)
|
||||||
|
@ -136,7 +150,10 @@ void Surface::setSpoilerParams(float liftPenalty, float dragPenalty)
|
||||||
|
|
||||||
void Surface::setFlapPos(float pos)
|
void Surface::setFlapPos(float pos)
|
||||||
{
|
{
|
||||||
|
if (_flapPos != pos) {
|
||||||
_flapPos = pos;
|
_flapPos = pos;
|
||||||
|
if (_surfN != 0) _surfN->getNode("flap-pos", true)->setFloatValue(pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Surface::setFlapEffectiveness(float effectiveness)
|
void Surface::setFlapEffectiveness(float effectiveness)
|
||||||
|
@ -152,12 +169,18 @@ double Surface::getFlapEffectiveness()
|
||||||
|
|
||||||
void Surface::setSlatPos(float pos)
|
void Surface::setSlatPos(float pos)
|
||||||
{
|
{
|
||||||
|
if (_slatPos != pos) {
|
||||||
_slatPos = pos;
|
_slatPos = pos;
|
||||||
|
if (_surfN != 0) _surfN->getNode("slat-pos", true)->setFloatValue(pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Surface::setSpoilerPos(float pos)
|
void Surface::setSpoilerPos(float pos)
|
||||||
{
|
{
|
||||||
|
if (_spoilerPos != pos) {
|
||||||
_spoilerPos = pos;
|
_spoilerPos = pos;
|
||||||
|
if (_surfN != 0) _surfN->getNode("spoiler-pos", true)->setFloatValue(pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the aerodynamic force given a wind vector v (in the
|
// Calculate the aerodynamic force given a wind vector v (in the
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef _SURFACE_HPP
|
#ifndef _SURFACE_HPP
|
||||||
#define _SURFACE_HPP
|
#define _SURFACE_HPP
|
||||||
|
|
||||||
|
#include <simgear/props/props.hxx>
|
||||||
#include "Version.hpp"
|
#include "Version.hpp"
|
||||||
|
|
||||||
namespace yasim {
|
namespace yasim {
|
||||||
|
@ -10,9 +11,15 @@ namespace yasim {
|
||||||
// front, and flaps act (in both lift and drag) toward the back.
|
// front, and flaps act (in both lift and drag) toward the back.
|
||||||
class Surface
|
class Surface
|
||||||
{
|
{
|
||||||
|
static int s_idGenerator;
|
||||||
|
int _id; //index for property tree
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Surface( Version * version );
|
Surface( Version * version );
|
||||||
|
|
||||||
|
int getID() { return _id; };
|
||||||
|
static void resetIDgen() { s_idGenerator = 0; };
|
||||||
|
|
||||||
// Position of this surface in local coords
|
// Position of this surface in local coords
|
||||||
void setPosition(float* p);
|
void setPosition(float* p);
|
||||||
void getPosition(float* out);
|
void getPosition(float* out);
|
||||||
|
@ -75,6 +82,8 @@ public:
|
||||||
void calcForce(float* v, float rho, float* forceOut, float* torqueOut);
|
void calcForce(float* v, float rho, float* forceOut, float* torqueOut);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
SGPropertyNode_ptr _surfN;
|
||||||
|
|
||||||
float stallFunc(float* v);
|
float stallFunc(float* v);
|
||||||
float flapLift(float alpha);
|
float flapLift(float alpha);
|
||||||
float controlDrag(float lift, float drag);
|
float controlDrag(float lift, float drag);
|
||||||
|
|
Loading…
Reference in a new issue