net.letskit.redbook.first
Class movelight

java.lang.Object
  extended by net.letskit.redbook.glskeleton
      extended by net.letskit.redbook.first.movelight
All Implemented Interfaces:
java.awt.event.KeyListener, java.awt.event.MouseListener, java.util.EventListener, javax.media.opengl.GLEventListener

public class movelight
extends glskeleton
implements javax.media.opengl.GLEventListener, java.awt.event.KeyListener, java.awt.event.MouseListener

This program demonstrates when to issue lighting and transformation commands to render a model with a light which is moved by a modeling transformation (rotate or translate). The light position is reset after the modeling transformation is called. The eye position does not change.

A sphere is drawn using a grey material characteristic. A single light source illuminates the object.

Interaction: pressing the left or middle mouse button alters the modeling transformation (x rotation) by 30 degrees. The scene is then redrawn with the light in a new position.

Author:
Kiet Le (Java port)

Constructor Summary
movelight()
           
 
Method Summary
 void display(javax.media.opengl.GLAutoDrawable drawable)
           
 void displayChanged(javax.media.opengl.GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged)
           
 void init(javax.media.opengl.GLAutoDrawable drawable)
           
 void keyPressed(java.awt.event.KeyEvent key)
           
 void keyReleased(java.awt.event.KeyEvent key)
           
 void keyTyped(java.awt.event.KeyEvent key)
           
static void main(java.lang.String[] args)
           
 void mouseClicked(java.awt.event.MouseEvent mouse)
           
 void mouseEntered(java.awt.event.MouseEvent mouse)
           
 void mouseExited(java.awt.event.MouseEvent mouse)
           
 void mousePressed(java.awt.event.MouseEvent mouse)
           
 void mouseReleased(java.awt.event.MouseEvent mouse)
           
 void reshape(javax.media.opengl.GLAutoDrawable drawable, int x, int y, int w, int h)
           
 
Methods inherited from class net.letskit.redbook.glskeleton
animate, pause, refresh, runExit, setCanvas, setCanvas, setDefaultAnimator, setDefaultListeners
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

movelight

public movelight()
Method Detail

main

public static void main(java.lang.String[] args)

init

public void init(javax.media.opengl.GLAutoDrawable drawable)
Specified by:
init in interface javax.media.opengl.GLEventListener

display

public void display(javax.media.opengl.GLAutoDrawable drawable)
Specified by:
display in interface javax.media.opengl.GLEventListener

reshape

public void reshape(javax.media.opengl.GLAutoDrawable drawable,
                    int x,
                    int y,
                    int w,
                    int h)
Specified by:
reshape in interface javax.media.opengl.GLEventListener

displayChanged

public void displayChanged(javax.media.opengl.GLAutoDrawable drawable,
                           boolean modeChanged,
                           boolean deviceChanged)
Specified by:
displayChanged in interface javax.media.opengl.GLEventListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent key)
Specified by:
keyTyped in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent key)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent key)
Specified by:
keyReleased in interface java.awt.event.KeyListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent mouse)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent mouse)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent mouse)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent mouse)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent mouse)
Specified by:
mouseExited in interface java.awt.event.MouseListener