The capability bits I included below allow you to REPLACE the
transparency object of the appearance, but not MODIFY that
transparency object. Hence #1 won't work.
You could probably get #1 working with adding something like this to
TransparencyAttributes ta = appearance.getTransparencyAttributes();
On Nov 15, 2006, at 6:58 AM, Michael Lees wrote:
> Hi Sean (and Bruno)
> Thanks for the replies.
> First of, let me say I've tried 3 different ways of changing the
> From my previous mail....
> >> public sim.portrayal3d.simple.CubePortrayal3D representation;
> >> representation = new sim.portrayal3d.simple.CubePortrayal3D
> The 3 different ways...
> 1. - Modifying transparency component directly
> 2. - Creating a new colour with new alpha value
> java.awt.Color colour2 = new java.awt.Color(colour.getRed(),
> colour.getGreen(), colour.getBlue(), (int)Math.round(trans*255));
> representation.appearance = CubePortrayal3D.appearanceForColor
> 3. - Creating a new transparency attribute object
> TransparencyAttributes(TransparencyAttributes.BLENDED, trans));
> First off, 2 works without any modification to MASON
> I tried as Sean suggested and...
> 3 now works.
> However, 1 still does not work, exception given:
> javax.media.j3d.CapabilityNotSetException: Transparency: no
> capability to set component
> Sorry, I appreciate this is probably a java3d question and thanks
> again for you help.
> Is there a right way to do this?
> Sean Luke wrote:
>> 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;
>> for(int i=0;i<scaledVerts.length;i++)
>> 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 execution.
>>> 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
> 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