Aviatrix3D
2.0 Dev

org.j3d.aviatrix3d
Class Viewpoint

java.lang.Object
  extended byorg.j3d.aviatrix3d.SceneGraphObject
      extended byorg.j3d.aviatrix3d.Node
          extended byorg.j3d.aviatrix3d.Leaf
              extended byorg.j3d.aviatrix3d.Viewpoint
All Implemented Interfaces:
java.lang.Comparable, Renderable, RenderableObject

public class Viewpoint
extends Leaf
implements RenderableObject

A viewpoint into the scene.

Viewpoints have their own implicit directional light (a headlight) that is controlled separately to the normal in-scenegraph lights. Lights are scoped by default and thus having the viewpoint also have a light following it around is a pain to deal with, you can select on directly on the viewpoint itself. This light is always pointing down the Z axis in the local coordinate system.

In addition to the headlight, a separate ambient light colour may be provided. Although this is provided, note that whether it has any effect is dependent on whether lighting is enabled on the object being rendered.

Version:
$Revision: 1.22 $
Author:
Justin Couch

Field Summary
 
Fields inherited from class org.j3d.aviatrix3d.Node
bounds, implicitBounds, INVALID_BOUNDS, parent
 
Fields inherited from class org.j3d.aviatrix3d.SceneGraphObject
alive, LISTENER_SET_NOT_LIVE_MESSAGE, updateHandler, WRITE_TIMING_MSG
 
Constructor Summary
Viewpoint()
          The default constructor where the headlight is implicitly turned off, and the default light type is directional.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compares this object with the specified object for order.
 int compareTo(Viewpoint vp)
          Compares this object with the specified object for order.
 boolean equals(java.lang.Object o)
          Compare this object for equality to the given object.
 boolean equals(Viewpoint vp)
          Compares this object with the specified object to check for equivalence.
 void getGlobalAmbientColor(float[] col)
          Retrieve the current colour value from the light.
 Renderable getRenderable(int bufferId)
          Get the Renderable instance needed to process this object for the given buffer ID.
 boolean isDirectionalLight()
          Get the current state of the headlight type.
 boolean isGlobalAmbientLightEnabled()
          Get the current state of the global ambient light usage.
 boolean isHeadlightEnabled()
          Get the current state of the headlight usage.
protected  void markBoundsDirty()
          Mark this node as having dirty bounds due to one of it's children having their bounds changed.
 void postRender(javax.media.opengl.GL gl)
           
 void render(javax.media.opengl.GL gl)
          This method is called to render this node.
 void setGlobalAmbientColor(float[] col)
          Set the ambient colour to the new value.
 void setGlobalAmbientLightEnabled(boolean state)
          Turn the global ambient lighting setting on or off.
 void setHeadlightEnabled(boolean state)
          Turn the local headlight on/off.
 void setHeadlightType(boolean state)
          Change the style of the headlight between directional and spot types.
 
Methods inherited from class org.j3d.aviatrix3d.Node
boundsChanged, checkForCyclicParent, getBounds, getParent, recomputeBounds, removeParent, setBounds, setLive, setParent, updateBounds, updateParentBounds
 
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject
checkForCyclicChild, dataChanged, getUserData, isLive, setUpdateHandler, setUserData
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Viewpoint

public Viewpoint()
The default constructor where the headlight is implicitly turned off, and the default light type is directional.

Method Detail

getRenderable

public Renderable getRenderable(int bufferId)
Get the Renderable instance needed to process this object for the given buffer ID.

Overrides:
getRenderable in class Leaf
Parameters:
bufferId - The ID of the buffer for the renderable to encapsulate
Returns:
The renderable object, or null if nothing to render

markBoundsDirty

protected void markBoundsDirty()
Mark this node as having dirty bounds due to one of it's children having their bounds changed.

Overrides:
markBoundsDirty in class Node

render

public void render(javax.media.opengl.GL gl)
This method is called to render this node. All openGL commands needed to render the node should be executed. Any transformations needed should be added to the transformation stack premultiplied. This method must be re-entrant as it can be called from multiple places at once.

Specified by:
render in interface RenderableObject
Parameters:
gl - The gl context to draw with

postRender

public void postRender(javax.media.opengl.GL gl)
Specified by:
postRender in interface RenderableObject

compareTo

public int compareTo(java.lang.Object o)
              throws java.lang.ClassCastException
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - The objec to be compared
Returns:
-1, 0 or 1 depending on order
Throws:
java.lang.ClassCastException - The specified object's type prevents it from being compared to this Object

equals

public boolean equals(java.lang.Object o)
Compare this object for equality to the given object.

Specified by:
equals in interface Renderable
Parameters:
o - The object to be compared
Returns:
True if these represent the same values

isHeadlightEnabled

public boolean isHeadlightEnabled()
Get the current state of the headlight usage.

Returns:
true if the headlight is currently active

setHeadlightEnabled

public void setHeadlightEnabled(boolean state)
                         throws InvalidWriteTimingException
Turn the local headlight on/off.

Parameters:
state - true to turn the light on
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

setGlobalAmbientLightEnabled

public void setGlobalAmbientLightEnabled(boolean state)
                                  throws InvalidWriteTimingException
Turn the global ambient lighting setting on or off.

Parameters:
state - true to turn the light on
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

isGlobalAmbientLightEnabled

public boolean isGlobalAmbientLightEnabled()
Get the current state of the global ambient light usage.

Returns:
true if the ambient light is currently active

setGlobalAmbientColor

public void setGlobalAmbientColor(float[] col)
                           throws java.lang.IllegalArgumentException,
                                  InvalidWriteTimingException
Set the ambient colour to the new value. Colour must be in the range [0, 1] otherwise an exception is generated.

Parameters:
col - The new colour value to use
Throws:
java.lang.IllegalArgumentException - The colour value is out of range
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

getGlobalAmbientColor

public void getGlobalAmbientColor(float[] col)
Retrieve the current colour value from the light.

Parameters:
col - An array to copy the colour value into

isDirectionalLight

public boolean isDirectionalLight()
Get the current state of the headlight type.

Returns:
true if the headlight is currently a directional light

setHeadlightType

public void setHeadlightType(boolean state)
                      throws InvalidWriteTimingException
Change the style of the headlight between directional and spot types.

Parameters:
state - true to turn the light to directional, false for spot
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

compareTo

public int compareTo(Viewpoint vp)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Parameters:
vp - The argument instance to be compared
Returns:
-1, 0 or 1 depending on order

equals

public boolean equals(Viewpoint vp)
Compares this object with the specified object to check for equivalence.

Parameters:
vp - The viewpoint instance to be compared
Returns:
true if the objects represent identical values

Aviatrix3D
2.0 Dev

Latest Info from http://aviatrix3d.j3d.org/
Copyright © 2003 - 2005 j3d.org