23 Nov 2015, 17:46
Hi Ketschak,
I had suspected that I would have to use the transformation matrix.
Now I will study new possibilities with these instruments you showed me.
Thanks again!
Best Regards.
I had suspected that I would have to use the transformation matrix.
Now I will study new possibilities with these instruments you showed me.
Thanks again!
Best Regards.
(23 Nov 2015, 12:26)Ketschak Wrote: Here is an example how to add an additional rotation transform:
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;
✠ nnDnn ✠ The peace of Christ! ✠ nnDnn ✠