VisualSim.simulators.gr.lib
Class GRShadedShape

java.lang.Object
  extended byVisualSim.kernel.util.NamedObj
      extended byVisualSim.kernel.InstantiableNamedObj
          extended byVisualSim.kernel.Entity
              extended byVisualSim.kernel.ComponentEntity
                  extended byVisualSim.actor.AtomicActor
                      extended byVisualSim.actor.TypedAtomicActor
                          extended byVisualSim.simulators.gr.kernel.GRActor
                              extended byVisualSim.simulators.gr.kernel.GRActor3D
                                  extended byVisualSim.simulators.gr.lib.GRShadedShape
All Implemented Interfaces:
VisualSim.actor.Actor, VisualSim.kernel.util.Changeable, java.lang.Cloneable, VisualSim.kernel.util.Debuggable, VisualSim.kernel.util.DebugListener, VisualSim.kernel.util.Derivable, VisualSim.actor.Executable, VisualSim.kernel.util.Instantiable, VisualSim.kernel.util.ModelErrorHandler, VisualSim.kernel.util.MoMLExportable, VisualSim.kernel.util.Moveable, VisualSim.kernel.util.Nameable, java.io.Serializable, VisualSim.actor.TypedActor
Direct Known Subclasses:
Box3D, CircularSweep3D, Cone3D, Cylinder3D, PolyCylinder3D, Sphere3D, TextString3D, Torus3D

public abstract class GRShadedShape
extends VisualSim.simulators.gr.kernel.GRActor3D

An abstract base class for GR Actors that have material and color properties.

The parameter diffuseColor determines the color of the object in the usual sense that it determines the color of light reflected off the object. The default is gray. The parameter emissiveColor specifies a color that is emitted by the object, and hence does not depend on illumination. It is black by default, which means that the object does not emit any light and will be invisible without illumination. The parameter specularColor determines the color of highlights that are reflected by the object if the object is set to be shiny.

The parameter shininess determines the shininess of the object. It ranges from 1.0 (the default) to 128.0, meaning not shiny to very shiny. A shiny object reflects the specularColor, unless it is black, in which case shininess has no effect.

The texture parameter can be used to specify an image file. The specified image will be mapped onto the shape.

The parameter transparency determines the transparency of the object. It ranges from 0.0 (the default) to 1.0, meaning opaque to fully transparent (which makes the object invisible).

The wireFrame parameter can be used to view only the lines that outline the polygons of the object and not the surface. The flat parameter can be set to make rendered polygons flat rather than rounded at the corners.

The allowRuntimeChanges parameter, if true, specifies that changes to parameter values during the execution of the model take effect immediately. By default, this parameter is false, which means that changes to parameter values take effect only on the next run of the model. A value of false yields better performance, but less interactivity. Changing this to true will only have an effect on the next run of the model.

Since:
VisualSim1.0
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class VisualSim.kernel.Entity
VisualSim.kernel.Entity.ContainedObjectsIterator
 
Field Summary
protected  javax.media.j3d.Appearance _appearance
          The appearance of this 3D object.
protected  boolean _changesAllowedNow
          Indicator that changes are currently allowed.
protected  javax.media.j3d.ColoringAttributes _coloringAttributes
          The coloring attributes, or null if not created.
protected  javax.media.j3d.Material _material
          The material of this 3D object.
protected  javax.media.j3d.PolygonAttributes _polygonAttributes
          Polygon attributes.
protected  javax.media.j3d.TransparencyAttributes _transparencyAttributes
          The transparency attributes, or null if not created.
 VisualSim.data.expr.Parameter allowRuntimeChanges
          If true, then changes to parameter values can be made during execution of the model.
 VisualSim.actor.gui.ColorAttribute diffuseColor
          The diffuse color, which is the color of the object reflecting illumination.
 VisualSim.actor.gui.ColorAttribute emissiveColor
          The emissive color, which is a color that does not depend on ambient illumination.
 VisualSim.data.expr.Parameter flat
          If true, render the facets flat rather than rounded.
 VisualSim.actor.TypedIOPort sceneGraphOut
          The output port for connecting to other GR Actors in the scene graph.
 VisualSim.actor.parameters.DoubleRangeParameter shininess
          The shininess of the 3D shape.
 VisualSim.actor.gui.ColorAttribute specularColor
          The specular color, which is a color of a highlight reflecting ambient illumination.
 VisualSim.data.expr.FileParameter texture
          Texture URL, which if non-empty, specifies an image file or URL.
 VisualSim.actor.parameters.DoubleRangeParameter transparency
          The transparency, where 0.0 means opaque (the default) and 1.0 means fully transparent.
 VisualSim.data.expr.Parameter wireFrame
          If true, render the shape using a wire frame.
 
