Class ObjectGridPortrayal3D
- All Implemented Interfaces:
Portrayal
,Portrayal3D
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.
-
Field Summary
Fields inherited from class sim.portrayal.FieldPortrayal
classPortrayals, field, immutableField, portrayalForAll, portrayalForNonNull, portrayalForNull, portrayalForRemainder, portrayals
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncompletedWrapper
(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
Returns a tree structure of the form InternalTransformGroup[model info].void
Sets the field, and sets the dirtyField flag to true.protected void
updateModel
(javax.media.j3d.TransformGroup globalTG) Returns a tree structure of the form InternalTransformGroup[model info].Methods inherited from class sim.portrayal3d.FieldPortrayal3D
getCurrentDisplay, getCurrentGUIState, getDefaultPortrayal, getDefaultTransform, getModel, getObjectLocation, getTransform, polygonAttributes, resetTransform, rotateX, rotateY, rotateZ, scale, scale, setCurrentDisplay, setObjectLocation, setTransform, transform, translate
Methods inherited from class sim.portrayal.FieldPortrayal
getAlternatePortrayalOrdering, getDefaultNullPortrayal, getField, getInspector, getName, getPortrayalForAll, getPortrayalForNonNull, getPortrayalForNull, getPortrayalForObject, getPortrayalForRemainder, getStatus, isDirtyField, isImmutableField, reset, setAlternatePortrayalOrdering, setDirtyField, setImmutableField, setPortrayalForAll, setPortrayalForClass, setPortrayalForNonNull, setPortrayalForNull, setPortrayalForObject, setPortrayalForRemainder, setSelected, setSelected
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface sim.portrayal.Portrayal
getInspector, getName, getStatus, setSelected
-
Constructor Details
-
ObjectGridPortrayal3D
public ObjectGridPortrayal3D()
-
-
Method Details
-
createModel
protected javax.media.j3d.TransformGroup createModel()Description copied from class:FieldPortrayal3D
Returns a tree structure of the form InternalTransformGroup[model info]....where InternalTransformGroup is an identity transformgroup whose transform will be modified elsewhere (create it but don't play with it).
- Specified by:
createModel
in classFieldPortrayal3D
-
updateModel
protected void updateModel(javax.media.j3d.TransformGroup globalTG) Description copied from class:FieldPortrayal3D
Returns a tree structure of the form InternalTransformGroup[model info]....where InternalTransformGroup 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 classFieldPortrayal3D
-
setField
Description copied from class:FieldPortrayal
Sets the field, and sets the dirtyField flag to true. May throw an exception if the field is inappropriate. The default version just sets the field and sets the dirtyField flag.- Overrides:
setField
in classFieldPortrayal
-
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 classFieldPortrayal3D
-