May 4, 2005
at 12:44 pm /
#11060
[BLOCKQUOTE class=’ip-ubbcode-quote’][div class=’ip-ubbcode-quote-title’]quote:[/div][div class=’ip-ubbcode-quote-content’]Originally posted by Paul Gausden:
The forward vector should always change at the same time as the up vector.
Since you are making the up (0,1,0), the y part of the forward vector must be 0.
If you take the original forward vector, set the Y part to 0 and re-normalise, it should work.
(Both vectors int he setorientation must always be normalised)
I learned a lot about 3D maths from a book my wife had for her uni course in 1987 – I bet you can’t find books on 3D that basic any more.
Also, the DirectX SDK has always had a good section at the start on 3D theory. [/div][/BLOCKQUOTE]
I wish I could find books that explained the stuff in idiotspeak, LOL…
It does behave the way you suggested, sort of…except it also rotates off the hinge. Visualize a box-one side of it should rotate up along the top edge with respect to the rest of the box. However, when I reset the Y component of the direction vector to 0 and use 0,1,0 as the up vector, it rotates upwards like it should, but then it also rotates to face the world Z axis.
Here’s the snippet that deals with rotating/flattening the object along a hinged edge:
[pre class=’ip-ubbcode-code-pre’]
‘Get hinge coords of both edge points (indices are stored in object name)
SelectedObject.GetPoint SelectedPointIndex1, ex1, ey1, ez1
SelectedObject.GetPoint SelectedPointIndex2, ex2, ey2, ez2
‘Get directional vector of edge and normalize
nx1 = ex2 – ex1
ny1 = ey2 – ey1
nz1 = ez2 – ez1
nLen = Sqr(nx1 * nx1 + ny1 * ny1 + nz1 * nz1)
nx1 = nx1 / nLen
ny1 = 0 ‘set to 0 as suggested
nz1 = nz1 / nLen
nx2 = 0 ‘these three values
ny2 = 1 ‘used to be
nz2 = 0 ‘the face’s normal
‘Set orientation
SelectedGroup.SetOrientation Nothing, 0, nx1, ny1, nz1, nx2, ny2, nz2
[/pre]
Math look off to you?
-Mel