Xavier,
You have the following options:
1) The loader you use hopefully supports the Scene.getNamedObjects()
method and using this you can find a quick place to start looking for your
Shape3D nodes. I haven't used this with the .obj loader, but I imagine it
supports. Either way, you may have to traverse the tree, which leads to #2.
Hashtable vrmlNames = vrmlScene.getNamedObjects();
for (Enumeration elems = vrmlNames.keys();elems.hasMoreElements();)
{
Object o = elems.nextElement();
if ( o instanceof Shape3D ) {
<apply your texture to the object appropriately>
}
}
2) You can traverse the tree from the top or from a particular node
returned by Scene.getNamedObjects(). Essentially, you can do something
like the following, where myRoot is the root of your universe or branch
that you wish to operate on. This example sets all Shape3D's in the branch
to wireframe. Obviously you would change this appropriately. Note, I'm
not sure if this works correctly for LINK objects or not--I suspect not.
applyWireframe( Group myRoot ) {
// Iterate through children
for ( int childCount = myRoot.numChildren(); childCount !=0;
childCount-- ) {
// Get reference for object
Object child = childGroup.getChild(0);
// If this is a Shape3D, make it wireframe
if ( child instanceof Shape3D ) {
PolygonAttributes pAttrib;
// Get reference to the shapes polygon attributes
// Note: should really ensure it has an appearance
node first
pAttrib =
((Shape3D)child).getAppearance().getPolygonAttributes();
// Ensure that the polygon attributes exist, if
not create them
if ( pAttrib == null ) {
pAttrib = new PolygonAttributes();
((Shape3D)child).getAppearance().setPolygonAttributes(
pAttrib );
}
// Set polygon attibutes to wireframe
pAttrib.setPolygonMode(
PolygonAttributes.POLYGON_LINE );
}
// If child is a group, recurse
if ( child instanceof Group ) {
applyWireframe( (Group) child);
}
}
Note, if the file you are loading has more than one object, you'll likely
want to add logic to ensure that you apply the texture to the particular
node you wish.
--Mark
At 05:32 PM 7/21/2000 +0200, you wrote:
>Hi fellows !!!
>
>I'm getting a bit nervous with textures... I'm trying to find a way to
>apply texture to an object that i've loaded (a .obj one) but it seems
>that i've missed an issue : the loader gives me a Scene object, i can
>get it's BranchGroup but i don't find methods such setAppearance() for
>shape3D in order to apply a texture.
>
>Can someone help me ?
>
>Xavier
>
>===========================================================================
>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".
Mark Ferneau
Xtivia Technologies, Inc.
[EMAIL PROTECTED]
240-462-6262 (cell)
801-437-4608 (efax)
[EMAIL PROTECTED] (text page)
===========================================================================
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".