I've been trying to use the lookAt() method of Transform3D, but when I
retrieve the transformation matrix and restore it later, the
transformation type flags don't seem to be getting computed correctly.
I don't think they get set correctly after the lookAt() either. Am I
misunderstanding the type flags, or is there something wrong here?
Here's my little test app. Can anyone explain the observed behavior?
//**********************************************************************
*******
// CLASS: T3DBugTest
// This class tests for existence of a bug in Transform3D where the
transform
// type is not properly set when a matrix is used to initialize the
// Transform3D node. The lookAt() transformation doesn't seem to
update the
// type flags correctly, and neither does setting the Transform3D from
a
// matrix.
//
// Generated output (JDK 1.2.1, J3D 1.1.1):
// AFFINE|CONGRUENT|IDENTITY|ORTHOGONAL|RIGID|SCALE|
// AFFINE|CONGRUENT|IDENTITY|ORTHOGONAL|RIGID|SCALE|
// AFFINE|CONGRUENT|IDENTITY|ORTHOGONAL|RIGID|SCALE|
// AFFINE|
//
//**********************************************************************
*******
import javax.media.j3d.Transform3D;
import javax.vecmath.Matrix4d;
import javax.vecmath.Point3d;
import javax.vecmath.Quat4d;
import javax.vecmath.Vector3d;
public class T3DBugTest
{
public T3DBugTest ()
{
final Transform3D t1 = new Transform3D();
final Transform3D t2 = new Transform3D();
final Matrix4d mat = new Matrix4d();
pType(t1); // AFFINE|CONGRUENT|IDENTITY|ORTHOGONAL|RIGID|SCALE
t1.lookAt(new Point3d(50,20,50), new Point3d(0,0,0), new
Vector3d(0,1,0));
pType(t1); // AFFINE|CONGRUENT|IDENTITY|ORTHOGONAL|RIGID|SCALE
// (Should be AFFINE|CONGRUENT|RIGID, I think)
t1.get(mat);
pType(t2); // AFFINE|CONGRUENT|IDENTITY|ORTHOGONAL|RIGID|SCALE
t2.set(mat); // should recompute type from matrix
pType(t2); // AFFINE (Should be whatever t1 was!)
}
public void pType (Transform3D t)
{
final int flags = t.getType();
if ((flags & Transform3D.AFFINE) != 0)
System.err.print("AFFINE|");
if ((flags & Transform3D.CONGRUENT) != 0)
System.err.print("CONGRUENT|");
if ((flags & Transform3D.IDENTITY) != 0)
System.err.print("IDENTITY|");
if ((flags & Transform3D.NEGATIVE_DETERMINANT) != 0 )
System.err.print("NEGATIVE_DETERMINANT|");
if ((flags & Transform3D.ORTHOGONAL) != 0 )
System.err.print("ORTHOGONAL|");
if ((flags & Transform3D.RIGID) != 0) System.err.print("RIGID|");
if ((flags & Transform3D.SCALE) != 0) System.err.print("SCALE|");
if ((flags & Transform3D.TRANSLATION) != 0)
System.err.print("TRANSLATION|");
if ((flags & Transform3D.ZERO) != 0) System.err.print("ZERO|");
System.err.println("");
}
public final static void main (String[] args)
{
new T3DBugTest();
}
}
--
Ellery Chan
Harris Corp.
[EMAIL PROTECTED]
=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/