+
+
+// $$$ end - added VS Renganathan, 15 Oct 2K
+// - added Venky , 12 Nov 2K
+
+void fgLoadDCS(void) {
+
+ ssgEntity *ship_obj = NULL;
+ // double bz[3];
+ // int j=0;
+ char obj_filename[25];
+
+ for ( int k = 0; k < 32; k++ ) {
+ ship_pos[k]=NULL;
+ }
+
+ SGPath tile_path( globals->get_fg_root());
+ tile_path.append( "Scenery" );
+ tile_path.append( "Objects.txt" );
+ sg_gzifstream in( tile_path.str() );
+ if ( ! in.is_open() ) {
+ SG_LOG( SG_TERRAIN, SG_ALERT, "Cannot open file: " << tile_path.str() );
+ } else {
+
+ SGPath modelpath( globals->get_fg_root() );
+ modelpath.append( "Models" );
+ modelpath.append( "Geometry" );
+
+ SGPath texturepath( globals->get_fg_root() );
+ texturepath.append( "Models" );
+ texturepath.append( "Textures" );
+
+ ssgModelPath( (char *)modelpath.c_str() );
+ ssgTexturePath( (char *)texturepath.c_str() );
+
+ ship_sel = new ssgSelector;
+
+ char c;
+ while ( ! in.eof() ) {
+ in >> ::skipws;
+ if ( in.get( c ) && c == '#' ) {
+ in >> skipeol;
+ } else {
+ in.putback(c);
+ in >> obj_filename >> obj_lat[objc] >> obj_lon[objc] >> obj_alt[objc];
+ /* cout << endl << obj_filename << " " << obj_lat[objc] << " " << obj_lon[objc] << " " << obj_alt[objc] << endl;
+ int chj=getchar();*/
+
+ obj_lon[objc] *=SGD_DEGREES_TO_RADIANS;
+ obj_lat[objc] *=SGD_DEGREES_TO_RADIANS;
+
+ ship_pos[objc] = new ssgTransform;
+
+ // type "repeat" in objects.txt to load one more
+ // instance of the last object.
+
+ if ( strcmp(obj_filename,"repeat") != 0) {
+ ship_obj = ssgLoadOBJ( obj_filename );
+ }
+
+ if ( ship_obj != NULL ) {
+ ship_pos[objc]->addKid( ship_obj ); // add object to transform node
+ ship_sel->addKid( ship_pos[objc] ); // add transform node to selector
+ } else {
+ SG_LOG( SG_TERRAIN, SG_ALERT, "Cannot open file: "
+ << obj_filename );
+ }
+
+ objc++;
+
+ if (in.eof()) break;
+ }
+ } // while
+
+ SG_LOG ( SG_TERRAIN, SG_ALERT, "Finished object processing." );
+
+ ship_sel->clrTraversalMaskBits( SSGTRAV_HOT );
+ scene->addKid( ship_sel ); //add selector node to root node
+ }
+
+ return;
+ }
+
+
+void fgUpdateDCS (void) {
+
+ // double eye_lat,eye_lon,eye_alt;
+ // 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];
+
+ // Instantaneous Geodetic Lat/Lon/Alt of moving object
+ FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+
+ // Deck should be the first object in objects.txt in case of fdm=ada
+
+ if (fgGetString("/sim/flight-model") == "ada") {
+ obj_lon[0] = fdm->get_aux5()*SGD_DEGREES_TO_RADIANS;
+ obj_lat[0] = fdm->get_aux6()*SGD_DEGREES_TO_RADIANS;
+ obj_alt[0] = fdm->get_aux7();
+ }
+
+ for ( int m = 0; m < objc; m++ ) {
+ //cout << endl << obj_lat[m]*SGD_RADIANS_TO_DEGREES << " " << obj_lon[m]*SGD_RADIANS_TO_DEGREES << " " << obj_alt[m] << " " << objc << endl;
+ //int v=getchar();
+
+ //Geodetic to Geocentric angles for rotation
+ sgGeodToGeoc(obj_lat[m],obj_alt[m],&sl_radius,&obj_latgc);
+
+ //moving object gbs-posn in cartesian coords
+ Point3D obj_posn = Point3D( obj_lon[m],obj_lat[m],obj_alt[m]);
+ 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
+
+ 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[m]*SGD_RADIANS_TO_DEGREES, ship_up );
+ sgMakeRotMat4( sgROT_lat, 90-obj_latgc*SGD_RADIANS_TO_DEGREES, 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[m]->setTransform( &shippos );
+ }
+ if ( ship_sel != NULL ) {
+ ship_sel->select(0xFFFFFFFF);
+ }
+}
+
+// $$$ end - added VS Renganathan, 15 Oct 2K
+// added Venky , 12 Nov 2K