Skip to main content

a change of the Shape3D

6 replies [Last post]
Anonymous

I want to make a change of the Shape3D while my program is running. Can anybody tell me, how can I do it?

bild = new TransformGroup();
bild.setCapability(bild.ALLOW_CHILDREN_WRITE);
bild.setCapability(bild.ALLOW_CHILDREN_READ);
bild.setCapability(bild.ALLOW_CHILDREN_EXTEND);
bild.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
bild.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);

shape1 = new Face(…);
bild.addChild(shape1);

I'm trying this way to change the child:

bild.removeChild(shape1);
bild.addChild(shape2);

but it doesn't work :–(

javax.media.j3d.RestrictedAccessException: Group: only a BranchGroup node may be removed

Can I remove the child of TransformGroup?
Thanks

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
pepe
Offline
Joined: 2003-06-10

watchout, there is currently a bug in changing geometries under some conditions (setting goemetries of different type for example)
This bug should be tracked down again very soon.

aces
Offline
Joined: 2003-07-17

> Can I change Shape3D while the program is running? Or
> can I just transform it?

Maybe I am wrong, but I understand you wish "deform" your shape, instead translate/rotate/scale/mod appearance/etc, like change a sphere to a box, right ?
If you wish to morph your shape there are some ways:
a) use Morph, but need the target geometries to get your interpolated shape between then; (Check Java3D Morph Demo)

b) access your geometry data info and update then properly;

c) use vertex shader (upcoming Java 1.4 running on shader capable video card);

Anonymous

Thank you!
I have got two shapes. First shape has got GeometryInfo.QUAD_ARRAY and second shape has got GeometryInfo.QUAD_ARRAY. Triangles and quadrangles must often be change by my application. By the way (shape.removeAllGeometries(); add.setGeometry()) it works very good :-)

Anonymous

Can I change Shape3D while the program is running? Or can I just transform it?

nitro
Offline
Joined: 2004-09-12

You can change the geometry/appearance of a shape while running.
shape.addGeometry();
shape set.Geometry();
...

Or you can use a BranchGroup which you detach from the scene
then change ist children an then reattach to 5the scene.

This should be done inside a Behavior due to some bug which wont be fixed that soon.

http://www.javadesktop.org/forums/thread.jspa?messageID=57374

Anonymous

many thanks