net.jinx.video
Class Context

java.lang.Object
  extended by net.jinx.video.Options
      extended by net.jinx.video.model.ModelContext
          extended by net.jinx.video.Context

public class Context
extends ModelContext

In addition to the attributes stored in Options, this class stores attributes that function as contextual data for rendering. The attributes defined in this class are not affected by the push() and pop() methods of the Options class.

API Stability: Stable; the setView and getView methods are beta.


Constructor Summary
Context()
          Constructs a new Context object.
Context(boolean initTM)
          Constructs a new Context object.
Context(boolean initTM, boolean initTS)
          Constructs a new Context object.
 
Method Summary
 int currentLight()
          Provides the number of the current light to use.
 float getAspectRatio()
          Provides thw current aspect ratio for the drawing area.
 Vector getCameraPosition()
          Provides the current position of the viewer/camera.
 float getDeltaTime()
          Provides the change in time value that should indicate how to use the interpolation value that's set in this class.
 java.awt.Rectangle getDrawingArea()
          Provides the rectangle describing the current drawing area.
 javax.media.opengl.GL getGL()
           
 javax.media.opengl.GLContext getGLContext()
           
 javax.media.opengl.GLDrawable getGLDrawable()
           
 float getInterpolation()
          Provides the current interpolation value.
 TextureManager getTextureManager()
          Provides the current TextureManager.
 TimeSource getTimeSource()
          Provides the TimeSource that will function as simulation clock for rendering.
 View getView()
          Provides the current View for the scene being rendered.
 boolean isInit()
          Provides the means to easily determine if the init() method of SplitScreenRenderer is currently running.
 int lastEnabledLight()
          Provides the number of the highest enabled light.
 int newLight()
          Increments the current light number and returns it.
 void resetLight()
          Resets the current light number to -1.
 void setCameraPosition(Vector cameraPosition)
          3D View implementations are required to call this when they update the position of the camera.
 void setDeltaTime(float deltaTime)
          Sets the change in time value that should indicate how to use the interpolation value that's set in this class.
 void setLastEnabledLight(int light)
          Tells the system that all lights up to the given number are now enabled.
 void setTextureManager(TextureManager textures)
          Sets the current TextureManager.
 void setTimeSource(TimeSource timeSource)
          Sets the TimeSource that functions as simulation clock for rendering.
 void setView(View view)
          Sets the current View.
 
Methods inherited from class net.jinx.video.model.ModelContext
getCurrentModel
 
Methods inherited from class net.jinx.video.Options
getAlpha, getAWTClearColor, getClearColor, getFarClip, getFOV, getGlobalAmbientLight, getNearClip, getSmoothness, getSolidity, getTextureMode, getTextureModeName, getTwosidedness, getUseLists, isAmbient, isCountingFrames, isDebuggingGL, isDiffuse, isEmissive, isShiny, isSpecular, isTracingGL, load, pop, push, setAlpha, setAmbient, setClearColor, setCountingFrames, setDebugGL, setDiffuse, setEmissive, setFarClip, setFOV, setGlobalAmbientLight, setNearClip, setShininess, setSmoothness, setSolidity, setSpecular, setTextureMode, setTextureModeName, setTraceGL, setTwosidedness, setUseLists, store
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Context

public Context()
Constructs a new Context object. The TextureManager is null. This is the same as Context(false).


Context

public Context(boolean initTM)
Constructs a new Context object. The TextureManager are initialized according to the flags. The TimeSource is configured as a default real-time TimeSource.

Parameters:
initTM - if true, a new TextureManager is constructed and the setTextureManager(TextureManager) method is called.

Context

public Context(boolean initTM,
               boolean initTS)
Constructs a new Context object. The TextureManager are initialized according to the flags.

Parameters:
initTM - if true, a new TextureManager is constructed and the setTextureManager(TextureManager) method is called.
initTS - if true, a default real-time TimeSource is constructed and the setTimeSoTimeSource) method is called. If this is false, you MUST configure the attached TimeSource before you can use the Context object produced from this constructor.
Method Detail

getCameraPosition

public final Vector getCameraPosition()
Provides the current position of the viewer/camera. This may only be a best guess location and only has meaning for a 3D view.

Returns:
the Vector with camera location data.

setCameraPosition

public void setCameraPosition(Vector cameraPosition)
3D View implementations are required to call this when they update the position of the camera.

Parameters:
cameraPosition - the Vector with camera location data.

getGLContext

public final javax.media.opengl.GLContext getGLContext()

getGLDrawable

public final javax.media.opengl.GLDrawable getGLDrawable()

getGL

public final javax.media.opengl.GL getGL()

getView

public final View getView()
Provides the current View for the scene being rendered.

Returns:
the current View.

setView

public void setView(View view)
Sets the current View. This should be called from a View implementation's view(Context) method.

Parameters:
view - the View.

getTimeSource

public final TimeSource getTimeSource()
Provides the TimeSource that will function as simulation clock for rendering. This will be null until setTimeSource(TimeSource) is called.

Returns:
the TimeSource.

setTimeSource

public void setTimeSource(TimeSource timeSource)
Sets the TimeSource that functions as simulation clock for rendering. This is a call-once method; all calls after the first with a non-null TimeSource are ignored, so once this has been set, it cannot be changed.

Parameters:
timeSource - the TimeSource.

getDeltaTime

public float getDeltaTime()
Provides the change in time value that should indicate how to use the interpolation value that's set in this class.

Returns:
the change in time value. If this is zero, then the system is most likely running in a real-time mode and the interpolation value has little or no meaning.

setDeltaTime

public void setDeltaTime(float deltaTime)
Sets the change in time value that should indicate how to use the interpolation value that's set in this class.

Parameters:
deltaTime - the change in time value.

getInterpolation

public final float getInterpolation()
Provides the current interpolation value. This will be a value from zero to one.

Returns:
the interpolation value.

isInit

public final boolean isInit()
Provides the means to easily determine if the init() method of SplitScreenRenderer is currently running.

Returns:
true if the init() method is running.

currentLight

public int currentLight()
Provides the number of the current light to use.

Returns:
the integer light number. -1 indicates that no lights have been used yet.

newLight

public int newLight()
Increments the current light number and returns it.

Returns:
the new light number.

resetLight

public void resetLight()
Resets the current light number to -1.


lastEnabledLight

public int lastEnabledLight()
Provides the number of the highest enabled light.

Returns:
the highest enabled light number.

setLastEnabledLight

public void setLastEnabledLight(int light)
Tells the system that all lights up to the given number are now enabled.

Parameters:
light - the light number.

getTextureManager

public TextureManager getTextureManager()
Provides the current TextureManager. This can be null.

Returns:
the current TextureManager.

setTextureManager

public void setTextureManager(TextureManager textures)
Sets the current TextureManager. This can be null, but shouldn't be unless you know you won't be using textures.

Parameters:
textures - the TextureManager.

getDrawingArea

public final java.awt.Rectangle getDrawingArea()
Provides the rectangle describing the current drawing area. This area covers all views. Even though the returned Rectangle is a mutable object, you should never modify it. Doing so is a bad idea.

Returns:
the Rectangle object describing the area. This can be null if the reshape(GLDrawable, int, int, int, int) method of SplitScreenRenderer has not been called yet.

getAspectRatio

public final float getAspectRatio()
Provides thw current aspect ratio for the drawing area.

Returns:
the current ratio of width to height (width divided by height).