I recently wrote a simple scene traversal algorithm to go through the
BranchGroup that the OBJ loader returns. This should get you started, you
may have to tweak it to do what you need, change the capability bits and
what not.
- Anthony
/**
* Traverse scene graph to set terrain following capabilities for all
objects.
* @param pGroup Base group to start at.
*/
private void traverseGroup( BranchGroup pGroup ) {
Object child;
Shape3D shape;
Enumeration children = pGroup.getAllChildren();
while ( children.hasMoreElements() ) {
child = children.nextElement();
if ( child instanceof BranchGroup ) {
((BranchGroup)child).setPickable(true);
traverseGroup( (BranchGroup)child );
}
else if ( child instanceof Shape3D ) {
shape = (Shape3D)child;
shape.setCapability( Shape3D.ALLOW_GEOMETRY_READ );
parseGeometry( shape );
}
}
}
/**
* Parse all the geometry in a Shape3D to set terrain following
capibilities.
* @param pShape Shape to parse through.
*/
private void parseGeometry( Shape3D pShape ) {
Object obj;
GeometryArray geometry;
Enumeration geometries = pShape.getAllGeometries();
while ( geometries.hasMoreElements() ) {
obj = geometries.nextElement();
if ( obj instanceof GeometryArray ) {
geometry = (GeometryArray)obj;
geometry.setCapability( GeometryArray.ALLOW_COORDINATE_READ |
GeometryArray.ALLOW_FORMAT_READ |
GeometryArray.ALLOW_COUNT_READ );
}
}
}
----- Original Message -----
From: "Phos77" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, January 15, 2003 12:34 PM
Subject: [JAVA3D] [Pick capability]
> | Hi all,
> | I've loaded a VRML file using VRML97 loader (vrml97.jar).
> | Now I want to be able to set the capability bit to pick objects in the
> VRML
> | scene I've just loaded.
> | I want to set this bit for every Shape3D...
> | How is it possible?
> |
> | Thank you very much for any help!
> |
> | Fausto Mancini
> |
> |
>
>
===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff JAVA3D-INTEREST". For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".