Print

Print


ALL objects will use SOME portrayal to draw them -- though it could  
simply be an empty portrayal that does nothing.  Setting the  
portrayalForObject to null (that is, clearing it) just causes  
FieldPortrayal to look elsewhere for the portrayal for the object.   
Instead you might set it to SimplePortrayal3D, which is the empty  
portrayal.

The FieldPortrayal looks in different places in this order:

1. Use the portrayalForAll if it's non-null.
2. If the object is null,
	2a. Use the portrayalForNull if it's non-null.
	2b. If setPortrayalForObject(null, _somePortrayal_) was called,
		use _somePortrayal_
	2c. Use defaultNullPortrayal.
3. If the object is non-null,
	3a. If the object itself IS a portrayal, use that.
	3b. Use the portrayalForNonNull if there is one.
	3c. If setPortrayalForObject(theObject, _somePortrayal_) was called
		for the object, use _somePortrayal_
	3d. If setPortrayalForClass(theObject'sClass, _somePortrayal_) was
		called for the object's class, use _somePortrayal_
	3e. Use portrayalForRemainder if there is one.
	3f. Use defaultPortrayal.

defaultNullPortrayal and defaultNullPortrayal are typically hard- 
coded into the FieldPortrayal; the other values (portrayalForAll,  
portrayalForNull, portrayalForNonNull, portrayalForRemainder, per- 
object portrayals, per-class portrayals) can all be set by you.  Note  
that 2b, 3c, and 3d are hashtable lookups and thus incur a constant  
overhead.  To be faster, you might have MASON successfully find your  
objects by steps 1, 2a, 3a, or 3b .


On Nov 15, 2006, at 12:41 PM, Michael Lees wrote:

> Hi again,
>
> another related java3d/portrayal question,
>
> How are you supposed to remove an item from the display?
> I was trying to use,
>
> FieldPortrayal.setPortrayalForObject(java.lang.Object obj, null)
>
> Which should remove the portrayal from the field?
> However, this doesn't seem to change the display.
>
> Thanks
>
> -Mike
>
> 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  
>> generateNormals,
>>     boolean generateTextureCoordinates, float scale)
>>         {
>>         this.generateNormals = generateNormals;
>>         this.generateTextureCoordinates = generateTextureCoordinates;
>>         this.appearance = appearance;
>>     // changed here
>>     appearance.setCapability 
>> (Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_READ);      
>> appearance.clearCapabilityIsFrequent 
>> (Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_READ);      
>> appearance.setCapability 
>> (Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_WRITE);      
>> appearance.clearCapabilityIsFrequent 
>> (Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_WRITE);          
>> 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.
>> Sean
>> On Nov 14, 2006, at 9:41 AM, Michael Lees wrote:
>>> Hi,
>>>
>>> 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 
>>> (colour,size)
>>>
>>>
>>> And then attempt to change the transparency by...
>>>
>>> representation.appearance.getTransparencyAttributes 
>>> ().setTransparency(1.0f);
>>>
>>>
>>> I noticed that nothing was appearing, looked like the cubes had 0  
>>> transparency.
>>>
>>> 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  
>>> Shape3D.
>>>
>>> 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  
>>> Portrayal3D).
>>>
>>> Thanks
>>>
>>> --Michael Lees
>>>
>>>
>>> This message has been checked for viruses but the contents of an  
>>> attachment
>>> 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  
>>> legislation.
>
>
>
>
>
> This message has been checked for viruses but the contents of an  
> attachment
> 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  
> legislation.