Rotating the cube by euler engles, carries the other axes together.
#3
Apost 
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;
Reply


Messages In This Thread
RE: Rotating the cube axis and not changing the cube angle - by Ketschak - 23 Nov 2015, 12:26

Forum Jump:


Copyright © 2011-2022 Spraylight GmbH.