Testing/playing -- placed objects randomly across the entire terrain.
This commit is contained in:
parent
f612f210fc
commit
bf40d877a1
6 changed files with 81 additions and 31 deletions
|
@ -30,6 +30,8 @@
|
|||
|
||||
#include <GL/glut.h>
|
||||
|
||||
#include <stdlib.h> /* for random(), srandom() */
|
||||
|
||||
#include "../constants.h"
|
||||
#include "../Scenery/mesh.h"
|
||||
#include "../Scenery/scenery.h"
|
||||
|
@ -59,15 +61,23 @@ void mesh_make_test_object(double lon, double lat) {
|
|||
origin = fgRotateCartesianPoint(origin);
|
||||
printf("Center of structure is: (%.4f, %.4f\n", origin.y, origin.z);
|
||||
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glVertex3d(origin.y + b, origin.z-b, elev);
|
||||
glVertex3d(origin.y - b, origin.z-b, elev);
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex3d(origin.y - b, origin.z - b, elev);
|
||||
glVertex3d(origin.y + b, origin.z - b, elev);
|
||||
glVertex3d(origin.y, origin.z, elev+h);
|
||||
glVertex3d(origin.y - b, origin.z+b, elev);
|
||||
glVertex3d(origin.y + b, origin.z+b, elev);
|
||||
glVertex3d(origin.y + b, origin.z-b, elev);
|
||||
glEnd();
|
||||
|
||||
glVertex3d(origin.y + b, origin.z - b, elev);
|
||||
glVertex3d(origin.y + b, origin.z + b, elev);
|
||||
glVertex3d(origin.y, origin.z, elev+h);
|
||||
|
||||
glVertex3d(origin.y + b, origin.z + b, elev);
|
||||
glVertex3d(origin.y - b, origin.z + b, elev);
|
||||
glVertex3d(origin.y, origin.z, elev+h);
|
||||
|
||||
glVertex3d(origin.y - b, origin.z + b, elev);
|
||||
glVertex3d(origin.y - b, origin.z - b, elev);
|
||||
glVertex3d(origin.y, origin.z, elev+h);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
/* walk through mesh and make ogl calls */
|
||||
|
@ -166,7 +176,19 @@ GLint mesh2GL(struct mesh *m) {
|
|||
}
|
||||
|
||||
/* this will go, it's only here for testing/debugging */
|
||||
mesh_make_test_object(-398391.28, 120070.41);
|
||||
|
||||
/*
|
||||
for ( i = m->originy; i < m->originy + (m->row_step * iend); i += 120 ) {
|
||||
for ( j = m->originx; j < m->originx + (m->col_step * jend); j += 120) {
|
||||
mesh_make_test_object(j, i);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
for ( i = 0; i < 800; i++ ) {
|
||||
mesh_make_test_object(m->originx + (random() * 3600.0 / RAND_MAX) ,
|
||||
m->originy + (random() * 3600.0 / RAND_MAX) );
|
||||
}
|
||||
|
||||
glEndList();
|
||||
|
||||
|
@ -176,9 +198,12 @@ GLint mesh2GL(struct mesh *m) {
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.32 1997/07/12 03:50:21 curt
|
||||
/* Added an #include <Windows32/Base.h> to help compiling for Win32
|
||||
/* Revision 1.33 1997/07/14 16:26:04 curt
|
||||
/* Testing/playing -- placed objects randomly across the entire terrain.
|
||||
/*
|
||||
* Revision 1.32 1997/07/12 03:50:21 curt
|
||||
* Added an #include <Windows32/Base.h> to help compiling for Win32
|
||||
*
|
||||
* Revision 1.31 1997/07/12 02:27:07 curt
|
||||
* Looking at potential scenery transformation/coordinate system problems.
|
||||
*
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
common.o: common.c common.h
|
||||
geometry.o: geometry.c geometry.h mesh.h
|
||||
mesh.o: mesh.c scenery.h mesh.h common.h
|
||||
mesh.o: mesh.c ../constants.h scenery.h mesh.h common.h
|
||||
parser.o: parser.c parsevrml.h geometry.h common.h mesh.h scenery.h
|
||||
scanner.o: scanner.c parser.h
|
||||
scenery.o: scenery.c scenery.h parsevrml.h
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
|
||||
#include <GL/glut.h>
|
||||
|
||||
#include "../constants.h"
|
||||
#include "scenery.h"
|
||||
#include "mesh.h"
|
||||
#include "common.h"
|
||||
|
@ -196,7 +197,7 @@ double mesh_altitude(double lon, double lat) {
|
|||
|
||||
if ( dx > dy ) {
|
||||
/* lower triangle */
|
||||
/* printf(" Lower triangle\n"); */
|
||||
printf(" Lower triangle\n");
|
||||
|
||||
x1 = xindex;
|
||||
y1 = yindex;
|
||||
|
@ -210,20 +211,24 @@ double mesh_altitude(double lon, double lat) {
|
|||
y3 = yindex + skip;
|
||||
z3 = eg.mesh_data[y3 * eg.cols + x3];
|
||||
|
||||
/* printf(" dx = %.2f dy = %.2f\n", dx, dy);
|
||||
printf(" dx = %.2f dy = %.2f\n", dx, dy);
|
||||
printf(" (x1,y1,z1) = (%d,%d,%d)\n", x1, y1, z1);
|
||||
printf(" (x2,y2,z2) = (%d,%d,%d)\n", x2, y2, z2);
|
||||
printf(" (x3,y3,z3) = (%d,%d,%d)\n", x3, y3, z3); */
|
||||
printf(" (x3,y3,z3) = (%d,%d,%d)\n", x3, y3, z3);
|
||||
|
||||
zA = dx * (z2 - z1) / skip + z1;
|
||||
zB = dx * (z3 - z1) / skip + z1;
|
||||
|
||||
/* printf(" zA = %.2f zB = %.2f\n", zA, zB); */
|
||||
printf(" zA = %.2f zB = %.2f\n", zA, zB);
|
||||
|
||||
elev = dy * (zB - zA) / dx + zA;
|
||||
if ( dx > EPSILON ) {
|
||||
elev = dy * (zB - zA) / dx + zA;
|
||||
} else {
|
||||
elev = zA;
|
||||
}
|
||||
} else {
|
||||
/* upper triangle */
|
||||
/* printf(" Upper triangle\n"); */
|
||||
printf(" Upper triangle\n");
|
||||
|
||||
x1 = xindex;
|
||||
y1 = yindex;
|
||||
|
@ -237,18 +242,22 @@ double mesh_altitude(double lon, double lat) {
|
|||
y3 = yindex + skip;
|
||||
z3 = eg.mesh_data[y3 * eg.cols + x3];
|
||||
|
||||
/* printf(" dx = %.2f dy = %.2f\n", dx, dy);
|
||||
printf(" dx = %.2f dy = %.2f\n", dx, dy);
|
||||
printf(" (x1,y1,z1) = (%d,%d,%d)\n", x1, y1, z1);
|
||||
printf(" (x2,y2,z2) = (%d,%d,%d)\n", x2, y2, z2);
|
||||
printf(" (x3,y3,z3) = (%d,%d,%d)\n", x3, y3, z3); */
|
||||
printf(" (x3,y3,z3) = (%d,%d,%d)\n", x3, y3, z3);
|
||||
|
||||
zA = dy * (z2 - z1) / skip + z1;
|
||||
zB = dy * (z3 - z1) / skip + z1;
|
||||
|
||||
/* printf(" zA = %.2f zB = %.2f\n", zA, zB );
|
||||
printf(" xB - xA = %.2f\n", eg.col_step * dy / eg.row_step); */
|
||||
printf(" zA = %.2f zB = %.2f\n", zA, zB );
|
||||
printf(" xB - xA = %.2f\n", eg.col_step * dy / eg.row_step);
|
||||
|
||||
elev = dx * (zB - zA) / dy + zA;
|
||||
if ( dy > EPSILON ) {
|
||||
elev = dx * (zB - zA) / dy + zA;
|
||||
} else {
|
||||
elev = zA;
|
||||
}
|
||||
}
|
||||
|
||||
return(elev);
|
||||
|
@ -256,9 +265,12 @@ double mesh_altitude(double lon, double lat) {
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.14 1997/07/12 04:01:14 curt
|
||||
/* Added #include <Windows32/Base.h> to help Win32 compiling.
|
||||
/* Revision 1.15 1997/07/14 16:26:04 curt
|
||||
/* Testing/playing -- placed objects randomly across the entire terrain.
|
||||
/*
|
||||
* Revision 1.14 1997/07/12 04:01:14 curt
|
||||
* Added #include <Windows32/Base.h> to help Win32 compiling.
|
||||
*
|
||||
* Revision 1.13 1997/07/12 02:27:11 curt
|
||||
* Looking at potential scenery transformation/coordinate system problems.
|
||||
*
|
||||
|
|
|
@ -41,7 +41,7 @@ struct scenery_params cur_scenery_params;
|
|||
/* Initialize the Scenery Management system */
|
||||
void fgSceneryInit() {
|
||||
/* set the default terrain detail level */
|
||||
cur_scenery_params.terrain_skip = 4;
|
||||
cur_scenery_params.terrain_skip = 5;
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,10 +65,13 @@ void fgSceneryRender() {
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.5 1997/07/11 03:23:19 curt
|
||||
/* Solved some scenery display/orientation problems. Still have a positioning
|
||||
/* (or transformation?) problem.
|
||||
/* Revision 1.6 1997/07/14 16:26:05 curt
|
||||
/* Testing/playing -- placed objects randomly across the entire terrain.
|
||||
/*
|
||||
* Revision 1.5 1997/07/11 03:23:19 curt
|
||||
* Solved some scenery display/orientation problems. Still have a positioning
|
||||
* (or transformation?) problem.
|
||||
*
|
||||
* Revision 1.4 1997/07/11 01:30:03 curt
|
||||
* More tweaking of terrian floor.
|
||||
*
|
||||
|
|
|
@ -49,13 +49,20 @@
|
|||
#define METER_TO_FEET 3.28083989501312335958
|
||||
|
||||
|
||||
/* For divide by zero avoidance, this will be close enough to zero */
|
||||
#define EPSILON 0.000001
|
||||
|
||||
|
||||
#endif CONSTANTS_H
|
||||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.2 1997/07/08 18:20:11 curt
|
||||
/* Working on establishing a hard ground.
|
||||
/* Revision 1.3 1997/07/14 16:26:03 curt
|
||||
/* Testing/playing -- placed objects randomly across the entire terrain.
|
||||
/*
|
||||
* Revision 1.2 1997/07/08 18:20:11 curt
|
||||
* Working on establishing a hard ground.
|
||||
*
|
||||
* Revision 1.1 1997/07/07 21:02:36 curt
|
||||
* Initial revision.
|
||||
* */
|
||||
|
|
|
@ -58,11 +58,14 @@ clean:
|
|||
include depend
|
||||
|
||||
fg_timer.o:
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c fg_timer.c
|
||||
$(CC) $(CFLAGS) -c fg_timer.c
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# $Log$
|
||||
# Revision 1.8 1997/07/14 16:26:05 curt
|
||||
# Testing/playing -- placed objects randomly across the entire terrain.
|
||||
#
|
||||
# Revision 1.7 1997/07/12 02:24:48 curt
|
||||
# Added ranlib.
|
||||
#
|
||||
|
|
Loading…
Reference in a new issue