# include <math.h>
#endif
-#ifdef HAVE_WINDOWS_H
-# include <windows.h>
-#endif
+// #ifdef HAVE_WINDOWS_H
+// # include <windows.h>
+// #endif
#include <stdio.h>
#include <string.h>
-#include <GL/glut.h>
-#include <XGL/xgl.h>
+// #include <GL/glut.h>
+// #include <XGL/xgl.h>
// #if defined ( __sun__ )
// extern "C" void *memmove(void *, const void *, size_t);
}
-// Load a .obj file and build the GL fragment list
+// Load a .obj file and build the fragment list
ssgBranch *fgObjLoad( const string& path, FGTileEntry *t) {
fgFRAGMENT fragment;
Point3D pp;
- double approx_normal[3], normal[3] /*, scale = 0.0 */;
+ double approx_normal[3] /*, normal[3], scale = 0.0 */;
// double x, y, z, xmax, xmin, ymax, ymin, zmax, zmin;
// GLfloat sgenparams[] = { 1.0, 0.0, 0.0, 0.0 };
- GLint display_list = 0;
+ // GLint display_list = 0;
int shading;
bool in_fragment = false, in_faces = false;
int vncount, vtcount;
// shared_done true and build the ssg shared lists
if ( ! shared_done ) {
// sanity check
- if ( nodes.size() != vncount ) {
+ if ( (int)nodes.size() != vncount ) {
FG_LOG( FG_TERRAIN, FG_ALERT,
"Tile has mismatched nodes and normals: "
<< path );
}
// series of individual triangles
- if ( in_faces ) {
- xglEnd();
- }
+ // if ( in_faces ) {
+ // xglEnd();
+ // }
// this also signals the start of a new fragment
if ( in_fragment ) {
// close out the previous structure and start the next
- xglEndList();
+ // xglEndList();
// printf("xglEnd(); xglEndList();\n");
// update fragment
- fragment.display_list = display_list;
+ // fragment.display_list = display_list;
// push this fragment onto the tile's object list
t->fragment_list.push_back(fragment);
// printf("start of fragment (usemtl)\n");
- display_list = xglGenLists(1);
- xglNewList(display_list, GL_COMPILE);
+ // display_list = xglGenLists(1);
+ // xglNewList(display_list, GL_COMPILE);
// printf("xglGenLists(); xglNewList();\n");
in_faces = false;
// fgPrintf( FG_TERRAIN, FG_DEBUG, "(t) = ");
- xglBegin(GL_TRIANGLE_STRIP);
+ // xglBegin(GL_TRIANGLE_STRIP);
// printf("xglBegin(tristrip) %d %d %d\n", n1, n2, n3);
odd = 1;
// Shading model is "GL_SMOOTH" so use precalculated
// (averaged) normals
// MAT3_SCALE_VEC(normal, normals[n1], scale);
- xglNormal3dv(normal);
+ // xglNormal3dv(normal);
pp = calc_tex_coords(nodes[n1], center);
- xglTexCoord2f(pp.lon(), pp.lat());
- xglVertex3dv(nodes[n1].get_n());
+ // xglTexCoord2f(pp.lon(), pp.lat());
+ // xglVertex3dv(nodes[n1].get_n());
// MAT3_SCALE_VEC(normal, normals[n2], scale);
- xglNormal3dv(normal);
+ // xglNormal3dv(normal);
pp = calc_tex_coords(nodes[n2], center);
- xglTexCoord2f(pp.lon(), pp.lat());
- xglVertex3dv(nodes[n2].get_n());
+ // xglTexCoord2f(pp.lon(), pp.lat());
+ // xglVertex3dv(nodes[n2].get_n());
// MAT3_SCALE_VEC(normal, normals[n3], scale);
- xglNormal3dv(normal);
+ // xglNormal3dv(normal);
pp = calc_tex_coords(nodes[n3], center);
- xglTexCoord2f(pp.lon(), pp.lat());
- xglVertex3dv(nodes[n3].get_n());
+ // xglTexCoord2f(pp.lon(), pp.lat());
+ // xglVertex3dv(nodes[n3].get_n());
} else {
// Shading model is "GL_FLAT" so calculate per face
// normals on the fly.
nodes[n3], approx_normal);
}
// MAT3_SCALE_VEC(normal, approx_normal, scale);
- xglNormal3dv(normal);
+ // xglNormal3dv(normal);
pp = calc_tex_coords(nodes[n1], center);
- xglTexCoord2f(pp.lon(), pp.lat());
- xglVertex3dv(nodes[n1].get_n());
+ // xglTexCoord2f(pp.lon(), pp.lat());
+ // xglVertex3dv(nodes[n1].get_n());
pp = calc_tex_coords(nodes[n2], center);
- xglTexCoord2f(pp.lon(), pp.lat());
- xglVertex3dv(nodes[n2].get_n());
+ // xglTexCoord2f(pp.lon(), pp.lat());
+ // xglVertex3dv(nodes[n2].get_n());
pp = calc_tex_coords(nodes[n3], center);
- xglTexCoord2f(pp.lon(), pp.lat());
- xglVertex3dv(nodes[n3].get_n());
+ // xglTexCoord2f(pp.lon(), pp.lat());
+ // xglVertex3dv(nodes[n3].get_n());
}
// printf("some normals, texcoords, and vertices\n");
approx_normal);
// MAT3_SCALE_VEC(normal, approx_normal, scale);
}
- xglNormal3dv(normal);
+ // xglNormal3dv(normal);
pp = calc_tex_coords(nodes[n4], center);
- xglTexCoord2f(pp.lon(), pp.lat());
- xglVertex3dv(nodes[n4].get_n());
+ // xglTexCoord2f(pp.lon(), pp.lat());
+ // xglVertex3dv(nodes[n4].get_n());
odd = 1 - odd;
last1 = n3;
fan_vertices.clear();
fan_tex_coords.clear();
- xglBegin(GL_TRIANGLE_FAN);
+ // xglBegin(GL_TRIANGLE_FAN);
in >> n1;
fan_vertices.push_back( n1 );
- xglNormal3dv(normals[n1]);
+ // xglNormal3dv(normals[n1]);
if ( in.get( c ) && c == '/' ) {
in >> tex;
fan_tex_coords.push_back( tex );
in.putback( c );
pp = calc_tex_coords(nodes[n1], center);
}
- xglTexCoord2f(pp.x(), pp.y());
- xglVertex3dv(nodes[n1].get_n());
+ // xglTexCoord2f(pp.x(), pp.y());
+ // xglVertex3dv(nodes[n1].get_n());
in >> n2;
fan_vertices.push_back( n2 );
- xglNormal3dv(normals[n2]);
+ // xglNormal3dv(normals[n2]);
if ( in.get( c ) && c == '/' ) {
in >> tex;
fan_tex_coords.push_back( tex );
in.putback( c );
pp = calc_tex_coords(nodes[n2], center);
}
- xglTexCoord2f(pp.x(), pp.y());
- xglVertex3dv(nodes[n2].get_n());
+ // xglTexCoord2f(pp.x(), pp.y());
+ // xglVertex3dv(nodes[n2].get_n());
// read all subsequent numbers until next thing isn't a number
while ( true ) {
// cout << " triangle = "
// << n1 << "," << n2 << "," << n3
// << endl;
- xglNormal3dv(normals[n3]);
+ // xglNormal3dv(normals[n3]);
if ( in.get( c ) && c == '/' ) {
in >> tex;
fan_tex_coords.push_back( tex );
in.putback( c );
pp = calc_tex_coords(nodes[n3], center);
}
- xglTexCoord2f(pp.x(), pp.y());
- xglVertex3dv(nodes[n3].get_n());
+ // xglTexCoord2f(pp.x(), pp.y());
+ // xglVertex3dv(nodes[n3].get_n());
fragment.add_face(n1, n2, n3);
n2 = n3;
}
- xglEnd();
+ // xglEnd();
// build the ssg entity
unsigned short *vindex =
// unoptimized face
if ( !in_faces ) {
- xglBegin(GL_TRIANGLES);
+ // xglBegin(GL_TRIANGLES);
// printf("xglBegin(triangles)\n");
in_faces = true;
}
fragment.add_face(n1, n2, n3);
// xglNormal3d(normals[n1][0], normals[n1][1], normals[n1][2]);
- xglNormal3dv(normals[n1]);
+ // xglNormal3dv(normals[n1]);
pp = calc_tex_coords(nodes[n1], center);
- xglTexCoord2f(pp.lon(), pp.lat());
- xglVertex3dv(nodes[n1].get_n());
+ // xglTexCoord2f(pp.lon(), pp.lat());
+ // xglVertex3dv(nodes[n1].get_n());
- xglNormal3dv(normals[n2]);
+ // xglNormal3dv(normals[n2]);
pp = calc_tex_coords(nodes[n2], center);
- xglTexCoord2f(pp.lon(), pp.lat());
- xglVertex3dv(nodes[n2].get_n());
+ // xglTexCoord2f(pp.lon(), pp.lat());
+ // xglVertex3dv(nodes[n2].get_n());
- xglNormal3dv(normals[n3]);
+ // xglNormal3dv(normals[n3]);
pp = calc_tex_coords(nodes[n3], center);
- xglTexCoord2f(pp.lon(), pp.lat());
- xglVertex3dv(nodes[n3].get_n());
+ // xglTexCoord2f(pp.lon(), pp.lat());
+ // xglVertex3dv(nodes[n3].get_n());
// printf("some normals, texcoords, and vertices (tris)\n");
} else if ( token == "q" ) {
// continue a triangle strip
}
// MAT3_SCALE_VEC(normal, approx_normal, scale);
}
- xglNormal3dv(normal);
+ // xglNormal3dv(normal);
pp = calc_tex_coords(nodes[n1], center);
- xglTexCoord2f(pp.lon(), pp.lat());
- xglVertex3dv(nodes[n1].get_n());
+ // xglTexCoord2f(pp.lon(), pp.lat());
+ // xglVertex3dv(nodes[n1].get_n());
// printf("a normal, texcoord, and vertex (4th)\n");
odd = 1 - odd;
}
// MAT3_SCALE_VEC(normal, approx_normal, scale);
}
- xglNormal3dv(normal);
+ // xglNormal3dv(normal);
pp = calc_tex_coords(nodes[n2], center);
- xglTexCoord2f(pp.lon(), pp.lat());
- xglVertex3dv(nodes[n2].get_n());
+ // xglTexCoord2f(pp.lon(), pp.lat());
+ // xglVertex3dv(nodes[n2].get_n());
// printf("a normal, texcoord, and vertex (4th)\n");
odd = 1 -odd;
if ( in_fragment ) {
// close out the previous structure and start the next
- xglEnd();
- xglEndList();
+ // xglEnd();
+ // xglEndList();
// printf("xglEnd(); xglEndList();\n");
// update fragment
- fragment.display_list = display_list;
+ // fragment.display_list = display_list;
// push this fragment onto the tile's object list
t->fragment_list.push_back(fragment);