Interface Portrayal3D
- All Superinterfaces:
Portrayal
- All Known Implementing Classes:
AxesPortrayal3D
,BranchGroupPortrayal3D
,CircledPortrayal3D
,ConePortrayal3D
,ContinuousPortrayal3D
,CubePortrayal3D
,CylinderPortrayal3D
,FieldPortrayal3D
,ImagePortrayal3D
,LabelledPortrayal3D
,LightPortrayal3D
,ObjectGridPortrayal3D
,PrimitivePortrayal3D
,Shape3DPortrayal3D
,SharedPortrayal3D
,SimplePortrayal3D
,SparseFieldPortrayal3D
,SparseGrid2DPortrayal3D
,SparseGridPortrayal3D
,SpherePortrayal3D
,SwitchedPortrayal3D
,TransformedPortrayal3D
,ValueGrid2DPortrayal3D
,ValueGridPortrayal3D
,ValuePortrayal3D
,WireFrameBoxPortrayal3D
A Portrayal3D has two basic functions. getModel(object) provides a Java3D model which draws the representation of an object and can be selected if appropriate. This is the Java3D equivalent to the draw(...) and hitObjects(...) methods in the 2D portrayal code. polygonAttributes() returns the polygon attributes of the Portrayal, enabling certain portrayals to have their vertex forms manipulated by the user via a GUI. This is primarily used for ValueGridPortrayal2D3Ds.
Portrayal3Ds provide their models in the following way: the top level of the object will be a TransformGroup whose Transform3D the Portrayal3D will not fool around with. Instead this TransformGroup is owned by the parent portrayal (say, a Field Portrayal) enabling it to move, rotate, and scale Portrayal3D with relative ease.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the current Display3D, or possibly null if it's not been set yet.Returns the current GUIState, or null if no GUIState has been set yet.javax.media.j3d.TransformGroup
Provides a TransformGroup which defines the node(s) to place in the scenegraph.javax.media.j3d.PolygonAttributes
Provides a PolygonAttributes which can be modified to change the underlying model's attributes (culling, vertex versus point versus fill).void
setCurrentDisplay
(Display3D display) Sets the current Display3D.Methods inherited from interface sim.portrayal.Portrayal
getInspector, getName, getStatus, setSelected
-
Method Details
-
getModel
Provides a TransformGroup which defines the node(s) to place in the scenegraph. This is the Portrayal3D equivalent of Portrayal2D's draw(object, graphics, drawinfo) method.You should hang your model off of the TransformGroup provided. You should not transform that TransformGroup in any way -- it is used elsewhere. Instead if you wish to transform your model (rotate it etc.) you should add your own additional TransformGroup as necessary.
The provided TransformGroup can be null; in this case you need to create and return the outer TransformGroup for the object. If the provided TransformGroup is non-null, you should modify it and return the same.
SimplePortrayals should assume the following contract: at the point that getModel(...) is called, the field portrayal and display will have already been set if it exists, else it will be null.
-
polygonAttributes
javax.media.j3d.PolygonAttributes polygonAttributes()Provides a PolygonAttributes which can be modified to change the underlying model's attributes (culling, vertex versus point versus fill). This is an optional function: you are free to return null -
setCurrentDisplay
Sets the current Display3D. Called by the Display3D on attach(...). -
getCurrentDisplay
Display3D getCurrentDisplay()Returns the current Display3D, or possibly null if it's not been set yet. SimplePortrayals should implement this method by returning a display if it's been set with setCurrentDisplay(...), else returning whatever the field portrayal's got set, else null if there is no field portrayal yet. -
getCurrentGUIState
GUIState getCurrentGUIState()Returns the current GUIState, or null if no GUIState has been set yet. The GUIState will be set *at least* immediately prior to getModel(...). You should implement this method as: { Display3D d = getCurrentDisplay(); return (d == null ? null : d.getSimulation()); }
-