I have been able to get the demos to work. Now I am trying to draw some contour lines and I can not see them. The center is at 1407.4397, 1248.7677
lowest elevation is 650.0 highest elevation is 1100.0
min X=740.291432, Y=842.416942
max X=2074.58807, Y=1655.118549
So I am trying to look at the site from the center pointing down at the site (xy plane on the screen).
I am creating the contour lines in a display list using the "natural" coordinates within the bounds above.
GL11.glNewList(1, GL11.GL_COMPILE);
GL11.glLineWidth(1.0f);
for (SiteElement contour: contourLines) {
GL11.glBegin(GL11.GL_LINE_LOOP);
GL11.glColor3f(1.0f, 1.0f, 1.0f);
for (Point p: contourLine.getPointList()) {
GL11.glVertex3d(p.getX().doubleValue(),
p.getY().doubleValue(),
p.getZ().doubleValue());
}
GL11.glEnd();
} // end for each contour line
GL11.glEndList();
This is how I setup the display (x, y, and z are the current desired viewpoint and are initialized
to the center, highest elevation):
private void viewWholeSurface(boolean initialize)
{
/*
The following is from a posting by Dave Shreiner on setting up a basic viewing
system:
First, compute a bounding sphere for all objects in your scene.
This should provide you with two bits of information: the center of the
sphere (let ( c.x, c.y, c.z ) be that point) and its diameter (call it "diam").
Next, choose a value for the zNear clipping plane. General guidelines
are to choose something larger than, but close to 1.0. So, let's say you set
*/
Point min = contour.getMinMax()[0].clone(),
max = contour.getMinMax()[1].clone();
float diam = (float) maxZ.subtract(minZ)
.max(max.getX().subtract(min.getX()))
.max(max.getY().subtract(min.getY()))
.doubleValue();
if (initialize)
{
/*
Structure your matrix calls in this order (for an Orthographic projection):
*/
float zNear = 1.0f,
zFar = zNear + diam;
/*
This approach should center your objects in the middle of the window
and stretch them to fit (i.e., its assuming that you're using a window
with aspect ratio = 1.0). If your window isn't square, compute left, right,
bottom, and top, as above, and put in the following logic
before the call to glOrtho():
*/
double aspect = 1.0;
if (mode.getWidth() != mode.getHeight())
{
aspect = (double) mode.getWidth() / (double) mode.getHeight();
}
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GLU.gluPerspective(45f, (float)aspect, zNear, zFar);
}
/*
The above code should position the objects in your scene appropriately.
If you intend to manipulate (i.e. rotate, etc.), you need to add a viewing
transform to it.
A typical viewing transform will go on the ModelView matrix and might look
like this:
*/
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
GL11.glViewport(0, 0, mode.getWidth(), mode.getHeight());
GL11.glShadeModel(GL11.GL_FLAT);
GLU.gluLookAt (x, y, z, x, y, 0f, 0f, 1f, 0f);
}
I setup the display by:
Display.setDisplayMode(mode);
Display.setTitle("CityView");
Display.create();
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
GL11.glClearDepth(1.0);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glDepthFunc(GL11.GL_LEQUAL);
viewWholeSurface(true);
To draw the contour lines, in the rendering loop, I:
viewWholeSurface(false);
GL11.glColor3f(1.0f, 1.0f, 1.0f);
GL11.glCallList(1);
So what am I doing wrong?