translation a model in directx

Started by
0 comments, last by Sc4Freak 16 years ago
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
The more applications I write, more I find out how less I know
Advertisement
Correct. All you need to do is create a translation matrix is set it using SetTransform().
NextWar: The Quest for Earth available now for Windows Phone 7.

This topic is closed to new replies.

Advertisement