+ return NULL;
+}
+
+ssgBranch* FGTileEntry::gen_runway_lights( ssgVertexArray *points,ssgVertexArray *normal,
+ ssgVertexArray *dir, int type[])
+{
+
+ //************** HARD CODED RUNWAY LIGHT TEXTURES BEGIN ************************
+ GLuint texEdge, texTaxi, texCenter, texTouchdown;
+ GLuint texThreshold, texCrossbar, texUndershoot, texApproach;
+ GLuint texRabbit, texVasi, texWhite, texRed, texGreen, texYellow;
+
+ //VASI lights
+ setColor(0.0,0.0,1.0,360.0, 0, 0, 0, 0);
+ setColor2(10.0, 40.0, 1, 1, 1, 1);
+ setColor2(6.0, 40.0, 1, 0.5, 0.5, 1);
+ setColor2(5.0, 40.0, 1, 0, 0, 1);
+ glGenTextures(1, &texVasi);
+ glBindTexture(GL_TEXTURE_2D, texVasi);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEXRES_X, TEXRES_Y, 0, GL_RGBA, GL_UNSIGNED_BYTE, env_map);
+ ssgSimpleState *vasi_state;
+ vasi_state = new ssgSimpleState();
+ vasi_state->ref();
+ vasi_state->setTexture( texVasi );
+ vasi_state->disable( GL_LIGHTING );
+ vasi_state->enable( GL_TEXTURE_2D );
+ vasi_state->setShadeModel( GL_SMOOTH );
+
+ //EDGE
+ setColor(0.0,0.0,-1.0,180.0, 1, 1, 0.5, 1);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glGenTextures(1, &texEdge);
+ glBindTexture(GL_TEXTURE_2D, texEdge);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEXRES_X, TEXRES_Y, 0, GL_RGBA, GL_UNSIGNED_BYTE, env_map);
+ ssgSimpleState *edge_state;
+ edge_state = new ssgSimpleState();
+ edge_state->ref();
+ edge_state->setTexture( texEdge );
+ edge_state->disable( GL_LIGHTING );
+ edge_state->enable( GL_TEXTURE_2D );
+ edge_state->setShadeModel( GL_SMOOTH );
+
+ //TOUCHDOWN
+ setColor(0.0,0.0,-1.0,180.0, 0, 1, 0, 1);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glGenTextures(1, &texTouchdown);
+ glBindTexture(GL_TEXTURE_2D, texTouchdown);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEXRES_X, TEXRES_Y, 0, GL_RGBA, GL_UNSIGNED_BYTE, env_map);
+ ssgSimpleState *touchdown_state;
+ touchdown_state = new ssgSimpleState();
+ touchdown_state->ref();
+ touchdown_state->setTexture( texTouchdown );
+ touchdown_state->disable( GL_LIGHTING );
+ touchdown_state->enable( GL_TEXTURE_2D );
+ touchdown_state->setShadeModel( GL_SMOOTH );
+
+ //THRESHOLD
+ setColor(0.0,0.0,-1.0,180.0, 1, 0, 0, 1);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glGenTextures(1, &texThreshold);
+ glBindTexture(GL_TEXTURE_2D, texThreshold);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEXRES_X, TEXRES_Y, 0, GL_RGBA, GL_UNSIGNED_BYTE, env_map);
+ ssgSimpleState *threshold_state;
+ threshold_state = new ssgSimpleState();
+ threshold_state->ref();
+ threshold_state->setTexture( texThreshold );
+ threshold_state->disable( GL_LIGHTING );
+ threshold_state->enable( GL_TEXTURE_2D );
+ threshold_state->setShadeModel( GL_SMOOTH );
+
+ //TAXI
+ setColor(0.0,0.0,-1.0,180.0, 0, 0, 1, 1);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glGenTextures(1, &texTaxi);
+ glBindTexture(GL_TEXTURE_2D, texTaxi);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEXRES_X, TEXRES_Y, 0, GL_RGBA, GL_UNSIGNED_BYTE, env_map);
+ ssgSimpleState *taxi_state;
+ taxi_state = new ssgSimpleState();
+ taxi_state->ref();
+ taxi_state->setTexture( texTaxi );
+ taxi_state->disable( GL_LIGHTING );
+ taxi_state->enable( GL_TEXTURE_2D );
+ taxi_state->setShadeModel( GL_SMOOTH );
+
+ //WHITE
+ setColor(0.0,0.0,-1.0,180.0, 1, 1, 1, 1);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glGenTextures(1, &texWhite);
+ glBindTexture(GL_TEXTURE_2D, texWhite);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEXRES_X, TEXRES_Y, 0, GL_RGBA, GL_UNSIGNED_BYTE, env_map);
+ ssgSimpleState *white_state;
+ white_state = new ssgSimpleState();
+ white_state->ref();
+ white_state->setTexture( texWhite );
+ white_state->disable( GL_LIGHTING );
+ white_state->enable( GL_TEXTURE_2D );
+ white_state->setShadeModel( GL_SMOOTH );
+
+ //RED
+ setColor(0.0,0.0,-1.0,180.0, 1, 0, 0, 1);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glGenTextures(1, &texRed);
+ glBindTexture(GL_TEXTURE_2D, texRed);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEXRES_X, TEXRES_Y, 0, GL_RGBA, GL_UNSIGNED_BYTE, env_map);
+ ssgSimpleState *red_state;
+ red_state = new ssgSimpleState();
+ red_state->ref();
+ red_state->setTexture( texRed );
+ red_state->disable( GL_LIGHTING );
+ red_state->enable( GL_TEXTURE_2D );
+ red_state->setShadeModel( GL_SMOOTH );
+
+ //GREEN
+ setColor(0.0,0.0,-1.0,180.0, 0, 1, 0, 1);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glGenTextures(1, &texGreen);
+ glBindTexture(GL_TEXTURE_2D, texGreen);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEXRES_X, TEXRES_Y, 0, GL_RGBA, GL_UNSIGNED_BYTE, env_map);
+ ssgSimpleState *green_state;
+ green_state = new ssgSimpleState();
+ green_state->ref();
+ green_state->setTexture( texGreen );
+ green_state->disable( GL_LIGHTING );
+ green_state->enable( GL_TEXTURE_2D );
+ green_state->setShadeModel( GL_SMOOTH );
+
+ //YELLOW
+ setColor(0.0,0.0,-1.0,180.0, 1, 1, 0, 1);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glGenTextures(1, &texYellow);
+ glBindTexture(GL_TEXTURE_2D, texYellow);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEXRES_X, TEXRES_Y, 0, GL_RGBA, GL_UNSIGNED_BYTE, env_map);
+ ssgSimpleState *yellow_state;
+ yellow_state = new ssgSimpleState();
+ yellow_state->ref();
+ yellow_state->setTexture( texYellow );
+ yellow_state->disable( GL_LIGHTING );
+ yellow_state->enable( GL_TEXTURE_2D );
+ yellow_state->setShadeModel( GL_SMOOTH );
+//************** HARD CODED RUNWAY LIGHT TEXTURES END ************************
+
+ ssgBranch *runway_lights = new ssgBranch;
+ sgVec3 v2,v3,inf,side;
+
+ ssgLeaf *leaf1 = NULL;
+ ssgLeaf *leaf2 = NULL;
+ ssgLeaf *leaf7 = NULL;
+ ssgLeaf *leaf8 = NULL;
+ ssgLeaf *leaf9 = NULL;
+
+ ssgVertexArray *vlw = new ssgVertexArray( 1 );
+ ssgNormalArray *nlw = new ssgNormalArray( 1 );
+ ssgVertexArray *vlt = new ssgVertexArray( 1 );
+ ssgNormalArray *nlt = new ssgNormalArray( 1 );
+ ssgVertexArray *vlr = new ssgVertexArray( 1 );
+ ssgNormalArray *nlr = new ssgNormalArray( 1 );
+ ssgVertexArray *vlg = new ssgVertexArray( 1 );
+ ssgNormalArray *nlg = new ssgNormalArray( 1 );
+ ssgVertexArray *vly = new ssgVertexArray( 1 );
+ ssgNormalArray *nly = new ssgNormalArray( 1 );
+
+ for ( int i = 0; i < points->getNum()-1; i=i++ ) {
+
+ // Allocate ssg structure
+ ssgVertexArray *vl = new ssgVertexArray( 1 );
+ ssgNormalArray *nl = new ssgNormalArray( 1 );
+ ssgVertexArray *vl1 = new ssgVertexArray( 1 );
+ ssgNormalArray *nl1 = new ssgNormalArray( 1 );
+
+ float *n1 = normal->get(i);
+ float *d1 = dir->get(i);
+
+ /* TEMPORARY CODE BEGIN
+ // calculate normal using 1st, 2nd & last vertices of the group
+ sgVec3 n1;
+ sgMakeNormal (n1, points->get(0), points->get(1), points->get(points->getNum()-1) );
+ sgVec3 d1;
+ sgSubVec3(d1,points->get(1),points->get(0));
+ printf("%f %f %f\n",n1[0],n1[1],n1[2]);
+ printf("%f %f %f\n",d1[0],d1[1],d1[2]);
+ type[i] = 2;
+ ----TEMPORARY CODE END */
+
+
+ sgNormaliseVec3 ( n1 );
+ sgNormaliseVec3 ( d1 );
+ sgVec3 d2;
+ d2[0] = -d1[0];
+ d2[1] = -d1[1];
+ d2[2] = -d1[2];
+
+ sgVectorProductVec3(side,n1,d1);
+ sgScaleVec3 (inf,n1,-50);
+ sgScaleVec3 (side,5);
+
+ float *v1 = points->get(i);
+ sgAddVec3(v2,v1,inf);
+ sgAddVec3(v3,v2,side);
+
+ if ( type[i] == 1) { //POINT,WHITE
+
+ vlw->add(v1);
+ nlw->add(d1);
+
+ } else if (type[i] == 2) { //POINT,TAXI
+
+ vlt->add(v1);
+ nlt->add(d1);
+
+ } else if (type[i] == 3) { //SINGLE POLYGON,VASI
+
+ vl->add(v1);
+ nl->add(d1);
+ vl->add(v3);
+ nl->add(d1);
+ vl->add(v2);
+ nl->add(d1);
+
+ ssgLeaf *leaf3 = NULL;
+ leaf3 = new ssgVtxTable ( GL_POLYGON, vl, nl, NULL, NULL );
+ leaf3->setState( vasi_state );
+ runway_lights->addKid( leaf3 );
+
+ } else if (type[i] == 4) { //BACK-TO-BACK POLYGONS,TOUCHDOWN/THRESHOLD
+
+ vl->add(v1);
+ nl->add(d1);
+ vl->add(v3);
+ nl->add(d1);
+ vl->add(v2);
+ nl->add(d1);
+
+ vl1->add(v3);
+ nl1->add(d2);
+ vl1->add(v1);
+ nl1->add(d2);
+ vl1->add(v2);
+ nl1->add(d2);
+
+ ssgLeaf *leaf41 = NULL;
+ leaf41 = new ssgVtxTable ( GL_POLYGON, vl, nl, NULL, NULL );
+ leaf41->setState( touchdown_state );
+ runway_lights->addKid( leaf41 );
+
+ ssgLeaf *leaf42 = NULL;
+ leaf42 = new ssgVtxTable ( GL_POLYGON, vl1, nl1, NULL, NULL );
+ leaf42->setState( threshold_state );
+ runway_lights->addKid( leaf42 );
+
+ } else if ( type[i] == 5) { //POINT,WHITE, SEQUENCE LIGHTS (RABBIT)
+
+ vl->add(v1);
+ nl->add(d1);
+ ssgLeaf *leaf5 = NULL;
+ leaf5 = new ssgVtxTable ( GL_POINTS, vl, nl, NULL, NULL );
+ leaf5->setState( white_state );
+ lightmaps_sequence->addKid (leaf5);
+
+ } else if ( type[i] == 6) { //POINT,WHITE, SEQUENCE LIGHTS (RABBIT)
+
+ vl->add(v1);
+ nl->add(d1);
+ ssgLeaf *leaf6 = NULL;
+ leaf6 = new ssgVtxTable ( GL_POINTS, vl, nl, NULL, NULL );
+ leaf6->setState( yellow_state );
+ ols_transform->addKid (leaf6);
+ // DO NOT DELETE THIS CODE - This is to compare a discrete FLOLS (without LOD) with analog FLOLS
+ // lightmaps_sequence->addKid (leaf6);
+ // DO NOT DELETE THIS CODE - This is to compare a discrete FLOLS (without LOD) with analog FLOLS
+
+ } else if (type[i] == 7) { //POINT,RED
+
+ vlr->add(v1);
+ nlr->add(d1);
+
+ } else if (type[i] == 8) { //POINT,GREEN
+
+ vlg->add(v1);
+ nlg->add(d1);
+
+ } else if (type[i] == 9) { //POINT,YELLOW
+
+ vly->add(v1);
+ nly->add(d1);
+
+ }
+
+ }
+
+ leaf1 = new ssgVtxTable ( GL_POINTS, vlw, nlw, NULL, NULL );
+ leaf1->setState( white_state );
+ runway_lights->addKid( leaf1 );
+
+ leaf2 = new ssgVtxTable ( GL_POINTS, vlt, nlt, NULL, NULL );
+ leaf2->setState( taxi_state );
+ runway_lights->addKid( leaf2 );
+
+ leaf7 = new ssgVtxTable ( GL_POINTS, vlr, nlr, NULL, NULL );
+ leaf7->setState( red_state );
+ runway_lights->addKid( leaf7 );
+
+ leaf8 = new ssgVtxTable ( GL_POINTS, vlg, nlg, NULL, NULL );
+ leaf8->setState( green_state );
+ // DO NOT DELETE THIS CODE - This is to compare a discrete FLOLS (without LOD) with analog FLOLS
+ ols_transform->ref();
+ lightmaps_sequence->addKid (ols_transform);
+ // DO NOT DELETE THIS CODE - This is to compare a discrete FLOLS (without LOD) with analog FLOLS
+ lightmaps_sequence->addKid (leaf8);
+
+ leaf9 = new ssgVtxTable ( GL_POINTS, vly, nly, NULL, NULL );
+ leaf9->setState( yellow_state );
+ runway_lights->addKid( leaf9 );
+
+ lightmaps_sequence->select(0xFFFFFF);
+ return runway_lights;
+}
+// ADA
+