1
0
Fork 0

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.
This commit is contained in:
curt 1998-07-08 14:47:20 +00:00
parent 0099b307bc
commit a0f58259dd
5 changed files with 97 additions and 16 deletions

View file

@ -172,8 +172,6 @@ int fgMATERIAL_MGR::load_lib ( void ) {
/* GL_LINEAR */ /* GL_LINEAR */
/* GL_NEAREST_MIPMAP_LINEAR */ /* GL_NEAREST_MIPMAP_LINEAR */
GL_LINEAR_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 */ /* load in the texture data */
tpath[0] = '\0'; tpath[0] = '\0';
@ -301,6 +299,12 @@ fgMATERIAL_MGR::~fgMATERIAL_MGR ( void ) {
// $Log$ // $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 // Revision 1.7 1998/07/04 00:54:28 curt
// Added automatic mipmap generation. // Added automatic mipmap generation.
// //

View file

@ -52,7 +52,7 @@ using namespace std;
#include <Main/options.hxx> #include <Main/options.hxx>
#include <Math/mat3.h> #include <Math/mat3.h>
#include <Math/fg_random.h> #include <Math/fg_random.h>
#include <Math/polar3d.h> #include <Math/polar3d.hxx>
#include "material.hxx" #include "material.hxx"
#include "obj.hxx" #include "obj.hxx"
@ -88,9 +88,9 @@ static void calc_normal(double p1[3], double p2[3],
// Calculate texture coordinates for a given point. // Calculate texture coordinates for a given point.
fgPolarPoint3d calc_tex_coords(double *node, fgCartesianPoint3d *ref) { fgPoint3d calc_tex_coords(double *node, fgPoint3d *ref) {
fgCartesianPoint3d cp; fgPoint3d cp;
fgPolarPoint3d pp; fgPoint3d pp;
cp.x = node[0] + ref->x; cp.x = node[0] + ref->x;
cp.y = node[1] + ref->y; cp.y = node[1] + ref->y;
@ -109,7 +109,7 @@ fgPolarPoint3d calc_tex_coords(double *node, fgCartesianPoint3d *ref) {
int fgObjLoad(char *path, fgTILE *tile) { int fgObjLoad(char *path, fgTILE *tile) {
fgOPTIONS *o; fgOPTIONS *o;
fgFRAGMENT fragment; fgFRAGMENT fragment;
fgPolarPoint3d pp; fgPoint3d pp;
char fgpath[256], line[256], material[256]; char fgpath[256], line[256], material[256];
double approx_normal[3], normal[3], scale; double approx_normal[3], normal[3], scale;
// double x, y, z, xmax, xmin, ymax, ymin, zmax, zmin; // double x, y, z, xmax, xmin, ymax, ymin, zmax, zmin;
@ -441,6 +441,12 @@ int fgObjLoad(char *path, fgTILE *tile) {
// $Log$ // $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 // Revision 1.16 1998/07/06 21:34:33 curt
// Added using namespace std for compilers that support this. // Added using namespace std for compilers that support this.
// //

View file

@ -42,10 +42,10 @@ struct fgSCENERY {
int terrain_skip; int terrain_skip;
/* center of current scenery chunk */ /* center of current scenery chunk */
fgCartesianPoint3d center; fgPoint3d center;
/* next center of current scenery chunk */ /* next center of current scenery chunk */
fgCartesianPoint3d next_center; fgPoint3d next_center;
/* angle of sun relative to current local horizontal */ /* angle of sun relative to current local horizontal */
double sun_angle; double sun_angle;
@ -71,9 +71,15 @@ void fgSceneryRender( void );
/* $Log$ /* $Log$
/* Revision 1.2 1998/05/02 01:52:16 curt /* Revision 1.3 1998/07/08 14:47:22 curt
/* Playing around with texture coordinates. /* 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 * Revision 1.1 1998/04/30 12:35:31 curt
* Added a command line rendering option specify smooth/flat shading. * Added a command line rendering option specify smooth/flat shading.
* *

View file

@ -60,7 +60,7 @@ class fgFRAGMENT {
public: public:
// culling data for this object fragment (fine grain culling) // culling data for this object fragment (fine grain culling)
fgCartesianPoint3d center; fgPoint3d center;
double bounding_radius; double bounding_radius;
// variable offset data for this object fragment for this frame // variable offset data for this object fragment for this frame
@ -96,9 +96,9 @@ class fgTILE {
public: public:
// culling data for whole tile (course grain culling) // culling data for whole tile (course grain culling)
fgCartesianPoint3d center; fgPoint3d center;
double bounding_radius; double bounding_radius;
fgCartesianPoint3d offset; fgPoint3d offset;
GLdouble model_view[16]; GLdouble model_view[16];
// this tile's official location in the world // this tile's official location in the world
@ -121,6 +121,12 @@ public:
// $Log$ // $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 // Revision 1.9 1998/07/06 21:34:34 curt
// Added using namespace std for compilers that support this. // Added using namespace std for compilers that support this.
// //

View file

@ -41,7 +41,10 @@
#include <Include/fg_types.h> #include <Include/fg_types.h>
#include <Main/options.hxx> #include <Main/options.hxx>
#include <Main/views.hxx> #include <Main/views.hxx>
#include <Math/fg_geodesy.h>
#include <Math/mat3.h> #include <Math/mat3.h>
#include <Math/polar3d.hxx>
#include <Math/vector.hxx>
#include "material.hxx" #include "material.hxx"
#include "obj.hxx" #include "obj.hxx"
@ -210,8 +213,24 @@ int fgTileMgrUpdate( void ) {
} }
// 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 // Calculate if point/radius is inside view frustum
static int viewable( fgCartesianPoint3d *cp, double radius ) { static int viewable( fgPoint3d *cp, double radius ) {
fgVIEW *v; fgVIEW *v;
MAT3hvec world, eye; MAT3hvec world, eye;
int viewable = 1; // start by assuming it's viewable int viewable = 1; // start by assuming it's viewable
@ -300,11 +319,12 @@ void fgTileMgrRender( void ) {
fgTILE *t; fgTILE *t;
fgVIEW *v; fgVIEW *v;
fgBUCKET p; fgBUCKET p;
fgCartesianPoint3d frag_offset; fgPoint3d frag_offset, fc, pp;
fgFRAGMENT *frag_ptr; fgFRAGMENT *frag_ptr;
fgMATERIAL *mtl_ptr; fgMATERIAL *mtl_ptr;
fgTILE *last_tile_ptr; fgTILE *last_tile_ptr;
GLdouble *m; GLdouble *m;
double dist, min_dist, lat_geod, alt, sea_level_r;
double x, y, z; double x, y, z;
list < fgFRAGMENT > :: iterator current; list < fgFRAGMENT > :: iterator current;
list < fgFRAGMENT > :: iterator last; list < fgFRAGMENT > :: iterator last;
@ -330,6 +350,7 @@ void fgTileMgrRender( void ) {
// initialize the transient per-material fragment lists // initialize the transient per-material fragment lists
material_mgr.init_transient_material_lists(); material_mgr.init_transient_material_lists();
min_dist = 100000.0;
// Pass 1 // Pass 1
// traverse the potentially viewable tile list // traverse the potentially viewable tile list
@ -354,6 +375,38 @@ void fgTileMgrRender( void ) {
m[14] = m[2] * x + m[6] * y + m[10] * z + m[14]; 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]; 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 // Course (tile based) culling
if ( viewable(&(t->offset), t->bounding_radius) ) { if ( viewable(&(t->offset), t->bounding_radius) ) {
// at least a portion of this tile could be viewable // at least a portion of this tile could be viewable
@ -478,6 +531,12 @@ void fgTileMgrRender( void ) {
// $Log$ // $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 // Revision 1.22 1998/07/04 00:54:31 curt
// Added automatic mipmap generation. // Added automatic mipmap generation.
// //