Scene.GetActiveEdge

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.

Great <!– s:) –><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /><!– s:) –> It’s nice to see things comming to order. Good stuff men <!– s:D –><img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy" /><!– s:D –>

James.

[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

Ignore my previous post-I worked around the problem by writing scripts that save and load geometry snapshots. In the end it’s more versatile for my needs anyway.

No sense spending a week on scripts that are supposed to save a week of development time, LOL…

I went back and revisited the hinge pivot script to make it smarter, and I’m having trouble figuring out how SetParent and the group version of AddChild are supposed to work with already existing groups. I want to add the panel that I’ve just hinged as a child to the panel that shares an edge with it.

I have it all working (edge adjacency, finding the correct parent, etc) except for the fact that using the syntax ‘ThisGroup.SetParent AnotherGroup’ bombs out with an error, while the syntax ‘AnotherGroup.AddChild ThisGroup’ just adds empty groups to AnotherGroup instead of moving everything in ThisGroup over to AnotherGroup with its hierarchy intact.

Has anyone successfully used SetParent or AddChild to move groups into other groups?

-Mel

You must be logged in to reply in this thread.

19 posts