mr3d
Class SceneManager

java.lang.Object
  extended bymr3d.debug.ErrorHandling
      extended bymr3d.SceneManager
All Implemented Interfaces:
Debugable

public class SceneManager
extends ErrorHandling
implements Debugable

The SceneManager is a fassade for the mr3d-engine. It is the interface between system and programmer. It gives access to all important system functionality necessary to produce 3-dimensional pictures.

SceneManager is a Singleton.

Since:
MR3Dv1.0
Version:
10-2004
Author:
Manuel Ruelke

Field Summary
static ObjectArray ALL
          Object array managing all 3D-objects in the 3D-scene.
private static int backClippingPlane
          Back Clipping Plane.
private  boolean debugMode
          Determines if the SceneManager is in debug mode.
private  boolean errorBreak
          Is true if error(s) have occured.
private static int frontClippingPlane
          Front Clipping Plane.
private static SceneManager instance
          Reference to the only instance of the class.
private static int nrOfInstances
          Stores the numbers of instances of SceneManager.
static PointArrayTable PAT
          Point array table object managing all the 3D-points needed for the 3D scene.
static CentralProjectionCamera sceneCamera
          Camera object for projecting the points to a view port.
static Renderer sceneRenderer
          sceneRenderer object for rendering a picture from the projections the camera calculates.
 
Fields inherited from class mr3d.debug.ErrorHandling
 
Fields inherited from interface mr3d.debug.Debugable
ERROR_INT, ERROR_STRING
 
Constructor Summary
private SceneManager()
          Constructor of SceneManager.
 
Method Summary
static int backClippingPlane()
          Returns the value of the frontClippingPlane.
static void clearScene()
          Deletes all data in the scene.
 int create3DObjectFromFile(java.lang.String fileName)
          Loads an 3D object from a file and adds it into the object array.
static SceneManager createInstance()
          Creates one instance of the SceneManager.
 void drawScene(Graphics g)
          Draws the whole scene to the specified Graphics objects.
static int frontClippingPlane()
          Returns the value of the frontClippingPlane.
 TriangleBased3DObject getObject(int OAI)
           
private  boolean hasErrors()
          Returns errorBreak variable.
 void setClippingPlanes(int frontClip, int backClip)
          Limits the view volume.
 void setDisplayDimensions(int screenwidth, int screenheight)
          Specifiies the screen dimensions.
private  void stopOnError()
          Sets errorBreak to true.
 void toConsole()
          Prints the contents of the object to the Java console.
 void toConsole(java.lang.String msgString)
          Prints the contents of the object to the Java console together with an information string.
 void toggleDebugMode(boolean toogleDebug)
          Activates or deactivates the debug mode.
 
Methods inherited from class mr3d.debug.ErrorHandling
getErrMsg, notifyError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALL

public static ObjectArray ALL
Object array managing all 3D-objects in the 3D-scene.


backClippingPlane

private static int backClippingPlane
Back Clipping Plane. Objects will not be drawn to the screen when they are further away from the camera than the clipping plane. The value specifies a plane in the camera coordinate system defined as f(x,y) = z = backClippingPlane.


debugMode

private boolean debugMode
Determines if the SceneManager is in debug mode. In debug mode the system puts out additional debug info.


errorBreak

private boolean errorBreak
Is true if error(s) have occured.


frontClippingPlane

private static int frontClippingPlane
Front Clipping Plane. Objects will not be drawn to the screen when they are closer to the camera than the clipping plane. The value specifies a plane in the camera coordinate system defined as f(x,y) = z = frontClippingPlane.


instance

private static SceneManager instance
Reference to the only instance of the class.


nrOfInstances

private static int nrOfInstances
Stores the numbers of instances of SceneManager. This is neccessary to make sure there is only one instance. SceneManager is a singleton.


PAT

public static PointArrayTable PAT
Point array table object managing all the 3D-points needed for the 3D scene.


sceneCamera

public static CentralProjectionCamera sceneCamera
Camera object for projecting the points to a view port.


sceneRenderer

public static Renderer sceneRenderer
sceneRenderer object for rendering a picture from the projections the camera calculates.

Constructor Detail

SceneManager

private SceneManager()
Constructor of SceneManager. It is private because SceneManager is a Singleton.

Method Detail

backClippingPlane

public static int backClippingPlane()
Returns the value of the frontClippingPlane.

Returns:
value of frontClippingPlane

clearScene

public static void clearScene()
Deletes all data in the scene.


create3DObjectFromFile

public int create3DObjectFromFile(java.lang.String fileName)
                           throws java.io.IOException
Loads an 3D object from a file and adds it into the object array.

Parameters:
fileName - name and path of the file
Returns:
object array index (handle to the object)
Throws:
java.io.IOException

createInstance

public static SceneManager createInstance()
Creates one instance of the SceneManager. This method checks the nrOfInstances value to ensure that only one instance is running.

Returns:
an instance of PointArrayTable

drawScene

public void drawScene(Graphics g)
Draws the whole scene to the specified Graphics objects.

Parameters:
g - the Graphics object the scene should be written on

frontClippingPlane

public static int frontClippingPlane()
Returns the value of the frontClippingPlane.

Returns:
value of frontClippingPlane

getObject

public TriangleBased3DObject getObject(int OAI)

hasErrors

private boolean hasErrors()
Returns errorBreak variable. This method returns true if errors have occured while processing the file.

Returns:
errorBreak variable

setClippingPlanes

public void setClippingPlanes(int frontClip,
                              int backClip)
Limits the view volume. When the reference point of an object reaches a clipping plane or goes beyond it the object will be set to invisible for it is outside the view volume. When the z-coordinate of any object's reference point is lesser than the value stored in backClippingPlane the object becomes invisible. If the z-coordinate of any object's point is greater than the value stored in frontClippingPlane the objects also becomes invisible.

To avoid graphic errors in the drawing process you have to make sure the follwong rules apply. The value for frontClippingPlane must be greater than the value n backClippingPlane. The value frontClippingPlane must not exceed or be equal to the value viewPlaneDistance.


setDisplayDimensions

public void setDisplayDimensions(int screenwidth,
                                 int screenheight)
Specifiies the screen dimensions. This is to avoid objects to be drawn outside of the display, which uses runtime ressources but does not produce visible result. Setting this option helps to keep the ressource usage down. Initial values are 176 by 144.

Parameters:
screenwidth - width of the screen in pixels
screenheight - height of the screen in pixels

stopOnError

private void stopOnError()
Sets errorBreak to true. This method is called when an error has occured.


toConsole

public void toConsole()
Description copied from interface: Debugable
Prints the contents of the object to the Java console. How the information will be displayed depends on what data the object contains. Depending on structure and contents every implementation of this function produces a different result on the console.

Specified by:
toConsole in interface Debugable

toConsole

public void toConsole(java.lang.String msgString)
Description copied from interface: Debugable
Prints the contents of the object to the Java console together with an information string. How the information will be displayed depends on what data the object contains. Depending on structure and contents every implementation of this function produces a different result on the console.

Specified by:
toConsole in interface Debugable

toggleDebugMode

public void toggleDebugMode(boolean toogleDebug)
Activates or deactivates the debug mode.

Parameters:
toogleDebug - if true debug mode is On, if false debug mode is Off