Rotating a 3D sphere, problem with Y axis

Hi! I am beginner with 3D in OF and have tried to solve a rotation problem, the answer is probably something simple!

I have a 3D primitive sphere that rotates to left and right based on interaction:

sphere.rotate (rotChangeX, 0.0, 1.0, 0.0);

This works fine. However, I would want the sphere to spin up and down as well when I get certain Y values. The X rotation can meanwhile continue or be stopped, does not matter. I have tried many combinations following this guide but so far with no success:

For example, if I use this combination I still get only the X rotation, not on Y axis:

 sphere.rotate (rotChangeX, 0.0, 1.0, 0.0);
 sphere.rotate(rotChangeY, 0, 1.0, 0.0);

Any help is welcome :slight_smile: warm thanks!


this did the trick!

sphere.rotate (1.0, rotChangeX, 0, 0.0);

Hey I see that you got it working, but here are a few thoughts. If I remember right, the 3d primitives have an ofNode inside them. Its .rotate() can take a quaternion as an argument, but its .rotateRad() takes 4 arguments. The first is the angle in radians, and the other three describe the axes of the rotation. So to get rotation around the x axis, you could use .rotateRad() with a non-zero argument for the x-axis, like sphere.rotateRad(rotChangeX, 1.0, 0.0, 0.0).