void RubikCube::transform(int axis, bool is_clockwise) { count++; Matrix3 mat; int x, y, z; float theta; theta = is_clockwise ? -DELTA_ANGLE : DELTA_ANGLE; switch (axis) { case 0: case 1: case 2: for (y = 0; y < 3; y++) for (z = 0; z < 3; z++) SubCube[axis][y][z]->multiMatrix(mat.Rotate(theta, axis/3)); if (count == COUNT_MAX_NUM) { count = 0; updateCubeIndex(axis, is_clockwise); } break; case 3: case 4: case 5: for (x = 0; x < 3; x++) for (z = 0; z < 3; z++) SubCube[x][axis%3][z]->multiMatrix(mat.Rotate(theta, axis/3)); if (count == COUNT_MAX_NUM) { count = 0; updateCubeIndex(axis, is_clockwise); } break; case 6: case 7: case 8: for (x = 0; x < 3; x++) for (y = 0; y < 3; y++) SubCube[x][y][axis%3]->multiMatrix(mat.Rotate(theta, axis/3)); if (count == COUNT_MAX_NUM) { count = 0; updateCubeIndex(axis, is_clockwise); } break; default: break; } }
void Opengl2dPainter::renderBegin(Pen& pen, Matrix3& matrix) { OpenglContext oglcontext(_pPimpl->hdc, _pPimpl->hrc); glClearColor(pen.color().r/ 255.0, pen.color().g/255.0, pen.color().b/255.0, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); Matrix3 m; m.Rotate( _pPimpl->angle); _pPimpl->worldMatrix = matrix * m; }