jme.controller
Class AbstractGameController

java.lang.Object
  extended byjme.controller.AbstractGameController
All Implemented Interfaces:
EntityController, KeyboardController, MouseController
Direct Known Subclasses:
BaseFPSController, BasicController, TrackingController

public abstract class AbstractGameController
extends java.lang.Object
implements KeyboardController, MouseController, EntityController

AbstractGameController defines common keyboard, mouse and camera behavior. It provides some convienience methods for handling mouse input, keyboard input and camera control as defined by KeyboardController, MouseController and EntityController.

Version:
$Id: AbstractGameController.java,v 1.3 2003/09/03 18:05:36 mojomonkey Exp $
Author:
Mark Powell

Field Summary
protected  Entity entity
           
 
Constructor Summary
AbstractGameController()
           
 
Method Summary
 int getAbsoluteMousePositionX()
          getAbsoluteMousePositionX retrieves the actual x position of the mouse cursor.
 int getAbsoluteMousePositionY()
          getAbsoluteMousePositionY retrieves the actual y position of the mouse cursor.
 Vector getEntityPosition()
          getEntityPosition returns the current location in three dimensional space of the Entity.
 int getMouseDeltaX()
          getMouseDeltaX returns the change in the X coordinate of the mouse since the previous frame.
 int getMouseDeltaY()
          getMouseDeltaY returns the change in the Y coordinate of the mouse since the previous frame.
 int getMousePositionX()
          getMousePositionX returns the x coordinate of the mouse within the application window.
 int getMousePositionY()
          getMousePositionY returns the y coordinate of the mouse within the application window.
 int getNumberOfButtons()
          getNumberOfButtons returns the number of buttons assigned to the mouse.
 boolean isButtonDown(int mouseButton)
          isButtonDown returns true if a specified button is currently pressed on the mouse, false if it is not.
 boolean isKeyDown(java.lang.Object keyCode)
          isKeyDown returns a boolean value if a key is pressed or not.
 int next()
          next returns the key code of the next key in the buffer.
 void pollKeyboard()
          pollKeyboard updates the state of the key variables to be either true or false depending on the current keyboard.
 void pollMouse()
          pollMouse updates the mouse position and the absolute mouse position.
abstract  void render()
          render sets the model view matrix to that defined by the Entity's position, view and up vectors.
 void setBuffered()
          setBuffered sets the keyboard to buffered mode.
 void setEntityPitch(float angle)
          setEntityPitch sets the pitch of the controlled entity.
 void setEntityPosition(Vector position)
          setEntityPosition sets the position of the Entity to the vector passed.
 void setEntityRoll(float angle)
          setEntityRoll sets the roll of the controlled entity.
 void setEntityYaw(float angle)
          setEntityYaw sets the yaw of the controlled entity.
 void setMousePosition(int x, int y)
          setMousePosition sets the x and y coordinate of the mouse within the cooridnates of the application window.
abstract  boolean update(float frameRate)
          update defines a method that should be called each round or frame.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entity

protected Entity entity
Constructor Detail

AbstractGameController

public AbstractGameController()
Method Detail

pollMouse

public void pollMouse()
pollMouse updates the mouse position and the absolute mouse position.

Specified by:
pollMouse in interface MouseController
See Also:
MouseController.pollMouse()

pollKeyboard

public void pollKeyboard()
Description copied from interface: KeyboardController
pollKeyboard updates the state of the key variables to be either true or false depending on the current keyboard.

Specified by:
pollKeyboard in interface KeyboardController
See Also:
KeyboardController.pollKeyboard()

isKeyDown

public boolean isKeyDown(java.lang.Object keyCode)
Description copied from interface: KeyboardController
isKeyDown returns a boolean value if a key is pressed or not. True is returned if the key is pressed, false otherwise.

Specified by:
isKeyDown in interface KeyboardController
Parameters:
keyCode - which key to check for. Implementations job to define how a keyCode is defined.
Returns:
true if the key is pressed, false if it is not.
See Also:
KeyboardController.isKeyDown(Object)

setBuffered

public void setBuffered()
Description copied from interface: KeyboardController
setBuffered sets the keyboard to buffered mode. All keyboard input will be placed in the buffer and can be retrieved one key press at a time using next.

Specified by:
setBuffered in interface KeyboardController
See Also:
KeyboardController.setBuffered()

next

public int next()
Description copied from interface: KeyboardController
next returns the key code of the next key in the buffer. To correctly use this, a call to setBuffered needs to be made.

Specified by:
next in interface KeyboardController
See Also:
KeyboardController.next()

getMousePositionX

public int getMousePositionX()
Description copied from interface: MouseController
getMousePositionX returns the x coordinate of the mouse within the application window. If the mouse moves out of the window, the position will set the correct coordinate to the window's extreme.

