Being stupid here, but I can’t figure this out.
I am working in JOGL, and the universe I am modelling is a unit cube, centered on the origin. I want to use the mouse to spin the cube about its centre, to view it from an angle. This is exactly he same as if the view is orbiting the cube at a constant radius.
My mouse handler accumulates x and y movements to build up an XRot and YRot value. Then in my display method I do:
gl.glRotated(gs.getXRotation(), 1.0f, 0.0f, 0.0f);
gl.glRotated(gs.getYRotation(), 0.0f, 1.0f, 0.0f);
gl.glRotated(gs.getZRotation(), 0.0f, 0.0f, 1.0f);
gl.glTranslated(axes.getXStart() - axes.getRange()/2, axes.getYStart() - axes.getRange()/2, axes.getZStart() - axes.getRange()/2);
gl.glScaled(axes.getRange(), axes.getRange(), axes.getRange());
(Z rotation is always 0, x/y/z start is 0, range is 1). Now the bottom corner of the cube rotates about the origin, but unfortunately the cube itself also rotates about the corner. So, I can see the cube from any angle, but it isn’t always in the centre of the screen.
Anyone know of a simple tutorial to get a cube to rotate about its own centre?