Hi Uwe. The TransformedPortrayal3D class uses a Java3D Transform3D
object underneath, and you can replace the Transform3D as you see
fit. However if you're calling the scale() method built into the
class, you need to understand that these are further scaling the
*existing* scale -- that is, it's multiplying the scales. For
example, if you called scale(2,2,2), and then again called scale
(2,2,2), your total scaling will be of size 4.
Also, note that performing scales, rotations, and translations, are
called affine transformations, and are done internally with a 4 by 4
matrix. Each operation multiplies that matrix by a new matrix -- and
matrix multiplications are NOT commutative. You can't do a rotate
and then a scale and expect it to be the same as a scale followed by
a rotate (say).
Sean
On Sep 16, 2006, at 7:38 PM, Uwe Grueters wrote:
> 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
|