I’m still having a problem and so i decided to simplify my test case to the simplest form that I could think of and I’ve made a quick and dirty example.
I also posted this question on the OPENGL forums since JavaGaming was down…here is what I posted:
http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=240770&fpart=2
I’ve created a quick demo of my problem and you can run it from here:
[url=http://www.zaczek.com/jogl/TestRotations.jnlp]TestRotations.jnlp[/url]
I implemented some rudimentary keyboard and mouse rotations but nothing real so don’t be surprised if the rotations are not acting as you expect - just quick and dirty:
Mouse Inputs - use left mouse button to rotate around
Keyboard Inputs:
1 - Focus on “Earth” (Earth Size: 6000 unit radius)
2 - Focus on Teapot located at 0, 0, 0
3 - Focus on Teapot located at 1000, 1000, 1000
4 - Focus on Teapot located at 10000, 10000, 10000
5 - Focus on Teapot located at 30000, 30000, 30000
6 - Focus on Teapot located at 60000, 60000, 60000
7 - Focus on Teapot located at 100000, 100000, 100000
Q - Far Clipping Plane: 100
W - Far Clipping Plane: 1000
E - Far Clipping Plane: 10000
R - Far Clipping Plane: 100000
T - Far Clipping Plane: 1000000
Y - Far Clipping Plane: 10000000
U - Far Clipping Plane: 100000000
A - Near Clipping Plane: 5.0
S - Near Clipping Plane: 0.5
D - Near Clipping Plane: 0.05
F - Near Clipping Plane: 0.005
G - Near Clipping Plane: 0.0005
H - Near Clipping Plane: 0.00005
J - Near Clipping Plane: 0.000005
Note that when viewing at 10,000 away from the earth (key 4) changing the clipping plane distance has no effect on the jitter…I can have a small far to near clipping ratio and still have horrible jitter.
Here is my display() method…note, this code is in JOGL but it would be almost exactly the same in OPENGL:
public void display(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
if (reset) {
int width = getWidth();
int height = getHeight();
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
// Set the Field-of-View, Aspect Ratio, Near & Far clipping planes
glu.gluPerspective(65.0, (double) width / (double) height, nearPlane, farPlane);
gl.glMatrixMode(GL.GL_MODELVIEW);
reset = false;
}
// Clear Screen And Depth Buffer
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
// Reset/Clear matrix
gl.glLoadIdentity();
// Update light position
// 0 in the last component causes jagged terminator on planets, 1 results
// in a smooth terminator but the location of the sunlight is no longer
// correct...not sure why. Old code used a 0 (zero) very successfully,
// what changed?!
gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, lightPosition, 0);
gl.glPushMatrix();
double posX = Math.cos(rotY * Math.PI / 180.0) * radiusOffset;
double posY = Math.sin(rotY * Math.PI / 180.0) * radiusOffset;
double zX = Math.cos(rotX * Math.PI / 180.0) * radiusOffset;
double zY = Math.sin(rotX * Math.PI / 180.0) * radiusOffset;
double eyeX = systemX + posX;
double eyeY = systemY + posY;
double eyeZ = systemZ + zY;
glu.gluLookAt(eyeX, eyeY, eyeZ,
systemX, systemY, systemZ,
0, 1, 0);
System.out.println("Eye: " + eyeX + ", " + eyeY + ", " + eyeZ);
System.out.println("View: " + systemX + ", " + systemY + ", " + systemZ);
// Draw stars
displayStars(gl);
// Draw Teapot
gl.glPushMatrix();
gl.glEnable(GL.GL_LIGHTING);
gl.glEnable(GL.GL_COLOR_MATERIAL);
gl.glDisable(GL.GL_CULL_FACE);
gl.glTranslated(teapotX, teapotY, teapotZ);
GLUT glut = new GLUT();
gl.glColor3f(1f, 1f, 0f);
glut.glutSolidTeapot(0.01);
gl.glDisable(GL.GL_LIGHTING);
gl.glColor3f(1f, 1f, 1f);
glut.glutWireTeapot(0.0101);
gl.glScaled(0.02, 0.02, 0.02);
displayAxes(gl);
gl.glPopMatrix();
// Draw Earth
displayEarth(gl);
gl.glPopMatrix();
// Flush The GL Rendering Pipeline
gl.glFlush();
}
Here are the links to the source codes:
KeyHandler.java
MouseHandler.java
Renderer.java
ResourceRetriever.java
TestRotations.java
TextureReader.java
BitmapLoader.java
stars.jpg
earth.jpg
BTW, Icetigris, I hope I didn’t hijack your thread here and if so please let me know and I’ll move my crap out of here into a separate thread…I just realized that your question may not be answered yet, sorry.