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_appearanceThe appearance of this 3D object.protected boolean_changesAllowedNowIndicator that changes are currently allowed.protected javax.media.j3d.ColoringAttributes_coloringAttributesThe coloring attributes, or null if not created.protected javax.media.j3d.Material_materialThe material of this 3D object.protected javax.media.j3d.PolygonAttributes_polygonAttributesPolygon attributes.protected javax.media.j3d.TransparencyAttributes_transparencyAttributesThe transparency attributes, or null if not created.ParameterallowRuntimeChangesIf true, then changes to parameter values can be made during execution of the model.ColorAttributediffuseColorThe diffuse color, which is the color of the object reflecting illumination.ColorAttributeemissiveColorThe emissive color, which is a color that does not depend on ambient illumination.ParameterflatIf true, render the facets flat rather than rounded.TypedIOPortsceneGraphOutThe output port for connecting to other GR Actors in the scene graph.DoubleRangeParametershininessThe shininess of the 3D shape.ColorAttributespecularColorThe specular color, which is a color of a highlight reflecting ambient illumination.FileParametertextureTexture URL, which if non-empty, specifies an image file or URL.DoubleRangeParametertransparencyThe transparency, where 0.0 means opaque (the default) and 1.0 means fully transparent.ParameterwireFrameIf 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.voidattributeChanged(Attribute attribute)Adjust the appearance when an attribute changes if such an update is supported by the allowRuntimeChanges parameter.java.lang.Objectclone(Workspace workspace)Override the base class to null out private variables.voidinitialize()Create the Java3D geometry and appearance for this GR actor.booleanprefire()Return false if the scene graph is already initialized.voidpreinitialize()Override the base class to ensure that material and appearance objects are created anew.voidwrapup()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:
attributeChangedin 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:
clonein 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 IllegalActionExceptionCreate the Java3D geometry and appearance for this GR actor.- Specified by:
initializein interfaceInitializable- Overrides:
initializein classGRActor- Throws:
IllegalActionException- If the current director is not a GRDirector.
-
prefire
public boolean prefire() throws IllegalActionExceptionReturn false if the scene graph is already initialized.- Specified by:
prefirein interfaceExecutable- Overrides:
prefirein classAtomicActor<TypedIOPort>- Returns:
- False if the scene graph is already initialized.
- Throws:
IllegalActionException- Not thrown in this base class
-
preinitialize
public void preinitialize() throws IllegalActionExceptionOverride the base class to ensure that material and appearance objects are created anew.- Specified by:
preinitializein interfaceInitializable- Overrides:
preinitializein classAtomicActor<TypedIOPort>- Throws:
IllegalActionException- If the current director is not a GRDirector.
-
wrapup
public void wrapup() throws IllegalActionExceptionOverride the base class to set to null the references to appearance and material. This prevents changes after the model has finished executing.- Specified by:
wrapupin interfaceInitializable- Overrides:
wrapupin classGRActor- Throws:
IllegalActionException- If the current director is not a GRDirector.
-
_createAppearance
protected void _createAppearance() throws IllegalActionExceptionCreate 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 IllegalActionExceptionSet 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 IllegalActionExceptionSend the scene graph token on the output.- Specified by:
_makeSceneGraphConnectionin 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:
_setViewScreenin classGRActor3D- Parameters:
actor- The view screen actor.- Throws:
IllegalActionException- If the given actor is not a ViewScreen3D or if an invalid texture is specified.
-
-