0
$\begingroup$

I've been following a tutorial https://www.youtube.com/watch?v=Vxc4P0YI2rI which uses Animation Nodes to put scales on a sphere: Screenshot

So in the beginning one scale is duplicated by the Object instancer and it creates as many scales as there are a vertices on the sphere. In a loop the local track axis of every scale is rotated according to the vector normales on the sphere (with a Direction to Rotation Node) in order to make them point outwards of the sphere. Below the node setup: enter image description here

Now I want to rotate the scales on the local z-axis. That's why I added those 3 maths nodes in the Loop frame. I thought if I increase the value for the z-value the scales would rotate accordingly until they are positioned flat on the sphere. But instead they rotate on the local y-axis ! If I increase instead the y-value some of the scales rotate as desired, but others rotate to the opposite direction ! :( enter image description here

I think I missunderstood the concept of rotating objects in AN / Blender. It would be nice if someone could explain me why I get different results from what I have expected. In the video there is a fix shown but the author doesn't explain why he is doing that. The fix is nice (and simple) but without explanation it's worthless since I might encounter similar problems in my own projects when using these techniques.

My blend file can be downloaded here: https://www.file-upload.net/download-13131607/scalesonsphere.blend.html

Edit:

Hey, still I've got a problem / something I don't understand. When the initial rotation of the scale I want to put on my Icosphere looks like this: Scale initial rotation

I get weird results:

Rotation scales along local y axis

However if I rotate my scale like this :

enter image description here

and apply my node tree after (with the Z-axis set as the direction vector in the Direction to Rotation node) everything rotates as expected:

Rotation along local z axis

Why do I get different behaviours here?

$\endgroup$

1 Answer 1

1
$\begingroup$

If you wanted to rotate an object around its z local axis in blender, what do you do? Do you change the rotation z euler value? Or do you use the rotate operator in the local transform orientation? Changing the rotation euler's values rotates the object in its global space, not in its local.

So, how do we rotate in local space in Animation Nodes? The answer is matrix multiplication which is the underlying mathematics behind blender's rotation operators. Compose a translation matrix that include the object's locations, then multiply that by the Rotation Matrix Output of the Direction To Rotation Node, then multiply the result by a rotation matrix, the last matrix act as the local transformation, so by editing its values, you are locally transforming.

Matrix

Another method would be to use Hamilton product on Quaternions, they are a little harder to understand though. Simply multiply your quaternions by another that include your local rotation information.

Quaternions

Yet another method would be to edit the guide axis to account for your rotation. See the documentation.

$\endgroup$
7
  • $\begingroup$ Hello and thanks for your answer which solves my problem with the sphere. However I noticed that when I change the local axis of the scale (by rotating ite and applying Rotation with ctrl a) some of them don't rotate as expected as well. Here's a screencast: recordit.co/GhRWwaqt5s Actually I wanted all to rotate on the y axis but those 2 in the front rotate different :/ Why is that happening ? $\endgroup$
    – Tutov
    May 17, 2018 at 12:52
  • $\begingroup$ @Tutov Applying rotations align the local space with the global space ! If you want further local transformation, perform another multiplication with another rotation matrix after the existing local rotation. $\endgroup$
    – Omar Emara
    May 17, 2018 at 20:26
  • $\begingroup$ Hey I've still got a problem :( I edited my initial question, could you take a look at it ? Thank you $\endgroup$
    – Tutov
    May 20, 2018 at 7:38
  • $\begingroup$ @Tutov I see. To fix this, use the Compose Matrix Node to create rotation matrices from the Euler output of the Direction To Rotation Node and use those matrices instead of the Matrix Rotation output of the node. I am not entirely sure why our old method don't work, I will investigate this later and report back. $\endgroup$
    – Omar Emara
    May 20, 2018 at 8:43
  • $\begingroup$ Any news on this ? By the way with your new solution there comes up another question to me: Why does the Matrix Output node of the "Direction To Rotation Node" delivers a different result than the "Compose Matrix Node" (both actually got the same input, didn't they) ? $\endgroup$
    – Tutov
    May 23, 2018 at 5:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .