public abstract class FieldPortrayal3D extends FieldPortrayal implements Portrayal3D
This class implements the getModel() function by breaking it down into two subsidiary functions which Field Portrayals need to implement: the createModel(...) and updateModel(...) functions.
FieldPortrayal3D maintains a user-modifiable transform called internalTransform, provides an additional layer of transform indirection goodness. internalTransform should be used primarily to adjust the location of the FieldPortrayal3D relative to other FieldPortrayal3Ds. Note that the internalTransform is not the root TransformGroup in the scenegraph handed to getModel(...) -- it's child of the root. However, the createModel() and updateModel() functions will see it as the root of their respective scenegraphs.
Many FieldPortrayals need to further transform themselves: for example, grids might need to shift themselves one-half a grid position. These operations should be done privately and should not fool around with internalTransform to get the job done.
Most FieldPortrayal3Ds benefit from knowing if their underlying fields are immutable.
FieldPortrayal3Ds must also implement the completedWrapper() method, which provides them with a PickIntersection and a LocationWrapper found stored in the object at that intersection.
classPortrayals, field, immutableField, portrayalForAll, portrayalForNonNull, portrayalForNull, portrayalForRemainder, portrayals
Constructor and Description |
---|
FieldPortrayal3D() |
FieldPortrayal3D(javax.media.j3d.Transform3D transform) |
Modifier and Type | Method and Description |
---|---|
abstract 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 abstract javax.media.j3d.TransformGroup |
createModel()
Returns a tree structure of the form
InternalTransformGroup[model info].
|
Display3D |
getCurrentDisplay()
Returns the current Display3D, or possibly null if it's not been set yet.
|
GUIState |
getCurrentGUIState()
Returns the current GUIState, or null if no GUIState has been set yet.
|
Portrayal |
getDefaultPortrayal()
Should return a portrayal which can portray any object regardless of
whether it's valid or not
|
protected javax.media.j3d.Transform3D |
getDefaultTransform()
Returns the default internal transform suggested for this FieldPortrayal3D.
|
javax.media.j3d.TransformGroup |
getModel(java.lang.Object obj,
javax.media.j3d.TransformGroup previousTransformGroup)
Produces the requested model.
|
java.lang.Object |
getObjectLocation(java.lang.Object object,
GUIState gui)
Returns the first location in the underlying field of the given object, if such a thing
is reasonable.
|
javax.media.j3d.Transform3D |
getTransform()
Returns a copy of the current internal transform for the FieldPortrayal3D.
|
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).
|
void |
resetTransform()
Resets the internal transform to the value of getDefaultTransform()
|
void |
rotateX(double degrees)
Modifies the internal transform by rotating along the current X axis the provided number of degrees.
|
void |
rotateY(double degrees)
Modifies the internal transform by rotating along the current Y axis the provided number of degrees.
|
void |
rotateZ(double degrees)
Modifies the internal transform by rotating along the current Z axis the provided number of degrees.
|
void |
scale(double value)
Modifies the internal transform by uniformly scaling it in all directions by the provided amount.
|
void |
scale(double sx,
double sy,
double sz)
Modifies the internal transform by scaling it in a nonuniform fashion.
|
void |
setCurrentDisplay(Display3D display)
Sets the current Display3D.
|
void |
setObjectLocation(java.lang.Object obj,
java.lang.Object location,
GUIState gui)
Sets location in the underlying field of the given object, if such a thing
is reasonable.
|
void |
setTransform(javax.media.j3d.Transform3D transform)
Sets the FieldPortrayal3D's internal Transform.
|
void |
transform(javax.media.j3d.Transform3D transform)
Changes the internal transform of the FieldPortrayal3D by
appending to it the provided transform operation.
|
void |
translate(double dx,
double dy,
double dz)
Modifies the internal transform by translating in the provided x, y, and z amounts.
|
protected void |
updateModel(javax.media.j3d.TransformGroup previousTransformGroup)
Returns a tree structure of the form
InternalTransformGroup[model info].
|
getDefaultNullPortrayal, getField, getInspector, getName, getPortrayalForAll, getPortrayalForNonNull, getPortrayalForNull, getPortrayalForObject, getPortrayalForRemainder, getStatus, isDirtyField, isImmutableField, reset, setDirtyField, setField, setImmutableField, setPortrayalForAll, setPortrayalForClass, setPortrayalForNonNull, setPortrayalForNull, setPortrayalForObject, setPortrayalForRemainder, setSelected, setSelected
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getInspector, getName, getStatus, setSelected
public FieldPortrayal3D()
public FieldPortrayal3D(javax.media.j3d.Transform3D transform)
public javax.media.j3d.PolygonAttributes polygonAttributes()
Portrayal3D
polygonAttributes
in interface Portrayal3D
public void setCurrentDisplay(Display3D display)
Portrayal3D
setCurrentDisplay
in interface Portrayal3D
public Display3D getCurrentDisplay()
Portrayal3D
getCurrentDisplay
in interface Portrayal3D
public GUIState getCurrentGUIState()
Portrayal3D
getCurrentGUIState
in interface Portrayal3D
public void setTransform(javax.media.j3d.Transform3D transform)
protected javax.media.j3d.Transform3D getDefaultTransform()
public javax.media.j3d.Transform3D getTransform()
public void transform(javax.media.j3d.Transform3D transform)
public void resetTransform()
public void rotateX(double degrees)
public void rotateY(double degrees)
public void rotateZ(double degrees)
public void translate(double dx, double dy, double dz)
public void scale(double value)
public void scale(double sx, double sy, double sz)
public Portrayal getDefaultPortrayal()
FieldPortrayal
getDefaultPortrayal
in class FieldPortrayal
public javax.media.j3d.TransformGroup getModel(java.lang.Object obj, javax.media.j3d.TransformGroup previousTransformGroup)
The TransformGroup tree structure should be of the form ModelTransformGroup[InternalTransformGroup[model info]].
InternalTransform is a hook for transforming the FieldPortrayal3D. The ModelTransformGroup should not be played with.
getModel
in interface Portrayal3D
protected abstract javax.media.j3d.TransformGroup createModel()
...where InternalTransformGroup is an identity transformgroup whose transform will be modified elsewhere (create it but don't play with it).
protected void updateModel(javax.media.j3d.TransformGroup previousTransformGroup)
...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.
public abstract LocationWrapper completedWrapper(LocationWrapper w, com.sun.j3d.utils.picking.PickIntersection pi, com.sun.j3d.utils.picking.PickResult pr)
public java.lang.Object getObjectLocation(java.lang.Object object, GUIState gui)
getObjectLocation
in class FieldPortrayal
public void setObjectLocation(java.lang.Object obj, java.lang.Object location, GUIState gui)
setObjectLocation
in class FieldPortrayal