-je écrire ce programme, mais il a exception dans la lignejeu d'écriture avec java3d
group.addChild(tg);
mais quand j'ajoute
TransformGroup tg = new TransformGroup();
dans le pour le bloc en boucle, il fonctionne avec tout problème s'il vous plaît me dire que ce raisonnons .
Merci.
ceci est mon code
public BranchGroup Creat()
{
BranchGroup group = new BranchGroup();
TransformGroup tg = new TransformGroup();
for(float x = 0.0f; x < 1.0f; x += 0.1f)
{
Transform3D td = new Transform3D();
Vector3f vector3f = new Vector3f(x, x, x);
td.setTranslation(vector3f);
tg.setTransform(td);
tg.addChild(new Cone(0.05f, 0.1f));
group.addChild(tg);
}
return group;
}
est ce qu'il est exception
Exception in thread "main" javax.media.j3d.MultipleParentException: Group.addChild: child already has a parent
at javax.media.j3d.GroupRetained.checkValidChild(GroupRetained.java:478)
at javax.media.j3d.GroupRetained.addChild(GroupRetained.java:487)
at javax.media.j3d.Group.addChild(Group.java:290)
at t39.Draw.Creat(Draw.java:68)
at t39.Draw.<init>(Draw.java:50)
at t39.Main.main(Main.java:22)
11 questions et aucune réponse acceptée ... bonne chance – mkoryak
Quelle est l'exception? Basé sur votre "fix", je supposerais (sans rien savoir sur la bibliothèque) que chaque 'TransformGroup' ne peut être ajouté à un' BranchGroup' parent qu'une seule fois. Dans l'état actuel, il semble que '' group.addChild (tg) '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' ''. –