Rotation with two axis.

Started by
0 comments, last by Bru 15 years, 4 months ago
Hey guys :) i found some intresting posts in this website and decided to register. i dont like being rude but i would like to ask something :) i have my little object with a dummy object which is followed by the camera(camera will always look at the object's back no matter where it is). it works fine with one axe, but when i tryed adding another one(using D3DXMatrixRotationYawPitchRoll) i got some weird result as shown in the video :
after hours of work full of pain and blood, i managed to reach the next conclusion : its probably the camera! even though its probably is the camera(or the yawpitchroll function) i cant realy seem to find what i did wrong there. would anyone mind to help me :)? here's a piece of code from my camera function :

D3DXVECTOR3 Target(0, 0,0);
 D3DXVECTOR3 sac(0, 300,0);
 D3DXVECTOR3 m_UpVector(0, 0, -1);
 D3DXMATRIXA16 m_View;
  D3DXMATRIXA16 camfix;
 

  D3DXVec3TransformCoord(&cam,&sac,&MainPlayer->Rotation);
//if(cam.y < 0){m_UpVector.z = 1;}//ignore this. probably useless
 D3DXMatrixLookAtLH(&m_View, &cam, &Target, &m_UpVector);
 D3DXMatrixTranslation(&camfix,-MainPlayer->x,-MainPlayer->y,-MainPlayer->z);


 p_dx_Device->SetTransform(D3DTS_VIEW, &(camfix*m_View));
and my object's matrix :

  D3DXMatrixTranslation(&Cordinates,x,y,z);    // translation matrix
     D3DXMatrixRotationYawPitchRoll(&Rotation,roty,rotx,rotz);
	   D3DXMatrixScaling(&Scale,scalex,scaley,scalez);    //rotation matrix
   p_dx_Device->SetTransform(D3DTS_WORLD, &(Scale*Rotation*Cordinates)); 
sorry for the bother, i will realy appreciate help :)
Advertisement
well after years of hard work i managed to find the problem
rotx*roty*rotz is not the same as YawPitchRoll and this caused me the problems. well thanks for entering :)

This topic is closed to new replies.

Advertisement