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

Re: AW: [x3d-public] containerField



Mirko Gontek wrote:
thank you! maybe someone can help me with another problem....

i try to create a scenegraph with sai that looks like this:

		<Transform>
			<Shape>
			   <Sphere/>
			</Shape>
			<TouchSensor/>
		</Transform>

i did this:

//create Shape X3DNode shape = mainScene.createNode("Shape");
SFNode shape_geometry = (SFNode) (shape.getField("geometry"));
X3DNode sphere = mainScene.createNode("Sphere"); shape_geometry.setValue(sphere);
//create TouchSensor
X3DNode touch = mainScene.createNode("TouchSensor");
//create Transform
X3DNode transf = mainScene.createNode("Transform"); //add shape and touchSensor as children to Transform
MFNode ch = (MFNode)transf.getField("children"); //or
addChildren
ch.setValue(2, new X3DNode[] {shape, touch });
//add Transform to Scene
mainScene.addRootNode(transf);



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

		MFNode children = (MFNode)transf.getField("children");
            		for(int j=0; j<children.size();j++){
                 	X3DNode n = children.get1Value(j);
                	System.out.println(n.getNodeName());
            		}

might be a timing issue. If your reading them directly after writing them they may not be in the nodes yet. The writes are buffered till the frame they are processed in.

and: when walking the scenegraph with rootNodes as parameter (like in the
SAISGWalkDemo) it does not work:
		X3DNode[] roots = mainScene.getRootNodes();
		walkSG(roots);

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)?


getRootNodes returns all the top level nodes(in your case everything added with addRootNode). I haven't tried what your doing, so perhaps the rootNodes field has not been updated correctly.



Not sure I follow the whole code. Can you send me a complete .java file and I'll look at it.


--
Alan Hudson

President Yumetech, Inc.                               www.yumetech.com
President Web3D Consortium                             www.web3d.org
206 340 8900
-------------------------------------------------------------------------
for list subscription/unsubscription,
go to http://www.web3d.org/cgi-bin/public_list_signup/lwgate/listsavail.html