probably a lot of people here have tackled this
one allready,
I did search in the archive and google, and a
lot came up, but it quickly turns complicated, with matrices and
all.
just hope there is a simple
answer...
I would like to place objects on a mesh's
points, oriented according to the normal.
getting to the positions is easy enough,
finding the normals too.
but going from the normals to an orientation is
less so.
note that I do not want to create a cluster per
point, and use objtocluster constraint, which is going to give me the result
I want.
in the end I want to be doing this with a lot
of objects and also particles so making thousands of constraints doesnt seem
right if all I'm after is "just a rotation"
any hints in where Im going wrong, and wether
this is the right approach to the problem?
----------
set sel =
selection(0)
set oGeometry =
sel.activeprimitive.geometry
set oPoints =
oGeometry.Points
for each pnt in
oPoints
set ("name" & i)
oNull.Kinematics.local.parameters("posx").value =
pnt.position.x
oNull.Kinematics.local.parameters("posy").value =
pnt.position.y
oNull.Kinematics.local.parameters("posz").value =
pnt.position.z
oNull.Kinematics.global.parameters("rotx").value =
pnt.normal.x
oNull.Kinematics.global.parameters("roty").value =
pnt.normal.y
oNull.Kinematics.global.parameters("rotz").value =
pnt.normal.z
next
-------------
now this is obviously no good for the
normals/orientations
the normal is a vector, and the rotation
are angles, so I cant just replace one with the other
right?
I tried with
radianstodegrees:
oNull.Kinematics.global.parameters("rotx").value =
xsimath.radianstodegrees(pnt.normal.x)
oNull.Kinematics.global.parameters("roty").value =
xsimath.radianstodegrees(pnt.normal.y)
oNull.Kinematics.global.parameters("rotz").value =
xsimath.radianstodegrees(pnt.normal.z)
but that doesnt look right
either
so looked all over in the scripting
reference
and noticed the existence of
setfromXYZangles and GetXYZanglesValues.
are these what I
need?
--------------------
set sel =
selection(0)
set oGeometry =
sel.activeprimitive.geometry
set oPoints =
oGeometry.Points
for each pnt in
oPoints
set ("name" & i)
oNull.Kinematics.local.parameters("posx").value =
pnt.position.x
oNull.Kinematics.local.parameters("posy").value =
pnt.position.y
oNull.Kinematics.local.parameters("posz").value =
pnt.position.z
set
oVector = XSIMath.CreateVector3
oVector.x = pnt.normal.x
oVector.y = pnt.normal.y
oVector.z = pnt.normal.z
set ROT =
XSIMath.CreateRotation
ROT.SetfromXYZAngles oVector
ROT.GetXYZAnglesValues X, Y, Z
oNull.Kinematics.global.parameters("rotx").value =
xsimath.radianstodegrees(X)
oNull.Kinematics.global.parameters("roty").value =
xsimath.radianstodegrees(Y)
oNull.Kinematics.global.parameters("rotz").value =
xsimath.radianstodegrees(Z)
next
----------------------
its different and doesnt
look right either?