@@ -69,6 +69,7 @@ JSBSimPlugin::JSBSimPlugin()
6969 plugin = this ;
7070
7171 geometryTrans = new osg::MatrixTransform ();
72+ geometryTrans->getOrCreateStateSet ()->setMode (GL_CULL_FACE , osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE );
7273
7374 loadAvailableAircraft ();
7475 readJoystickConfiguration ();
@@ -148,6 +149,7 @@ JSBSimPlugin::~JSBSimPlugin()
148149 {
149150 delete FDMExec;
150151 delete printCatalog;
152+ delete startAction;
151153 delete debugButton;
152154 delete resetButton;
153155 delete upButton;
@@ -175,7 +177,8 @@ void JSBSimPlugin::reset(double dz)
175177 // Compute the eyepoint transformation from the aircraft. The GetXYZep method returns
176178 // a dimension in inches, so we divide by
177179 osg::Vec3 aircraftEyePoint (Aircraft->GetXYZep (1 ), Aircraft->GetXYZep (2 ), Aircraft->GetXYZep (3 ));
178- eyePoint = osg::Matrix::translate (aircraftEyePoint / 0.00254 );
180+ eyePoint = osg::Matrix::translate (aircraftEyePoint * 25.4 );
181+ std::cout << " EYE POINT " << aircraftEyePoint * 25.4 << std::endl;
179182
180183 std::shared_ptr<JSBSim::FGInitialCondition> IC = FDMExec->GetIC ();
181184 if (!IC ->Load (SGPath (" reset00.xml" )))
@@ -184,7 +187,7 @@ void JSBSimPlugin::reset(double dz)
184187 }
185188
186189 // Transform the viewer coordinates to lat/lng
187- osg::Vec3 pos = GeoData::instance ()->getGlobalPosition ();
190+ osg::Vec3d pos = GeoData::instance ()->getGlobalPosition ();
188191
189192 float altitude = pos.z ();
190193 float altitudeFt = altitude / METERS_PER_FOOT - Aircraft->GetXYZep (3 ) * FEET_PER_INCH ;
@@ -196,9 +199,9 @@ void JSBSimPlugin::reset(double dz)
196199 // there is also IC->SetAltitudeAGLFtIC(...), maybe we want that?
197200
198201 // Align heading to viewer, reset roll (wings level), keep pitch according to aircraft reset file
199- osg::Vec3 dir (viewer (1 , 0 ), viewer (1 , 1 ), viewer (1 , 2 ));
202+ osg::Vec3d dir (viewer (1 , 0 ), viewer (1 , 1 ), viewer (1 , 2 ));
200203 dir.normalize ();
201- IC ->SetPsiRadIC (atan2 (dir[1 ], dir[0 ])); // heading
204+ IC ->SetPsiRadIC (atan2 (dir[1 ], dir[0 ]) - M_PI_2 ); // heading
202205 IC ->SetPhiRadIC (0.0 ); // roll
203206
204207 // IC->SetPsiRadIC(0.0); // heading
@@ -343,10 +346,10 @@ void JSBSimPlugin::loadAvailableAircraft()
343346 .systemsDir = entry.value <std::string>(" " , " systemsDir" , " systems" )->value (),
344347 .enginesDir = entry.value <std::string>(" " , " enginesDir" , " engine" )->value (),
345348 .geometryTransform = osg::Matrix::scale (s, s, s)
346- * osg::Matrix ::rotate (
347- osg::DegreesToRadians (h), osg::Vec3 (0 , 0 , 1 ),
348- osg::DegreesToRadians (p), osg::Vec3 (1 , 0 , 0 ),
349- osg::DegreesToRadians (r), osg::Vec3 (0 , 1 , 0 ))
349+ * osg::Matrixd ::rotate (
350+ osg::DegreesToRadians (h), osg::Vec3d (0 , 0 , 1 ),
351+ osg::DegreesToRadians (p), osg::Vec3d (1 , 0 , 0 ),
352+ osg::DegreesToRadians (r), osg::Vec3d (0 , 1 , 0 ))
350353 * osg::Matrix::translate (x, y, z),
351354 };
352355
@@ -483,6 +486,10 @@ bool JSBSimPlugin::init()
483486 if (FDMExec)
484487 FDMExec->PrintPropertyCatalog (); });
485488
489+ startAction = new ui::Action (JSBMenu, " start" );
490+ startAction->setCallback ([this ]()
491+ { coVRNavigationManager::instance ()->setNavMode (" JSBSim" ); });
492+
486493 pauseButton = new ui::Button (JSBMenu, " pause" );
487494 pauseButton->setState (false );
488495 pauseButton->setCallback ([this ](bool state)
@@ -735,25 +742,25 @@ bool JSBSimPlugin::update()
735742 auto vehicleState = Propagate->GetVState ();
736743 auto location = vehicleState.vLocation ;
737744
738- osg::Vec3 pos (location.GetLongitudeDeg (), location.GetLatitudeDeg (), location.GetGeodAltitude () * METERS_PER_FOOT );
745+ osg::Vec3d pos (location.GetLongitudeDeg (), location.GetLatitudeDeg (), location.GetGeodAltitude () * METERS_PER_FOOT );
739746
740- float scale = cover->getScale ();
747+ double scale = cover->getScale ();
741748 auto position = GeoData::instance ()->globalToProject (pos);
742- auto trans = osg::Matrix ::translate (position * scale);
749+ auto trans = osg::Matrixd ::translate (position * scale);
743750
744751 float heading = Propagate->GetEuler (JSBSim::FGJSBBase::ePsi);
745752 float roll = Propagate->GetEuler (JSBSim::FGJSBBase::ePhi);
746753 float pitch = Propagate->GetEuler (JSBSim::FGJSBBase::eTht);
747754
748755 // std::cout << " Heading " << heading << " Roll " << roll << " Pitch " << pitch << std::endl;
749756 // auto rot = osg::Matrix::rotate(
750- // -pitch, osg::Vec3 (1, 0, 0),
751- // roll, osg::Vec3 (0, 1, 0),
752- // heading, osg::Vec3 (0, 0, 1));
757+ // -pitch, osg::Vec3d (1, 0, 0),
758+ // roll, osg::Vec3d (0, 1, 0),
759+ // heading, osg::Vec3d (0, 0, 1));
753760
754- auto rot = osg::Matrix ::rotate (roll, osg::Vec3 (0 , 1 , 0 )) * osg::Matrix::rotate (pitch, osg::Vec3 (1 , 0 , 0 )) * osg::Matrix::rotate (-heading, osg::Vec3 (0 , 0 , 1 ));
761+ auto rot = osg::Matrixd ::rotate (roll, osg::Vec3d (0 , 1 , 0 )) * osg::Matrix::rotate (pitch, osg::Vec3d (1 , 0 , 0 )) * osg::Matrix::rotate (-heading, osg::Vec3d (0 , 0 , 1 ));
755762
756- osg::Matrix newPos = osg::Matrix::inverse (/* osg::Matrix::rotate(-M_PI_2, 0, 0, 1.0) * eyePoint */ rot * trans);
763+ osg::Matrixd newPos = osg::Matrix::inverse (/* osg::Matrix::rotate(-M_PI_2, 0, 0, 1.0) * eyePoint */ rot * trans);
757764
758765 if (newPos.isNaN ())
759766 {
@@ -846,6 +853,7 @@ void JSBSimPlugin::setEnabled(bool flag)
846853 {
847854 cover->getScene ()->removeChild (geometryTrans.get ());
848855 }
856+
849857 if (coVRMSController::instance ()->isMaster ())
850858 {
851859 if (flag)
@@ -943,7 +951,7 @@ void JSBSimPlugin::updateUdp()
943951 }
944952}
945953
946- void JSBSimPlugin::addThermal (const osg::Vec3 &velocity, float turbulence)
954+ void JSBSimPlugin::addThermal (const osg::Vec3d &velocity, float turbulence)
947955{
948956 m_windVelocityTarget += velocity;
949957 m_windTurbulenceTarget += turbulence;
0 commit comments