I was looking through my old code and I noticed an old behavior I had that
did something like the Orbit Behavior but it was horribly convoluted and I
wanted to share. =)
The transformation is a 4x4 matrix right? If I remeber correctly from when
I was playing with it the basic composition is:
Xx Yx Zx 0
Xy Yy Zy 0
Xz Yz Zz 0
Px Py Pz 1
Where X, Y, and Z are the unit vectors for the new coordinate system and P
is the offset of this coordinate system from the previous one. If you had
no offset then it would look like:
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
Each unit vector corresponds to the unit vector in the previous coordinate
system and there is no offset. There is no transformation. Say you had a
90 degree roation on z though, going from:
|y x|
| |
| x y |
+----- to -----+
/ /
/ z / z
That would look like:
0 -1 0 0
1 0 0 0
0 0 1 0
0 0 0 1
Because if you put the new x-axis in the old coordinate system it would be
<0, 1, 0> and the y-axis would be <-1, 0, 0> and z stays the same.
That kinda make sense? If you were going to have a translation up one unit
(+1 on y) but no rotation you would do:
1 0 0 0
0 1 0 0
0 0 1 0
0 1 0 1
For scaling you just change the size of the unit vectors, say you wanted a
uniform scaling of 2x on all axies:
2 0 0 0
0 2 0 0
0 0 2 0
0 0 0 1
These different properties can be combined to make up a transform. So,
what I did was each time the mouse moved I would compute the translation
and then the angle between the vector and the x-z plane. I would increase
the angle to find the new point, then the z-axis unit vector of the new
coordinate frame was just the offset vector normalized and then I found a
unit vector parallel with the x-z plane and perpendicular with the z-axis
for the x-axis and finally just crossed those two to get a unit normal for
the y-axis. All that craziness just to move the camera around in a sphere.
=) The stuff about the composition of the transformaiton matrix I always
thought was neat how that worked out, because to translate a point from
one frame to another you just multiply the two matrices together.
Will
===========================================================================
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".