Rich Gold wrote:
> Is there a method for rotating an object around an arbitary point in space?
Or one
> vertix of the object (as opposed to its center)? In VRML you could set the
center - I
> can't seem to find it in J3D (but I'm sure its there!)
There is diffrent ways you could do this, It depends on what you want to do,
what is animated or intereactive and what is not.
The way to do it in general is to translate the object to that abitrary point
(so that the arbitrary point becomes the objects origin) and then rotate it.
Now if you want to intereactively change or animate the rotation, then the
best way to do this is to create a TransformGroup for the rotation, and a
Transform Group for the translation, and parent the object to the translate
group and the translate group to the rotation and the rotation to what ever
it is going to be parent to (root maybe).
A simple example is...
BranchGroup objRoot = new BranchGroup();
{
TransformGroup rotateTG = new TransformGroup();
rotateTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
Alpha rotationAlpha = new Alpha(-1, 16000);
RotationInterpolator rotator = new RotationInterpolator(rotationAlpha,
rotateTG);
rotator.setSchedulingBounds(globalBounds);
rotateTG.addChild(rotator);
{
Transform3D trans3D = new Transform3D();
trans3D.setTranslation(new Vector3d(-arbitraryX,-
arbitraryY,-arbitraryZ);
TransformGroup translateTG = new TransformGroup(new Transform3D());
{
translateTG.addChild(new ColorCube(0.4));
}
rotateTG.addChild(translateTG);
}
objRoot.addChild(objTranslate);
}
There may be syntax issues with this (have not tried it), but it should give
you the idea. It basicly creates a transformgroup that does the rotation, and
adds to it a rotation/spin animation and the translation you can replace
arbitraryX,Y, and Z with actual values you want to use instead, making sure
to make the values negative to their original value (if its -5 make it 5, if
its 3 make it -3, etc), just remember that where ever the arbitrary point is,
that you translate it to that location by making the point negative.
Leyland Needham
===========================================================================
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".