My research group has written a couple of applets that try and illustrate
this concept. We present it in 2D for simplicity, but it can be extended to
3D quite easily. Take a look at:
http://www.cs.brown.edu/exploratory/research/applets/domains/scenegraph/cata
log.html
The Transformation Game is probably the most relevant. The other applets
illustrate scenegraph concepts but don't map directly to the Java3D
scenegraph structure so may be more confusing than helpful.
You'll need to have the Java plugin installed to use these applets.
Please let me know if you use these applets and have any comments.

I'd also like to add to the explanation below:
I mentally add intermediate shape nodes when looking at a diagram like the
one below to better understand what's going on. In the example from the
previous message, for instance, you have:

BG -> TG1 -> TG2 -> S1

(TG1 is a translation & TG2 is a rotation)
You can think of it as:

BG -> (S3) -> TG1 -> (S2) -> TG2 -> S1

S1 is the shape at the origin positioned wherever its geometry's vertex
coordinates place it
S2 represents S1 rotated as specified in TG2, but still located at the
origin
S3 represents S2 translated as specified in TG1. Notice that S2 was rotated
so S3 has been rotated in its local coordinates (i.e. around the origin)
then translated away from that origin.

S2 and S3 don't, of course, exist in the scenegraph, but they are useful for
seeing how S1 is transformed by the various transforms in the scenegraph.

It's important to realize that at a later time you can change the rotation
transform in TG2 and the shape will correctly change its rotation about its
own axes. This is because TG2 is ALWAYS applied before TG1 every time the
scene is re-rendered. So S2 will be rotated differently but TG1 will
translate S2 by the same amount as before. So S3 now represents S1 rotated
about its local axes, then translated away from the origin.

If you flip the order of the transforms:

BG -> TG2 -> TG1 -> S1

You will apply the translation BEFORE the rotation. So the object rotates as
if it were attached to the pencil side of an open compass where the sharp
tip of the compass is at the origin.

This ability to chain transforms in the scenegraph is, in my opinion, one of
the most powerful aspects of using a scenegraph since it simplifies the way
one thinks about transforming objects. One can set up a complex chain of
transforms to position an object just right and not only can you change any
one of those transforms to affect the object but Java3D will use the
capability bits to compress (or pre-compose) as many of those transforms as
it can when compiling the scenegraph. Very cool stuff, as far as I'm
concerned.

-Jean Laleuf
[EMAIL PROTECTED]

ps. Feel free to let me know if any of this doesn't make sense :)
pps. I'll also give out hints to the transformation game if you need them.

-----Original Message-----
From: Discussion list for Java 3D API
[mailto:[EMAIL PROTECTED]]On Behalf Of Corysia Taware
Sent: Monday, July 30, 2001 11:59 AM
To: [EMAIL PROTECTED]
Subject: Re: [JAVA3D] Rotating objects about their own axes


Rotating an object about it's own axis is easy.  This
is what you're doing in the Java3D Tutorial, chapter
1.  The only difference really is that the object is
sitting at the origin...so it is also rotating about
the origin.

To rotate an object about it's own axis, but away from
the origin, you simply add a second TransformGroup.

(BG)--(TG1)--(TG2)--/S\

In the above diagram, TG1 would be a TransformGroup
object that translates the object to its location.
TG2 is a TransformGroup that handles the rotation.

If you're familiar with OpenGL, it's done in a very
similar way.  In OpenGL, you rotate the object first
because the object is always placed at the origin.
Next you translate the object away to its location in
space.  If you read the diagram above backwards (in
OpenGL, you draw backwards, too) you'll see it's doing
the same thing.

*  Shape is drawn at 0,0,0.
*  Shape is rotated by TG2.
*  The rotated Shape is then translated by TG1.


--- Fergus Murray <[EMAIL PROTECTED]> wrote:
>  As it happens I, too, would like to
> rotate my objects around
> their own axes but am having some trouble.


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

===========================================================================
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".

===========================================================================
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".

Reply via email to