> Date: Mon, 30 Jun 2003 11:48:07 -0400
> From: "Young, Jason" <[EMAIL PROTECTED]>
>
> [cm1] = A B C D = [w2vp][vp2e][e2cc]
> (inverse is cm1^-1)
> [...]
> so if I have my own projection matrix, I can apply these matrices to the
> geometry vertices:
>
> [w2vp][vp2e][my_projection][cm1^-1]
>
> then the net effect is:
> [w2vp][vp2e][my_projection][cm1^-1][cm1] = [w2vp][vp2e][my_projection]
>
> Which is my own custom projection matrix.
> When rendered, transforming my geometry points by
>
> [w2vp][vp2e][my_projection][cm1^-1]
>
> should look the same as calling
>
> view.setCompatibilityModeEnable(true);
> view.setVpcToEc(vp2e);
> view.setLeftProjection(my_projection);
>
> But it doesn't. So obviously my assumptions or my thoughts are flawed.
> What do I not yet understand about J3D or the matrix chain process?
> _______________________________________________________
> Here is my code:
> [..]
> Transform3D w2vp = new Transform3D(initial);
> [...]
You probably aren't making the same mistake again, but I don't see here
what the value of `initial' is. We'll presume the value is identity and
the view platform is at the origin, unrotated, or that the value is the
inverse of the view platform's local to vworld transform.
> Point3d p3d = new Point3d();
> for(int i=0; i < count; i++) {
> groundgeo.getCoordinate(i,p3d);
> cheatProjection.transform(p3d);
> groundgeo.setCoordinate(i,p3d);
> }
I'd call this either a bug in the Transform3D API design or the
documentation or possibly both. The Point3d variants of transform()
only apply 3D transforms; w is assumed to be 1.0 and the 4th row of the
transform matrix isn't used. You need to use the Vector4d variants and
divide by w yourself:
Point3d p3d = new Point3d();
Vector4d v4d = new Vector4d();
for (int i = 0 ; i < count ; i++) {
groundgeom.getCoordinate(i, p3d);
v4d.set(p3d); v4d.w = 1.0;
cheatProjection.transform(v4d);
p3d.x = v4d.x / v4d.w;
p3d.y = v4d.y / v4d.w;
p3d.z = v4d.z / v4d.w;
groundgeo.setCoordinate(1, p3d);
}
I think it oughta work... give it a try.
-- Mark Hood
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".