help finding center to pan around

This topic is 4224 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi all, I'm trying to make the NeHe lesson #34 tutorial rotate around the center of the map and I got it to rotate (but it rotates off one of the corners of the map). I'm not sure how to center it. I thought just pointing the camera at the center would do it, but no matter what I try, I get a different angle of the view which doesn't rotate around the center smoothly. All I've really done was add the glRotate() and I can pan around it, but it rotates around the corner of the map. Any help much appreciated.
   public void display(GLAutoDrawable drawable) {
update();
GL gl = drawable.getGL();
this.glDrawable = drawable;

gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

glu.gluLookAt(212, 60, 194, 186, 55, 171, 0, 1, 0);

gl.glScalef(scaleValue, scaleValue, scaleValue);
gl.glRotatef(panValue, 0.0f, 1.0f, 0.0f);

renderHeightMap(gl, heightMap);
}

private void update() {
if (zoomIn) {
scaleValue += 0.01f;
}

if (zoomOut) {
scaleValue -= 0.01f;
}

if (panLeft) {
panValue += 1.0f;
}

if (panRight) {
panValue -= 1.0f;
}
}

[Edited by - lender on July 29, 2006 2:09:56 AM]

Share on other sites
what you can do is start with an eye vector instead and do a little math. gluLookAt will then convert it back.

gluLook at when called does this: L(ook Direction) = C(enter) - E(ye)
so this translates to C(enter) = L(ook) + E(ye)
so if you know L and E, you can compute C. C doesn't really mean center of the screen in pure terms sort to say...

Y-Go

Share on other sites
ha ha ha, nevermind cross what is said, i haven't eaten breakfast this morning yet. it is the center, and this is why i use my own version of gluLookAt that takes an L instead. check MESA source for code for gluLookAt and modify it if you are using a vector camera.

Y-Go

Share on other sites
Ok, is there any other way I can find the center of this map? No matter what I try, it's confusing to me. I think x, y, or z is one way, and it ends up another.