• Advertisement
Sign in to follow this  

translation a model in directx

This topic is 3627 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

Hi, I am trying to translate a model in Directx. I am not sure if I am doing it the right way. The following code is what I am using
// get the world transform - multiply it with the current transform
	// and then set the new transform
	D3DXMATRIX transform, invTransform, invTranspose;
	device->GetTransform(D3DTS_WORLD, &transform);
	D3DXMatrixInverse(&invTransform, NULL, &transform);
	D3DXMatrixTranspose(&invTranspose, &invTransform);
	
	D3DXVec3TransformNormal(&m_Position, &m_Position, &invTranspose);

	D3DXMatrixTranslation(&transform, m_Position.x, m_Position.y, m_Position.z);
	device->SetTransform(D3DTS_WORLD, &(transform * invTransform));

Is this the correct way to do it ? Or do I just have to create a translation matrix and do device->SetTransform(D3DTS_WORLD, &transMatrix); Thanks

Share this post


Link to post
Share on other sites
Advertisement
Correct. All you need to do is create a translation matrix is set it using SetTransform().

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement