X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FAIModel%2FAIBase.cxx;h=de107a682bfc8ae356784e42c119304aa80098b3;hb=d35b8db13f7aceee46d63b061cd20e6d3968f92a;hp=74ce8fa895624e93dacf84534b8fdaa1d0542e6e;hpb=157eb857ef36636a316947fe1eb3d9a8bea1959b;p=flightgear.git diff --git a/src/AIModel/AIBase.cxx b/src/AIModel/AIBase.cxx index 74ce8fa89..de107a682 100644 --- a/src/AIModel/AIBase.cxx +++ b/src/AIModel/AIBase.cxx @@ -32,11 +32,8 @@ #include #include -#include -#include -#include +#include #include -#include #include #include #include @@ -47,7 +44,6 @@ #include #include "AIBase.hxx" -#include "AIModelData.hxx" #include "AIManager.hxx" const char *default_model = "Models/Geometry/glider.ac"; @@ -86,6 +82,40 @@ FGAIBase::FGAIBase(object_type ot) : _impact_reported = false; _collision_reported = false; _subID = 0; + + _x_offset = 0; + _y_offset = 0; + _z_offset = 0; + + _pitch_offset = 0; + _roll_offset = 0; + _yaw_offset = 0; + + userpos = SGGeod::fromDeg(0, 0); + + pos = SGGeod::fromDeg(0, 0); + speed = 0; + altitude_ft = 0; + speed_north_deg_sec = 0; + speed_east_deg_sec = 0; + turn_radius_ft = 0; + + ft_per_deg_lon = 0; + ft_per_deg_lat = 0; + + horiz_offset = 0; + vert_offset = 0; + ht_diff = 0; + + serviceable = false; + + fp = 0; + + rho = 1; + T = 280; + p = 1e5; + a = 340; + Mach = 0; } FGAIBase::~FGAIBase() { @@ -178,7 +208,6 @@ bool FGAIBase::init(bool search_in_AI_path) { model = load3DModel(f, props); if (model.valid() && _initialized == false) { - model->setNodeMask(model->getNodeMask() & ~SG_NODEMASK_TERRAIN_BIT); aip.init( model.get() ); aip.setVisible(true); invisible = false; @@ -196,7 +225,8 @@ bool FGAIBase::init(bool search_in_AI_path) { void FGAIBase::initModel(osg::Node *node) { if (model.valid()) { - fgSetString("/ai/models/model-added", props->getPath()); + + fgSetString("/ai/models/model-added", props->getPath().c_str()); } else if (!model_path.empty()) { SG_LOG(SG_INPUT, SG_WARN, "AIBase: Could not load model " << model_path); @@ -209,7 +239,8 @@ void FGAIBase::initModel(osg::Node *node) osg::Node* FGAIBase::load3DModel(const string &path, SGPropertyNode *prop_root) { - model = SGModelLib::loadPagedModel(path, prop_root, new FGAIModelData(this, prop_root)); + model = SGModelLib::loadPagedModel(path, prop_root, new FGNasalModelData(prop_root)); + initModel(model.get()); return model.get(); } @@ -319,9 +350,16 @@ void FGAIBase::unbind() { props->untie("radar/ht-diff-ft"); props->untie("controls/lighting/nav-lights"); + + props->setBoolValue("/sim/controls/radar/", true); + } double FGAIBase::UpdateRadar(FGAIManager* manager) { + bool control = fgGetBool("/sim/controls/radar", true); + + if(!control) return 0; + double radar_range_ft2 = fgGetDouble("/instrumentation/radar/range"); bool force_on = fgGetBool("/instrumentation/radar/debug-mode", false); radar_range_ft2 *= SG_NM_TO_METER * SG_METER_TO_FEET * 1.1; // + 10% @@ -446,6 +484,12 @@ SGVec3d FGAIBase::getCartPos() const { return cartPos; } +bool FGAIBase::getGroundElevationM(const SGGeod& pos, double& elev, + const SGMaterial** material) const { + return globals->get_scenery()->get_elevation_m(pos, elev, material, + model.get()); +} + double FGAIBase::_getCartPosX() const { SGVec3d cartPos = getCartPos(); return cartPos.x();