This is a continuation from the projection coordinates thread of 2 weeks ago. I've
read ViewInfo.java and have a set of assumptions, but something is still missing.
Here's the latest...
_______________________________________________________
ASSUMPTIONS
- From what I gather from ViewInfo.java, we have
the coordinate spaces: clipping, eye, image plate, view platform, virtual world
(coexistence coordinates are for when you move the frame and it changes the view
so I don't need to worry about coexistence coordinates)
- I think in terms of a view matrix and a projection matrix.
As I originally learned it, what I think of as a view matrix takes you from:
virtual world -> view platform -> image plate -> eye,
and my projection matrix takes you from: eye -> clipping coordinates
- Here is my impression of the chain of matrices java uses
to go between the various spaces:
[J3D PROJECTION MATRIX] [ ----- J3D VIEW MATRIX---] [TRANSFORMS ABOVE VP]
clipping -> -> eye -> image plate -> view platform -> virtual world
[D] [C] [B] [A]
matrix chain (camera model) that J3D applies to get geometry coordinates to screen:
W2VP = A ( transform above view platform )
VP2E = B C ( ViewInfo.getViewPlatformToEye(c, vp2e, null) )
E2CC = D ( ViewInfo.getProjection(c, e2cc, null); )
[cm1] = A B C D = [w2vp][vp2e][e2cc]
(inverse is cm1^-1)
_______________________________________________________
HERE'S WHAT I WANT TO DO
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:
ViewInfo vInfo = new ViewInfo(view);
Transform3D vp2e = new Transform3D();
Transform3D e2cc = new Transform3D();
vInfo.getProjection(c, e2cc, null);
vInfo.getViewPlatformToEye(c, vp2e, null);
Transform3D w2vp = new Transform3D(initial);
Transform3D myProjection = new Transform3D();
myProjection.perspective(Math.PI/2, 3.0, 1.0, 100.0);
// both blocks of code should render the same image
// but they don't
boolean cheatRenderer = true;
if( ! cheatRenderer ) {
view.setCompatibilityModeEnable(true);
view.setVpcToEc(vp2e);
view.setLeftProjection(myProjection);
}
else {
Transform3D cameraModelJ3D = new Transform3D();
cameraModelJ3D.mul( e2cc );
cameraModelJ3D.mul( vp2e );
cameraModelJ3D.mul( w2vp );
Transform3D inverseJ3DCamera = new Transform3D();
inverseJ3DCamera.invert(cameraModelJ3D);
//[w2vp][vp2e][my_projection][cm1^-1]
Transform3D cheatProjection = new Transform3D();
cheatProjection.mul(inverseJ3DCamera);
cheatProjection.mul(myProjection);
cheatProjection.mul(vp2e);
cheatProjection.mul(w2vp);
GeometryArray groundgeo = (GeometryArray)ground.getGeometry();
int count = groundgeo.getVertexCount();
Point3d p3d = new Point3d();
for(int i=0; i < count; i++) {
groundgeo.getCoordinate(i,p3d);
cheatProjection.transform(p3d);
groundgeo.setCoordinate(i,p3d);
}
}
===========================================================================
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".