Switched back to per vertex normals and smooth shading for terrain.
This commit is contained in:
parent
feabb5024a
commit
09b8076bca
3 changed files with 74 additions and 77 deletions
|
@ -104,7 +104,7 @@ static void fgInitVisuals() {
|
||||||
/* xglFogf (GL_FOG_START, 1.0); */
|
/* xglFogf (GL_FOG_START, 1.0); */
|
||||||
xglFogf (GL_FOG_END, w->visibility);
|
xglFogf (GL_FOG_END, w->visibility);
|
||||||
/* xglFogf (GL_FOG_DENSITY, w->visibility); */
|
/* xglFogf (GL_FOG_DENSITY, w->visibility); */
|
||||||
/* xglHint (GL_FOG_HINT, GL_FASTEST); */
|
xglHint (GL_FOG_HINT, GL_NICEST /* GL_FASTEST */ );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ static void fgUpdateViewParams() {
|
||||||
x_10 = x_8 * x_2;
|
x_10 = x_8 * x_2;
|
||||||
|
|
||||||
light = pow(1.1, -x_10 / 30.0);
|
light = pow(1.1, -x_10 / 30.0);
|
||||||
ambient = 0.3 * light;
|
ambient = 0.2 * light;
|
||||||
diffuse = 0.9 * light;
|
diffuse = 0.9 * light;
|
||||||
|
|
||||||
sky_brightness = 0.85 * pow(1.2, -x_8 / 20.0) + 0.15;
|
sky_brightness = 0.85 * pow(1.2, -x_8 / 20.0) + 0.15;
|
||||||
|
@ -281,7 +281,7 @@ static void fgRenderFrame( void ) {
|
||||||
xglPopMatrix();
|
xglPopMatrix();
|
||||||
|
|
||||||
/* draw scenery */
|
/* draw scenery */
|
||||||
xglShadeModel( GL_FLAT );
|
xglShadeModel( GL_SMOOTH );
|
||||||
xglEnable( GL_DEPTH_TEST );
|
xglEnable( GL_DEPTH_TEST );
|
||||||
xglEnable( GL_FOG );
|
xglEnable( GL_FOG );
|
||||||
xglFogfv (GL_FOG_COLOR, l->fog_color);
|
xglFogfv (GL_FOG_COLOR, l->fog_color);
|
||||||
|
@ -623,9 +623,12 @@ int main( int argc, char *argv[] ) {
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.39 1997/12/22 23:45:45 curt
|
/* Revision 1.40 1997/12/30 01:38:37 curt
|
||||||
/* First stab at sunset/sunrise sky glow effects.
|
/* Switched back to per vertex normals and smooth shading for terrain.
|
||||||
/*
|
/*
|
||||||
|
* Revision 1.39 1997/12/22 23:45:45 curt
|
||||||
|
* First stab at sunset/sunrise sky glow effects.
|
||||||
|
*
|
||||||
* Revision 1.38 1997/12/22 04:14:28 curt
|
* Revision 1.38 1997/12/22 04:14:28 curt
|
||||||
* Aligned sky with sun so dusk/dawn effects can be correct relative to the sun.
|
* Aligned sky with sun so dusk/dawn effects can be correct relative to the sun.
|
||||||
*
|
*
|
||||||
|
|
125
Scenery/obj.c
125
Scenery/obj.c
|
@ -70,6 +70,7 @@ GLint fgObjLoad(char *path) {
|
||||||
GLint area;
|
GLint area;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int first, ncount, vncount, n1, n2, n3, n4;
|
int first, ncount, vncount, n1, n2, n3, n4;
|
||||||
|
static int use_vertex_norms = 1;
|
||||||
int i, winding;
|
int i, winding;
|
||||||
int last1, last2, odd;
|
int last1, last2, odd;
|
||||||
|
|
||||||
|
@ -150,30 +151,6 @@ GLint fgObjLoad(char *path) {
|
||||||
|
|
||||||
/* printf("(t) = "); */
|
/* printf("(t) = "); */
|
||||||
|
|
||||||
/* try to get the proper rotation by calculating an
|
|
||||||
* approximate normal and seeing if it is close to the
|
|
||||||
* precalculated normal */
|
|
||||||
/* v1[0] = nodes[n2][0] - nodes[n1][0];
|
|
||||||
v1[1] = nodes[n2][1] - nodes[n1][1];
|
|
||||||
v1[2] = nodes[n2][2] - nodes[n1][2];
|
|
||||||
v2[0] = nodes[n3][0] - nodes[n1][0];
|
|
||||||
v2[1] = nodes[n3][1] - nodes[n1][1];
|
|
||||||
v2[2] = nodes[n3][2] - nodes[n1][2];
|
|
||||||
MAT3cross_product(approx_normal, v1, v2);
|
|
||||||
MAT3_NORMALIZE_VEC(approx_normal,temp);
|
|
||||||
printf("Approx normal = %.2f %.2f %.2f\n", approx_normal[0],
|
|
||||||
approx_normal[1], approx_normal[2]);
|
|
||||||
dot_prod = MAT3_DOT_PRODUCT(normals[n1], approx_normal);
|
|
||||||
printf("Dot product = %.4f\n", dot_prod); */
|
|
||||||
/* angle = acos(dot_prod); */
|
|
||||||
/* printf("Normal ANGLE = %.3f rads.\n", angle); */
|
|
||||||
|
|
||||||
/* if ( dot_prod < -0.5 ) {
|
|
||||||
xglFrontFace( GL_CW );
|
|
||||||
} else {
|
|
||||||
xglFrontFace( GL_CCW );
|
|
||||||
} */
|
|
||||||
|
|
||||||
xglBegin(GL_TRIANGLE_STRIP);
|
xglBegin(GL_TRIANGLE_STRIP);
|
||||||
|
|
||||||
if ( winding ) {
|
if ( winding ) {
|
||||||
|
@ -182,41 +159,45 @@ GLint fgObjLoad(char *path) {
|
||||||
odd = 0;
|
odd = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( odd ) {
|
if ( use_vertex_norms ) {
|
||||||
calc_normal(nodes[n1], nodes[n2], nodes[n3], approx_normal);
|
xglNormal3d(normals[n1][0], normals[n1][1], normals[n1][2]);
|
||||||
|
xglVertex3d(nodes[n1][0] - ref.x, nodes[n1][1] - ref.y,
|
||||||
|
nodes[n1][2] - ref.z);
|
||||||
|
|
||||||
|
xglNormal3d(normals[n2][0], normals[n2][1], normals[n2][2]);
|
||||||
|
xglVertex3d(nodes[n2][0] - ref.x, nodes[n2][1] - ref.y,
|
||||||
|
nodes[n2][2] - ref.z);
|
||||||
|
|
||||||
|
xglNormal3d(normals[n3][0], normals[n3][1], normals[n3][2]);
|
||||||
|
xglVertex3d(nodes[n3][0] - ref.x, nodes[n3][1] - ref.y,
|
||||||
|
nodes[n3][2] - ref.z);
|
||||||
} else {
|
} else {
|
||||||
calc_normal(nodes[n2], nodes[n1], nodes[n3], approx_normal);
|
if ( odd ) {
|
||||||
|
calc_normal(nodes[n1], nodes[n2], nodes[n3], approx_normal);
|
||||||
|
} else {
|
||||||
|
calc_normal(nodes[n2], nodes[n1], nodes[n3], approx_normal);
|
||||||
|
}
|
||||||
|
xglNormal3dv(approx_normal);
|
||||||
|
|
||||||
|
xglVertex3d(nodes[n1][0] - ref.x, nodes[n1][1] - ref.y,
|
||||||
|
nodes[n1][2] - ref.z);
|
||||||
|
xglVertex3d(nodes[n2][0] - ref.x, nodes[n2][1] - ref.y,
|
||||||
|
nodes[n2][2] - ref.z);
|
||||||
|
xglVertex3d(nodes[n3][0] - ref.x, nodes[n3][1] - ref.y,
|
||||||
|
nodes[n3][2] - ref.z);
|
||||||
}
|
}
|
||||||
xglNormal3dv(approx_normal);
|
|
||||||
|
|
||||||
/* xglNormal3d(normals[n1][0], normals[n1][1], normals[n1][2]); */
|
|
||||||
xglVertex3d(nodes[n1][0] - ref.x, nodes[n1][1] - ref.y,
|
|
||||||
nodes[n1][2] - ref.z);
|
|
||||||
|
|
||||||
/* xglNormal3d(normals[n2][0], normals[n2][1], normals[n2][2]); */
|
|
||||||
xglVertex3d(nodes[n2][0] - ref.x, nodes[n2][1] - ref.y,
|
|
||||||
nodes[n2][2] - ref.z);
|
|
||||||
|
|
||||||
/* xglNormal3d(normals[n3][0], normals[n3][1], normals[n3][2]); */
|
|
||||||
xglVertex3d(nodes[n3][0] - ref.x, nodes[n3][1] - ref.y,
|
|
||||||
nodes[n3][2] - ref.z);
|
|
||||||
|
|
||||||
odd = 1 - odd;
|
odd = 1 - odd;
|
||||||
last1 = n2;
|
last1 = n2;
|
||||||
last2 = n3;
|
last2 = n3;
|
||||||
|
|
||||||
if ( n4 > 0 ) {
|
if ( n4 > 0 ) {
|
||||||
if ( odd ) {
|
if ( use_vertex_norms ) {
|
||||||
calc_normal(nodes[last1], nodes[last2], nodes[n4],
|
xglNormal3d(normals[n4][0], normals[n4][1], normals[n4][2]);
|
||||||
approx_normal);
|
|
||||||
} else {
|
} else {
|
||||||
calc_normal(nodes[last2], nodes[last1], nodes[n4],
|
calc_normal(nodes[n3], nodes[n2], nodes[n4], approx_normal);
|
||||||
approx_normal);
|
xglNormal3dv(approx_normal);
|
||||||
}
|
}
|
||||||
calc_normal(nodes[n3], nodes[n2], nodes[n4], approx_normal);
|
|
||||||
xglNormal3dv(approx_normal);
|
|
||||||
|
|
||||||
/*xglNormal3d(normals[n4][0], normals[n4][1], normals[n4][2]);*/
|
|
||||||
xglVertex3d(nodes[n4][0] - ref.x, nodes[n4][1] - ref.y,
|
xglVertex3d(nodes[n4][0] - ref.x, nodes[n4][1] - ref.y,
|
||||||
nodes[n4][2] - ref.z);
|
nodes[n4][2] - ref.z);
|
||||||
|
|
||||||
|
@ -258,16 +239,19 @@ GLint fgObjLoad(char *path) {
|
||||||
sscanf(line, "q %d %d\n", &n1, &n2);
|
sscanf(line, "q %d %d\n", &n1, &n2);
|
||||||
/* printf("read %d %d\n", n1, n2); */
|
/* printf("read %d %d\n", n1, n2); */
|
||||||
|
|
||||||
if ( odd ) {
|
if ( use_vertex_norms ) {
|
||||||
calc_normal(nodes[last1], nodes[last2], nodes[n1],
|
xglNormal3d(normals[n1][0], normals[n1][1], normals[n1][2]);
|
||||||
approx_normal);
|
|
||||||
} else {
|
} else {
|
||||||
calc_normal(nodes[last2], nodes[last1], nodes[n1],
|
if ( odd ) {
|
||||||
approx_normal);
|
calc_normal(nodes[last1], nodes[last2], nodes[n1],
|
||||||
|
approx_normal);
|
||||||
|
} else {
|
||||||
|
calc_normal(nodes[last2], nodes[last1], nodes[n1],
|
||||||
|
approx_normal);
|
||||||
|
}
|
||||||
|
xglNormal3dv(approx_normal);
|
||||||
}
|
}
|
||||||
xglNormal3dv(approx_normal);
|
|
||||||
|
|
||||||
/* xglNormal3d(normals[n1][0], normals[n1][1], normals[n1][2]); */
|
|
||||||
xglVertex3d(nodes[n1][0] - ref.x, nodes[n1][1] - ref.y,
|
xglVertex3d(nodes[n1][0] - ref.x, nodes[n1][1] - ref.y,
|
||||||
nodes[n1][2] - ref.z);
|
nodes[n1][2] - ref.z);
|
||||||
|
|
||||||
|
@ -277,16 +261,20 @@ GLint fgObjLoad(char *path) {
|
||||||
|
|
||||||
if ( n2 > 0 ) {
|
if ( n2 > 0 ) {
|
||||||
/* printf(" (cont)\n"); */
|
/* printf(" (cont)\n"); */
|
||||||
if ( odd ) {
|
|
||||||
calc_normal(nodes[last1], nodes[last2], nodes[n2],
|
|
||||||
approx_normal);
|
|
||||||
} else {
|
|
||||||
calc_normal(nodes[last2], nodes[last1], nodes[n2],
|
|
||||||
approx_normal);
|
|
||||||
}
|
|
||||||
xglNormal3dv(approx_normal);
|
|
||||||
|
|
||||||
/*xglNormal3d(normals[n2][0], normals[n2][1], normals[n2][2]);*/
|
if ( use_vertex_norms ) {
|
||||||
|
xglNormal3d(normals[n2][0], normals[n2][1], normals[n2][2]);
|
||||||
|
} else {
|
||||||
|
if ( odd ) {
|
||||||
|
calc_normal(nodes[last1], nodes[last2], nodes[n2],
|
||||||
|
approx_normal);
|
||||||
|
} else {
|
||||||
|
calc_normal(nodes[last2], nodes[last1], nodes[n2],
|
||||||
|
approx_normal);
|
||||||
|
}
|
||||||
|
xglNormal3dv(approx_normal);
|
||||||
|
}
|
||||||
|
|
||||||
xglVertex3d(nodes[n2][0] - ref.x, nodes[n2][1] - ref.y,
|
xglVertex3d(nodes[n2][0] - ref.x, nodes[n2][1] - ref.y,
|
||||||
nodes[n2][2] - ref.z);
|
nodes[n2][2] - ref.z);
|
||||||
|
|
||||||
|
@ -327,9 +315,12 @@ GLint fgObjLoad(char *path) {
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.13 1997/12/18 23:32:36 curt
|
/* Revision 1.14 1997/12/30 01:38:46 curt
|
||||||
/* First stab at sky dome actually starting to look reasonable. :-)
|
/* Switched back to per vertex normals and smooth shading for terrain.
|
||||||
/*
|
/*
|
||||||
|
* Revision 1.13 1997/12/18 23:32:36 curt
|
||||||
|
* First stab at sky dome actually starting to look reasonable. :-)
|
||||||
|
*
|
||||||
* Revision 1.12 1997/12/17 23:13:47 curt
|
* Revision 1.12 1997/12/17 23:13:47 curt
|
||||||
* Began working on rendering the sky.
|
* Began working on rendering the sky.
|
||||||
*
|
*
|
||||||
|
|
|
@ -232,8 +232,8 @@ void fgTimeUpdate(struct fgFLIGHT *f, struct fgTIME *t) {
|
||||||
|
|
||||||
/* get current Unix calendar time (in seconds) */
|
/* get current Unix calendar time (in seconds) */
|
||||||
/* warp = 60; */
|
/* warp = 60; */
|
||||||
warp += 100;
|
warp += 0;
|
||||||
t->cur_time = time(NULL) + (-3.5) * 60 * 60;
|
t->cur_time = time(NULL) + (0) * 60 * 60;
|
||||||
t->cur_time += warp;
|
t->cur_time += warp;
|
||||||
printf("Current Unix calendar time = %ld warp = %ld\n", t->cur_time, warp);
|
printf("Current Unix calendar time = %ld warp = %ld\n", t->cur_time, warp);
|
||||||
|
|
||||||
|
@ -285,10 +285,13 @@ void fgTimeUpdate(struct fgFLIGHT *f, struct fgTIME *t) {
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.21 1997/12/23 04:58:39 curt
|
/* Revision 1.22 1997/12/30 01:38:47 curt
|
||||||
/* Tweaked the sky coloring a bit to build in structures to allow finer rgb
|
/* Switched back to per vertex normals and smooth shading for terrain.
|
||||||
/* control.
|
|
||||||
/*
|
/*
|
||||||
|
* Revision 1.21 1997/12/23 04:58:39 curt
|
||||||
|
* Tweaked the sky coloring a bit to build in structures to allow finer rgb
|
||||||
|
* control.
|
||||||
|
*
|
||||||
* Revision 1.20 1997/12/15 23:55:06 curt
|
* Revision 1.20 1997/12/15 23:55:06 curt
|
||||||
* Add xgl wrappers for debugging.
|
* Add xgl wrappers for debugging.
|
||||||
* Generate terrain normals on the fly.
|
* Generate terrain normals on the fly.
|
||||||
|
|
Loading…
Reference in a new issue