Print

Print


Dear all, 

I am completely new to this list and to MASON. 

I intend to develop a model for virtual plants in 3d. Plant attributes 
(height, diameter) are calculated in the simulation and ConePortrayals3D 
for the plants created at runtime shall reflect these attributes. 

I found example code in the Balls3D model that does similar things to a 
SpherePortrayal3D. The BallPortrayal inherits from the SpherePortrayal3D 
and overrides the getModel method of the superclass. The if condition 
becomes true when the TransformGroup passed to the method is null (as in 
the getModel method of the superclass) or when the passed in Object casted 
to Ball has changed its mass. In the statements that are executed in that 
case the SpherePortayal3D scale-variable is multiplied by the BallObject's 
radius, that also has changed. So, there is a dynamic connection of the 
attributes of a ball and its portrayal. 

I tried to follow this scheme by creating a PlantPortrayal that extends 
TransformedPortrayal3D, overriding its getModel method, putting in || 
((Plant)obj).oldDiameter != ((Plant)obj).diameter and trying to change the 
internalTransform using components from the method code for scaling
(double,double,double) and rotatingY in the TransformedPortrayal3D. 

However, when I ran the code with a step method in which the diameter is 
increased by 1 each time step I saw the cone size to increase drametically  
at step 1 and at step 2 the cones seemed to be too large to be displayed.

Has anyone written code to dynamically connect a "TransformedPortrayal3D" 
to attributes of the underlying agent? Is there anyone, who could give me 
some advice in these matters? 

Since this behaviour is such a basic requirement for the model development 
I would greatly appreciate any helpful suggestions. 

Thank you very much in advance, Uwe