Hello,
I have two Canvas3D, one is for object view and the other is only for
axis rotation. I want to get a MouseRotate behavior from the object
view canvas3D to axis Canvas3D, so I can synchronise the rotation
between them.
I couldn't find any similar examples up to now, but some people said
that I should use MouseBehaviorCallback and setupCallback, etc. But I
couldn't figure out how to do it.
Or, should I use one Canvas3D with multiple view? If so, how can I do
it?
Could you give me any simple examples plz?
Thanks for your help.
Sungwoo
maya2000 - 02 Oct 2004 09:27 GMT
I solved my problem. See below code.
Now two Canvas3D receive a same mouseRotate behaviour.
Let me know if there is more better and efficient way.
Sungwoo
-----------
public class MouseSync implements MouseBehaviorCallback {
public MouseSync() {
......
}
public void threeDSceneCreation() {
......
MouseRotate myMouseRotate = new MouseRotate();
// Mouse rotate event capture to synchronise the axis view rotation.
myMouseRotate.setupCallback(this);
this.transformChanged(MouseBehaviorCallback.ROTATE, matrix1);
myMouseRotate.setTransformGroup(tg1);
myMouseRotate.setSchedulingBounds(new BoundingSphere());
childBG1.addChild(myMouseRotate);
MouseTranslate myMouseTranslate = new MouseTranslate();
myMouseTranslate.setTransformGroup(tg1);
myMouseTranslate.setSchedulingBounds(new BoundingSphere());
childBG1.addChild(myMouseTranslate);
MouseZoom myMouseZoom = new MouseZoom();
myMouseZoom.setTransformGroup(tg1);
myMouseZoom.setSchedulingBounds(new BoundingSphere());
childBG1.addChild(myMouseZoom);
rootBranchGroup.addChild(childBG1);
}
public void transformChanged(int param, Transform3D transform3D) {
//------------------------------------------------
// For all behaviour sync i.e., rotation, zoom, translation.
//------------------------------------------------
// axDis.tg.setTransform(transform3D);
//------------------------------------------------
// For roation behaviour sync only.
//------------------------------------------------
Quat4d q4d = new Quat4d();
AxisAngle4d a4d = new AxisAngle4d();
// Places the quaternion equivalent of the normalized rotational
// component of this transform into the quaternion parameter.
transform3D.get(q4d);
// Sets the value of this axis-angle to the rotational equivalent of
// the passed quaternion.
a4d.set(q4d);
// Sets the rotation from a transform3D data.
transform3D.set(q4d);
transform3D.setRotation(a4d);
// Set the new rotation info to the target Canvas3D.
axDis.tg.setTransform(transform3D);
}
}