Specified by:
getMousePositionX in interface MouseController
Returns:
the regular x coordinate of the mouse.
See Also:
MouseController.getMousePositionX()

getMousePositionY

public int getMousePositionY()
Description copied from interface: MouseController
getMousePositionY returns the y coordinate of the mouse within the application window. If the mouse moves out of the window, the position will set the correct coordinate to the window's extreme.

Specified by:
getMousePositionY in interface MouseController
Returns:
the regular y coordinate of the mouse.
See Also:
MouseController.getMousePositionY()

getAbsoluteMousePositionX

public int getAbsoluteMousePositionX()
Description copied from interface: MouseController
getAbsoluteMousePositionX retrieves the actual x position of the mouse cursor.

Specified by:
getAbsoluteMousePositionX in interface MouseController
Returns:
the actual x position of the mouse cursor.
See Also:
MouseController.getAbsoluteMousePositionX()

getAbsoluteMousePositionY

public int getAbsoluteMousePositionY()
Description copied from interface: MouseController
getAbsoluteMousePositionY retrieves the actual y position of the mouse cursor.

Specified by:
getAbsoluteMousePositionY in interface MouseController
Returns:
the actual y position of the mouse cursor.
See Also:
MouseController.getAbsoluteMousePositionY()

getMouseDeltaX

public int getMouseDeltaX()
Description copied from interface: MouseController
getMouseDeltaX returns the change in the X coordinate of the mouse since the previous frame.

Specified by:
getMouseDeltaX in interface MouseController
Returns:
the change in X since the previous frame.
See Also:
MouseController.getMouseDeltaX()

getMouseDeltaY

public int getMouseDeltaY()
Description copied from interface: MouseController
getMouseDeltaY returns the change in the Y coordinate of the mouse since the previous frame.

Specified by:
getMouseDeltaY in interface MouseController
Returns:
the change in Y since the previous frame.
See Also:
MouseController.getMouseDeltaY()

setMousePosition

public void setMousePosition(int x,
                             int y)
Description copied from interface: MouseController
setMousePosition sets the x and y coordinate of the mouse within the cooridnates of the application window.

Specified by:
setMousePosition in interface MouseController
Parameters:
x - the new x coordinate.
y - the new y coordinate.
See Also:
MouseController.setMousePosition(int, int)

getNumberOfButtons

public int getNumberOfButtons()
Description copied from interface: MouseController
getNumberOfButtons returns the number of buttons assigned to the mouse.

Specified by:
getNumberOfButtons in interface MouseController
Returns:
the number of buttons the mouse has.

isButtonDown

public boolean isButtonDown(int mouseButton)
Description copied from interface: MouseController
isButtonDown returns true if a specified button is currently pressed on the mouse, false if it is not.

Specified by:
isButtonDown in interface MouseController
Parameters:
mouseButton - the button id to check.
Returns:
true if the button is pressed, false if it is not.
See Also:
MouseController.isButtonDown(int)

setEntityPosition

public void setEntityPosition(Vector position)
Description copied from interface: EntityController
setEntityPosition sets the position of the Entity to the vector passed.

Specified by:
setEntityPosition in interface EntityController
Parameters:
position - the new position of the Entity.
See Also:
EntityController.setEntityPosition(Vector)

setEntityYaw

public void setEntityYaw(float angle)
setEntityYaw sets the yaw of the controlled entity.

Specified by:
setEntityYaw in interface EntityController
Parameters:
angle - the yaw angle of the controlled entity.

setEntityRoll

public void setEntityRoll(float angle)
setEntityRoll sets the roll of the controlled entity.

Specified by:
setEntityRoll in interface EntityController
Parameters:
angle - the roll angle of the controlled entity.

setEntityPitch

public void setEntityPitch(float angle)
setEntityPitch sets the pitch of the controlled entity.

Specified by:
setEntityPitch in interface EntityController
Parameters:
angle - the pitch angle of the controlled entity.

getEntityPosition

public Vector getEntityPosition()
Description copied from interface: EntityController
getEntityPosition returns the current location in three dimensional space of the Entity.

Specified by:
getEntityPosition in interface EntityController
Returns:
the position of the Entity.
See Also:
EntityController.getEntityPosition()

render

public abstract void render()
Description copied from interface: EntityController
render sets the model view matrix to that defined by the Entity's position, view and up vectors.

Specified by:
render in interface EntityController
See Also:
EntityController.render()

update

public abstract boolean update(float frameRate)
update defines a method that should be called each round or frame. What occurs during this update is the responsiblity of the subclass. A typical implementation would be to poll all devices, process input, then update the state of the entity.

Parameters:
frameRate - denotes the current speed of the rendering, to allow for time based movements.