/* GL_LINEAR */
/* GL_NEAREST_MIPMAP_LINEAR */
GL_LINEAR_MIPMAP_LINEAR ) ;
- xglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ) ;
- xglHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ) ;
/* load in the texture data */
tpath[0] = '\0';
// $Log$
+// Revision 1.8 1998/07/08 14:47:20 curt
+// Fix GL_MODULATE vs. GL_DECAL problem introduced by splash screen.
+// polare3d.h renamed to polar3d.hxx
+// fg{Cartesian,Polar}Point3d consolodated.
+// Added some initial support for calculating local current ground elevation.
+//
// Revision 1.7 1998/07/04 00:54:28 curt
// Added automatic mipmap generation.
//
#include <Main/options.hxx>
#include <Math/mat3.h>
#include <Math/fg_random.h>
-#include <Math/polar3d.h>
+#include <Math/polar3d.hxx>
#include "material.hxx"
#include "obj.hxx"
// Calculate texture coordinates for a given point.
-fgPolarPoint3d calc_tex_coords(double *node, fgCartesianPoint3d *ref) {
- fgCartesianPoint3d cp;
- fgPolarPoint3d pp;
+fgPoint3d calc_tex_coords(double *node, fgPoint3d *ref) {
+ fgPoint3d cp;
+ fgPoint3d pp;
cp.x = node[0] + ref->x;
cp.y = node[1] + ref->y;
int fgObjLoad(char *path, fgTILE *tile) {
fgOPTIONS *o;
fgFRAGMENT fragment;
- fgPolarPoint3d pp;
+ fgPoint3d pp;
char fgpath[256], line[256], material[256];
double approx_normal[3], normal[3], scale;
// double x, y, z, xmax, xmin, ymax, ymin, zmax, zmin;
// $Log$
+// Revision 1.17 1998/07/08 14:47:21 curt
+// Fix GL_MODULATE vs. GL_DECAL problem introduced by splash screen.
+// polare3d.h renamed to polar3d.hxx
+// fg{Cartesian,Polar}Point3d consolodated.
+// Added some initial support for calculating local current ground elevation.
+//
// Revision 1.16 1998/07/06 21:34:33 curt
// Added using namespace std for compilers that support this.
//
int terrain_skip;
/* center of current scenery chunk */
- fgCartesianPoint3d center;
+ fgPoint3d center;
/* next center of current scenery chunk */
- fgCartesianPoint3d next_center;
+ fgPoint3d next_center;
/* angle of sun relative to current local horizontal */
double sun_angle;
/* $Log$
-/* Revision 1.2 1998/05/02 01:52:16 curt
-/* Playing around with texture coordinates.
+/* Revision 1.3 1998/07/08 14:47:22 curt
+/* Fix GL_MODULATE vs. GL_DECAL problem introduced by splash screen.
+/* polare3d.h renamed to polar3d.hxx
+/* fg{Cartesian,Polar}Point3d consolodated.
+/* Added some initial support for calculating local current ground elevation.
/*
+ * Revision 1.2 1998/05/02 01:52:16 curt
+ * Playing around with texture coordinates.
+ *
* Revision 1.1 1998/04/30 12:35:31 curt
* Added a command line rendering option specify smooth/flat shading.
*
public:
// culling data for this object fragment (fine grain culling)
- fgCartesianPoint3d center;
+ fgPoint3d center;
double bounding_radius;
// variable offset data for this object fragment for this frame
public:
// culling data for whole tile (course grain culling)
- fgCartesianPoint3d center;
+ fgPoint3d center;
double bounding_radius;
- fgCartesianPoint3d offset;
+ fgPoint3d offset;
GLdouble model_view[16];
// this tile's official location in the world
// $Log$
+// Revision 1.10 1998/07/08 14:47:22 curt
+// Fix GL_MODULATE vs. GL_DECAL problem introduced by splash screen.
+// polare3d.h renamed to polar3d.hxx
+// fg{Cartesian,Polar}Point3d consolodated.
+// Added some initial support for calculating local current ground elevation.
+//
// Revision 1.9 1998/07/06 21:34:34 curt
// Added using namespace std for compilers that support this.
//
#include <Include/fg_types.h>
#include <Main/options.hxx>
#include <Main/views.hxx>
+#include <Math/fg_geodesy.h>
#include <Math/mat3.h>
+#include <Math/polar3d.hxx>
+#include <Math/vector.hxx>
#include "material.hxx"
#include "obj.hxx"
}
+// Calculate shortest distance from point to line
+static double point_line_dist( fgPoint3d *tc, fgPoint3d *vp, MAT3vec d) {
+ MAT3vec p, p0;
+ double dist;
+
+ p[0] = tc->x; p[1] = tc->y; p[2] = tc->z;
+ p0[0] = vp->x; p0[1] = vp->y; p0[2] = vp->z;
+
+ dist = fgPointLine(p, p0, d);
+
+ // printf("dist = %.2f\n", dist);
+
+ return(dist);
+}
+
+
// Calculate if point/radius is inside view frustum
-static int viewable( fgCartesianPoint3d *cp, double radius ) {
+static int viewable( fgPoint3d *cp, double radius ) {
fgVIEW *v;
MAT3hvec world, eye;
int viewable = 1; // start by assuming it's viewable
fgTILE *t;
fgVIEW *v;
fgBUCKET p;
- fgCartesianPoint3d frag_offset;
+ fgPoint3d frag_offset, fc, pp;
fgFRAGMENT *frag_ptr;
fgMATERIAL *mtl_ptr;
fgTILE *last_tile_ptr;
GLdouble *m;
+ double dist, min_dist, lat_geod, alt, sea_level_r;
double x, y, z;
list < fgFRAGMENT > :: iterator current;
list < fgFRAGMENT > :: iterator last;
// initialize the transient per-material fragment lists
material_mgr.init_transient_material_lists();
+ min_dist = 100000.0;
// Pass 1
// traverse the potentially viewable tile list
m[14] = m[2] * x + m[6] * y + m[10] * z + m[14];
m[15] = m[3] * x + m[7] * y + m[11] * z + m[15];
+ // temp ... calc current terrain elevation
+ // calculate distance from vertical tangent line at
+ // current position to center of tile.
+ dist = point_line_dist(&(t->offset), &(v->view_pos), v->local_up);
+ if ( dist < t->bounding_radius ) {
+
+ // traverse fragment list for tile
+ current = t->fragment_list.begin();
+ last = t->fragment_list.end();
+
+ while ( current != last ) {
+ frag_ptr = &(*current);
+ current++;
+ dist = point_line_dist( &(frag_ptr->center), &(v->view_pos),
+ v->local_up);
+ if ( dist <= frag_ptr->bounding_radius ) {
+ if ( dist < min_dist ) {
+ min_dist = dist;
+ // compute geocentric coordinates of tile center
+ pp = fgCartToPolar3d(frag_ptr->center);
+ // convert to geodetic coordinates
+ fgGeocToGeod(pp.lat, pp.radius, &lat_geod,
+ &alt, &sea_level_r);
+ }
+ }
+ }
+
+ if ( min_dist <= t->bounding_radius ) {
+ printf("min_dist = %.2f alt = %.2f\n", min_dist, alt);
+ }
+ }
+
// Course (tile based) culling
if ( viewable(&(t->offset), t->bounding_radius) ) {
// at least a portion of this tile could be viewable
// $Log$
+// Revision 1.23 1998/07/08 14:47:23 curt
+// Fix GL_MODULATE vs. GL_DECAL problem introduced by splash screen.
+// polare3d.h renamed to polar3d.hxx
+// fg{Cartesian,Polar}Point3d consolodated.
+// Added some initial support for calculating local current ground elevation.
+//
// Revision 1.22 1998/07/04 00:54:31 curt
// Added automatic mipmap generation.
//