glapp
Class GLCamera

java.lang.Object
  extended by glapp.GLCamera

public class GLCamera
extends java.lang.Object

Camera class by Philipp Crocoll at CodeColony (codecolony.de). Ported from C++ to Java by mark napier (potatoland.org). Can move camera position forward/back, pan left/right, shift up/down, and rotate around X, Y, Z axes. Uses gluLookat() to orient scene to camera position. See Camera.render(). To use: renderScene() { GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); camera.Render(); // render scene ... } Requires GL_Vector to perform vector operations. jul13,2006: added move(x,y,z). added ctor(pos,dir,up).


Field Summary
 GL_Vector Position
           
 GL_Vector RightVector
           
 float RotatedX
           
 float RotatedY
           
 float RotatedZ
           
 GL_Vector UpVector
           
 GL_Vector ViewDir
           
 
Constructor Summary
GLCamera()
           
GLCamera(float posx, float posy, float posz, float dirx, float diry, float dirz, float upx, float upy, float upz)
           
 
Method Summary
 GL_Vector getViewDir()
          Return the current camera view direction
 void Move(float x, float y, float z)
          Move camera position in the given direction
 void Move(GL_Vector Direction)
          Move camera position in the given direction
 void MoveForward(float Distance)
           
 void MoveTo(float x, float y, float z)
          Move camera to the given xyz
 void MoveUpward(float Distance)
           
 void Render()
          Call GLU.gluLookAt() to set view position, direction and orientation.
 void RotateV(float Angle)
          Rotate the camera around the absolute vertical axis (0,1,0), NOT around the cameras Y axis.
 void RotateX(float Angle)
           
 void RotateY(float Angle)
           
 void RotateZ(float Angle)
           
 void setCamera(float targetX, float targetY, float targetZ, float distance)
          Set the camera to look at a target.
 void setCamera(float posx, float posy, float posz, float dirx, float diry, float dirz, float upx, float upy, float upz)
          Set the camera position, view direction and up vector.
 void StrafeRight(float Distance)
           
 void viewDir(GL_Vector direction)
          Move camera position in the given direction
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ViewDir

public GL_Vector ViewDir

RightVector

public GL_Vector RightVector

UpVector

public GL_Vector UpVector

Position

public GL_Vector Position

RotatedX

public float RotatedX

RotatedY

public float RotatedY

RotatedZ

public float RotatedZ
Constructor Detail

GLCamera

public GLCamera()

GLCamera

public GLCamera(float posx,
                float posy,
                float posz,
                float dirx,
                float diry,
                float dirz,
                float upx,
                float upy,
                float upz)
Method Detail

setCamera

public void setCamera(float posx,
                      float posy,
                      float posz,
                      float dirx,
                      float diry,
                      float dirz,
                      float upx,
                      float upy,
                      float upz)
Set the camera position, view direction and up vector. NOTE: direction is direction the camera is facing NOT a target position (as in gluLookAt()).

Parameters:
posx - Position of camera
posy -
posz -
dirx - Direction camera is facing
diry -
dirz -
upx - Up vector
upy -
upz -

setCamera

public void setCamera(float targetX,
                      float targetY,
                      float targetZ,
                      float distance)
Set the camera to look at a target. Positions the camera on the same X and Y as the target, at the Z value specified by the distance param, looking down the Z axis.

Parameters:
targetX - camera will face this XYZ
targetY -
targetZ -
distance - distance from target

viewDir

public void viewDir(GL_Vector direction)
Move camera position in the given direction


Move

public void Move(GL_Vector Direction)
Move camera position in the given direction


Move

public void Move(float x,
                 float y,
                 float z)
Move camera position in the given direction


MoveTo

public void MoveTo(float x,
                   float y,
                   float z)
Move camera to the given xyz


RotateX

public void RotateX(float Angle)

RotateY

public void RotateY(float Angle)

RotateZ

public void RotateZ(float Angle)

RotateV

public void RotateV(float Angle)
Rotate the camera around the absolute vertical axis (0,1,0), NOT around the cameras Y axis. This simulates a person looking up or down and rotating in place. You will rotate your body around the vertical axis, while your head remains tilted at the same angle.

Parameters:
Angle - the angle to rotate around the vertical axis in degrees

MoveForward

public void MoveForward(float Distance)

MoveUpward

public void MoveUpward(float Distance)

StrafeRight

public void StrafeRight(float Distance)

Render

public void Render()
Call GLU.gluLookAt() to set view position, direction and orientation. Be sure that the modelview matrix is current before calling Render() (glMatrixMode(GL_MODEL_VIEW)).


getViewDir

public GL_Vector getViewDir()
Return the current camera view direction