This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > VRML > December 2003 > Using xj3d to access VRML-node





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Using xj3d to access VRML-node
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");
}
}



Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews