Aviatrix3D
2.1.0

org.j3d.aviatrix3d
Class Shape3D

java.lang.Object
  extended by org.j3d.aviatrix3d.SceneGraphObject
      extended by org.j3d.aviatrix3d.Node
          extended by org.j3d.aviatrix3d.Leaf
              extended by org.j3d.aviatrix3d.Shape3D
All Implemented Interfaces:
java.lang.Comparable, PickableObject, PickTarget, SinglePickTarget, Cullable, LeafCullable, ObjectRenderable, Renderable, ShapeRenderable
Direct Known Subclasses:
Box, Cone, Cylinder, Sphere, Spring, Torus

public class Shape3D
extends Leaf
implements PickableObject, SinglePickTarget, LeafCullable, ShapeRenderable, ObjectRenderable

A Shape3D class wraps polygonal geometry and appearance information. into a single visual chunk.

By default, all shapes are pickable.

Internationalisation Resource Names

Version:
$Revision: 1.42 $
Author:
Justin Couch, Alan Hudson

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_TIMING_ERR_PROP, updateHandler
 
Fields inherited from interface org.j3d.aviatrix3d.picking.PickableObject
COLLIDABLE_OBJECT, GENERAL_OBJECT, PROXIMITY_OBJECT, VISIBLE_OBJECT
 
Fields inherited from interface org.j3d.aviatrix3d.picking.PickTarget
CUSTOM_PICK_TYPE, GROUP_PICK_TYPE, LEAF_PICK_TYPE, SINGLE_PICK_TYPE
 
Fields inherited from interface org.j3d.aviatrix3d.rendering.LeafCullable
AUDIO_CULLABLE, CLIP_CULLABLE, FOG_CULLABLE, GEOMETRY_CULLABLE, LIGHT_CULLABLE, OVERRIDE_CULLABLE
 
Constructor Summary
Shape3D()
          Creates a shape with no geometry or appearance set.
 
Method Summary
protected  void checkForCyclicChild(SceneGraphObject parent)
          Check to see if this node is the same reference as the passed node that is a parent of this node.
 boolean checkPickMask(int mask)
          Check the given pick mask against the node's internal pick mask representation.
 int compareTo(java.lang.Object o)
          Compares this object with the specified object for order.
 int compareTo(Shape3D sh)
          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(Shape3D sh)
          Compares this object with the specified object to check for equivalence.
 Appearance getAppearance()
          Get the current appearance associated with this shape.
 AppearanceRenderable getAppearanceRenderable()
          Fetch the renderable that represents the visual appearance modifiers of this shape.
 void getCenter(float[] center)
          Get the centre of the shape object.
 int getCullableType()
          Get the type that this cullable represents.
 Geometry getGeometry()
          Get the current geometry associated with this shape.
 GeometryRenderable getGeometryRenderable()
          Fetch the renderable that represents the geometry of this shape.
 BoundingVolume getPickableBounds()
          Get the bounds of this picking target so that testing can be performed on the object.
 PickTarget getPickableChild()
          Return the child that is pickable of from this target.
 int getPickMask()
          Get the current pickable state mask of this object.
 int getPickTargetType()
          Return the type constant that represents the type of pick target this is.
 Renderable getRenderable()
          Get the child renderable of this object.
 boolean is2D()
          Check to see whether this shape is something that represents 2D or 3D geometry.
 boolean isVisible()
          State check to see whether the shape in it's current setup is visible.
 void pickBatch(PickRequest[] reqs, int numRequests)
          Check for all intersections against this geometry and it's children to see if there is an intersection with the given set of requests.
 void pickSingle(PickRequest req)
          Check for all intersections against this geometry and it's children to see if there is an intersection with the given set of requests.
 void postRender(javax.media.opengl.GL gl)
           
protected  void recomputeBounds()
          Internal method to recalculate the implicit bounds of this Node.
 void render(javax.media.opengl.GL gl)
          This method is called to render this node.
 void requestBoundsUpdate()
          Request a recomputation of the bounds of this object.
 void setAppearance(Appearance newApp)
          Set the appearance for this shape.
 void setGeometry(Geometry newGeom)
          Set the geometry for this shape.
