Here is an example how to add an additional rotation transform:
and here is an example how to rotate the cube with the mouse:
void App::ColorCubeLogic::OnProcessTick(const Logic::IState* state)
{
static Double angleX = 0;
static Double angleY = Math::HALF_PI;
static Double spinSpeed = 0.007;
angleX += spinSpeed;
angleX = Math::Fmod(angleX, Math::TWO_PI);
angleY = Math::Fmod(angleY, Math::TWO_PI);
mCubeTransform->SetRotation(angleX, angleY, 0);
Graph::Matrix transform(Matrix::IDENTITY);
transform.SetRotationComponentX(angleX);
Graph::Matrix& cubeTransform = mCubeTransform->GetTransform();
cubeTransform = transform * cubeTransform;
and here is an example how to rotate the cube with the mouse:
void App::ColorCubeLogic::OnProcessTick(const Logic::IState* state)
{
Logic::IDeviceHandler* deviceHandler = state->GetDeviceHandler();
static Real posX, posY;
Real oldX = posX;
Real oldY = posY;
deviceHandler->GetMousePosition(posX, posY);
Real dx = oldX - posX;
Real dy = oldY - posY;
Graph::Matrix transform(Matrix::IDENTITY);
if (deviceHandler->IsMouseButtonPressed(IEnums::MOUSE_BUTTON_LEFT))
{
transform.SetRotationComponentXYZ(2*dy,-2*dx,0,IEnums::ROTATION_ORDER_ZYX);
}
Graph::Matrix& cubeTransform = mCubeTransform->GetTransform();
cubeTransform = transform * cubeTransform;