sim.portrayal3d
Class SparseFieldPortrayal3D

java.lang.Object
  extended bysim.portrayal.FieldPortrayal
      extended bysim.portrayal3d.FieldPortrayal3D
          extended bysim.portrayal3d.SparseFieldPortrayal3D
All Implemented Interfaces:
Portrayal, Portrayal3D, java.io.Serializable
Direct Known Subclasses:
Continuous3DPortrayal, SparseGrid3DPortrayal

public abstract class SparseFieldPortrayal3D
extends FieldPortrayal3D

Generic functionality for a field portrayal in Java3D mode: It handles the creation and update of the part of the scene it is responsible for, including dynamic addition/deletion of objects. The implementors must provide menas for converting the position of the objects in the field into vecmath.Vector3d through getLocationOfObjectAsVector3d

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class sim.portrayal.FieldPortrayal
FieldPortrayal.CustomInspector
 
Field Summary
 SparseField field
           
protected  javax.media.j3d.Transform3D tmpLocalT
          tmp Transform3D it is reused, since the TGs are copying it internally
protected  javax.vecmath.Vector3d tmpVect
          tmp Vector3d
 
Fields inherited from class sim.portrayal3d.FieldPortrayal3D
overallT
 
Fields inherited from class sim.portrayal.FieldPortrayal
classPortrayals, portrayalForAll, portrayalForNull, portrayalForRemainder, portrayals
 
Constructor Summary
SparseFieldPortrayal3D(SparseField field, double width, double height)
           
SparseFieldPortrayal3D(SparseField field, double x, double y, double width, double height)
           
SparseFieldPortrayal3D(SparseField field, double x, double y, double z, double dx, double dy, double dz)
           
SparseFieldPortrayal3D(SparseField field, javax.media.j3d.Transform3D transf)
           
 
Method Summary
 javax.media.j3d.TransformGroup createModel()
          Create J3D subgraphs for all objects in the field note that each subgraph points to the simulation object it represents, for update purposes.
 Portrayal getDefaultPortrayal()
          Should return a portrayal which can portray any object regardless of whether it's valid or not
abstract  javax.vecmath.Vector3d getLocationOfObjectAsVector3d(java.lang.Object location)
          Instead of allocating a new Vector3d for every call, reuse tmpVect, unless concurrecy is an issue.
 javax.media.j3d.TransformGroup getModel(java.lang.Object obj, javax.media.j3d.TransformGroup modelTG)
          If argument is null, it should behave like createModel; otherwise, it is updateModel.
protected  javax.media.j3d.BranchGroup InsertModelForNewObject(java.lang.Object o, javax.media.j3d.Transform3D localT)
          This function is called from createMode for each object in the field and from the updateModel part of getModel for the new objects.
 void portray(java.lang.Object grid)
           
 
Methods inherited from class sim.portrayal3d.FieldPortrayal3D
completedWrapper, setParentPortrayal
 
Methods inherited from class sim.portrayal.FieldPortrayal
getDefaultNullPortrayal, getField, getInspector, getName, getPortrayalForAll, getPortrayalForNull, getPortrayalForObject, getPortrayalForRemainder, setField, setPortrayalForAll, setPortrayalForClass, setPortrayalForNull, setPortrayalForObject, setPortrayalForRemainder, 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, setSelected
 

Field Detail

field

public SparseField field

tmpVect

protected javax.vecmath.Vector3d tmpVect
tmp Vector3d


tmpLocalT

protected javax.media.j3d.Transform3D tmpLocalT
tmp Transform3D it is reused, since the TGs are copying it internally

Constructor Detail

SparseFieldPortrayal3D

public SparseFieldPortrayal3D(SparseField field,
                              double width,
                              double height)

SparseFieldPortrayal3D

public SparseFieldPortrayal3D(SparseField field,
                              double x,
                              double y,
                              double width,
                              double height)

SparseFieldPortrayal3D

public SparseFieldPortrayal3D(SparseField field,
                              double x,
                              double y,
                              double z,
                              double dx,
                              double dy,
                              double dz)

SparseFieldPortrayal3D

public SparseFieldPortrayal3D(SparseField field,
                              javax.media.j3d.Transform3D transf)
Method Detail

portray

public void portray(java.lang.Object grid)

getDefaultPortrayal

public Portrayal getDefaultPortrayal()
Description copied from class: FieldPortrayal
Should return a portrayal which can portray any object regardless of whether it's valid or not

Specified by:
getDefaultPortrayal in class FieldPortrayal

getLocationOfObjectAsVector3d

public abstract javax.vecmath.Vector3d getLocationOfObjectAsVector3d(java.lang.Object location)
Instead of allocating a new Vector3d for every call, reuse tmpVect, unless concurrecy is an issue.


createModel

public javax.media.j3d.TransformGroup createModel()
Create J3D subgraphs for all objects in the field note that each subgraph points to the simulation object it represents, for update purposes.


InsertModelForNewObject

protected javax.media.j3d.BranchGroup InsertModelForNewObject(java.lang.Object o,
                                                              javax.media.j3d.Transform3D localT)
This function is called from createMode for each object in the field and from the updateModel part of getModel for the new objects. In order to dynamically add/remove the subtrees associated with children, I have to wrap their TGs into BranchGroups.


getModel

public javax.media.j3d.TransformGroup getModel(java.lang.Object obj,
                                               javax.media.j3d.TransformGroup modelTG)
Description copied from interface: Portrayal3D
If argument is null, it should behave like createModel; otherwise, it is updateModel. The newly created version or the updated one should be returned. The sub-scene graph repesented by a portrayal is wraped in a TransformGroup, so the parent could place the child at the apropriate position relative to the parent's coordinate system. The child is responsible for positioning itself relative to its own coordinate system. E.g. if the model assumes the position for an object is the postion of its center/upper-left corner/etc, then the portrayal for the object should have the center/upper-left corner of the J3D model of the object in the origin of its coorniate system.