protected  void setLive(boolean state)
          Notification that this object is live now.
 void setPickMask(int state)
          Set the node as being pickable currently using the given bit mask.
protected  void setUpdateHandler(NodeUpdateHandler handler)
          Set the scenegraph update handler for this node.
protected  void updateBounds()
          Update this node's bounds and then call the parent to update it's bounds.
 
Methods inherited from class org.j3d.aviatrix3d.Node
boundsChanged, checkForCyclicParent, getBounds, getParent, markBoundsDirty, removeParent, setBounds, setParent, updateParentBounds
 
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject
dataChanged, getAppUpdateWriteTimingMessage, getBoundsWriteTimingMessage, getDataWriteTimingMessage, getUserData, isLive, setUserData
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.j3d.aviatrix3d.rendering.LeafCullable
getBounds
 

Constructor Detail

Shape3D

public Shape3D()
Creates a shape with no geometry or appearance set.

Method Detail

getCullableType

public int getCullableType()
Get the type that this cullable represents.

Specified by:
getCullableType in interface LeafCullable
Returns:
One of the _CULLABLE constants

getRenderable

public Renderable getRenderable()
Get the child renderable of this object.

Specified by:
getRenderable in interface LeafCullable
Returns:
an array of nodes

isVisible

public boolean isVisible()
State check to see whether the shape in it's current setup is visible. Various reasons for this are stated in the class docs.

Specified by:
isVisible in interface ShapeRenderable
Returns:
true if the shape has something to render

is2D

public boolean is2D()
Check to see whether this shape is something that represents 2D or 3D geometry. Pure 2D geometry is not effected by any EffectRenderable, while 3D is. Note that this can be changed depending on the type of geometry itself. A Shape3D node with an IndexedLineArray that only has 2D coordinates is as much a 2D geometry as a raster object.

Specified by:
is2D in interface ShapeRenderable
Returns:
True if this is 2D geometry, false if this is 3D

getCenter

public void getCenter(float[] center)
Get the centre of the shape object. Used for transparency depth sorting based on the center of the bounds of the object.

Specified by:
getCenter in interface ShapeRenderable
Parameters:
center - The object to copy the center coordinates in to

getGeometryRenderable

public GeometryRenderable getGeometryRenderable()
Fetch the renderable that represents the geometry of this shape.

Specified by:
getGeometryRenderable in interface ShapeRenderable
Returns:
The current geometry renderable or null if none

getAppearanceRenderable

public AppearanceRenderable getAppearanceRenderable()
Fetch the renderable that represents the visual appearance modifiers of this shape.

Specified by:
getAppearanceRenderable in interface ShapeRenderable
Returns:
The current appearance renderable or null if none

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 ObjectRenderable
Parameters:
gl - The gl context to draw with

postRender

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

updateBounds

protected void updateBounds()
Update this node's bounds and then call the parent to update it's bounds. Used to propogate bounds changes from the leaves of the tree to the root.

Overrides:
updateBounds in class Node

recomputeBounds

protected void recomputeBounds()
Internal method to recalculate the implicit bounds of this Node. By default the bounds are a point sphere, so derived classes should override this method with something better.

Overrides:
recomputeBounds in class Node

requestBoundsUpdate

public void requestBoundsUpdate()
Request a recomputation of the bounds of this object. If this object is not currently live, you can request a recompute of the bounds to get the most current values. If this node is currently live, then the request is ignored.

This will request the geometry to recompute the bounds. If the geometry is found to be live during this process, it will not update, and thus the value used will be the last updated (ie from the previous frame it was processed).

Overrides:
requestBoundsUpdate in class Node

setLive

protected void setLive(boolean state)
Notification that this object is live now. Overridden to make sure that the live state of the nodes represents the same state as the parent scene graph.

Overrides:
setLive in class SceneGraphObject
Parameters:
state - true if this should be marked as live now

setUpdateHandler

protected void setUpdateHandler(NodeUpdateHandler handler)
Set the scenegraph update handler for this node. It will notify all its children of the value. A null value will clear the current handler.

Overrides:
setUpdateHandler in class SceneGraphObject
Parameters:
handler - The instance to use as a handler

