Archived

This topic is now archived and is closed to further replies.

maxell120

90 x 90 y 90 z

Recommended Posts

i know there something wrong with this one,i''m a bit new to 3d. i rotate my object by 90 about the x-axis, then by 90 about the y-axis, finally 90 about the z-axis. if i reset my values according to the inverser order of how i placed it(z,y,x), it returns to back to it''s original position. But if i reset in a different manner,for example (x,y,z) order i don''t seem to arrive at the correct origin anymore. here is a sample code on how i assign my rotation:
  

void ObjectHandle::UpdateAngles(int axis, FLOAT offset1, FLOAT offset2)
{
	float angle = 0.0f;
	D3DXVECTOR3 taxis = D3DXVECTOR3(0.0f, 0.0f, 0.0f);;
	D3DXQUATERNION tempQuat;
	D3DXQuaternionIdentity(&tempQuat);
	
	switch(axis)
	{
	case X	:	m_properties.angles.x += offset1; 

				angle = (float)sqrt(  pow(offset1,2) + pow(0.0f,2) + pow(0.0f,2));
				D3DXVec3Normalize(&taxis, &D3DXVECTOR3(1.0f,0.0f,0.0f));
				D3DXQuaternionRotationAxis(&tempQuat, &taxis, offset1);
				break;
	case Y	:	m_properties.angles.y += offset1; 

				angle = (float)sqrt(  pow(0.0f,2)+ pow(offset1,2) + pow(0.0f,2));
				D3DXVec3Normalize(&taxis, &D3DXVECTOR3(0.0f,1.0f,0.0f));
				D3DXQuaternionRotationAxis(&tempQuat, &taxis, offset1);	

				break;
	case Z	:	m_properties.angles.z += offset1; 

				angle = (float)sqrt(  pow(0.0f,2)+ pow(0.0f,2) + pow(offset1,2));
				D3DXVec3Normalize(&taxis, &D3DXVECTOR3(0.0f,0.0f,1.0f));
				D3DXQuaternionRotationAxis(&tempQuat, &taxis, offset1);

				break;
	case XY	:	m_properties.angles.x += offset1; 
				m_properties.angles.y += offset2; 
				
				angle = (float)sqrt(  pow(offset1,2)+ pow(offset2,2) + pow(0.0f,2));
				D3DXVec3Normalize(&taxis, &D3DXVECTOR3(offset1,offset2,0.0f));
				D3DXQuaternionRotationAxis(&tempQuat, &taxis, angle);
	
				break;
	case YZ	:	m_properties.angles.y += offset1; 
				m_properties.angles.z += offset2; 
	
				angle = (float)sqrt(  pow(0.0f,2)+ pow(offset1,2) + pow(offset2,2));
				D3DXVec3Normalize(&taxis, &D3DXVECTOR3(0.0f,offset1, offset2));
				D3DXQuaternionRotationAxis(&tempQuat, &taxis, angle);
	
				break;
	case XZ	:	m_properties.angles.x += offset1; 
				m_properties.angles.z += offset2; 
				
				angle = (float)sqrt(  pow(offset1,2)+ pow(0.0f,2) + pow(offset2,2));
				D3DXVec3Normalize(&taxis, &D3DXVECTOR3(offset1,0.0f, offset2));
				D3DXQuaternionRotationAxis(&tempQuat, &taxis, angle);
	
				break;
	}

m_transform.Quat *= tempQuat;
}

  
hope you guys could help thanks..

Share this post


Link to post
Share on other sites