This has most probably been asked before. But a search for 'fixed axes, static axes etc' did not bring up anything I wanted.
I want to rotate an object about fixed axes in 3d. In the usual examples on rotating about the x and y and z axes, the rotation about one axis changes the other axes and therefore subsequent rotations will be about the new rotated axes.
Here is what I could come up with( seeing some opengl program I had written long ago):
Quote:PMatrix3D m3d;
void setup(){
size(400, 400, P3D);
m3d = new PMatrix3D();
}
void draw(){
background(150);
translate(width/2, height/2, 200);
applyMatrix(m3d);
box(50, 50, 50);
}
void keyPressed(){
if ( key == CODED)
{
if (keyCode == UP )
{
resetMatrix();
rotate(2*PI/180.0,1.0,0.0,0.0);
applyMatrix(m3d);
getMatrix(m3d);
}
else if (keyCode == RIGHT)
{
resetMatrix();
rotate(2*PI/180.0,0.0,1.0,0.0);
applyMatrix(m3d);
getMatrix(m3d);
}
}
}
Now I have read that applyMatrix() is to be avoided. Can this sort of thing be done any other way in Processing?
Please do excuse me if this has been discussed in another post.