Fields inherited from class VisualSim.simulators.gr.kernel.GRActor3D
_viewScreen
 
Fields inherited from class VisualSim.simulators.gr.kernel.GRActor
_allowAttributeChanges, _isSceneGraphInitialized
 
Fields inherited from class VisualSim.actor.AtomicActor
_stopRequested, Block_Documentation
 
Fields inherited from class VisualSim.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Fields inherited from interface VisualSim.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
 
Constructor Summary
GRShadedShape(VisualSim.kernel.CompositeEntity container, java.lang.String name)
          Construct an actor with the given container and name.
 
Method Summary
protected  void _createAppearance()
          Create the material appearance of the shaded 3D actor.
protected  void _createModel()
          Set the color and appearance of this 3D object.
protected  void _makeSceneGraphConnection()
          Send the scene graph token on the output.
protected  void _setViewScreen(VisualSim.simulators.gr.kernel.GRActor actor)
          Override the base class to set the texture, if one is specified, now that the view screen is known.
 void attributeChanged(VisualSim.kernel.util.Attribute attribute)
          Adjust the appearance when an attribute changes if such an update is supported by the allowRuntimeChanges parameter.
 java.lang.Object clone(VisualSim.kernel.util.Workspace workspace)
          Override the base class to null out private variables.
 void initialize()
          Create the Java3D geometry and appearance for this GR actor.
 boolean prefire()
          Return false if the scene graph is already initialized.
 void preinitialize()
          Override the base class to ensure that material and appearance objects are created anew.
 void wrapup()
          Override the base class to set to null the references to appearance and material.
 
Methods inherited from class VisualSim.simulators.gr.kernel.GRActor3D
_addChild, _getNodeObject, _startRenderer, _stopRenderer
 
Methods inherited from class VisualSim.simulators.gr.kernel.GRActor
fire
 
Methods inherited from class VisualSim.actor.TypedAtomicActor
_addPort, attributeTypeChanged, clone, newPort, typeConstraintList
 
Methods inherited from class VisualSim.actor.AtomicActor
_createReceivers, connectionsChanged, getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, iterate, newReceiver, outputPortList, postfire, pruneDependencies, removeDependency, setContainer, stop, stopFire, terminate
 
Methods inherited from class VisualSim.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
 
Methods inherited from class VisualSim.kernel.Entity
_description, _exportMoMLContents, _removePort, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName, validateSettables
 
Methods inherited from class VisualSim.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition
 
Methods inherited from class VisualSim.kernel.util.NamedObj
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeList, attributeList, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setNormalDebugging, setPersistent, setSource, setVerboseDebugging, sortContainedObjects, toplevel, toString, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface VisualSim.actor.Actor
getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, newReceiver, outputPortList
 
Methods inherited from interface VisualSim.actor.Executable
iterate, postfire, stop, stopFire, terminate
 
Methods inherited from interface VisualSim.kernel.util.Nameable
description, getContainer, getFullName, getName, getName, setName
 
Methods inherited from interface VisualSim.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
 

Field Detail

allowRuntimeChanges

public VisualSim.data.expr.Parameter allowRuntimeChanges
If true, then changes to parameter values can be made during execution of the model. This is a boolean that defaults to false.


diffuseColor

public VisualSim.actor.gui.ColorAttribute diffuseColor
The diffuse color, which is the color of the object reflecting illumination. Note that the alpha value (the fourth element of the array), which would normally specify transparency, is ignored. The default color is grey.


emissiveColor

public VisualSim.actor.gui.ColorAttribute emissiveColor
The emissive color, which is a color that does not depend on ambient illumination. Note that the alpha value (the fourth element of the array), which would normally specify transparency, is ignored. The default color is black, which means that there is no emissive color (illumination is required).


sceneGraphOut

public VisualSim.actor.TypedIOPort sceneGraphOut
The output port for connecting to other GR Actors in the scene graph. The type is SceneGraphToken.


shininess

public VisualSim.actor.parameters.DoubleRangeParameter shininess
The shininess of the 3D shape. This parameter should contain a DoubleToken in the range 1.0 to 128.0, where 1.0 represents not shiny and 128.0 represents very shiny. This is a double with default 1.0.


specularColor

public VisualSim.actor.gui.ColorAttribute specularColor
The specular color, which is a color of a highlight reflecting ambient illumination. Note that the alpha value (the fourth element of the array), which would normally specify transparency, is ignored. The default color is white, which means that the illumination is reflected white.


texture

