[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [x3d-public] containerField



but: where are the children? they are visible, but here nothing appears:

Your shape has no appearance... add an Appearance node to its appearance field and it will show with a default material (all white):


SFNode shape_appearance = (SFNode) (shape.getField("appearance"));
X3DNode appearance = mainScene.createNode("Appearance");
shape_appearance.setValue(appearance);

i thought that getRootNodes() returned all Nodes of the Scene. is that
wrong? if yes, how can i achieve this? what would be the correct way to
make all nodes of the scene available (also the children of the transform)?

As for the second question, getRootNodes returns only the top-level nodes in the scene. For instance, in your code, only the Transform node. To walk the scenegraph, write a recursive method that takes an X3DNode as an argument and does the following:


- Check if the node is a group or leaf node. A pretty straightforward (if not, currently, the only) way to check if a node is a group node, try to get a "children" field. If that fails, the node is a leaf node and has no children. Otherwise, the node is a group node and has children that can be accessed by getting the value of the children field as an X3DNode[].

- If the node is a group node, apply any processing required (e.g., transformations in case of a Transform node) and recurse for all children.

- If the node is a leaf node, just apply any processing required (e.g., System.out.println its type, add its fields to a JTree, etc).

You should then call this method for all nodes returned by the getRootNodes. This is a pretty much standard approach as to walking hierarchical structures.

Hope I helped

George

-------------------------------------------------------------------------
for list subscription/unsubscription,
go to http://www.web3d.org/cgi-bin/public_list_signup/lwgate/listsavail.html