Hi,
I have tried to use Eric's code of 'MouseOrbit.java' for
rotating the view around a picked point. But this does not
work as it should do.
Instead of the TransformGroup of the center point I have used
directly the picked point as orbit center point and set it as
translation in the Transform3D of the 'tg_ghost_T3D'.
private void calcTransformOrbit() {
double dy = yawAngleDelta;
double dx = pitchAngleDelta;
Transform3D tempT3D = new Transform3D();
Transform3D orbitT3D = new Transform3D();
tempT3D.rotX(dx);
orbitT3D.mul(tempT3D);
tempT3D.rotY(dy);
orbitT3D.mul(tempT3D);
Transform3D tg_ghost_T3D = new Transform3D();
// viewPlatformTG.getTransform(tg_ghost_T3D);
if( pickedPoint != null ) {
// Transform3D currXform = new Transform3D();
// viewPlatformTG.getTransform(currXform);
// currXform.transform(pickedPoint);
tg_ghost_T3D.setTranslation(new Vector3d(pickedPoint.x,
pickedPoint.y, pickedPoint.z) );
}
// tg_ghost.getTransform(tg_ghost_T3D);
Vector3f tg_ghost_vec3f = new Vector3f();
tg_ghost_T3D.get(tg_ghost_vec3f); // Save the
tg_ghost_vec3f for later
Matrix4d tg_ghost_mat4d = new Matrix4d();
tg_ghost_T3D.get(tg_ghost_mat4d); // Save the
tg_ghost_mat4d for later
Transform3D VPTG_ghost_T3D_inverted = new Transform3D();
Transform3D VPTG_ghost_T3D_noninverted = new Transform3D();
viewPlatformTG.getTransform(VPTG_ghost_T3D_inverted);
viewPlatformTG.getTransform(VPTG_ghost_T3D_noninverted);
VPTG_ghost_T3D_inverted.setTranslation(new
Vector3d(0.0,0.0,0.0));
VPTG_ghost_T3D_noninverted.setTranslation(new
Vector3d(0.0,0.0,0.0));
// Invert the Viewer's T3D so we can remove it from the
objects Transform
VPTG_ghost_T3D_inverted.invert();
// Multiply the inverted Viewer Ghost T3D to factor it out
of the objects Transform
//orbitT3D.mul(VPTG_ghost_T3D_inverted, orbitT3D);
tg_ghost_T3D.mul(VPTG_ghost_T3D_inverted, tg_ghost_T3D);
tg_ghost_T3D.setTranslation(new Vector3d(0.0,0.0,0.0));
boolean invert = true;
if (invert)
{
tg_ghost_T3D.mul(tg_ghost_T3D, orbitT3D);
}
else
{
tg_ghost_T3D.mul(orbitT3D, tg_ghost_T3D);
}
// Multiply the noninverted Viewer Ghost T3D to factor it
back into the objects Transform
tg_ghost_T3D.mul(VPTG_ghost_T3D_noninverted, tg_ghost_T3D);
tg_ghost_T3D.setTranslation(tg_ghost_vec3f);
// tg_ghost.setTransform(tg_ghost_T3D); // Needs to
accumulate for next drag
//tg.setTransform(tg_ghost_T3D);
// Now do this for the viewer
Transform3D VPTG_ghost_T3D;
VPTG_ghost_T3D = new Transform3D();
viewPlatformTG.getTransform(VPTG_ghost_T3D);
Vector3f VPTG_ghost_vec3f = new Vector3f();
VPTG_ghost_T3D.get(VPTG_ghost_vec3f); // Save the
VPTG_ghost_vec3f for later
Vector3f temp_vec3f = new Vector3f();
temp_vec3f.x = VPTG_ghost_vec3f.x - tg_ghost_vec3f.x;
temp_vec3f.y = VPTG_ghost_vec3f.y - tg_ghost_vec3f.y;
temp_vec3f.z = VPTG_ghost_vec3f.z - tg_ghost_vec3f.z;
VPTG_ghost_T3D.setTranslation(temp_vec3f);
VPTG_ghost_T3D.mul(VPTG_ghost_T3D_inverted, VPTG_ghost_T3D);
if (invert)
{
VPTG_ghost_T3D.mul(VPTG_ghost_T3D, orbitT3D);
}
else
{
VPTG_ghost_T3D.mul(orbitT3D, VPTG_ghost_T3D);
}
VPTG_ghost_T3D.mul(VPTG_ghost_T3D_noninverted,
VPTG_ghost_T3D);
VPTG_ghost_T3D.get(temp_vec3f);
temp_vec3f.x = temp_vec3f.x + tg_ghost_vec3f.x;
temp_vec3f.y = temp_vec3f.y + tg_ghost_vec3f.y;
temp_vec3f.z = temp_vec3f.z + tg_ghost_vec3f.z;
VPTG_ghost_T3D.setTranslation(temp_vec3f);
viewPlatformTG.setTransform( VPTG_ghost_T3D );
}
But the view rotating behaviors in the same way as the
MouseRotate in J3D. What have I done wrong? According to
my testing it's also no difference with the following code.
private void calcTransformOrbit2() {
double dy = yawAngleDelta;
double dx = pitchAngleDelta;
Transform3D tempT3D = new Transform3D();
Transform3D orbitT3D = new Transform3D();
tempT3D.setTranslation( new Vector3d( pickedPoint.x, pickedPoint.y,
pickedPoint.z ) );
orbitT3D.mul(tempT3D);
double y_factor = 1.0;
double x_factor = 1.0;
tempT3D.rotX(dx*x_factor);
orbitT3D.mul(tempT3D);
tempT3D.rotY(dy*y_factor);
orbitT3D.mul(tempT3D);
Transform3D viewPlatformT3D = new Transform3D();
viewPlatformTG.getTransform(viewPlatformT3D);
viewPlatformT3D.mul( orbitT3D );
currentVpT3D.set( viewPlatformT3D );
}
Any hints or any examples to do this will be appreciated.
Thanks,
Bo
-------------------------------------------------------------
myview technologies GmbH & Co. KG
Riemekestra�e 160 ~ D-33106 Paderborn ~ Germany
E-Mail: mailto:[EMAIL PROTECTED]
Telefon: +49/5251/69090-351 ~ Fax: +49/5251/69090-399
-------------------------------------------------------------
===========================================================================
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".