1 // obj.cxx -- routines to handle "sorta" WaveFront .obj format files.
3 // Written by Curtis Olson, started October 1997.
5 // Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #ifdef FG_MATH_EXCEPTION_CLASH
35 // #if defined ( __sun__ )
36 // extern "C" void *memmove(void *, const void *, size_t);
37 // extern "C" void *memset(void *, int, size_t);
40 #include <Include/compiler.h>
44 #include <vector> // STL
45 #include <ctype.h> // isdigit()
47 #include <Debug/logstream.hxx>
48 #include <Misc/fgstream.hxx>
49 #include <Include/fg_constants.h>
50 #include <Main/options.hxx>
51 #include <Math/mat3.h>
52 #include <Math/fg_geodesy.hxx>
53 #include <Math/fg_random.h>
54 #include <Math/point3d.hxx>
55 #include <Math/polar3d.hxx>
56 #include <Misc/stopwatch.hxx>
57 #include <Misc/texcoord.hxx>
58 #include <Scenery/tileentry.hxx>
60 #include "materialmgr.hxx"
67 typedef vector < int > int_list;
68 typedef int_list::iterator int_list_iterator;
69 typedef int_list::const_iterator int_point_list_iterator;
72 static double normals[FG_MAX_NODES][3];
73 static double tex_coords[FG_MAX_NODES*3][3];
76 // given three points defining a triangle, calculate the normal
77 static void calc_normal(Point3D p1, Point3D p2,
78 Point3D p3, double normal[3])
83 v1[0] = p2[0] - p1[0]; v1[1] = p2[1] - p1[1]; v1[2] = p2[2] - p1[2];
84 v2[0] = p3[0] - p1[0]; v2[1] = p3[1] - p1[1]; v2[2] = p3[2] - p1[2];
86 MAT3cross_product(normal, v1, v2);
87 MAT3_NORMALIZE_VEC(normal,temp);
89 // fgPrintf( FG_TERRAIN, FG_DEBUG, " Normal = %.2f %.2f %.2f\n",
90 // normal[0], normal[1], normal[2]);
94 #define FG_TEX_CONSTANT 69.0
96 // Calculate texture coordinates for a given point.
97 static Point3D local_calc_tex_coords(const Point3D& node, const Point3D& ref) {
100 // double tmplon, tmplat;
102 // cout << "-> " << node[0] << " " << node[1] << " " << node[2] << endl;
103 // cout << "-> " << ref.x() << " " << ref.y() << " " << ref.z() << endl;
105 cp = Point3D( node[0] + ref.x(),
109 pp = fgCartToPolar3d(cp);
111 // tmplon = pp.lon() * RAD_TO_DEG;
112 // tmplat = pp.lat() * RAD_TO_DEG;
113 // cout << tmplon << " " << tmplat << endl;
115 pp.setx( fmod(RAD_TO_DEG * FG_TEX_CONSTANT * pp.x(), 11.0) );
116 pp.sety( fmod(RAD_TO_DEG * FG_TEX_CONSTANT * pp.y(), 11.0) );
118 if ( pp.x() < 0.0 ) {
119 pp.setx( pp.x() + 11.0 );
122 if ( pp.y() < 0.0 ) {
123 pp.sety( pp.y() + 11.0 );
126 // cout << pp << endl;
132 // Generate a generic ocean tile on the fly
133 ssgBranch *fgGenTile( const string& path, FGTileEntry *t) {
136 fragment.tile_ptr = t;
138 ssgSimpleState *state = NULL;
140 ssgBranch *tile = new ssgBranch () ;
141 tile -> setName ( (char *)path.c_str() ) ;
143 // find Ocean material in the properties list
144 if ( ! material_mgr.find( "Ocean", fragment.material_ptr )) {
145 FG_LOG( FG_TERRAIN, FG_ALERT,
146 "Ack! unknown usemtl name = " << "Ocean"
150 // set the texture width and height values for this
152 FGMaterial m = fragment.material_ptr->get_m();
153 double tex_width = m.get_xsize();
154 double tex_height = m.get_ysize();
157 state = fragment.material_ptr->get_state();
159 // Calculate center point
160 FGBucket b = t->tile_bucket;
161 double clon = b.get_center_lon();
162 double clat = b.get_center_lat();
163 double height = b.get_height();
164 double width = b.get_width();
166 Point3D center = fgGeodToCart(Point3D(clon*DEG_TO_RAD,clat*DEG_TO_RAD,0.0));
168 fragment.center = center;
169 // cout << "center = " << center << endl;;
171 // Caculate corner vertices
173 geod[0] = Point3D( clon - width/2.0, clat - height/2.0, 0.0 );
174 geod[1] = Point3D( clon + width/2.0, clat - height/2.0, 0.0 );
175 geod[2] = Point3D( clon + width/2.0, clat + height/2.0, 0.0 );
176 geod[3] = Point3D( clon - width/2.0, clat + height/2.0, 0.0 );
180 for ( i = 0; i < 4; ++i ) {
181 rad[i] = Point3D( geod[i].x() * DEG_TO_RAD, geod[i].y() * DEG_TO_RAD,
185 Point3D cart[4], rel[4];
187 for ( i = 0; i < 4; ++i ) {
188 cart[i] = fgGeodToCart(rad[i]);
189 rel[i] = cart[i] - center;
190 t->nodes.push_back( rel[i] );
191 // cout << "corner " << i << " = " << cart[i] << endl;
196 // Calculate bounding radius
197 t->bounding_radius = center.distance3D( cart[0] );
198 fragment.bounding_radius = t->bounding_radius;
199 // cout << "bounding radius = " << t->bounding_radius << endl;
203 for ( i = 0; i < 4; ++i ) {
204 normals[i] = cart[i];
205 double length = normals[i].distance3D( Point3D(0.0) );
206 normals[i] /= length;
207 // cout << "normal = " << normals[i] << endl;
210 // Calculate texture coordinates
211 point_list geod_nodes;
213 for ( i = 0; i < 4; ++i ) {
214 geod_nodes.push_back( geod[i] );
218 for ( i = 0; i < 4; ++i ) {
219 rectangle.push_back( i );
221 point_list texs = calc_tex_coords( b, geod_nodes, rectangle,
222 1000.0 / tex_width );
224 // Build flight gear structure
225 fragment.add_face(0, 1, 2);
226 fragment.add_face(0, 2, 3);
227 t->fragment_list.push_back(fragment);
229 // Allocate ssg structure
230 sgVec3 *vtlist = new sgVec3 [ 4 ];
231 t->vec3_ptrs.push_back( vtlist );
232 sgVec3 *vnlist = new sgVec3 [ 4 ];
233 t->vec3_ptrs.push_back( vnlist );
234 sgVec2 *tclist = new sgVec2 [ 4 ];
235 t->vec2_ptrs.push_back( tclist );
237 for ( i = 0; i < 4; ++i ) {
238 sgSetVec3( vtlist[i],
239 rel[i].x(), rel[i].y(), rel[i].z() );
240 sgSetVec3( vnlist[i],
241 normals[i].x(), normals[i].y(), normals[i].z() );
242 sgSetVec2( tclist[i], texs[i].x(), texs[i].y() );
245 unsigned short *vindex = new unsigned short [ 4 ];
246 t->index_ptrs.push_back( vindex );
247 unsigned short *tindex = new unsigned short [ 4 ];
248 t->index_ptrs.push_back( tindex );
249 for ( i = 0; i < 4; ++i ) {
255 new ssgVTable ( GL_TRIANGLE_FAN,
260 leaf->setState( state );
262 tile->addKid( leaf );
263 // if ( current_options.get_clouds() ) {
264 // fgGenCloudTile(path, t, tile);
271 // Load a .obj file and build the fragment list
272 ssgBranch *fgObjLoad( const string& path, FGTileEntry *t, const bool is_base) {
275 double approx_normal[3] /*, normal[3], scale = 0.0 */;
276 // double x, y, z, xmax, xmin, ymax, ymin, zmax, zmin;
277 // GLfloat sgenparams[] = { 1.0, 0.0, 0.0, 0.0 };
278 // GLint display_list = 0;
280 bool in_fragment = false, in_faces = false;
281 int vncount, vtcount;
282 int n1 = 0, n2 = 0, n3 = 0, n4 = 0;
284 int last1 = 0, last2 = 0;
289 double scenery_version = 0.0;
290 double tex_width = 1000.0, tex_height = 1000.0;
291 bool shared_done = false;
292 int_list fan_vertices;
293 int_list fan_tex_coords;
295 ssgSimpleState *state = NULL;
296 sgVec3 *vtlist, *vnlist;
299 ssgBranch *tile = new ssgBranch () ;
301 tile -> setName ( (char *)path.c_str() ) ;
303 // Attempt to open "path.gz" or "path"
304 fg_gzifstream in( path );
305 if ( ! in.is_open() ) {
306 FG_LOG( FG_TERRAIN, FG_ALERT, "Cannot open file: " << path );
307 FG_LOG( FG_TERRAIN, FG_ALERT, "default to ocean tile: " << path );
309 return fgGenTile( path, t );
312 shading = current_options.get_shading();
321 t->bounding_radius = 0.0;
328 // ignore initial comments and blank lines. (priming the pump)
329 // in >> skipcomment;
336 while ( in.get(c) && c != '\0' ) {
339 while ( ! in.eof() ) {
348 if ( in.get( c ) && c == '#' ) {
349 // process a comment line
351 // getline( in, line );
352 // cout << "comment = " << line << endl;
356 if ( token == "Version" ) {
357 // read scenery versions number
358 in >> scenery_version;
359 // cout << "scenery_version = " << scenery_version << endl;
360 } else if ( token == "gbs" ) {
361 // reference point (center offset)
363 in >> t->center >> t->bounding_radius;
367 in >> junk1 >> junk2;
370 // cout << "center = " << center
371 // << " radius = " << t->bounding_radius << endl;
372 } else if ( token == "bs" ) {
373 // reference point (center offset)
374 in >> fragment.center;
375 in >> fragment.bounding_radius;
377 // cout << "center = " << fragment.center
378 // << " radius = " << fragment.bounding_radius << endl;
379 } else if ( token == "usemtl" ) {
380 // material property specification
382 // if first usemtl with shared_done = false, then set
383 // shared_done true and build the ssg shared lists
384 if ( ! shared_done ) {
386 if ( (int)nodes.size() != vncount ) {
387 FG_LOG( FG_TERRAIN, FG_ALERT,
388 "Tile has mismatched nodes and normals: "
394 vtlist = new sgVec3 [ nodes.size() ];
395 t->vec3_ptrs.push_back( vtlist );
396 vnlist = new sgVec3 [ vncount ];
397 t->vec3_ptrs.push_back( vnlist );
398 tclist = new sgVec2 [ vtcount ];
399 t->vec2_ptrs.push_back( tclist );
401 for ( i = 0; i < (int)nodes.size(); ++i ) {
402 sgSetVec3( vtlist[i],
403 nodes[i][0], nodes[i][1], nodes[i][2] );
405 for ( i = 0; i < vncount; ++i ) {
406 sgSetVec3( vnlist[i],
411 for ( i = 0; i < vtcount; ++i ) {
412 sgSetVec2( tclist[i],
418 // series of individual triangles
423 // this also signals the start of a new fragment
425 // close out the previous structure and start the next
427 // printf("xglEnd(); xglEndList();\n");
430 // fragment.display_list = display_list;
432 // push this fragment onto the tile's object list
433 t->fragment_list.push_back(fragment);
438 // printf("start of fragment (usemtl)\n");
440 // display_list = xglGenLists(1);
441 // xglNewList(display_list, GL_COMPILE);
442 // printf("xglGenLists(); xglNewList();\n");
445 // reset the existing face list
446 // printf("cleaning a fragment with %d faces\n",
447 // fragment.faces.size());
450 // scan the material line
453 fragment.tile_ptr = t;
455 // find this material in the properties list
456 if ( ! material_mgr.find( material, fragment.material_ptr )) {
457 FG_LOG( FG_TERRAIN, FG_ALERT,
458 "Ack! unknown usemtl name = " << material
462 // set the texture width and height values for this
464 FGMaterial m = fragment.material_ptr->get_m();
465 tex_width = m.get_xsize();
466 tex_height = m.get_ysize();
467 state = fragment.material_ptr->get_state();
468 // cout << "(w) = " << tex_width << " (h) = "
469 // << tex_width << endl;
471 // initialize the fragment transformation matrix
473 for ( i = 0; i < 16; i++ ) {
474 fragment.matrix[i] = 0.0;
476 fragment.matrix[0] = fragment.matrix[5] =
477 fragment.matrix[10] = fragment.matrix[15] = 1.0;
480 // unknown comment, just gobble the input untill the
490 // cout << "token = " << token << endl;
492 if ( token == "vn" ) {
494 if ( vncount < FG_MAX_NODES ) {
495 in >> normals[vncount][0]
496 >> normals[vncount][1]
497 >> normals[vncount][2];
500 FG_LOG( FG_TERRAIN, FG_ALERT,
501 "Read too many vertex normals in " << path
502 << " ... dying :-(" );
505 } else if ( token == "vt" ) {
506 // vertex texture coordinate
507 if ( vtcount < FG_MAX_NODES*3 ) {
508 in >> tex_coords[vtcount][0]
509 >> tex_coords[vtcount][1];
512 FG_LOG( FG_TERRAIN, FG_ALERT,
513 "Read too many vertex texture coords in " << path
518 } else if ( token == "v" ) {
520 if ( t->ncount < FG_MAX_NODES ) {
521 /* in >> nodes[t->ncount][0]
522 >> nodes[t->ncount][1]
523 >> nodes[t->ncount][2]; */
525 nodes.push_back(node);
530 FG_LOG( FG_TERRAIN, FG_ALERT,
531 "Read too many nodes in " << path
532 << " ... dying :-(");
535 } else if ( token == "t" ) {
536 // start a new triangle strip
538 n1 = n2 = n3 = n4 = 0;
540 // fgPrintf( FG_TERRAIN, FG_DEBUG,
541 // " new tri strip = %s", line);
542 in >> n1 >> n2 >> n3;
543 fragment.add_face(n1, n2, n3);
545 // fgPrintf( FG_TERRAIN, FG_DEBUG, "(t) = ");
547 // xglBegin(GL_TRIANGLE_STRIP);
548 // printf("xglBegin(tristrip) %d %d %d\n", n1, n2, n3);
554 // Shading model is "GL_SMOOTH" so use precalculated
555 // (averaged) normals
556 // MAT3_SCALE_VEC(normal, normals[n1], scale);
557 // xglNormal3dv(normal);
558 pp = local_calc_tex_coords(nodes[n1], center);
559 // xglTexCoord2f(pp.lon(), pp.lat());
560 // xglVertex3dv(nodes[n1].get_n());
562 // MAT3_SCALE_VEC(normal, normals[n2], scale);
563 // xglNormal3dv(normal);
564 pp = local_calc_tex_coords(nodes[n2], center);
565 // xglTexCoord2f(pp.lon(), pp.lat());
566 // xglVertex3dv(nodes[n2].get_n());
568 // MAT3_SCALE_VEC(normal, normals[n3], scale);
569 // xglNormal3dv(normal);
570 pp = local_calc_tex_coords(nodes[n3], center);
571 // xglTexCoord2f(pp.lon(), pp.lat());
572 // xglVertex3dv(nodes[n3].get_n());
574 // Shading model is "GL_FLAT" so calculate per face
575 // normals on the fly.
577 calc_normal(nodes[n1], nodes[n2],
578 nodes[n3], approx_normal);
580 calc_normal(nodes[n2], nodes[n1],
581 nodes[n3], approx_normal);
583 // MAT3_SCALE_VEC(normal, approx_normal, scale);
584 // xglNormal3dv(normal);
586 pp = local_calc_tex_coords(nodes[n1], center);
587 // xglTexCoord2f(pp.lon(), pp.lat());
588 // xglVertex3dv(nodes[n1].get_n());
590 pp = local_calc_tex_coords(nodes[n2], center);
591 // xglTexCoord2f(pp.lon(), pp.lat());
592 // xglVertex3dv(nodes[n2].get_n());
594 pp = local_calc_tex_coords(nodes[n3], center);
595 // xglTexCoord2f(pp.lon(), pp.lat());
596 // xglVertex3dv(nodes[n3].get_n());
598 // printf("some normals, texcoords, and vertices\n");
604 // There can be three or four values
606 while ( in.get(c) ) {
608 break; // only the one
618 fragment.add_face(n3, n2, n4);
621 // Shading model is "GL_SMOOTH"
622 // MAT3_SCALE_VEC(normal, normals[n4], scale);
624 // Shading model is "GL_FLAT"
625 calc_normal(nodes[n3], nodes[n2], nodes[n4],
627 // MAT3_SCALE_VEC(normal, approx_normal, scale);
629 // xglNormal3dv(normal);
630 pp = local_calc_tex_coords(nodes[n4], center);
631 // xglTexCoord2f(pp.lon(), pp.lat());
632 // xglVertex3dv(nodes[n4].get_n());
637 // printf("a normal, texcoord, and vertex (4th)\n");
639 } else if ( (token == "tf") || (token == "ts") ) {
641 // fgPrintf( FG_TERRAIN, FG_DEBUG, "new fan");
643 fan_vertices.clear();
644 fan_tex_coords.clear();
647 // xglBegin(GL_TRIANGLE_FAN);
650 fan_vertices.push_back( n1 );
651 // xglNormal3dv(normals[n1]);
652 if ( in.get( c ) && c == '/' ) {
654 fan_tex_coords.push_back( tex );
655 if ( scenery_version >= 0.4 ) {
656 if ( tex_width > 0 ) {
657 tclist[tex][0] *= (1000.0 / tex_width);
659 if ( tex_height > 0 ) {
660 tclist[tex][1] *= (1000.0 / tex_height);
663 pp.setx( tex_coords[tex][0] * (1000.0 / tex_width) );
664 pp.sety( tex_coords[tex][1] * (1000.0 / tex_height) );
667 pp = local_calc_tex_coords(nodes[n1], center);
669 // xglTexCoord2f(pp.x(), pp.y());
670 // xglVertex3dv(nodes[n1].get_n());
673 fan_vertices.push_back( n2 );
674 // xglNormal3dv(normals[n2]);
675 if ( in.get( c ) && c == '/' ) {
677 fan_tex_coords.push_back( tex );
678 if ( scenery_version >= 0.4 ) {
679 if ( tex_width > 0 ) {
680 tclist[tex][0] *= (1000.0 / tex_width);
682 if ( tex_height > 0 ) {
683 tclist[tex][1] *= (1000.0 / tex_height);
686 pp.setx( tex_coords[tex][0] * (1000.0 / tex_width) );
687 pp.sety( tex_coords[tex][1] * (1000.0 / tex_height) );
690 pp = local_calc_tex_coords(nodes[n2], center);
692 // xglTexCoord2f(pp.x(), pp.y());
693 // xglVertex3dv(nodes[n2].get_n());
695 // read all subsequent numbers until next thing isn't a number
706 if ( ! isdigit(c) || in.eof() ) {
711 fan_vertices.push_back( n3 );
712 // cout << " triangle = "
713 // << n1 << "," << n2 << "," << n3
715 // xglNormal3dv(normals[n3]);
716 if ( in.get( c ) && c == '/' ) {
718 fan_tex_coords.push_back( tex );
719 if ( scenery_version >= 0.4 ) {
720 if ( tex_width > 0 ) {
721 tclist[tex][0] *= (1000.0 / tex_width);
723 if ( tex_height > 0 ) {
724 tclist[tex][1] *= (1000.0 / tex_height);
727 pp.setx( tex_coords[tex][0] * (1000.0 / tex_width) );
728 pp.sety( tex_coords[tex][1] * (1000.0 / tex_height) );
731 pp = local_calc_tex_coords(nodes[n3], center);
733 // xglTexCoord2f(pp.x(), pp.y());
734 // xglVertex3dv(nodes[n3].get_n());
736 if ( token == "tf" ) {
738 fragment.add_face(n1, n2, n3);
743 fragment.add_face(n1, n2, n3);
745 fragment.add_face(n2, n1, n3);
755 // build the ssg entity
756 unsigned short *vindex =
757 new unsigned short [ fan_vertices.size() ];
758 t->index_ptrs.push_back( vindex );
760 unsigned short *tindex =
761 new unsigned short [ fan_tex_coords.size() ];
762 t->index_ptrs.push_back( tindex );
764 for ( i = 0; i < (int)fan_vertices.size(); ++i ) {
765 vindex[i] = fan_vertices[i];
767 for ( i = 0; i < (int)fan_tex_coords.size(); ++i ) {
768 tindex[i] = fan_tex_coords[i];
771 if ( token == "tf" ) {
774 new ssgVTable ( GL_TRIANGLE_FAN,
775 fan_vertices.size(), vindex, vtlist,
776 fan_vertices.size(), vindex, vnlist,
777 fan_tex_coords.size(), tindex, tclist,
782 new ssgVTable ( GL_TRIANGLE_STRIP,
783 fan_vertices.size(), vindex, vtlist,
784 fan_vertices.size(), vindex, vnlist,
785 fan_tex_coords.size(), tindex, tclist,
788 leaf->setState( state );
790 tile->addKid( leaf );
792 } else if ( token == "f" ) {
796 // xglBegin(GL_TRIANGLES);
797 // printf("xglBegin(triangles)\n");
801 // fgPrintf( FG_TERRAIN, FG_DEBUG, "new triangle = %s", line);*/
802 in >> n1 >> n2 >> n3;
803 fragment.add_face(n1, n2, n3);
805 // xglNormal3d(normals[n1][0], normals[n1][1], normals[n1][2]);
806 // xglNormal3dv(normals[n1]);
807 pp = local_calc_tex_coords(nodes[n1], center);
808 // xglTexCoord2f(pp.lon(), pp.lat());
809 // xglVertex3dv(nodes[n1].get_n());
811 // xglNormal3dv(normals[n2]);
812 pp = local_calc_tex_coords(nodes[n2], center);
813 // xglTexCoord2f(pp.lon(), pp.lat());
814 // xglVertex3dv(nodes[n2].get_n());
816 // xglNormal3dv(normals[n3]);
817 pp = local_calc_tex_coords(nodes[n3], center);
818 // xglTexCoord2f(pp.lon(), pp.lat());
819 // xglVertex3dv(nodes[n3].get_n());
820 // printf("some normals, texcoords, and vertices (tris)\n");
821 } else if ( token == "q" ) {
822 // continue a triangle strip
825 // fgPrintf( FG_TERRAIN, FG_DEBUG, "continued tri strip = %s ",
829 // There can be one or two values
831 while ( in.get(c) ) {
833 break; // only the one
842 // fgPrintf( FG_TERRAIN, FG_DEBUG, "read %d %d\n", n1, n2);
845 fragment.add_face(last1, last2, n1);
847 fragment.add_face(last2, last1, n1);
851 // Shading model is "GL_SMOOTH"
852 // MAT3_SCALE_VEC(normal, normals[n1], scale);
854 // Shading model is "GL_FLAT"
856 calc_normal(nodes[last1], nodes[last2],
857 nodes[n1], approx_normal);
859 calc_normal(nodes[last2], nodes[last1],
860 nodes[n1], approx_normal);
862 // MAT3_SCALE_VEC(normal, approx_normal, scale);
864 // xglNormal3dv(normal);
866 pp = local_calc_tex_coords(nodes[n1], center);
867 // xglTexCoord2f(pp.lon(), pp.lat());
868 // xglVertex3dv(nodes[n1].get_n());
869 // printf("a normal, texcoord, and vertex (4th)\n");
876 // fgPrintf( FG_TERRAIN, FG_DEBUG, " (cont)\n");
879 fragment.add_face(last1, last2, n2);
881 fragment.add_face(last2, last1, n2);
885 // Shading model is "GL_SMOOTH"
886 // MAT3_SCALE_VEC(normal, normals[n2], scale);
888 // Shading model is "GL_FLAT"
890 calc_normal(nodes[last1], nodes[last2],
891 nodes[n2], approx_normal);
893 calc_normal(nodes[last2], nodes[last1],
894 nodes[n2], approx_normal);
896 // MAT3_SCALE_VEC(normal, approx_normal, scale);
898 // xglNormal3dv(normal);
900 pp = local_calc_tex_coords(nodes[n2], center);
901 // xglTexCoord2f(pp.lon(), pp.lat());
902 // xglVertex3dv(nodes[n2].get_n());
903 // printf("a normal, texcoord, and vertex (4th)\n");
910 FG_LOG( FG_TERRAIN, FG_WARN, "Unknown token in "
911 << path << " = " << token );
914 // eat white space before start of while loop so if we are
915 // done with useful input it is noticed before hand.
925 // close out the previous structure and start the next
928 // printf("xglEnd(); xglEndList();\n");
931 // fragment.display_list = display_list;
933 // push this fragment onto the tile's object list
934 t->fragment_list.push_back(fragment);
938 // Draw normal vectors (for visually verifying normals)
940 xglColor3f(0.0, 0.0, 0.0);
941 for ( i = 0; i < t->ncount; i++ ) {
942 xglVertex3d(nodes[i][0],
945 xglVertex3d(nodes[i][0] + 500*normals[i][0],
946 nodes[i][1] + 500*normals[i][1],
947 nodes[i][2] + 500*normals[i][2]);
957 FG_LOG( FG_TERRAIN, FG_DEBUG,
958 "Loaded " << path << " in "
959 << stopwatch.elapsedSeconds() << " seconds" );
961 // Generate a cloud layer above the tiles
962 // if ( current_options.get_clouds() ) {
963 // fgGenCloudTile(path, t, tile);