| Chris Lambert 2003-12-05, 9:15 am |
| Hello,
I'm new to xj3d and vrml and I loaded a VRML scene into my Java3D
application. Now I'd like to change the translation of a Transform node with
known DEF. I used the getNamedObjects-method of the scene to get all named
nodes. Then I can get the node as ScenceGraphObject (see code). What I need
is a node-object to access the translation. Does anybody know how to cast or
convert the SceneGraphObject?
thanks
Chris Lambert
Code:
// get Named Objects of VRML scene
Hashtable namedObjects = scene.getNamedObjects();
if (namedObjects != null)
{
for (Enumeration e = namedObjects.keys(); e.hasMoreElements(); )
{
System.out.println(e.nextElement());
}
if (namedObjects.isEmpty())
{
System.out.println("empty");
} else {
System.out.println(namedObjects.size());
}
// get Node with DEF "ObjectShape"
Object myTransform = namedObjects.get("ObjectTransform");
if (myShape instanceof SceneGraphObject)
{
System.out.println("ok");
SceneGraphObject sgo = (SceneGraphObject)myTransform;
// todo: change translation of Transform
} else {
System.out.println("not ok");
}
}
|