Jump to content
  • Advertisement

Archived

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

maxell120

90 x 90 y 90 z

This topic is 5792 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
Of course, that''s normal. Did you expect the two rotation orders to give the same result? Maybe we can help you if you tell us why you want them to give the same result.

My site

Share this post


Link to post
Share on other sites
i''m trying to create an application just like studio max, inputing values, in three axis, then returning to the origin if reset to zero happens.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!