|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsim.portrayal3d.SimplePortrayal3D
public class SimplePortrayal3D
The superclass of all 3D Simple Portrayals which by default adds nothing to the 3D scene. Since nothing is added to the scene, nothing is shown and you cannot select anything. Subclasses add items to the scene, so they can then be selected if they so choose. By default SimplePortrayal3Ds respond to requests for inspectors by providing a basic LabelledList which shows all the portrayed object's object properties (see sim.util.SimpleProperties). They also respond to inspector update requests by updating this same LabelledList. No polygonAttributes are provided by default, and setSelected always true by default.
SimplePortrayal3Ds have a parentPortrayal, which is the FieldPortrayal3D which houses them. This value can be null if the SimplePortrayal3D was added directly into the Display3D's collection of portrayals rather than being used inside a field portrayal. The contract SimplePortrayal3Ds may assume is that the parentPortrayal, if it exists, will have been set prior to getModel(...) being called.
Various utility functions are provided. setPickableFlags makes a Java3D object pickable (necessary for inspectability and selection). clearPickableFlags does the opposite. appearanceForColor creates a Java3D appearance that's a flat version of the color which requires no lighting -- a very basic default appearance function. If the color has a degree of transparency, the appearance will as well.
A default appearance is provided for subclasses which wish to draw themselves using a default: flat white opaque.
Field Summary | |
---|---|
static javax.media.j3d.Appearance |
DEFAULT_APPEARANCE
Flat white opaque. |
protected FieldPortrayal3D |
parentPortrayal
Used by the SimplePortrayal3D to add its parent to its pickInfo object when the user picks the SimplePortrayal3D. |
Constructor Summary | |
---|---|
SimplePortrayal3D()
|
Method Summary | |
---|---|
static javax.media.j3d.Appearance |
appearanceForColor(java.awt.Color unlitColor)
Creates an Appearance equivalent to a flat opaque surface of the provided color, needing no lighting. |
static javax.media.j3d.Appearance |
appearanceForColors(java.awt.Color ambientColor,
java.awt.Color emissiveColor,
java.awt.Color diffuseColor,
java.awt.Color specularColor,
float shininess,
float opacity)
Creates an Appearance with the provided lit colors. |
static javax.media.j3d.Appearance |
appearanceForImage(java.awt.Image image,
boolean opaque)
Creates an Appearance using the provided image. |
static void |
clearPickableFlags(javax.media.j3d.Node n)
Utility method which makes the given Node unpickable. |
Inspector |
getInspector(LocationWrapper wrapper,
GUIState state)
Provide an inspector for an object. |
javax.media.j3d.TransformGroup |
getModel(java.lang.Object object,
javax.media.j3d.TransformGroup prev)
Provides a TransformGroup which defines the node(s) to place in the scenegraph. |
java.lang.String |
getName(LocationWrapper wrapper)
Returns a static, one-line name for the given object that is useful for a human to distinguish it from other objects. |
java.lang.String |
getStatus(LocationWrapper wrapper)
Returns a simple, informative one-line description of the current status of the object, which may change at any time to reflect how the object is changing. |
boolean |
isSelected(java.lang.Object obj)
|
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). |
static void |
setAppearanceFlags(javax.media.j3d.Appearance a)
Sets a variety of flags on an Appearance so that its features can be modified when the scene is live. |
void |
setParentPortrayal(FieldPortrayal3D p)
Sets the parent portrayal (a FieldPortrayal3D). |
static void |
setPickableFlags(javax.media.j3d.Geometry geom)
Utility method which prepares the given Geometry to be pickable (for selection and inspection). |
static void |
setPickableFlags(javax.media.j3d.Shape3D s3d)
Utility method which prepares the given Shape3D to be pickable (for selection and inspection). |
boolean |
setSelected(LocationWrapper wrapper,
boolean selected)
If the object is selected, adds it to a hash table of selected objects for which this SimplePortrayal3D's isSelected() method will return TRUE. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final javax.media.j3d.Appearance DEFAULT_APPEARANCE
protected FieldPortrayal3D parentPortrayal
Constructor Detail |
---|
public SimplePortrayal3D()
Method Detail |
---|
public static javax.media.j3d.Appearance appearanceForColor(java.awt.Color unlitColor)
public static javax.media.j3d.Appearance appearanceForColors(java.awt.Color ambientColor, java.awt.Color emissiveColor, java.awt.Color diffuseColor, java.awt.Color specularColor, float shininess, float opacity)
public static javax.media.j3d.Appearance appearanceForImage(java.awt.Image image, boolean opaque)
public javax.media.j3d.PolygonAttributes polygonAttributes()
Portrayal3D
polygonAttributes
in interface Portrayal3D
public javax.media.j3d.TransformGroup getModel(java.lang.Object object, javax.media.j3d.TransformGroup prev)
Portrayal3D
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 parentPortrayal will have already been set if it exists, else it will be null.
getModel
in interface Portrayal3D
public Inspector getInspector(LocationWrapper wrapper, GUIState state)
Portrayal
getInspector
in interface Portrayal
public java.lang.String getStatus(LocationWrapper wrapper)
Portrayal
getStatus
in interface Portrayal
public java.lang.String getName(LocationWrapper wrapper)
Portrayal
getName
in interface Portrayal
public void setParentPortrayal(FieldPortrayal3D p)
public boolean isSelected(java.lang.Object obj)
public boolean setSelected(LocationWrapper wrapper, boolean selected)
There are two implications to this approach. First, it means that after you've selected an object, there's a hash table attached to its portrayal. If you're using the same portrayal for lots of stuff, that's no big deal. But if you've got per-object portrayals and a lot of objects (or if the objects are themselves SimplePortrayal3D subclasses) then that's a fair number of hash tables. This is a minor memory issue but if you don't care about testing for whether you've been selected or not, you could just override this method to always return TRUE (and don't call super.selected(...) ) and the hash table will never be created. Note that isSelected will always return FALSE for your portrayal in this situation.
Second, though you can test for selection with the isSelected() method, if you want to, say, change the look of your portrayal based on whether or not it's selected, you will need to test isSelected() each time getModel() is called and modify the model accordingly. This could be a bit expensive. We're working on an approach for you to be able to test if the object was RECENTLY selected or deselected so you could only test then, but it's nontrivial to do without using up a lot of memory.
setSelected
in interface Portrayal
public static void setAppearanceFlags(javax.media.j3d.Appearance a)
public static void setPickableFlags(javax.media.j3d.Shape3D s3d)
public static void setPickableFlags(javax.media.j3d.Geometry geom)
public static void clearPickableFlags(javax.media.j3d.Node n)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |