Transform3D Questions

In the Transform3D class there are several methods that set a scale value. For instance the following:


    /**
     * Sets the rotational component (upper 3x3) of this transform to the
     * values in the specified matrix. The other elements of this transform
     * are unchanged. An SVD (singular value decomposition) is performed 
     * on this object's upper 3x3 matrix to factor out the scale, then this
     * objects upper 3x3 matrix components are replaced by the input
     * rotational components, and finally the scale is reapplied to the 
     * rotational components.
     */

    public final void setRotation(Matrix3f m) 

So what exactly is happening here? Is it the following steps:

1> Each element of the upper 3x3 matrix of the transform is being divided by the scale, and put back into the matrix.
2> Replace the elements in the upper 3x3 matrix with the new values from m.
3> Multiply the upper 3x3 matrix elements by the scale and replace the values.

If so what is the point of step number 1? If not then I’m obviously not understanding what SVD does and can someone explain it and/or show me some pseudo code?

Thanks.

Another question:

If you have:

1> TransformGroup that contains a rotational matrix defining 30 deg rotation around the X axis (Transform3D)
2> A child of 1 that is another TransformGroup containing a rotational matrix defining 15 deg rotation around the X axis (Transform3D)
3> A child of 2 that is another TransformGroup containing a translational matrix.

How would you get a single Transform3D that does the 45 deg rotation from the two matrices 1 & 2?

Do you multiply them together?

Do have to find all the transforms in the graph that are the same type, decompose them and add them together?

Do TransformGroup nodes effect everything below them in the scene graph?

hm, they leave all nodes below unchanged, but of course change their global positions.

But thats the trivial point in the scenegraph.

More important - they effect all nodes the way up to the root, bc. changing a transform is most likely to change the bounds of the parent nodes.

AFAIK, some scenegraph implementation have event systems for that, but something like


TransformGroup#setTransform( Transform3D tx )
{
    mTx = tx;
    getParent().reComputeBounds();
}

might do the job as well.

Okay so if I have:

if I have a BranchGroup containing TransformGroup A, that performs a translation and has TransformGroup B as a child. And B performs a rotation and has Shape3D children.

I should get:

no translation on B children and only rotation?

It seems that would make it very difficult to create a complicated object.

Another question:

I currently have it so the transform applies to everything under it in the graph. In the above example I’m getting a weird effect, the rotation works but the translation looks like it is causing a shear instead of a translate any idea what is causing that? I use the bottom row of the matrix for the translation which I think is correct. So it does a glMultMatrix for the translation and then another glMultMatrix for the rotation.

[quote]Okay so if I have:

if I have a BranchGroup containing TransformGroup A, that performs a translation and has TransformGroup B as a child. And B performs a rotation and has Shape3D children.

I should get:

no translation on B children and only rotation?
[/quote]
?? not sure. B has no translation with respect to A, but very well in the world. The shape is first translated, then rotated in the new position.

?? No, it is constructed that way to make complicated object simple! Having a spinning radar on a big ship e.g. - just spin the TransformGroup of the radar that is a child of the ship. The radar will travel anywhere the ship goes…

A 4x4 matrix can express a shear, so I assume you matrix construction has bugs.

yeah I had the translation values in the location for shear values. Duh! :stuck_out_tongue: