#include "tri2obj.h"
-#include "../../Src/Include/constants.h"
-#include "../../Src/Include/types.h"
-#include "../../Src/Math/fg_geodesy.h"
-#include "../../Src/Math/mat3.h"
-#include "../../Src/Math/polar.h"
-#include "../../Src/Scenery/tileutils.h"
+#include <Include/fg_constants.h>
+#include <Include/fg_types.h>
+#include <Bucket/bucketutils.h>
+
+#include <Math/fg_geodesy.h>
+#include <Math/mat3.h>
+#include <Math/polar3d.h>
int nodecount, tricount;
int normalcount = 0;
-struct fgCartesianPoint nodes[MAX_NODES];
-int tris[MAX_TRIS][3];
-int new_tris[MAX_TRIS][3];
+static fgCartesianPoint3d nodes[MAX_NODES];
+static int tris[MAX_TRIS][3];
-float normals[MAX_NODES][3];
+static double normals[MAX_NODES][3];
-struct bucket my_index;
-struct bucket ne_index, nw_index, sw_index, se_index;
-struct bucket north_index, south_index, east_index, west_index;
+fgBUCKET my_index;
+fgBUCKET ne_index, nw_index, sw_index, se_index;
+fgBUCKET north_index, south_index, east_index, west_index;
/* convert a geodetic point lon(arcsec), lat(arcsec), elev(meter) to
* a cartesian point */
-struct fgCartesianPoint geod_to_cart(double geod[3]) {
- struct fgCartesianPoint p;
+fgCartesianPoint3d geod_to_cart(double geod[3]) {
+ fgCartesianPoint3d cp;
+ fgPolarPoint3d pp;
double gc_lon, gc_lat, sl_radius;
/* printf("A geodetic point is (%.2f, %.2f, %.2f)\n",
/* printf("A geocentric point is (%.2f, %.2f, %.2f)\n", gc_lon,
gc_lat, sl_radius+geod[2]); */
- p = fgPolarToCart(gc_lon, gc_lat, sl_radius+geod[2]);
+ pp.lon = gc_lon;
+ pp.lat = gc_lat;
+ pp.radius = sl_radius+geod[2];
+ cp = fgPolarToCart3d(pp);
- /* printf("A cart point is (%.8f, %.8f, %.8f)\n", p.x, p.y, p.z); */
+ /* printf("A cart point is (%.8f, %.8f, %.8f)\n", cp.x, cp.y, cp.z); */
- return(p);
+ return(cp);
}
/* given three points defining a triangle, calculate the normal */
-void calc_normal(struct fgCartesianPoint p1, struct fgCartesianPoint p2,
- struct fgCartesianPoint p3, double normal[3])
+void calc_normal(fgCartesianPoint3d p1, fgCartesianPoint3d p2,
+ fgCartesianPoint3d p3, double normal[3])
{
double v1[3], v2[3];
- float temp;
+ double temp;
v1[0] = p2.x - p1.x; v1[1] = p2.y - p1.y; v1[2] = p2.z - p1.z;
v2[0] = p3.x - p1.x; v2[1] = p3.y - p1.y; v2[2] = p3.z - p1.z;
MAT3cross_product(normal, v1, v2);
- MAT3_NORMALIZE_VEC(normal,temp);
+ MAT3_NORMALIZE_VEC(normal, temp);
/* printf(" Normal = %.2f %.2f %.2f\n", normal[0], normal[1], normal[2]); */
}
long int index;
if ( strcmp(ext, ".sw") == 0 ) {
- gen_base_path(&my_index, scene_path);
- index = gen_index(&my_index);
+ fgBucketGenBasePath(&my_index, scene_path);
+ index = fgBucketGenIndex(&my_index);
sprintf(file, "%s/%s/%ld.1.sw", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
- gen_base_path(&west_index, scene_path);
- index = gen_index(&west_index);
+ fgBucketGenBasePath(&west_index, scene_path);
+ index = fgBucketGenIndex(&west_index);
sprintf(file, "%s/%s/%ld.1.se", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
- gen_base_path(&sw_index, scene_path);
- index = gen_index(&sw_index);
+ fgBucketGenBasePath(&sw_index, scene_path);
+ index = fgBucketGenIndex(&sw_index);
sprintf(file, "%s/%s/%ld.1.ne", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
- gen_base_path(&south_index, scene_path);
- index = gen_index(&south_index);
+ fgBucketGenBasePath(&south_index, scene_path);
+ index = fgBucketGenIndex(&south_index);
sprintf(file, "%s/%s/%ld.1.nw", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
if ( strcmp(ext, ".se") == 0 ) {
- gen_base_path(&my_index, scene_path);
- index = gen_index(&my_index);
+ fgBucketGenBasePath(&my_index, scene_path);
+ index = fgBucketGenIndex(&my_index);
sprintf(file, "%s/%s/%ld.1.se", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
- gen_base_path(&east_index, scene_path);
- index = gen_index(&east_index);
+ fgBucketGenBasePath(&east_index, scene_path);
+ index = fgBucketGenIndex(&east_index);
sprintf(file, "%s/%s/%ld.1.sw", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
- gen_base_path(&se_index, scene_path);
- index = gen_index(&se_index);
+ fgBucketGenBasePath(&se_index, scene_path);
+ index = fgBucketGenIndex(&se_index);
sprintf(file, "%s/%s/%ld.1.nw", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
- gen_base_path(&south_index, scene_path);
- index = gen_index(&south_index);
+ fgBucketGenBasePath(&south_index, scene_path);
+ index = fgBucketGenIndex(&south_index);
sprintf(file, "%s/%s/%ld.1.ne", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
if ( strcmp(ext, ".ne") == 0 ) {
- gen_base_path(&my_index, scene_path);
- index = gen_index(&my_index);
+ fgBucketGenBasePath(&my_index, scene_path);
+ index = fgBucketGenIndex(&my_index);
sprintf(file, "%s/%s/%ld.1.ne", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
- gen_base_path(&east_index, scene_path);
- index = gen_index(&east_index);
+ fgBucketGenBasePath(&east_index, scene_path);
+ index = fgBucketGenIndex(&east_index);
sprintf(file, "%s/%s/%ld.1.nw", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
- gen_base_path(&ne_index, scene_path);
- index = gen_index(&ne_index);
+ fgBucketGenBasePath(&ne_index, scene_path);
+ index = fgBucketGenIndex(&ne_index);
sprintf(file, "%s/%s/%ld.1.sw", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
- gen_base_path(&north_index, scene_path);
- index = gen_index(&north_index);
+ fgBucketGenBasePath(&north_index, scene_path);
+ index = fgBucketGenIndex(&north_index);
sprintf(file, "%s/%s/%ld.1.se", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
if ( strcmp(ext, ".nw") == 0 ) {
- gen_base_path(&my_index, scene_path);
- index = gen_index(&my_index);
+ fgBucketGenBasePath(&my_index, scene_path);
+ index = fgBucketGenIndex(&my_index);
sprintf(file, "%s/%s/%ld.1.nw", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
- gen_base_path(&west_index, scene_path);
- index = gen_index(&west_index);
+ fgBucketGenBasePath(&west_index, scene_path);
+ index = fgBucketGenIndex(&west_index);
sprintf(file, "%s/%s/%ld.1.ne", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
- gen_base_path(&nw_index, scene_path);
- index = gen_index(&nw_index);
+ fgBucketGenBasePath(&nw_index, scene_path);
+ index = fgBucketGenIndex(&nw_index);
sprintf(file, "%s/%s/%ld.1.se", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
- gen_base_path(&north_index, scene_path);
- index = gen_index(&north_index);
+ fgBucketGenBasePath(&north_index, scene_path);
+ index = fgBucketGenIndex(&north_index);
sprintf(file, "%s/%s/%ld.1.sw", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
if ( strcmp(ext, ".south") == 0 ) {
- gen_base_path(&my_index, scene_path);
- index = gen_index(&my_index);
+ fgBucketGenBasePath(&my_index, scene_path);
+ index = fgBucketGenIndex(&my_index);
sprintf(file, "%s/%s/%ld.1.south", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
- gen_base_path(&south_index, scene_path);
- index = gen_index(&south_index);
+ fgBucketGenBasePath(&south_index, scene_path);
+ index = fgBucketGenIndex(&south_index);
sprintf(file, "%s/%s/%ld.1.north", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
if ( strcmp(ext, ".north") == 0 ) {
- gen_base_path(&my_index, scene_path);
- index = gen_index(&my_index);
+ fgBucketGenBasePath(&my_index, scene_path);
+ index = fgBucketGenIndex(&my_index);
sprintf(file, "%s/%s/%ld.1.north", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
- gen_base_path(&north_index, scene_path);
- index = gen_index(&north_index);
+ fgBucketGenBasePath(&north_index, scene_path);
+ index = fgBucketGenIndex(&north_index);
sprintf(file, "%s/%s/%ld.1.south", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
if ( strcmp(ext, ".west") == 0 ) {
- gen_base_path(&my_index, scene_path);
- index = gen_index(&my_index);
+ fgBucketGenBasePath(&my_index, scene_path);
+ index = fgBucketGenIndex(&my_index);
sprintf(file, "%s/%s/%ld.1.west", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
- gen_base_path(&west_index, scene_path);
- index = gen_index(&west_index);
+ fgBucketGenBasePath(&west_index, scene_path);
+ index = fgBucketGenIndex(&west_index);
sprintf(file, "%s/%s/%ld.1.east", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
if ( strcmp(ext, ".east") == 0 ) {
- gen_base_path(&my_index, scene_path);
- index = gen_index(&my_index);
+ fgBucketGenBasePath(&my_index, scene_path);
+ index = fgBucketGenIndex(&my_index);
sprintf(file, "%s/%s/%ld.1.east", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
- gen_base_path(&east_index, scene_path);
- index = gen_index(&east_index);
+ fgBucketGenBasePath(&east_index, scene_path);
+ index = fgBucketGenIndex(&east_index);
sprintf(file, "%s/%s/%ld.1.west", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
if ( strcmp(ext, ".body") == 0 ) {
- gen_base_path(&my_index, scene_path);
- index = gen_index(&my_index);
+ fgBucketGenBasePath(&my_index, scene_path);
+ index = fgBucketGenIndex(&my_index);
sprintf(file, "%s/%s/%ld.1.body", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
while ( fgets(line, 250, fp) != NULL ) {
if ( strncmp(line, "vn ", 3) == 0 ) {
- sscanf(line, "vn %f %f %f\n", &normals[normalcount][0],
- &normals[normalcount][1], &normals[normalcount][2]);
+ sscanf( line, "vn %lf %lf %lf\n",
+ &normals[normalcount][0],
+ &normals[normalcount][1],
+ &normals[normalcount][2] );
/*
printf("read_normals(%d) %.2f %.2f %.2f %s", normalcount,
normals[normalcount][0], normals[normalcount][1],
/* dump vertices */
printf(" writing vertices\n");
for ( i = 1; i <= nodecount; i++ ) {
- fprintf(obj, "v %.2f %.2f %.2f\n",
+ fprintf(obj, "v %.6f %.6f %.6f\n",
nodes[i].x, nodes[i].y, nodes[i].z);
}
}
tmp_index = atoi(temp);
printf("%ld\n", tmp_index);
- parse_index(tmp_index, &my_index);
+ fgBucketParseIndex(tmp_index, &my_index);
printf("bucket = %d %d %d %d\n",
my_index.lon, my_index.lat, my_index.x, my_index.y);
/* generate the indexes of the neighbors */
- offset_bucket(&my_index, &ne_index, 1, 1);
- offset_bucket(&my_index, &nw_index, -1, 1);
- offset_bucket(&my_index, &se_index, 1, -1);
- offset_bucket(&my_index, &sw_index, -1, -1);
+ fgBucketOffset(&my_index, &ne_index, 1, 1);
+ fgBucketOffset(&my_index, &nw_index, -1, 1);
+ fgBucketOffset(&my_index, &se_index, 1, -1);
+ fgBucketOffset(&my_index, &sw_index, -1, -1);
- offset_bucket(&my_index, &north_index, 0, 1);
- offset_bucket(&my_index, &south_index, 0, -1);
- offset_bucket(&my_index, &east_index, 1, 0);
- offset_bucket(&my_index, &west_index, -1, 0);
+ fgBucketOffset(&my_index, &north_index, 0, 1);
+ fgBucketOffset(&my_index, &south_index, 0, -1);
+ fgBucketOffset(&my_index, &east_index, 1, 0);
+ fgBucketOffset(&my_index, &west_index, -1, 0);
/* load the input data files */
triload(basename, basepath);
/* $Log$
-/* Revision 1.8 1998/01/17 01:25:39 curt
-/* Added support for shared normals.
+/* Revision 1.17 1998/07/04 00:56:40 curt
+/* typedef'd struct fgBUCKET.
/*
+ * Revision 1.16 1998/05/23 15:20:41 curt
+ * Output more digits after the decimal place.
+ *
+ * Revision 1.15 1998/05/02 01:54:39 curt
+ * Converting to polar3d.h routines.
+ *
+ * Revision 1.14 1998/04/18 04:01:32 curt
+ * Now use libMath rather than having local copies of math routines.
+ *
+ * Revision 1.13 1998/04/14 02:26:11 curt
+ * Code reorganizations. Added a Lib/ directory for more general libraries.
+ *
+ * Revision 1.12 1998/04/08 23:22:18 curt
+ * Adopted Gnu automake/autoconf system.
+ *
+ * Revision 1.11 1998/03/03 16:01:00 curt
+ * More c++ compile tweaks.
+ *
+ * Revision 1.10 1998/01/31 00:41:27 curt
+ * Made a few changes converting floats to doubles.
+ *
+ * Revision 1.9 1998/01/27 18:37:04 curt
+ * Lots of updates to get back in sync with changes made over in .../Src/
+ *
+ * Revision 1.8 1998/01/17 01:25:39 curt
+ * Added support for shared normals.
+ *
* Revision 1.7 1998/01/12 02:42:00 curt
* Average up to five triangles per vertex instead of three.
*