I'm trying to project a virtual runway image on the HUD and I do not fully understand the FlightGear coordinate system.  I am using the following code to get the four corners on the runway and seem to correspond to the absolute_view_pos vector when located on the corner of the runway.  I am trying to render spheres on the corners of the runway to be sure that the XYZ coordinates of the runway corners are correct, but the spheres are not being displayed.  I feel that the model view and/or the projection matrix may be incorrect since I am trying to render the spheres inside the HUD instrument draw() function.

void runway_instr::get_rwy_points(sgdVec3 *corners) {   
        Point3D center = globals->get_scenery()->get_center();
        
double alt = current_aircraft.fdm_state->get_Runway_altitude()*SG_FEET_TO_METER;
        
double length = (runway.length/2.0)*SG_FEET_TO_METER;
        
double width = (runway.width/2.0)*SG_FEET_TO_METER;
        
double frontLat,frontLon,backLat,backLon,az,tempLat,tempLon;

        geo_direct_wgs_84(alt,runway.lat,runway.lon,runway.heading,length,&backLat,&backLon,&az);
        geo_direct_wgs_84(alt,runway.lat,runway.lon,runway.heading+
180,length,&frontLat,&frontLon,&az); 
        
        geo_direct_wgs_84(alt,backLat,backLon,runway.heading+
90,width,&tempLat,&tempLon,&az);
        sgGeodToCart(tempLat*SG_DEGREES_TO_RADIANS,tempLon*SG_DEGREES_TO_RADIANS,alt,corners[
0]);

        geo_direct_wgs_84(alt,backLat,backLon,runway.heading-
90,width,&tempLat,&tempLon,&az);
        sgGeodToCart(tempLat*SG_DEGREES_TO_RADIANS,tempLon*SG_DEGREES_TO_RADIANS,alt,corners[
1]);

        geo_direct_wgs_84(alt,frontLat,frontLon,runway.heading-
90,width,&tempLat,&tempLon,&az);
        sgGeodToCart(tempLat*SG_DEGREES_TO_RADIANS,tempLon*SG_DEGREES_TO_RADIANS,alt,corners[
2]);

        geo_direct_wgs_84(alt,frontLat,frontLon,runway.heading+
90,width,&tempLat,&tempLon,&az);
        sgGeodToCart(tempLat*SG_DEGREES_TO_RADIANS,tempLon*SG_DEGREES_TO_RADIANS,alt,corners[
3]);
}

void runway_instr::draw() {
         runway = get_active_runway();
         get_rwy_points(rwy_corners);
         FGViewer* view = globals->get_current_view();

        
double * viewPos = view->get_absolute_view_pos();
        
const sgVec4 *viewVec = view->get_VIEW();

        glMatrixMode(GL_PROJECTION);
        glPushMatrix();
        glLoadIdentity();
        
        glLoadMatrixf( (
float *)viewVec );

        glMatrixMode(GL_MODELVIEW);
        glPushMatrix();
        glLoadIdentity();
 
        GLUquadricObj *quad = gluNewQuadric();
        
        
for(int c=0; c<4; c++) {
                
                glTranslatef(rwy_corners[c][
0],rwy_corners[c][1],rwy_corners[c][2]);
                gluSphere(quad,
100.0,50,50);
                glTranslatef(-rwy_corners[c][
0],-rwy_corners[c][1],-rwy_corners[c][2]);
        }
    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();      
}

Aaron I. Wilson
AST: Computer Engineer
TEL:  (304) 367-8299
FAX:  (304) 367-8203
[EMAIL PROTECTED]
http://www.ivv.nasa.gov/

_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel
2f585eeea02e2c79d7b1d8c4963bae2d

Reply via email to