Notifications
Clear all

[Closed] Alignment or rotation of objects

I am currently rotating the objects based on numbers that I provide on each rotation axis. It works well.
The question is if there is any way to be able to orient the axes “just a little bit is enough” the alignment does not have to be exact with respect to the bones.
The problem is that the Z axis of the objects must not leave the “imaginary” plane that are the white lines drawn.

Sample Scene

10 Replies
planenormal = [0,0,1] -- the plane  normal
dirpos = [0,0,0] -- the dummy pos
dirnormal = [0.781506,0.493022,0.382331]  -- the bone direction
xx = normalize (cross dirnormal planenormal)
yy = cross dirnormal xx
obj.transform = (matrix3 yy dirnormal xx dirpos)

Thanks for the answer, what is the right way to use it?

It is applied to one object at a time and after that is to relocate each object to where it was originally created, is that correct? because applying the script takes the object to the center of the scene.

This value as you get it, how do you get it?
dirnormal = [0.781506,0.493022,0.382331] – the bone direction

that’s what you have created dummy’s dir

These are basic questions. Sorry.
1:How do you get the direction of a bone?, to get the transformations I use $.transform
2:When applying the new transformation to each object, should I place it back in its place of origin?

I think you havn’t learn matrix , you can use a -90 angle matrix multiply left the bone’s transform to get the Z-based matrix , you can calculate everything before created

dirpos = bone.pos
dirnormal = ((eulerangles 0 0 -90) as matrix3 * Bone.transform).row3
1 Reply
(@darwin)
Joined: 10 months ago

Posts: 0

Thanks for the explanation,… I wasn’t aware of this, I’ll keep studying.

I did a mistake , for this problem , just need use bone.transfor.row1 to get it , and for others , I used a wrong axes to rotate

It’s pretty sure I’m using it incorrectly, you can generate a .gif image and upload it to see the result you get?

Now if I understand you… It works very well! Thank you very much.