Hi everyone,
I am new to Java 3D; I am writing an application and I need to continuously
add and remove objects from a scene.
Adding is easy, but removing seems to be difficult in that a BranchGroup has
only the: removeChild(int i) method.
Now I do not know the index number of the object I want to delete, moreover
this nuber seems to change during the object lifetime...
The only solution I found is to scan all the objetc tree looking for the
object I want ot delete. But this is likely to be a very
performance-inefficient solution....
Do you have better alternatives?
Thanks a lot, for any suggestion
Marco
P.S.
Here in the follow I report the code I wrote...
private void removeFromScene(Node bye)
{
/* remove the link from the scene */
int k = 0;
Enumeration e = this.getAllChildren();
while(e.hasMoreElements())
{
Node x = (Node)e.nextElement();
if (x instanceof BranchGroup)
{
Node li=null;
try
{
li = ((BranchGroup)x).getChild(0);
} catch (Exception cnse)
{
k++; continue;
}
if(li.equals(bye))
{
this.removeChild(k);
break;
}
}
k++;
}
}
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".