checkForCyclicChild

protected void checkForCyclicChild(SceneGraphObject parent)
                            throws CyclicSceneGraphStructureException
Check to see if this node is the same reference as the passed node that is a parent of this node. This is the downwards check to ensure that there is no cyclic scene graph structures at the point where someone adds a node to the scenegraph. When the reference and this are the same, an exception is generated. Since each class may have different lists of child node setups, this should be overriden by any class that can take children, and have the call passed along to the children.

Overrides:
checkForCyclicChild in class SceneGraphObject
Parameters:
parent - The reference to check against this class
Throws:
CyclicSceneGraphStructureException - Equal parent and child

setPickMask

public void setPickMask(int state)
Set the node as being pickable currently using the given bit mask. A mask of 0 will completely disable picking.

Specified by:
setPickMask in interface PickableObject
Parameters:
state - A bit mask of available options to pick for

getPickMask

public int getPickMask()
Get the current pickable state mask of this object. A value of zero means it is completely unpickable.

Specified by:
getPickMask in interface PickableObject
Returns:
A bit mask of available options to pick for

pickBatch

public void pickBatch(PickRequest[] reqs,
                      int numRequests)
               throws NotPickableException,
                      InvalidPickTimingException
Check for all intersections against this geometry and it's children to see if there is an intersection with the given set of requests.

Specified by:
pickBatch in interface PickableObject
Parameters:
reqs - The list of picks to be made, starting at this object
numRequests - The number of valid pick requests to process
Throws:
NotPickableException - This object has been marked as non pickable, but you decided to try to call the method anyway
InvalidPickTimingException - An attempt was made to pick outside of the ApplicationUpdateObserver callback method

pickSingle

public void pickSingle(PickRequest req)
                throws NotPickableException,
                       InvalidPickTimingException
Check for all intersections against this geometry and it's children to see if there is an intersection with the given set of requests.

Specified by:
pickSingle in interface PickableObject
Parameters:
req - The details of the pick to be made
Throws:
NotPickableException - This object has been marked as non pickable, but you decided to try to call the method anyway
InvalidPickTimingException - An attempt was made to pick outside of the ApplicationUpdateObserver callback method

getPickableChild

public PickTarget getPickableChild()
Return the child that is pickable of from this target. If there is none then return null.

Specified by:
getPickableChild in interface SinglePickTarget
Returns:
The child pickable object or null

getPickTargetType

public final int getPickTargetType()
Return the type constant that represents the type of pick target this is. Used to provided optimised picking implementations.

Specified by:
getPickTargetType in interface PickTarget
Returns:
One of the _PICK_TYPE constants

checkPickMask

public boolean checkPickMask(int mask)
Check the given pick mask against the node's internal pick mask representation. If there is a match in one or more bitfields then this will return true, allowing picking to continue to process for this target.

Specified by:
checkPickMask in interface PickTarget
Parameters:
mask - The bit mask to check against
Returns:
true if the mask has an overlapping set of bitfields

getPickableBounds

public BoundingVolume getPickableBounds()
Get the bounds of this picking target so that testing can be performed on the object.

Specified by:
getPickableBounds in interface PickTarget
Returns:
A representation of the volume representing the pickable objects

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
Overrides:
equals in class java.lang.Object
Parameters:
o - The object to be compared
Returns:
True if these represent the same values

getGeometry

public Geometry getGeometry()
Get the current geometry associated with this shape.

Returns:
the current instance

setGeometry

public void setGeometry(Geometry newGeom)
                 throws InvalidWriteTimingException
Set the geometry for this shape. A null value will clear the geometry.

Parameters:
newGeom - The geometry
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener bounds changed callback method

getAppearance

public Appearance getAppearance()
Get the current appearance associated with this shape.

Returns:
the current instance

setAppearance

public void setAppearance(Appearance newApp)
                   throws InvalidWriteTimingException
Set the appearance for this shape.

Parameters:
newApp - The appearance
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

compareTo

public int compareTo(Shape3D sh)
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:
sh - The argument instance to be compared
Returns:
-1, 0 or 1 depending on order

equals

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

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

Aviatrix3D
2.1.0

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