Posted by: kyuzo Mar 22 2007, 01:29 PM
hi
my
scene contains 2 objects; i want to aply a transformation on each when
i click on them; so i use a transform group on wich i add the selected
object as a child, and remove the other object (the previously selected
one). removeChild() doesnt seem to work for me, and the tranformation
gets aplied to the both spheres.
here's some code, hopefuly easier to understand than my english 
CODE
import sandy.view.Camera3D;
import sandy.core.World3D;
import sandy.primitive.*;
import sandy.core.data.*;
import sandy.core.group.Group;
import sandy.core.transform.*;
import sandy.core.group.TransformGroup;
import sandy.util.Ease;
import sandy.events.*;
import sandy.core.*;
import sandy.math.*;
class Main{
var tg:TransformGroup;
public function Main(){
tg=new TransformGroup();
var camera:Camera3D=new Camera3D(600,600);
camera.setPosition(-50,50,-150);
camera.lookAt(0,30,0);
World3D.getInstance().setCamera(camera);
var root:Group=new Group();
var tg1:TransformGroup=new TransformGroup();
var c1:Sphere=new Sphere(3,3);
c1.enableEvents(true);
tg1.addChild(c1);
c1.addEventListener(ObjectEvent.onPressEVENT,this,onClick);
var tg2:TransformGroup=new TransformGroup();
var t2:Transform3D=new Transform3D();
t2.translate(-30,0,20);
tg2.setTransform(t2);
var c2:Sphere=new Sphere(3,3);
c2.enableEvents(true);
tg2.addChild(c2);
c2.addEventListener(ObjectEvent.onPressEVENT,this,onClick);
root.addChild(tg1);
root.addChild(tg2);
root.addChild(tg);
World3D.getInstance().setRootGroup(root);
World3D.getInstance().render();
}
public function onClick(e:ObjectEvent){
var c:Box=e.getTarget();
tg.removeChild(c.getId()); //what should i use here?
var ease:Ease=new Ease();
var ri:RotationInterpolator=new RotationInterpolator(ease.create(),20,0,35);
ri.setAxisOfRotation(new Vector(0,1,0));
var
ti1:PositionInterpolator=new PositionInterpolator(ease.create(),20,new
Vector(0,0,0),new Vector(30,50,20));
var s:Sequence3D=new Sequence3D();
s.addChild(ri);
s.addChild(ti1);
tg.addChild(c.getParent());
tg.setTransform(s);
}
static function main(){
var main=new Main();
}
}
http://tcornel.googlepages.com/sandy1.swf
i would appreciate any help.
thank you.
Posted by: kiroukou Mar 22 2007, 02:19 PM
Hi,
I think someone else did notice that problem too.
As far as I remember, it was a stupid bug in the remove method of the Node class.
I've to say that I don't remember everything since I'm in the new version for a while already 
Maybe you can give it a look. Otherwise I'll do that, and update the svn with the fixed problem.
Thanks for the report.
Posted by: kyuzo Mar 22 2007, 08:09 PM
hi
looks like the removeChild method expect the children to have successive id's, beginning with 0, which doesnt happens.
instead of tg.removeChild() i use tg.getChildList().splice(0), which in my case get the job done. i'll use this hack for now.
thanks for responding.
Posted by: kiroukou Mar 23 2007, 07:41 AM
Ok thanks for your investigation...
I do remember that something wrong was remaining there... I'll note that 
Thanks