I am attempting to make a cube that can rotate in any direction on command. I am currently trying to see if I can make it rotate at all on command, and I think that it does rotate, but I am trying to think about how to animate the rotation. Any help would be appreciated. Current code below.
I thought that by making the rotateY depend on the angle variable. I made it so that when rotate is true, the angle variable starts to increase in value, and the rotateY would rotate at the angle variable. However, it did not work. I think that it has something to do with the rotateY and the angle value.
I tested the code you posted, and I liked how it worked, although when I pressed space again, the box was reset back to its original person. I looked at the code, and I believe this is because the box is put after the rotation code.
I edited the code to my liking, and created some new variables to make the rotation a little more regulated. I still do not understand why the box keeps reappearing in its original position.
That’s probaly because when you rotate 90 degrees and then 180 degree, they look exactly the same. Try instead of float anglechgU=HALF_PI/90; better float anglechgU=HALF_PI/76; so it’s not 90, then 180… which would look exactly the same…
I am actually planning to get the sides of cube to have different colors, so I was hoping to get the rotation down first, before putting the colors in the desired positions.
This should be “after 360”.
They are not “the same angle”; mathematically sin(θ) = sin( θ+360) and will yield the same rotation and plot in this example.
I mean: after 90 degrees they look the same as 0 degrees, 180 degrees, 270 degrees, when you rotate around one axis only. So better around by 76 degrees for example
by that i meant that after I deactivate the rotation command, the box appears in its original position after the rotation stops, even if it does not rotate 90 degrees.
I think that I will need to create some vectors for the rotation code, because when I rotate the cube in the desired direction, for example, rotate it upward 90 deg/.5 pi, it seems that the entire dimensional plane moves around with it, because after the X rotation is finished, and if I rotate it to the right by pressing d, it seems like the cube rotates along its Z axis. In fact, it is actually rotating along the angleY variable with the rotateY bit I put in there. The two println functions in there were used to prove this.