unc.cdva.renderingengine
Class GraphicsManager

java.lang.Object
  extended by unc.cdva.renderingengine.GraphicsManager
All Implemented Interfaces:
java.util.EventListener, GraphicsEventListener

public class GraphicsManager
extends java.lang.Object
implements GraphicsEventListener

Object that manage the graphics elements of the game. Basically it keeps a copy of every kind of 3D objects that will need during the game. Then when a new object has to be displayed, it clones that first copy of the object to speed up the process and decrease the memory usage All the objects are loaded by parsing an xml files that contains all their properties. This manager is implemented as a singleton.

Author:
Guillaume Conte

Field Summary
static GraphicsManager singleton
          Singleton
 
Method Summary
 void addGun(GraphicsEvent event, Id itemId)
          Invoked when a new gun is added
 void addProblem(GraphicsEvent event, Id problemId, Object3D object)
          Invoked when a new problem is added
 void addProjectile(GraphicsEvent event, Id itemId)
          Invoked when a projectile is added
 void addReticle(GraphicsEvent event, Id problemId)
          Invoked when a new reticle is added
 void addTarget(GraphicsEvent event, Id itemId)
          Invoked when a target is added
 DisplayList getDisplayList()
           
 AnimatedObject getGun(Id id)
          Get a gun object from the gun list according to its id
static GraphicsManager getInstance(boolean useShader, javax.media.opengl.GL gl)
          Initialize the graphic manager if needed, and return the only instance allowed to be instanciated
 ItemsBean getItemsBean()
           
 Object3D getProblem(Id problemId)
          Get a problem object from the problem list according to its id
 AnimatedObject getProjectile(Id itemId)
          Get a projectile object from the projectile list according to its id
 TextureAnimatedObject getReticle(Id problemId)
          Get a reticle object from the reticle list according to a problem id
 TextureAnimatedObject getReticleInstance()
           
 AnimatedObject getTarget(Id id)
          Get a target object from the target list according to its id
 void initLevel(GraphicsEvent event)
          Invoked when a level is started
 void initObjects()
          Load the prototype of all the objects in memory
 void loadBackground(GraphicsEvent event, java.lang.String type)
          Invoked when the background has to be change
 void removeGun(GraphicsEvent event, Id itemId)
          Invoked when a gun is removed
 void removeProblem(GraphicsEvent event, Id problemId)
          Invoked when a problem is removed
 void removeProjectile(GraphicsEvent event, Id itemId)
          Invoked when a projectile is removed
 void removeReticle(GraphicsEvent event, Id problemId)
          Invoked when a reticle if removed
 void removeTarget(GraphicsEvent event, Id id)
          Invoked when a target is removed
 void setDisplayList(DisplayList displayList)
           
 void setItemsBean(GraphicsEvent event, ItemsBean itemsBean)
          Invoked when the itemsBean of the listener has to be reset.
 void updateDisplayList(GraphicsEvent event)
          Invoked when the display list has to be updated
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

singleton

public static GraphicsManager singleton
Singleton

Method Detail

getInstance

public static GraphicsManager getInstance(boolean useShader,
                                          javax.media.opengl.GL gl)
Initialize the graphic manager if needed, and return the only instance allowed to be instanciated

Parameters:
useShader - are we using the toon shading program?
gl - OpengGL context
Returns:
the instance of the graphic manager

initObjects

public void initObjects()
Load the prototype of all the objects in memory


initLevel

public void initLevel(GraphicsEvent event)
Description copied from interface: GraphicsEventListener
Invoked when a level is started

Specified by:
initLevel in interface GraphicsEventListener
See Also:
GraphicsEventListener.initLevel(GraphicsEvent)

updateDisplayList

public void updateDisplayList(GraphicsEvent event)
Description copied from interface: GraphicsEventListener
Invoked when the display list has to be updated

Specified by:
updateDisplayList in interface GraphicsEventListener
See Also:
GraphicsEventListener.updateDisplayList(GraphicsEvent)

loadBackground

public void loadBackground(GraphicsEvent event,
                           java.lang.String type)
Description copied from interface: GraphicsEventListener
Invoked when the background has to be change

Specified by:
loadBackground in interface GraphicsEventListener
type - "main" to load the main background, "option" to load the option background
See Also:
GraphicsEventListener.loadBackground(GraphicsEvent, String)

addProblem

public void addProblem(GraphicsEvent event,
                       Id problemId,
                       Object3D object)
Description copied from interface: GraphicsEventListener
Invoked when a new problem is added

Specified by:
addProblem in interface GraphicsEventListener
problemId - id of the problem
object - drawable object representing the problem
See Also:
GraphicsEventListener.addProblem(unc.cdva.events.graphicsevents.GraphicsEvent, unc.cdva.utils.Id, unc.cdva.graphics.models.Object3D)

getProblem

public Object3D getProblem(Id problemId)
Get a problem object from the problem list according to its id

Parameters:
problemId - id of the problem
Returns:
requested object or null

removeProblem

