Michael, you don't want to replace the appearance of an object.
That's what Shape3D.ALLOW_APPEARANCE_WRITE does. What you want to do
is be able to do is change the Appearance's attributes itself,
something like this:
public CubePortrayal3D(Appearance appearance, boolean
boolean generateTextureCoordinates, float scale)
this.generateNormals = generateNormals;
this.generateTextureCoordinates = generateTextureCoordinates;
this.appearance = appearance;
// changed here
this.scale = scale;
scaledVerts[i] = verts[i]*scale;
But that might not work, because when the portrayal creates the scene
object, assigning it the Appearance, Java3D may *copy* the
appearance, and so changing the appearance later on doesn't change
the copy that's being used. You'll have to see for yourself to
determine this. If it's the case that it doesn't work, then I have
some other ideas.
On Nov 14, 2006, at 9:41 AM, Michael Lees wrote:
> I'm trying to vary the transparency of a cube during the simulation
> I define the following....
> public sim.portrayal3d.simple.CubePortrayal3D representation;
> representation = new sim.portrayal3d.simple.CubePortrayal3D
> And then attempt to change the transparency by...
> I noticed that nothing was appearing, looked like the cubes had 0
> Surrounding the setTransparency call with a try catch I realised
> the follow exception was being thrown...
> javax.media.j3d.CapabilityNotSetException: Appearance: no
> capability to get transparencyAttributes
> Looking into CubePortrayal3D.getModel I found the following...
> 131: Shape3D localShape = new Shape3D(quadArray,appearance);
> 132: localShape.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
> Which should allow you to change the appearance properties of the
> However, is the problem that I'm calling getTransparencyAttributes
> () when localShape.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
> has not been set?
> Or I'm I going about this all the wrong way? How should I change
> the transparency of a CubePortrayal3D (or more generally any
> Michael Lees
> This message has been checked for viruses but the contents of an
> may still contain software viruses, which could damage your
> computer system:
> you are advised to perform your own checks. Email communications
> with the
> University of Nottingham may be monitored as permitted by UK