Nanping Lo wrote: > Hi, > The previous posting got chopped off, so I am > posting again... > > I would like to have a EAI/java applet that can control > variable number of objects in a VRML model (i.e. one java > applet that works with multiple wrl files). However, > I am having problem reading in nodes in the following > fashion, > > ---- > // declaration > Node object[] = null; > > ... > > for (i=0; i object[i] = browser.getNode("Object"+i); > ... > } > > ---- > in the wrl file. I have, > > DEF Object1 Transform { Hi Nanping, Here are some observations I have had while making n-body simulations. My first idea was to add new DEF'd nodes to scene, DEF'd in order. This method which is to use CreateVrmlFromString "DEF"+i is not workable. After no small amount of head scratching, I have found it handy to use a PROTO structure like this: # here is a proto to index. in the index you could use any proto. PROTO ProtoToIndex[ field SFInt32 value] { # some implementation ... } PROTO ProtoToIndex2[ field SFInt32 value] { # other implementation ... } PROTO Index[eventIn MFNode set_children field MFNode children eventOut MFNode children_changed ] { Group{ eventIn MFNode set_children IS set_children field MFNode children IS children eventOut MFNode children_changed IS children_changed } } DEF RootIndex Index{children [ ProtoToIndex{value 3} ProtoToIndex{value 5} ProtoToIndex{value 7} #... ProtoToIndex2{value 8} #... } Then, using EAI, create EventOutObserver. Use the method getNode("RootIndexNode"}. Advise the observer of the children_changed of the Index PROTO. When the children_changed eventOut is received from RootIndexNode PROTO, go through the index of this MFNode and assign each member to a member of SFNode array. Then, you have references to each of these nodes by index. Then you can apply iterative algorithm to each PROTO with each having it's own state. Throughout this process, it is only necessary to DEF one node, the RootIndexNode. Benifits of this approach is to handle n number of objects with separate states, as well as enabling the ability to add and remove objects form situation. Also, when sending events to the indexed PROTOs, it is possible to send an array of events through intermediary PROTO, essentially enabling array type addressing in VRML. Here is an example, http://www.tomco.net/~raf/faqs/TestExternal4.java.txt. This example illustrates a very simple application of this concept. As in anything, there are some other methods to do this. If other people come up with ways to scale up object handling like this please contact me. A script node method would be good to have, and can be accomplished using the same method of indexing MFNode. You mentioned in previous letter you were looking for alternate methods and had seen TestTraverse. I haven't seen any other approach that uses this method yet or other like method to enable n body simulation. Anybody else? Have a good one, Ross