You have to also rotate the bricks around their x-axis, when using rotation matrix tools this is simply done before the other tilting stuff using e.g.
matrix.rotate(0.5*M_PI, 1, 0, 0); //90deg rotate
And the tilt would go like e.g
matrix.rotate(tiltAngle, 0, 0, 1);
These are examples the syntax depends on the library used.
The tangent method might be faster (less overhead) but like you are experiencing it becomes very messy very soon
matrix.rotate(0.5*M_PI, 1, 0, 0); //90deg rotate
And the tilt would go like e.g
matrix.rotate(tiltAngle, 0, 0, 1);
These are examples the syntax depends on the library used.
The tangent method might be faster (less overhead) but like you are experiencing it becomes very messy very soon
