+
+
+// $$$ end - added VS Renganathan, 15 Oct 2K
+void fgLoadDCS(void) {
+
+ double obj_lat,obj_lon,obj_alt;
+ int i = 1;
+ string obj_filename;
+
+ FGPath tile_path( globals->get_options()->get_fg_root());
+ tile_path.append( "Scenery" );
+ tile_path.append( "Objects.txt" );
+ fg_gzifstream in( tile_path.str() );
+ if ( ! in.is_open() ) {
+ FG_LOG( FG_TERRAIN, FG_ALERT, "Cannot open file: " << tile_path.str() );
+ }
+
+ FGPath modelpath( globals->get_options()->get_fg_root() );
+ modelpath.append( "Models" );
+ modelpath.append( "Geometry" );
+
+ FGPath texturepath( globals->get_options()->get_fg_root() );
+ texturepath.append( "Models" );
+ texturepath.append( "Textures" );
+
+ ssgModelPath( (char *)modelpath.c_str() );
+ ssgTexturePath( (char *)texturepath.c_str() );
+
+ // while ( ! in.eof() ) {
+ // in >> obj_filename >> obj_lat >> obj_lon >> obj_alt;
+ // totalDCSobj = totalDCSobj+1;
+
+ ship_sel = new ssgSelector;
+ ship_pos = new ssgTransform;
+ ssgEntity *ship_obj = ssgLoadOBJ( "saratoga.obj" );
+ if ( ship_obj != NULL ) {
+ ship_pos->addKid( ship_obj ); // add object to transform node
+ ship_sel->addKid( ship_pos ); // add transform node to selector
+ // ssgFlatten( ship_obj );
+ // ssgStripify( ship_sel );
+ ship_sel->clrTraversalMaskBits( SSGTRAV_HOT );
+ scene->addKid( ship_sel ); //add selector node to root node
+ } else {
+ FG_LOG( FG_TERRAIN, FG_ALERT, "Cannot open file: " << "saratoga.obj" );
+ }
+
+ // if (in.eof()) break;
+
+ // } // while
+ return;
+}
+
+
+void fgUpdateDCS (void) {
+
+ double eye_lat,eye_lon,eye_alt;
+ static double obj_lat=15.377603*DEG_TO_RAD;
+ static double obj_lon= 73.816436*DEG_TO_RAD;
+ static double obj_alt=0.15;
+ static double obj_head;
+ double sl_radius,obj_latgc;
+ float nresultmat[4][4];
+ sgMat4 Trans,rothead,rotlon,rot180,rotlat,resultmat1,resultmat2,resultmat3;
+ double bz[3];
+
+ obj_lat = obj_lat + 0.0000001;
+
+ // Instantaneous Geodetic Lat/Lon/Alt of moving object
+ // obj_lon = current_aircraft.fdm_state->get_aux5()*DEG_TO_RAD;
+ // obj_lat = current_aircraft.fdm_state->get_aux6()*DEG_TO_RAD;
+ // obj_alt = current_aircraft.fdm_state->get_aux7();
+
+ // Geodetic to Geocentric angles for rotation
+ sgGeodToGeoc(obj_lat,obj_alt,&sl_radius,&obj_latgc);
+
+ // moving object gbs-posn in cartesian coords
+ Point3D obj_posn = Point3D( obj_lon,obj_lat,obj_alt);
+ Point3D obj_pos = sgGeodToCart( obj_posn );
+
+ // Translate moving object w.r.t eye
+ Point3D Objtrans = obj_pos-scenery.center;
+ bz[0]=Objtrans.x();
+ bz[1]=Objtrans.y();
+ bz[2]=Objtrans.z();
+
+ // rotate dynamic objects for lat,lon & alt and other motion about its axes
+ if ( ship_sel != NULL ) {
+ ship_sel->select(1);
+
+ sgMat4 sgTRANS;
+ sgMakeTransMat4( sgTRANS, bz[0],bz[1],bz[2]);
+
+ sgVec3 ship_fwd,ship_rt,ship_up;
+ sgSetVec3( ship_fwd, 1.0, 0.0, 0.0);//east,roll
+ sgSetVec3( ship_rt, 0.0, 1.0, 0.0);//up,pitch
+ sgSetVec3( ship_up, 0.0, 0.0, 1.0); //north,yaw
+
+ sgMat4 sgROT_lon, sgROT_lat, sgROT_hdg;
+ sgMakeRotMat4( sgROT_lon, obj_lon*RAD_TO_DEG, ship_up );
+ sgMakeRotMat4( sgROT_lat, 90-obj_latgc*RAD_TO_DEG, ship_rt );
+ sgMakeRotMat4( sgROT_hdg, 180.0, ship_up );
+
+ sgMat4 sgTUX;
+ sgCopyMat4( sgTUX, sgROT_hdg );
+ sgPostMultMat4( sgTUX, sgROT_lat );
+ sgPostMultMat4( sgTUX, sgROT_lon );
+ sgPostMultMat4( sgTUX, sgTRANS );
+
+ sgCoord shippos;
+ sgSetCoord( &shippos, sgTUX );
+ ship_pos->setTransform( &shippos );
+ }
+}
+
+// $$$ end - added VS Renganathan, 15 Oct 2K