Hey all,
I’ve got rotation working w/ the up, down, pg_up, pg_down, right and left arrows. But now I’d like to get it working with the mouse cursor so that I can rotate my objects on screen. Can anyone help me out w/ how to do that. Below is the rotations I currently have in my display() method.
gl.glRotatef(xrot, 1.0f, 0.0f, 0.0f);
gl.glRotatef(yrot, 0.0f, 1.0f, 0.0f);
gl.glRotatef(zrot, 0.0f, 0.0f, 1.0f);
And here’s my keyPressed() method …
public void keyPressed(KeyEvent e) {
switch (e.getKeyCode()) {
case KeyEvent.VK_PAGE_UP:
zrot += 2.0f;
break;
case KeyEvent.VK_PAGE_DOWN:
zrot -= 2.0f;
break;
case KeyEvent.VK_UP:
xrot += 2.0f;
break;
case KeyEvent.VK_DOWN:
xrot -= 2.0f;
break;
case KeyEvent.VK_RIGHT:
yrot += 2.0f;
break;
case KeyEvent.VK_LEFT:
yrot -= 2.0f;
break;
}
this.gldrawable.display();
}
Also, anyone know what’s needed to make my objects zoom in and out?
Any help much appreciated.