public VisualSim.data.expr.FileParameter texture
Texture URL, which if non-empty, specifies an image file or URL. The image from the file is mapped onto the shape as a texture.


transparency

public VisualSim.actor.parameters.DoubleRangeParameter transparency
The transparency, where 0.0 means opaque (the default) and 1.0 means fully transparent. The type is double.


wireFrame

public VisualSim.data.expr.Parameter wireFrame
If true, render the shape using a wire frame. This is a boolean that defaults to false.


flat

public VisualSim.data.expr.Parameter flat
If true, render the facets flat rather than rounded. This is a boolean that defaults to false.


_appearance

protected javax.media.j3d.Appearance _appearance
The appearance of this 3D object.


_changesAllowedNow

protected boolean _changesAllowedNow
Indicator that changes are currently allowed.


_coloringAttributes

protected javax.media.j3d.ColoringAttributes _coloringAttributes
The coloring attributes, or null if not created.


_material

protected javax.media.j3d.Material _material
The material of this 3D object.


_polygonAttributes

protected javax.media.j3d.PolygonAttributes _polygonAttributes
Polygon attributes.


_transparencyAttributes

protected javax.media.j3d.TransparencyAttributes _transparencyAttributes
The transparency attributes, or null if not created.

Constructor Detail

GRShadedShape

public GRShadedShape(VisualSim.kernel.CompositeEntity container,
                     java.lang.String name)
              throws VisualSim.kernel.util.IllegalActionException,
                     VisualSim.kernel.util.NameDuplicationException
Construct an actor with the given container and name.

Parameters:
container - The container.
name - The name of this actor.
Throws:
VisualSim.kernel.util.IllegalActionException - If the actor cannot be contained by the proposed container.
VisualSim.kernel.util.NameDuplicationException - If the container already has an actor with this name.
Method Detail

attributeChanged

public void attributeChanged(VisualSim.kernel.util.Attribute attribute)
                      throws VisualSim.kernel.util.IllegalActionException
Adjust the appearance when an attribute changes if such an update is supported by the allowRuntimeChanges parameter.

Throws:
VisualSim.kernel.util.IllegalActionException

clone

public java.lang.Object clone(VisualSim.kernel.util.Workspace workspace)
                       throws java.lang.CloneNotSupportedException
Override the base class to null out private variables.

Throws:
java.lang.CloneNotSupportedException

initialize

public void initialize()
                throws VisualSim.kernel.util.IllegalActionException
Create the Java3D geometry and appearance for this GR actor.

Throws:
VisualSim.kernel.util.IllegalActionException - If the current director is not a GRDirector.

prefire

public boolean prefire()
                throws VisualSim.kernel.util.IllegalActionException
Return false if the scene graph is already initialized.

Returns:
False if the scene graph is already initialized.
Throws:
VisualSim.kernel.util.IllegalActionException - Not thrown in this base class

preinitialize

public void preinitialize()
                   throws VisualSim.kernel.util.IllegalActionException
Override the base class to ensure that material and appearance objects are created anew.

Throws:
VisualSim.kernel.util.IllegalActionException - If the current director is not a GRDirector.

wrapup

public void wrapup()
            throws VisualSim.kernel.util.IllegalActionException
Override the base class to set to null the references to appearance and material. This prevents changes after the model has finished executing.

Throws:
VisualSim.kernel.util.IllegalActionException - If the current director is not a GRDirector.

_createAppearance

protected void _createAppearance()
                          throws VisualSim.kernel.util.IllegalActionException
Create the material appearance of the shaded 3D actor. This has the side effect of setting the protected variable _changesAllowedNow so that derived classes can check it.

Throws:
VisualSim.kernel.util.IllegalActionException - If a parameter cannot be evaluated.

_createModel

protected void _createModel()
                     throws VisualSim.kernel.util.IllegalActionException
Set the color and appearance of this 3D object. This has the side effect of setting the protected variable _changesAllowedNow so that derived classes can check it.

Throws:
VisualSim.kernel.util.IllegalActionException - If a parameter cannot be evaluated.

_makeSceneGraphConnection

protected void _makeSceneGraphConnection()
                                  throws VisualSim.kernel.util.IllegalActionException
Send the scene graph token on the output.

Throws:
VisualSim.kernel.util.IllegalActionException

_setViewScreen

protected void _setViewScreen(VisualSim.simulators.gr.kernel.GRActor actor)
                       throws VisualSim.kernel.util.IllegalActionException
Override the base class to set the texture, if one is specified, now that the view screen is known.

Throws:
VisualSim.kernel.util.IllegalActionException - If the given actor is not a ViewScreen3D or if an invalid texture is specified.