|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--pickingExt.PickObject
Contains methods to aid in picking. A PickObject is created for a given Canvas3D and a BranchGroup. SceneGraphObjects under the specified BranchGroup can then be checked to determine if they have been picked.
The pick modes are PICK_BOUNDS and PICK_GEOMETRY. PICK_BOUNDS traverses the scene graph and returns the SceneGraphPaths whose bounds intersect the pick shape. PICK_GEOMETRY takes the result of a PICK_BOUNDS then returns the SceneGraphPaths whose geometry intersects the pick shape.
The pick shape is generated using the x,y location of the pick and the pick shape mode. The pick shape modes are SHAPE_RAY, SHAPE_APERTURE and SHAPE_RAY_APERTURE. SHAPE_RAY generates a PickRay through the x,y location of the pick for use for both the bounds and geometry phases of the pick. SHAPE_APERTURE generates a PickBounds (using a BoundingPolytope) around the x,y location of the pick in the shape specified by the pick aperture. The PickBounds is is used for both the bounds and geometry phases of the pick. SHAPE_RAY_APERTURE uses a PickRay for the bounds phase of the pick and then a PickBounds for the geometry phase of the pick.
The best performance comes from doing PICK_BOUNDS picking using a SHAPE_RAY pick shape.
More accurate picks come from using PICK_GEOMETRY. When using PICK_GEOMETRY, the ALLOW_INTERSECT bit must be set on the Shape3D nodes to be picked. Picking lines is difficult or impossible using SHAPE_RAY, use SHAPE_APERTURE or SHAPE_RAY_APERTURE instead. SHAPE_RAY_APERTURE should give better performance than SHAPE_APERTURE, but it may make it slightly harder to pick shapes that are near the back of the scene.
Field Summary | |
static int |
BRANCH_GROUP
A flag to indicate to the pickNode method to return a BranchGroup
node from a given SceneGraphPath . |
static int |
GROUP
A flag to indicate to the pickNode method to return a Group node from
a given SceneGraphPath . |
static int |
LINK
A flag to indicate to the pickNode method to return a Link node from
a given SceneGraphPath . |
static int |
MORPH
A flag to indicate to the pickNode method to return a Morph node from
a given SceneGraphPath . |
static int |
PRIMITIVE
A flag to indicate to the pickNode method to return a Primitive node
from a given SceneGraphPath . |
static int |
SHAPE_APERTURE
Sets the pick shape mode to use an aperture-based pick shape |
static int |
SHAPE_RAY
Sets the pick shape mode to use a ray-based pick shape |
static int |
SHAPE_RAY_APERTURE
Sets the pick shape mode to use a ray-based pick shape for bounds intersections and an aperture-based pick shape for geometry intersections |
static int |
SHAPE3D
A flag to indicate to the pickNode method to return a Shape3D node from
a given SceneGraphPath . |
static int |
SWITCH
A flag to indicate to the pickNode method to return a Switch node from
a given SceneGraphPath . |
static int |
TRANSFORM_GROUP
A flag to indicate to the pickNode method to return a TransformGroup
node from a given SceneGraphPath . |
static int |
USE_BOUNDS
Set this flag if you want to pick by bounds. |
static int |
USE_GEOMETRY
Set this flag if you want to pick by bounds and then geometry. |
Constructor Summary | |
PickObject(javax.media.j3d.Canvas3D c,
javax.media.j3d.BranchGroup root)
Creates a PickObject with a ray-based pick shape |
Method Summary | |
javax.media.j3d.PickBounds |
generatePickAperture(int xpos,
int ypos)
Creates a bounding polytope PickShape which is a set of planes around the point (xpos,ypos). |
javax.media.j3d.PickRay |
generatePickRay(int xpos,
int ypos)
Creates a PickRay that starts at the viewer position and points into the scene in the direction of (xpos, ypos) specified in window space. |
javax.media.j3d.PickShape |
generatePickShape(int xpos,
int ypos,
int pickType)
Creates a PickShape using the window space selection point (xpos, ypos). |
java.awt.Point[] |
getPickAperture()
Returns the pick aperture for SHAPE_APERTURE or SHAPE_RAY_APERTURE mode |
int |
getPickMode()
Returns the pick mode |
int |
getPickShapeMode()
Returns the pick shape mode |
javax.media.j3d.SceneGraphPath[] |
pickAll(int xpos,
int ypos)
Returns an array referencing all the items that are pickable below the BranchGroup (specified in the PickObject constructor) that
intersect with the pick shape specified by the pick shape mode, centered
on the point (xpos, ypos) in window space. |
javax.media.j3d.SceneGraphPath[] |
pickAll(int xpos,
int ypos,
int flag)
Returns an array referencing all the items that are pickable below the BranchGroup (specified in the PickObject constructor) that
intersect with the pick shape specified by the pick shape mode, centered
on the point (xpos, ypos) in window space. |
javax.media.j3d.SceneGraphPath[] |
pickAllSorted(int xpos,
int ypos)
Returns a sorted array of references to all the Pickable items below the BranchGroup (specified in the PickObject constructor) that
intersects with pick shape specified by the pick shape mode, centered
on the point (xpos, ypos) in window space. |
javax.media.j3d.SceneGraphPath[] |
pickAllSorted(int xpos,
int ypos,
int flag)
Returns a sorted array of references to all the Pickable items below the BranchGroup (specified in the PickObject constructor) that
intersects with pick shape specified by the pick shape mode, centered
on the point (xpos, ypos) in window space. |
javax.media.j3d.SceneGraphPath |
pickAny(int xpos,
int ypos)
Returns a reference to any item that is Pickable below the specified BranchGroup (specified in the PickObject constructor) which
intersects with the pick shape specified by the pick shape mode, centered
on the point (xpos, ypos) in window space. |
javax.media.j3d.SceneGraphPath |
pickAny(int xpos,
int ypos,
int flag)
Returns a reference to any item that is Pickable below the specified BranchGroup (specified in the PickObject constructor) which
intersects with the pick shape specified by the pick shape mode, centered
on the point (xpos, ypos) in window space. |
javax.media.j3d.SceneGraphPath |
pickClosest(int xpos,
int ypos)
Returns a reference to the item that is closest to the viewer and is Pickable below the BranchGroup (specified in the PickObject
constructor) which intersects with the pick shape specified by the pick
shape mode, centered on the point (xpos, ypos) in window space. |
javax.media.j3d.SceneGraphPath |
pickClosest(int xpos,
int ypos,
int flag)
Returns a reference to the item that is closest to the viewer and is Pickable below the BranchGroup (specified in the PickObject
constructor) which intersects with the pick shape specified by the pick
shape mode, centered on the point (xpos, ypos) in window space. |
javax.media.j3d.Node |
pickNode(javax.media.j3d.SceneGraphPath sgPath,
int flags)
Returns a reference to a Pickable Node that
is of the specified type
that is contained in the specified SceneGraphPath . |
javax.media.j3d.Node |
pickNode(javax.media.j3d.SceneGraphPath sgPath,
int flags,
int occurrence)
Returns a reference to a Pickable Node that
is of the specified type
that is contained in the specified SceneGraphPath . |
void |
setPickAperture(java.awt.Point[] aperturePts)
Sets the pick aperture for SHAPE_APERTURE or SHAPE_RAY_APERTURE mode |
void |
setPickMode(int mode)
Sets the pick mode |
void |
setPickShapeMode(int mode)
Sets the pick shape mode |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final int SHAPE3D
Shape3D
node from
a given SceneGraphPath
.pickNode(javax.media.j3d.SceneGraphPath, int)
public static final int MORPH
Morph
node from
a given SceneGraphPath
.pickNode(javax.media.j3d.SceneGraphPath, int)
public static final int PRIMITIVE
Primitive
node
from a given SceneGraphPath
.pickNode(javax.media.j3d.SceneGraphPath, int)
public static final int LINK
Link
node from
a given SceneGraphPath
.pickNode(javax.media.j3d.SceneGraphPath, int)
public static final int GROUP
Group
node from
a given SceneGraphPath
.pickNode(javax.media.j3d.SceneGraphPath, int)
public static final int TRANSFORM_GROUP
TransformGroup
node from a given SceneGraphPath
.pickNode(javax.media.j3d.SceneGraphPath, int)
public static final int BRANCH_GROUP
BranchGroup
node from a given SceneGraphPath
.pickNode(javax.media.j3d.SceneGraphPath, int)
public static final int SWITCH
Switch
node from
a given SceneGraphPath
.pickNode(javax.media.j3d.SceneGraphPath, int)
public static final int USE_GEOMETRY
public static final int USE_BOUNDS
public static final int SHAPE_RAY
public static final int SHAPE_APERTURE
public static final int SHAPE_RAY_APERTURE
Constructor Detail |
public PickObject(javax.media.j3d.Canvas3D c, javax.media.j3d.BranchGroup root)
c
- Current J3D canvas.root
- The portion of the scenegraph for which picking is to occur
on. It has to be a BranchGroup
.BranchGroup
,
Canvas3D
Method Detail |
public javax.media.j3d.PickRay generatePickRay(int xpos, int ypos)
xpos
- The value along the x-axis.ypos
- The value along the y-axis.public javax.media.j3d.PickBounds generatePickAperture(int xpos, int ypos)
xpos
- The value along the x-axis.ypos
- The value along the y-axis.public javax.media.j3d.PickShape generatePickShape(int xpos, int ypos, int pickType)
xpos
- The value along the x-axis.ypos
- The value along the y-axis.mode
- The pick mode, either USE_BOUNDS or USE_GEOMETRYpublic void setPickMode(int mode)
mode
- The pick mode, either USE_GEOMETRY or USE_BOUNDS. The default
is USE_BOUNDS.public int getPickMode()
public void setPickShapeMode(int mode)
mode
- The pick shape mode, either SHAPE_RAY, SHAPE_APERTURE, or
SHAPE_RAY_APERTURE. The default is SHAPE_RAY.public int getPickShapeMode()
public void setPickAperture(java.awt.Point[] aperturePts)
Point[]
- aperturePts The pick aperture, which should be a convex,
counter-clockwise loop of Points around 0,0public java.awt.Point[] getPickAperture()
public javax.media.j3d.SceneGraphPath[] pickAll(int xpos, int ypos)
BranchGroup
(specified in the PickObject constructor) that
intersect with the pick shape specified by the pick shape mode, centered
on the point (xpos, ypos) in window space. The resultant array is
unordered.xpos
- The x coordinate of the pick shapeypos
- The y coordinate of the pick shapenull
is returned..SceneGraphPath
public javax.media.j3d.SceneGraphPath[] pickAllSorted(int xpos, int ypos)
BranchGroup
(specified in the PickObject constructor) that
intersects with pick shape specified by the pick shape mode, centered
on the point (xpos, ypos) in window space.
Element [0] references the item closest to viewer.xpos
- The x coordinate of the pick shapeypos
- The y coordinate of the pick shapenull
is returned..SceneGraphPath
public javax.media.j3d.SceneGraphPath pickAny(int xpos, int ypos)
BranchGroup
(specified in the PickObject constructor) which
intersects with the pick shape specified by the pick shape mode, centered
on the point (xpos, ypos) in window space.xpos
- The x coordinate of the pick shapeypos
- The y coordinate of the pick shapenull
is returned..SceneGraphPath
public javax.media.j3d.SceneGraphPath pickClosest(int xpos, int ypos)
BranchGroup
(specified in the PickObject
constructor) which intersects with the pick shape specified by the pick
shape mode, centered on the point (xpos, ypos) in window space.xpos
- The x coordinate of the pick shapeypos
- The y coordinate of the pick shapenull
is returned.SceneGraphPath
public javax.media.j3d.SceneGraphPath[] pickAll(int xpos, int ypos, int flag)
BranchGroup
(specified in the PickObject constructor) that
intersect with the pick shape specified by the pick shape mode, centered
on the point (xpos, ypos) in window space. The resultant array is
unordered.xpos
- The x coordinate of the pick shapeypos
- The y coordinate of the pick shapeflag
- Specifies USE_BOUNDS or USE_GEOMETRYnull
is returned..SceneGraphPath
public javax.media.j3d.SceneGraphPath[] pickAllSorted(int xpos, int ypos, int flag)
BranchGroup
(specified in the PickObject constructor) that
intersects with pick shape specified by the pick shape mode, centered
on the point (xpos, ypos) in window space.
Element [0] references the item closest to viewer.xpos
- The x coordinate of the pick shapeypos
- The y coordinate of the pick shapeflag
- Specifies USE_BOUNDS or USE_GEOMETRYnull
is returned..SceneGraphPath
public javax.media.j3d.SceneGraphPath pickAny(int xpos, int ypos, int flag)
BranchGroup
(specified in the PickObject constructor) which
intersects with the pick shape specified by the pick shape mode, centered
on the point (xpos, ypos) in window space.xpos
- The x coordinate of the pick shapeypos
- The y coordinate of the pick shapeflag
- Specifies USE_BOUNDS or USE_GEOMETRYnull
is returned..SceneGraphPath
public javax.media.j3d.SceneGraphPath pickClosest(int xpos, int ypos, int flag)
BranchGroup
(specified in the PickObject
constructor) which intersects with the pick shape specified by the pick
shape mode, centered on the point (xpos, ypos) in window space.xpos
- The x coordinate of the pick shapeypos
- The y coordinate of the pick shapeflag
- Specifys picking by Geometry or Bounds.null
is returned.SceneGraphPath
public javax.media.j3d.Node pickNode(javax.media.j3d.SceneGraphPath sgPath, int flags)
Node
that
is of the specified type
that is contained in the specified SceneGraphPath
.
If more than one node of the same type is encountered, the node
closest to the Object
will be returned.sgPath
- The SceneGraphPath
to be traversed.flags
- The Node
types interested in picking.Node
type.
Starting from the Locale. If no pickable object is found null
of the specifed types, null
is returned.public javax.media.j3d.Node pickNode(javax.media.j3d.SceneGraphPath sgPath, int flags, int occurrence)
Node
that
is of the specified type
that is contained in the specified SceneGraphPath
.
The Node
returned is the nth occurrence
of a Node
that is of the specified type.sgPath
- The SceneGraphPath
to be traversed.flags
- The Node
types interested.occurrence
- Which occurrence of a Node
that
matches the specified type to return. An occurrence
of
1 means to return the first occurrence of that object type (the object
closest to the viewer).occurrence
of a Node
of type flags
, starting from the Locale. If no pickable object is
found, null
is returned.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |