Sorry all - forgot the attachment. Here it is...

 

Cheers,
Tom Richards

-----Original Message-----
From:   T.G. Richards [SMTP:[EMAIL PROTECTED]]
Sent:   Wednesday, March 03, 1999 10:25 AM
To:     'Doug Gehringer'
Cc:     [EMAIL PROTECTED]
Subject:        RE: [java3d] Setting Capabilities on Primitive objects

Doug Gehringer wrote:

> From: "David Grace" <[EMAIL PROTECTED]>
>
> I have displayed a Cone with:
> Cone cone = new Cone();       
> 
> and then tried to allow modification of its appearance with both:
> cone.setCapability(Primitive.ENABLE_APPEARANCE_MODIFY);  and
> cone.setPrimitiveFlags(Primitive.ENABLE_APPEARANCE_MODIFY);
> 
> (I'm not sure which one of these is appropriate)
> 
> but when I call cone.getAppearance() or cone.setAppearance() I get an error at 
> runtime that says CapabilityNotSetException.

All the utility primitives return a Group which holds the elements of the 
primitive.  For example, a Cone actually has two Shape3Ds, one for bottom and 
the other for the sides.  So Cone.setCapabilty() changes the cap bits on the 
group which holds the Shape3Ds, not the Shape3d's.

Try setting the ENABLE_APPEARANCE_MODIFY flag in the the constructor for Cone.  
This will set the cap bits correctly on the Shape3Ds.  You should then be able 
to call Cone.setAppearance() without an exception.


I'm having the same problem setting the appearance of primitives at run-time. I 
followed the advice above & set the primitive's capabilities in the constructor (see 
attached Test.java file). It worked - sort of. When I change the appearance, the 
change succeeds but I get the following error:

Exception occurred during event dispatching:
javax.media.j3d.CapabilityNotSetException: Group: no capability to read children
        at javax.media.j3d.Group.getChild(Compiled Code)
        at com.sun.j3d.utils.geometry.Cylinder.setAppearance(Cylinder.java:156)
        at Test$2.actionPerformed(Test.java:60)
        at java.awt.Button.processActionEvent(Button.java:308)
        at java.awt.Button.processEvent(Button.java:281)
        at java.awt.Component.dispatchEventImpl(Compiled Code)
        at java.awt.Component.dispatchEvent(Compiled Code)
        at java.awt.EventQueue.dispatchEvent(Compiled Code)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:68)

I've tried setting the ALLOW_CHILDREN_READ and ALLOW_CHILDREN_WRITE capabilities of 
the cylinder, but I get the same error and in addition the appearance change only 
affects the body of the cylinder & not the end caps.

I've tried getting an enumeration of the cylinder's Shape3D children & setting their 
appearances individually. This cures the error, but I still end up with just the 
cylinder body changing appearance.

I'd be very grateful for any advice on this one - I'm stuck!

Many thanks,
Tom Richards
University of Bath, UK




<<< java/*; name="Test.java": Unrecognized >>>

Reply via email to