public void removeProblem(GraphicsEvent event,
                          Id problemId)
Description copied from interface: GraphicsEventListener
Invoked when a problem is removed

Specified by:
removeProblem in interface GraphicsEventListener
problemId - id of the problem
See Also:
GraphicsEventListener.removeProblem(unc.cdva.events.graphicsevents.GraphicsEvent, unc.cdva.utils.Id)

addTarget

public void addTarget(GraphicsEvent event,
                      Id itemId)
Description copied from interface: GraphicsEventListener
Invoked when a target is added

Specified by:
addTarget in interface GraphicsEventListener
itemId - id of the target
See Also:
GraphicsEventListener.addTarget(unc.cdva.events.graphicsevents.GraphicsEvent, unc.cdva.utils.Id)

getTarget

public AnimatedObject getTarget(Id id)
Get a target object from the target list according to its id

Parameters:
id - id of the target
Returns:
requested object or null

removeTarget

public void removeTarget(GraphicsEvent event,
                         Id id)
Description copied from interface: GraphicsEventListener
Invoked when a target is removed

Specified by:
removeTarget in interface GraphicsEventListener
id - id of the target that has to be removed
See Also:
GraphicsEventListener.removeTarget(unc.cdva.events.graphicsevents.GraphicsEvent, unc.cdva.utils.Id)

addGun

public void addGun(GraphicsEvent event,
                   Id itemId)
Description copied from interface: GraphicsEventListener
Invoked when a new gun is added

Specified by:
addGun in interface GraphicsEventListener
itemId - id of the new gun
See Also:
GraphicsEventListener.addGun(unc.cdva.events.graphicsevents.GraphicsEvent, unc.cdva.utils.Id)

getGun

public AnimatedObject getGun(Id id)
Get a gun object from the gun list according to its id

Parameters:
id - id of the gun
Returns:
requested object or null

removeGun

public void removeGun(GraphicsEvent event,
                      Id itemId)
Description copied from interface: GraphicsEventListener
Invoked when a gun is removed

Specified by:
removeGun in interface GraphicsEventListener
itemId - id of the gun
See Also:
GraphicsEventListener.removeGun(unc.cdva.events.graphicsevents.GraphicsEvent, unc.cdva.utils.Id)

addProjectile

public void addProjectile(GraphicsEvent event,
                          Id itemId)
Description copied from interface: GraphicsEventListener
Invoked when a projectile is added

Specified by:
addProjectile in interface GraphicsEventListener
itemId - id of the projectile
See Also:
GraphicsEventListener.addProjectile(unc.cdva.events.graphicsevents.GraphicsEvent, unc.cdva.utils.Id)

getProjectile

public AnimatedObject getProjectile(Id itemId)
Get a projectile object from the projectile list according to its id

Parameters:
itemId - id of the projectile
Returns:
requested object or null

removeProjectile

public void removeProjectile(GraphicsEvent event,
                             Id itemId)
Description copied from interface: GraphicsEventListener
Invoked when a projectile is removed

Specified by:
removeProjectile in interface GraphicsEventListener
itemId - id of the projectile that has to be removed
See Also:
GraphicsEventListener.removeProjectile(unc.cdva.events.graphicsevents.GraphicsEvent, unc.cdva.utils.Id)

addReticle

public void addReticle(GraphicsEvent event,
                       Id problemId)
Description copied from interface: GraphicsEventListener
Invoked when a new reticle is added

Specified by:
addReticle in interface GraphicsEventListener
problemId - id of the new reticle
See Also:
GraphicsEventListener.addReticle(unc.cdva.events.graphicsevents.GraphicsEvent, unc.cdva.utils.Id)

getReticle

public TextureAnimatedObject getReticle(Id problemId)
Get a reticle object from the reticle list according to a problem id

Parameters:
problemId - id of the problem
Returns:
requested object or null

removeReticle

public void removeReticle(GraphicsEvent event,
                          Id problemId)
Description copied from interface: GraphicsEventListener
Invoked when a reticle if removed

Specified by:
removeReticle in interface GraphicsEventListener
problemId - id of the reticle
See Also:
GraphicsEventListener.removeReticle(unc.cdva.events.graphicsevents.GraphicsEvent, unc.cdva.utils.Id)

getReticleInstance

public TextureAnimatedObject getReticleInstance()
Returns:
Returns the reticle.

getDisplayList

public DisplayList getDisplayList()
Returns:
the displayList

getItemsBean

public ItemsBean getItemsBean()
Returns:
the itemsBean

setDisplayList

public void setDisplayList(DisplayList displayList)
Parameters:
displayList - the displayList to set

setItemsBean

public void setItemsBean(GraphicsEvent event,
                         ItemsBean itemsBean)
Description copied from interface: GraphicsEventListener
Invoked when the itemsBean of the listener has to be reset.

Specified by:
setItemsBean in interface GraphicsEventListener
Parameters:
itemsBean - the itemsBean to set
See Also:
GraphicsEvent, ItemsBean