Resetting orientation after rotation

Hello. I’m sure this is a simple question, but I don’t know enough yet about the terminology to find how to achieve what I want.

Here’s what I want to do:

  • I create a pyramid
  • I rotate it upside-down so it points to the “ground”
  • I then try to rotate it around the Y-axis like a spinning top, but it goes in the opposite direction than intended

I know this is because it was first flipped upside down, but I’m not sure how to ‘reset it’ so it spins on the Y-axis correctly.

That’s because rotate uses its local coordinate system to rotate around. You want to rotate around the global axis which would be I think

[Java]
Quaternion q = new Quaternion ().fromAngles(angle, vector); // or however you have the quaternion you want to rotate your model around.
q.multLocal (spatial.getLocalRotation ()); // multiplying this way uses the parent’s coordinate system
spatial.setLocalRotation (q);[/java]

Edit: Realized all the grammatical errors after typing this on the phone, so correcting them.

Or attach the pyramid to a node, orient it in the node however you like and rotate the node.

Thank you both. I went with zarch’s suggestion in the end, which worked ok (and is probably a bit more robust?).

If you can use nodes then do it :slight_smile:

Well, I don’t know that its more robust but its definitely simpler… and that generally leads to better reliability etc :slight_smile: