38 bool autoTooltipsMaster =
fgGetBool(
"/sim/rendering/automatic-animation-tooltips/enabled");
39 int autoTooltipsMasterMax =
fgGetInt(
"/sim/rendering/automatic-animation-tooltips/max-count");
40 SG_LOG(SG_INPUT, SG_DEBUG,
""
41 <<
" autoTooltipsMaster=" << autoTooltipsMaster
42 <<
" autoTooltipsMasterMax=" << autoTooltipsMasterMax
44 osg::Node* node = simgear::SGModelLib::loadModel(path.utf8Str(), prop_root, NULL, autoTooltipsMaster, autoTooltipsMasterMax);
46 node->setNodeMask(~SG_NODEMASK_TERRAIN_BIT);
148 if (_aircraft.get()) {
149 SG_LOG(SG_AIRCRAFT, SG_ALERT,
"FGAircraftModel::init: already inited");
153 simgear::ErrorReportContext ec(
"primary-aircraft",
"yes");
154 _fx =
new FGFX(
"fx");
157 SGPropertyNode_ptr sim =
fgGetNode(
"/sim",
true);
158 for (
auto model : sim->getChildren(
"model")) {
159 std::string path = model->getStringValue(
"path",
"Models/Geometry/glider.ac");
160 std::string
usage = model->getStringValue(
"usage",
"external");
162 simgear::ErrorReportContext ec(
"aircraft-model", path);
164 SGPath resolvedPath =
globals->resolve_aircraft_path(path);
165 if (resolvedPath.isNull()) {
166 simgear::reportFailure(simgear::LoadFailure::NotFound,
167 simgear::ErrorCode::XMLModelLoad,
168 "Failed to find aircraft model", SGPath::fromUtf8(path));
169 SG_LOG(SG_AIRCRAFT, SG_ALERT,
"Failed to find aircraft model: " << path);
173 osg::Node* node = NULL;
176 }
catch (
const sg_exception &ex) {
177 simgear::reportFailure(simgear::LoadFailure::BadData,
178 simgear::ErrorCode::XMLModelLoad,
179 "Failed to load aircraft model:" + ex.getFormattedMessage(),
181 SG_LOG(SG_AIRCRAFT, SG_ALERT,
"Failed to load aircraft from " << path <<
':');
182 SG_LOG(SG_AIRCRAFT, SG_ALERT,
" " << ex.getFormattedMessage());
185 if (
usage ==
"interior") {
187 if (!_interior.get()) {
188 _interior.reset(
new SGModelPlacement);
189 _interior->init(node);
191 _interior->add(node);
195 if (!_aircraft.get()) {
196 _aircraft.reset(
new SGModelPlacement);
197 _aircraft->init(node);
199 _aircraft->add(node);
205 if (!_aircraft.get()) {
206 SG_LOG(SG_AIRCRAFT, SG_ALERT,
"(Falling back to glider.ac.)");
207 osg::Node* model =
fgLoad3DModel(SGPath::fromUtf8(
"Models/Geometry/glider.ac"),
209 _aircraft.reset(
new SGModelPlacement);
210 _aircraft->init(model);
214 osg::Node* node = _aircraft->getSceneGraph();
215 globals->get_scenery()->get_aircraft_branch()->addChild(node);
217 if (_interior.get()) {
218 node = _interior->getSceneGraph();
219 globals->get_scenery()->get_interior_branch()->addChild(node);
224 visitor_highlight.traverse(*node);
275 int view_number =
globals->get_viewmgr()->getCurrentViewIndex();
276 int is_internal =
fgGetBool(
"/sim/current-view/internal");
278 if (view_number == 0 && !is_internal) {
279 _aircraft->setVisible(
false);
281 _aircraft->setVisible(
true);
284 double heading, pitch, roll;
285 globals->get_aircraft_orientation(heading, pitch, roll);
286 SGQuatd orient = SGQuatd::fromYawPitchRollDeg(heading, pitch, roll);
288 SGGeod pos =
globals->get_aircraft_position();
290 _aircraft->setPosition(pos);
291 _aircraft->setOrientation(orient);
294 if (_interior.get()) {
295 _interior->setPosition(pos);
296 _interior->setOrientation(orient);
301 _fx->set_position_geod( pos );
302 _fx->set_orientation( orient );
304 _velocity = SGVec3d( _speed_n->getDoubleValue(),
305 _speed_e->getDoubleValue(),
306 _speed_d->getDoubleValue() );
307 _fx->set_velocity( _velocity );
309 float temp_c =
fgGetFloat(
"/environment/temperature-degc");
310 float humidity =
fgGetFloat(
"/environment/relative-humidity");
311 float pressure =
fgGetFloat(
"/environment/pressure-inhg")*SG_INHG_TO_PA/1000.0f;
312 _fx->set_atmosphere( temp_c, humidity, pressure );