sim.portrayal3d.grid
Class ObjectGridPortrayal3D
java.lang.Object
sim.portrayal.FieldPortrayal
sim.portrayal3d.FieldPortrayal3D
sim.portrayal3d.grid.ObjectGridPortrayal3D
- All Implemented Interfaces:
- java.io.Serializable, Portrayal, Portrayal3D
public class ObjectGridPortrayal3D
- extends FieldPortrayal3D
Portrays ObjectGrid2D and ObjectGrid3D in 3D space. A (0,0) or (0,0,0) object is centered
on the origin. 2D fields are spread through the XY plane and are presumed to have Z=0.
You should be aware that ObjectGrid3DPortrayal3D is slow, especially if objects change
a lot at given locations. This is because it has to update
all the objects on a per location basis rather than on a per object basis.
This is a worst-case scenario for Java3D.
Note for Java3D users: We experimented with a number of approaches to dealing with this.
One approach was to use shared groups and only portray an object once, then use links to draw
it in many locations. This has two subapproaches: you can wrap the link in a BranchGroup and
replace it and the BranchGroup when the object changes at that location; or you can just change
the link directly. The first approach is very slow (building BranchGroups isn't efficient).
The second approach has promise, but there are grievous bugs in Java3D's handling of links
which generate all sorts of race conditions with array bounds exceptions and null pointer exceptions
etc. internal to Java3D when you change the SharedGroup that a link is pointing to. Ultimately
we just gave up and used BranchGroups wrapping whole new submodels, entire copies for each
location. Memory inefficient, but it's the fastest method we have figured out which doesn't
break with stupid Sun bugs. It's also fairly simple to grok. Sorry.
- See Also:
- Serialized Form
Method Summary |
LocationWrapper |
completedWrapper(LocationWrapper w,
com.sun.j3d.utils.picking.PickIntersection pi,
com.sun.j3d.utils.picking.PickResult pr)
Given the provided PickIntersection and the PickResult it came from, fill in w the location of
the picked object, and return it. |
protected javax.media.j3d.TransformGroup |
createModel()
Returns a tree structure of the form
InternalTransform[model info]. |
void |
setField(java.lang.Object field)
Sets the field. |
protected void |
updateModel(javax.media.j3d.TransformGroup globalTG)
Returns a tree structure of the form
InternalTransform[model info]. |
Methods inherited from class sim.portrayal3d.FieldPortrayal3D |
getDefaultPortrayal, getDefaultTransform, getModel, getTransform, polygonAttributes, resetTransform, rotateX, rotateY, rotateZ, scale, scale, setTransform, transform, translate |
Methods inherited from class sim.portrayal.FieldPortrayal |
getDefaultNullPortrayal, getField, getInspector, getName, getPortrayalForAll, getPortrayalForNonNull, getPortrayalForNull, getPortrayalForObject, getPortrayalForRemainder, getStatus, isImmutableField, setImmutableField, setPortrayalForAll, setPortrayalForClass, setPortrayalForNonNull, setPortrayalForNull, setPortrayalForObject, setPortrayalForRemainder, setSelected |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ObjectGridPortrayal3D
public ObjectGridPortrayal3D()
createModel
protected javax.media.j3d.TransformGroup createModel()
- Description copied from class:
FieldPortrayal3D
- Returns a tree structure of the form
InternalTransform[model info].
...where InternalTransform is an identity transformgroup whose transform will be
modified elsewhere (create it but don't play with it).
- Specified by:
createModel
in class FieldPortrayal3D
updateModel
protected void updateModel(javax.media.j3d.TransformGroup globalTG)
- Description copied from class:
FieldPortrayal3D
- Returns a tree structure of the form
InternalTransform[model info].
...where InternalTransform is an identity transformgroup whose transform will be
modified elsewhere (don't play with it). By default, this function does nothing.
Override it to update the model when it's called.
- Overrides:
updateModel
in class FieldPortrayal3D
setField
public void setField(java.lang.Object field)
- Description copied from class:
FieldPortrayal
- Sets the field. Also sets dirtyField = true. May throw an exception if the field is inappropriate.
- Specified by:
setField
in class FieldPortrayal
completedWrapper
public LocationWrapper completedWrapper(LocationWrapper w,
com.sun.j3d.utils.picking.PickIntersection pi,
com.sun.j3d.utils.picking.PickResult pr)
- Description copied from class:
FieldPortrayal3D
- Given the provided PickIntersection and the PickResult it came from, fill in w the location of
the picked object, and return it. Alternatively, return a new LocationWrapper with all
information filled in. The PickResult is provided you in case the object is in a shared
group and you need to identify what link had connected to it.
- Specified by:
completedWrapper
in class FieldPortrayal3D