Class GRShadedShape
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
- Direct Known Subclasses:
Box3D
,CircularSweep3D
,Cone3D
,Cylinder3D
,Loader3D
,PolyCylinder3D
,Sphere3D
,TextString3D
,Torus3D
public abstract class GRShadedShape extends 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:
- Ptolemy II 1.0
- Version:
- $Id$
- Author:
- C. Fong, Steve Neuendorffer, Edward A. Lee
- Pt.AcceptedRating:
- Green (liuxj)
- Pt.ProposedRating:
- Green (eal)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description 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.Parameter
allowRuntimeChanges
If true, then changes to parameter values can be made during execution of the model.ColorAttribute
diffuseColor
The diffuse color, which is the color of the object reflecting illumination.ColorAttribute
emissiveColor
The emissive color, which is a color that does not depend on ambient illumination.Parameter
flat
If true, render the facets flat rather than rounded.TypedIOPort
sceneGraphOut
The output port for connecting to other GR Actors in the scene graph.DoubleRangeParameter
shininess
The shininess of the 3D shape.ColorAttribute
specularColor
The specular color, which is a color of a highlight reflecting ambient illumination.FileParameter
texture
Texture URL, which if non-empty, specifies an image file or URL.DoubleRangeParameter
transparency
The transparency, where 0.0 means opaque (the default) and 1.0 means fully transparent.Parameter
wireFrame
If true, render the shape using a wire frame.-
Fields inherited from class ptolemy.domains.gr.kernel.GRActor3D
_viewScreen
-
Fields inherited from class ptolemy.domains.gr.kernel.GRActor
_allowAttributeChanges, _isSceneGraphInitialized
-
Fields inherited from class ptolemy.actor.TypedAtomicActor
_typesValid
-
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
-
-
Constructor Summary
Constructors Constructor Description GRShadedShape(CompositeEntity container, java.lang.String name)
Construct an actor with the given container and name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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(GRActor actor)
Override the base class to set the texture, if one is specified, now that the view screen is known.void
attributeChanged(Attribute attribute)
Adjust the appearance when an attribute changes if such an update is supported by the allowRuntimeChanges parameter.java.lang.Object
clone(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 ptolemy.domains.gr.kernel.GRActor3D
_addChild, _getNodeObject
-
Methods inherited from class ptolemy.actor.TypedAtomicActor
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate
-
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
-
Methods inherited from class ptolemy.kernel.Entity
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
-
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
-
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, postfire, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, removeInitializable
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
allowRuntimeChanges
public 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 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 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 TypedIOPort sceneGraphOut
The output port for connecting to other GR Actors in the scene graph. The type is SceneGraphToken.
-
shininess
public 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 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 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 DoubleRangeParameter transparency
The transparency, where 0.0 means opaque (the default) and 1.0 means fully transparent. The type is double.
-
wireFrame
public Parameter wireFrame
If true, render the shape using a wire frame. This is a boolean that defaults to false.
-
flat
public 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(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Construct an actor with the given container and name.- Parameters:
container
- The container.name
- The name of this actor.- Throws:
IllegalActionException
- If the actor cannot be contained by the proposed container.NameDuplicationException
- If the container already has an actor with this name.
-
-
Method Detail
-
attributeChanged
public void attributeChanged(Attribute attribute) throws IllegalActionException
Adjust the appearance when an attribute changes if such an update is supported by the allowRuntimeChanges parameter.- Overrides:
attributeChanged
in classNamedObj
- Parameters:
attribute
- The attribute that changed.- Throws:
IllegalActionException
- If the change is not acceptable to this container (not thrown in this base class).
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Override the base class to null out private variables.- Overrides:
clone
in classTypedAtomicActor
- Parameters:
workspace
- The workspace for the new object.- Returns:
- A new actor.
- Throws:
java.lang.CloneNotSupportedException
- If a derived class contains an attribute that cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
initialize
public void initialize() throws IllegalActionException
Create the Java3D geometry and appearance for this GR actor.- Specified by:
initialize
in interfaceInitializable
- Overrides:
initialize
in classGRActor
- Throws:
IllegalActionException
- If the current director is not a GRDirector.
-
prefire
public boolean prefire() throws IllegalActionException
Return false if the scene graph is already initialized.- Specified by:
prefire
in interfaceExecutable
- Overrides:
prefire
in classAtomicActor<TypedIOPort>
- Returns:
- False if the scene graph is already initialized.
- Throws:
IllegalActionException
- Not thrown in this base class
-
preinitialize
public void preinitialize() throws IllegalActionException
Override the base class to ensure that material and appearance objects are created anew.- Specified by:
preinitialize
in interfaceInitializable
- Overrides:
preinitialize
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- If the current director is not a GRDirector.
-
wrapup
public void wrapup() throws IllegalActionException
Override the base class to set to null the references to appearance and material. This prevents changes after the model has finished executing.- Specified by:
wrapup
in interfaceInitializable
- Overrides:
wrapup
in classGRActor
- Throws:
IllegalActionException
- If the current director is not a GRDirector.
-
_createAppearance
protected void _createAppearance() throws 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:
IllegalActionException
- If a parameter cannot be evaluated.
-
_createModel
protected void _createModel() throws 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:
IllegalActionException
- If a parameter cannot be evaluated.
-
_makeSceneGraphConnection
protected void _makeSceneGraphConnection() throws IllegalActionException
Send the scene graph token on the output.- Specified by:
_makeSceneGraphConnection
in classGRActor
- Throws:
IllegalActionException
- Always thrown for this base class.
-
_setViewScreen
protected void _setViewScreen(GRActor actor) throws IllegalActionException
Override the base class to set the texture, if one is specified, now that the view screen is known.- Overrides:
_setViewScreen
in classGRActor3D
- Parameters:
actor
- The view screen actor.- Throws:
IllegalActionException
- If the given actor is not a ViewScreen3D or if an invalid texture is specified.
-
-