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 <Scenery/tileentry.hxx>
58 #include <Clouds/cloudobj.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
97 // Calculate texture coordinates for a given point.
98 static Point3D calc_tex_coords(const Point3D& node, const Point3D& ref) {
101 // double tmplon, tmplat;
103 // cout << "-> " << node[0] << " " << node[1] << " " << node[2] << endl;
104 // cout << "-> " << ref.x() << " " << ref.y() << " " << ref.z() << endl;
106 cp = Point3D( node[0] + ref.x(),
110 pp = fgCartToPolar3d(cp);
112 // tmplon = pp.lon() * RAD_TO_DEG;
113 // tmplat = pp.lat() * RAD_TO_DEG;
114 // cout << tmplon << " " << tmplat << endl;
116 pp.setx( fmod(RAD_TO_DEG * FG_TEX_CONSTANT * pp.x(), 11.0) );
117 pp.sety( fmod(RAD_TO_DEG * FG_TEX_CONSTANT * pp.y(), 11.0) );
119 if ( pp.x() < 0.0 ) {
120 pp.setx( pp.x() + 11.0 );
123 if ( pp.y() < 0.0 ) {
124 pp.sety( pp.y() + 11.0 );
127 // cout << pp << endl;
133 // Generate a generic ocean tile on the fly
134 ssgBranch *fgGenTile( const string& path, FGTileEntry *t) {
137 fragment.tile_ptr = t;
139 ssgSimpleState *state = NULL;
141 ssgBranch *tile = new ssgBranch () ;
142 tile -> setName ( (char *)path.c_str() ) ;
144 // find Ocean material in the properties list
145 if ( ! material_mgr.find( "Ocean", fragment.material_ptr )) {
146 FG_LOG( FG_TERRAIN, FG_ALERT,
147 "Ack! unknown usemtl name = " << "Ocean"
151 // set the texture width and height values for this
153 FGMaterial m = fragment.material_ptr->get_m();
154 // double tex_width = m.get_xsize();
155 // double tex_height = m.get_ysize();
158 state = fragment.material_ptr->get_state();
160 // Calculate center point
161 FGBucket b = t->tile_bucket;
162 double clon = b.get_center_lon();
163 double clat = b.get_center_lat();
164 double height = b.get_height();
165 double width = b.get_width();
167 Point3D center = fgGeodToCart(Point3D(clon*DEG_TO_RAD,clat*DEG_TO_RAD,0.0));
169 fragment.center = center;
170 // cout << "center = " << center << endl;;
172 // Caculate corner vertices
174 geod[0] = Point3D( clon - width/2.0, clat - height/2.0, 0.0 );
175 geod[1] = Point3D( clon + width/2.0, clat - height/2.0, 0.0 );
176 geod[2] = Point3D( clon + width/2.0, clat + height/2.0, 0.0 );
177 geod[3] = Point3D( clon - width/2.0, clat + height/2.0, 0.0 );
181 for ( i = 0; i < 4; ++i ) {
182 rad[i] = Point3D( geod[i].x() * DEG_TO_RAD, geod[i].y() * DEG_TO_RAD,
186 Point3D cart[4], rel[4];
188 for ( i = 0; i < 4; ++i ) {
189 cart[i] = fgGeodToCart(rad[i]);
190 rel[i] = cart[i] - center;
191 t->nodes.push_back( rel[i] );
192 // cout << "corner " << i << " = " << cart[i] << endl;
197 // Calculate bounding radius
198 t->bounding_radius = center.distance3D( cart[0] );
199 fragment.bounding_radius = t->bounding_radius;
200 // cout << "bounding radius = " << t->bounding_radius << endl;
204 for ( i = 0; i < 4; ++i ) {
205 normals[i] = cart[i];
206 double length = normals[i].distance3D( Point3D(0.0) );
207 normals[i] /= length;
208 // cout << "normal = " << normals[i] << endl;
211 // Calculate texture coordinates
213 for ( i = 0; i < 4; ++i ) {
214 texs[i] = calc_tex_coords( rel[i], center );
215 // cout << "texture coordinate = " << texs[i] << endl;
218 // Build flight gear structure
219 fragment.add_face(0, 1, 2);
220 fragment.add_face(0, 2, 3);
221 t->fragment_list.push_back(fragment);
223 // Build ssg structure
224 t->vtlist = new sgVec3 [ 4 ];
225 t->vnlist = new sgVec3 [ 4 ];
226 t->tclist = new sgVec2 [ 4 ];
228 for ( i = 0; i < 4; ++i ) {
229 sgSetVec3( t->vtlist[i],
230 rel[i].x(), rel[i].y(), rel[i].z() );
231 sgSetVec3( t->vnlist[i],
232 normals[i].x(), normals[i].y(), normals[i].z() );
233 sgSetVec2( t->tclist[i], texs[i].x(), texs[i].y() );
236 unsigned short *vindex = new unsigned short [ 4 ];
237 t->free_ptrs.push_back( vindex );
238 unsigned short *tindex = new unsigned short [ 4 ];
239 t->free_ptrs.push_back( tindex );
240 for ( i = 0; i < 4; ++i ) {
246 new ssgVTable ( GL_TRIANGLE_FAN,
247 4, vindex, t->vtlist,
248 4, vindex, t->vnlist,
249 4, tindex, t->tclist,
251 leaf->setState( state );
253 tile->addKid( leaf );
254 if ( current_options.get_clouds() ) {
255 fgGenCloudTile(path, t, tile);
262 // Load a .obj file and build the fragment list
263 ssgBranch *fgObjLoad( const string& path, FGTileEntry *t) {
266 double approx_normal[3] /*, normal[3], scale = 0.0 */;
267 // double x, y, z, xmax, xmin, ymax, ymin, zmax, zmin;
268 // GLfloat sgenparams[] = { 1.0, 0.0, 0.0, 0.0 };
269 // GLint display_list = 0;
271 bool in_fragment = false, in_faces = false;
272 int vncount, vtcount;
273 int n1 = 0, n2 = 0, n3 = 0, n4 = 0;
275 int last1 = 0, last2 = 0;
280 double scenery_version = 0.0;
281 double tex_width = 1000.0, tex_height = 1000.0;
282 bool shared_done = false;
283 int_list fan_vertices;
284 int_list fan_tex_coords;
286 ssgSimpleState *state = NULL;
288 ssgBranch *tile = new ssgBranch () ;
290 tile -> setName ( (char *)path.c_str() ) ;
292 // Attempt to open "path.gz" or "path"
293 fg_gzifstream in( path );
294 if ( ! in.is_open() ) {
295 FG_LOG( FG_TERRAIN, FG_ALERT, "Cannot open file: " << path );
296 FG_LOG( FG_TERRAIN, FG_ALERT, "default to ocean tile: " << path );
298 return fgGenTile( path, t );
301 shading = current_options.get_shading();
307 t->bounding_radius = 0.0;
313 // ignore initial comments and blank lines. (priming the pump)
314 // in >> skipcomment;
321 while ( in.get(c) && c != '\0' ) {
324 while ( ! in.eof() ) {
333 if ( in.get( c ) && c == '#' ) {
334 // process a comment line
336 // getline( in, line );
337 // cout << "comment = " << line << endl;
341 if ( token == "Version" ) {
342 // read scenery versions number
343 in >> scenery_version;
344 // cout << "scenery_version = " << scenery_version << endl;
345 } else if ( token == "gbs" ) {
346 // reference point (center offset)
347 in >> t->center >> t->bounding_radius;
349 // cout << "center = " << center
350 // << " radius = " << t->bounding_radius << endl;
351 } else if ( token == "bs" ) {
352 // reference point (center offset)
353 in >> fragment.center;
354 in >> fragment.bounding_radius;
356 // cout << "center = " << fragment.center
357 // << " radius = " << fragment.bounding_radius << endl;
358 } else if ( token == "usemtl" ) {
359 // material property specification
361 // if first usemtl with shared_done = false, then set
362 // shared_done true and build the ssg shared lists
363 if ( ! shared_done ) {
365 if ( (int)nodes.size() != vncount ) {
366 FG_LOG( FG_TERRAIN, FG_ALERT,
367 "Tile has mismatched nodes and normals: "
373 t->vtlist = new sgVec3 [ nodes.size() ];
374 t->vnlist = new sgVec3 [ vncount ];
375 t->tclist = new sgVec2 [ vtcount ];
377 for ( i = 0; i < (int)nodes.size(); ++i ) {
378 sgSetVec3( t->vtlist[i],
379 nodes[i][0], nodes[i][1], nodes[i][2] );
381 for ( i = 0; i < vncount; ++i ) {
382 sgSetVec3( t->vnlist[i],
387 for ( i = 0; i < vtcount; ++i ) {
388 sgSetVec2( t->tclist[i],
394 // series of individual triangles
399 // this also signals the start of a new fragment
401 // close out the previous structure and start the next
403 // printf("xglEnd(); xglEndList();\n");
406 // fragment.display_list = display_list;
408 // push this fragment onto the tile's object list
409 t->fragment_list.push_back(fragment);
414 // printf("start of fragment (usemtl)\n");
416 // display_list = xglGenLists(1);
417 // xglNewList(display_list, GL_COMPILE);
418 // printf("xglGenLists(); xglNewList();\n");
421 // reset the existing face list
422 // printf("cleaning a fragment with %d faces\n",
423 // fragment.faces.size());
426 // scan the material line
429 fragment.tile_ptr = t;
431 // find this material in the properties list
432 if ( ! material_mgr.find( material, fragment.material_ptr )) {
433 FG_LOG( FG_TERRAIN, FG_ALERT,
434 "Ack! unknown usemtl name = " << material
438 // set the texture width and height values for this
440 FGMaterial m = fragment.material_ptr->get_m();
441 tex_width = m.get_xsize();
442 tex_height = m.get_ysize();
443 state = fragment.material_ptr->get_state();
444 // cout << "(w) = " << tex_width << " (h) = "
445 // << tex_width << endl;
447 // initialize the fragment transformation matrix
449 for ( i = 0; i < 16; i++ ) {
450 fragment.matrix[i] = 0.0;
452 fragment.matrix[0] = fragment.matrix[5] =
453 fragment.matrix[10] = fragment.matrix[15] = 1.0;
456 // unknown comment, just gobble the input untill the
466 // cout << "token = " << token << endl;
468 if ( token == "vn" ) {
470 if ( vncount < FG_MAX_NODES ) {
471 in >> normals[vncount][0]
472 >> normals[vncount][1]
473 >> normals[vncount][2];
476 FG_LOG( FG_TERRAIN, FG_ALERT,
477 "Read too many vertex normals in " << path
478 << " ... dying :-(" );
481 } else if ( token == "vt" ) {
482 // vertex texture coordinate
483 if ( vtcount < FG_MAX_NODES*3 ) {
484 in >> tex_coords[vtcount][0]
485 >> tex_coords[vtcount][1];
488 FG_LOG( FG_TERRAIN, FG_ALERT,
489 "Read too many vertex texture coords in " << path
494 } else if ( token == "v" ) {
496 if ( t->ncount < FG_MAX_NODES ) {
497 /* in >> nodes[t->ncount][0]
498 >> nodes[t->ncount][1]
499 >> nodes[t->ncount][2]; */
501 nodes.push_back(node);
504 FG_LOG( FG_TERRAIN, FG_ALERT,
505 "Read too many nodes in " << path
506 << " ... dying :-(");
509 } else if ( token == "t" ) {
510 // start a new triangle strip
512 n1 = n2 = n3 = n4 = 0;
514 // fgPrintf( FG_TERRAIN, FG_DEBUG,
515 // " new tri strip = %s", line);
516 in >> n1 >> n2 >> n3;
517 fragment.add_face(n1, n2, n3);
519 // fgPrintf( FG_TERRAIN, FG_DEBUG, "(t) = ");
521 // xglBegin(GL_TRIANGLE_STRIP);
522 // printf("xglBegin(tristrip) %d %d %d\n", n1, n2, n3);
528 // Shading model is "GL_SMOOTH" so use precalculated
529 // (averaged) normals
530 // MAT3_SCALE_VEC(normal, normals[n1], scale);
531 // xglNormal3dv(normal);
532 pp = calc_tex_coords(nodes[n1], center);
533 // xglTexCoord2f(pp.lon(), pp.lat());
534 // xglVertex3dv(nodes[n1].get_n());
536 // MAT3_SCALE_VEC(normal, normals[n2], scale);
537 // xglNormal3dv(normal);
538 pp = calc_tex_coords(nodes[n2], center);
539 // xglTexCoord2f(pp.lon(), pp.lat());
540 // xglVertex3dv(nodes[n2].get_n());
542 // MAT3_SCALE_VEC(normal, normals[n3], scale);
543 // xglNormal3dv(normal);
544 pp = calc_tex_coords(nodes[n3], center);
545 // xglTexCoord2f(pp.lon(), pp.lat());
546 // xglVertex3dv(nodes[n3].get_n());
548 // Shading model is "GL_FLAT" so calculate per face
549 // normals on the fly.
551 calc_normal(nodes[n1], nodes[n2],
552 nodes[n3], approx_normal);
554 calc_normal(nodes[n2], nodes[n1],
555 nodes[n3], approx_normal);
557 // MAT3_SCALE_VEC(normal, approx_normal, scale);
558 // xglNormal3dv(normal);
560 pp = calc_tex_coords(nodes[n1], center);
561 // xglTexCoord2f(pp.lon(), pp.lat());
562 // xglVertex3dv(nodes[n1].get_n());
564 pp = calc_tex_coords(nodes[n2], center);
565 // xglTexCoord2f(pp.lon(), pp.lat());
566 // xglVertex3dv(nodes[n2].get_n());
568 pp = calc_tex_coords(nodes[n3], center);
569 // xglTexCoord2f(pp.lon(), pp.lat());
570 // xglVertex3dv(nodes[n3].get_n());
572 // printf("some normals, texcoords, and vertices\n");
578 // There can be three or four values
580 while ( in.get(c) ) {
582 break; // only the one
592 fragment.add_face(n3, n2, n4);
595 // Shading model is "GL_SMOOTH"
596 // MAT3_SCALE_VEC(normal, normals[n4], scale);
598 // Shading model is "GL_FLAT"
599 calc_normal(nodes[n3], nodes[n2], nodes[n4],
601 // MAT3_SCALE_VEC(normal, approx_normal, scale);
603 // xglNormal3dv(normal);
604 pp = calc_tex_coords(nodes[n4], center);
605 // xglTexCoord2f(pp.lon(), pp.lat());
606 // xglVertex3dv(nodes[n4].get_n());
611 // printf("a normal, texcoord, and vertex (4th)\n");
613 } else if ( (token == "tf") || (token == "ts") ) {
615 // fgPrintf( FG_TERRAIN, FG_DEBUG, "new fan");
617 fan_vertices.clear();
618 fan_tex_coords.clear();
621 // xglBegin(GL_TRIANGLE_FAN);
624 fan_vertices.push_back( n1 );
625 // xglNormal3dv(normals[n1]);
626 if ( in.get( c ) && c == '/' ) {
628 fan_tex_coords.push_back( tex );
629 if ( scenery_version >= 0.4 ) {
630 if ( tex_width > 0 ) {
631 t->tclist[tex][0] *= (1000.0 / tex_width);
633 if ( tex_height > 0 ) {
634 t->tclist[tex][1] *= (1000.0 / tex_height);
637 pp.setx( tex_coords[tex][0] * (1000.0 / tex_width) );
638 pp.sety( tex_coords[tex][1] * (1000.0 / tex_height) );
641 pp = calc_tex_coords(nodes[n1], center);
643 // xglTexCoord2f(pp.x(), pp.y());
644 // xglVertex3dv(nodes[n1].get_n());
647 fan_vertices.push_back( n2 );
648 // xglNormal3dv(normals[n2]);
649 if ( in.get( c ) && c == '/' ) {
651 fan_tex_coords.push_back( tex );
652 if ( scenery_version >= 0.4 ) {
653 if ( tex_width > 0 ) {
654 t->tclist[tex][0] *= (1000.0 / tex_width);
656 if ( tex_height > 0 ) {
657 t->tclist[tex][1] *= (1000.0 / tex_height);
660 pp.setx( tex_coords[tex][0] * (1000.0 / tex_width) );
661 pp.sety( tex_coords[tex][1] * (1000.0 / tex_height) );
664 pp = calc_tex_coords(nodes[n2], center);
666 // xglTexCoord2f(pp.x(), pp.y());
667 // xglVertex3dv(nodes[n2].get_n());
669 // read all subsequent numbers until next thing isn't a number
680 if ( ! isdigit(c) || in.eof() ) {
685 fan_vertices.push_back( n3 );
686 // cout << " triangle = "
687 // << n1 << "," << n2 << "," << n3
689 // xglNormal3dv(normals[n3]);
690 if ( in.get( c ) && c == '/' ) {
692 fan_tex_coords.push_back( tex );
693 if ( scenery_version >= 0.4 ) {
694 if ( tex_width > 0 ) {
695 t->tclist[tex][0] *= (1000.0 / tex_width);
697 if ( tex_height > 0 ) {
698 t->tclist[tex][1] *= (1000.0 / tex_height);
701 pp.setx( tex_coords[tex][0] * (1000.0 / tex_width) );
702 pp.sety( tex_coords[tex][1] * (1000.0 / tex_height) );
705 pp = calc_tex_coords(nodes[n3], center);
707 // xglTexCoord2f(pp.x(), pp.y());
708 // xglVertex3dv(nodes[n3].get_n());
710 if ( token == "tf" ) {
712 fragment.add_face(n1, n2, n3);
717 fragment.add_face(n1, n2, n3);
719 fragment.add_face(n2, n1, n3);
729 // build the ssg entity
730 unsigned short *vindex =
731 new unsigned short [ fan_vertices.size() ];
732 t->free_ptrs.push_back( vindex );
734 unsigned short *tindex =
735 new unsigned short [ fan_tex_coords.size() ];
736 t->free_ptrs.push_back( tindex );
738 for ( i = 0; i < (int)fan_vertices.size(); ++i ) {
739 vindex[i] = fan_vertices[i];
741 for ( i = 0; i < (int)fan_tex_coords.size(); ++i ) {
742 tindex[i] = fan_tex_coords[i];
745 if ( token == "tf" ) {
748 new ssgVTable ( GL_TRIANGLE_FAN,
749 fan_vertices.size(), vindex, t->vtlist,
750 fan_vertices.size(), vindex, t->vnlist,
751 fan_tex_coords.size(), tindex,t->tclist,
756 new ssgVTable ( GL_TRIANGLE_STRIP,
757 fan_vertices.size(), vindex, t->vtlist,
758 fan_vertices.size(), vindex, t->vnlist,
759 fan_tex_coords.size(), tindex,t->tclist,
762 leaf->setState( state );
764 tile->addKid( leaf );
766 } else if ( token == "f" ) {
770 // xglBegin(GL_TRIANGLES);
771 // printf("xglBegin(triangles)\n");
775 // fgPrintf( FG_TERRAIN, FG_DEBUG, "new triangle = %s", line);*/
776 in >> n1 >> n2 >> n3;
777 fragment.add_face(n1, n2, n3);
779 // xglNormal3d(normals[n1][0], normals[n1][1], normals[n1][2]);
780 // xglNormal3dv(normals[n1]);
781 pp = calc_tex_coords(nodes[n1], center);
782 // xglTexCoord2f(pp.lon(), pp.lat());
783 // xglVertex3dv(nodes[n1].get_n());
785 // xglNormal3dv(normals[n2]);
786 pp = calc_tex_coords(nodes[n2], center);
787 // xglTexCoord2f(pp.lon(), pp.lat());
788 // xglVertex3dv(nodes[n2].get_n());
790 // xglNormal3dv(normals[n3]);
791 pp = calc_tex_coords(nodes[n3], center);
792 // xglTexCoord2f(pp.lon(), pp.lat());
793 // xglVertex3dv(nodes[n3].get_n());
794 // printf("some normals, texcoords, and vertices (tris)\n");
795 } else if ( token == "q" ) {
796 // continue a triangle strip
799 // fgPrintf( FG_TERRAIN, FG_DEBUG, "continued tri strip = %s ",
803 // There can be one or two values
805 while ( in.get(c) ) {
807 break; // only the one
816 // fgPrintf( FG_TERRAIN, FG_DEBUG, "read %d %d\n", n1, n2);
819 fragment.add_face(last1, last2, n1);
821 fragment.add_face(last2, last1, n1);
825 // Shading model is "GL_SMOOTH"
826 // MAT3_SCALE_VEC(normal, normals[n1], scale);
828 // Shading model is "GL_FLAT"
830 calc_normal(nodes[last1], nodes[last2],
831 nodes[n1], approx_normal);
833 calc_normal(nodes[last2], nodes[last1],
834 nodes[n1], approx_normal);
836 // MAT3_SCALE_VEC(normal, approx_normal, scale);
838 // xglNormal3dv(normal);
840 pp = calc_tex_coords(nodes[n1], center);
841 // xglTexCoord2f(pp.lon(), pp.lat());
842 // xglVertex3dv(nodes[n1].get_n());
843 // printf("a normal, texcoord, and vertex (4th)\n");
850 // fgPrintf( FG_TERRAIN, FG_DEBUG, " (cont)\n");
853 fragment.add_face(last1, last2, n2);
855 fragment.add_face(last2, last1, n2);
859 // Shading model is "GL_SMOOTH"
860 // MAT3_SCALE_VEC(normal, normals[n2], scale);
862 // Shading model is "GL_FLAT"
864 calc_normal(nodes[last1], nodes[last2],
865 nodes[n2], approx_normal);
867 calc_normal(nodes[last2], nodes[last1],
868 nodes[n2], approx_normal);
870 // MAT3_SCALE_VEC(normal, approx_normal, scale);
872 // xglNormal3dv(normal);
874 pp = calc_tex_coords(nodes[n2], center);
875 // xglTexCoord2f(pp.lon(), pp.lat());
876 // xglVertex3dv(nodes[n2].get_n());
877 // printf("a normal, texcoord, and vertex (4th)\n");
884 FG_LOG( FG_TERRAIN, FG_WARN, "Unknown token in "
885 << path << " = " << token );
888 // eat white space before start of while loop so if we are
889 // done with useful input it is noticed before hand.
899 // close out the previous structure and start the next
902 // printf("xglEnd(); xglEndList();\n");
905 // fragment.display_list = display_list;
907 // push this fragment onto the tile's object list
908 t->fragment_list.push_back(fragment);
912 // Draw normal vectors (for visually verifying normals)
914 xglColor3f(0.0, 0.0, 0.0);
915 for ( i = 0; i < t->ncount; i++ ) {
916 xglVertex3d(nodes[i][0],
919 xglVertex3d(nodes[i][0] + 500*normals[i][0],
920 nodes[i][1] + 500*normals[i][1],
921 nodes[i][2] + 500*normals[i][2]);
929 FG_LOG( FG_TERRAIN, FG_DEBUG,
930 "Loaded " << path << " in "
931 << stopwatch.elapsedSeconds() << " seconds" );
933 // Generate a cloud layer above the tiles
934 if ( current_options.get_clouds() ) {
935 fgGenCloudTile(path, t, tile);