Sign in to follow this  
Richy321

Model Following camera fps issue

Recommended Posts

Richy321    122
So I have a gun/hands model that I'm trying to make follow the camera in a standard fps style. (c++ / directx) I do some transforms in hud initialisation to get the model all lining up with my camera. I thought the best way would be to multiply the models transforms by the inverse view matrix then it would apply the same translations and rotations to the model. When I inverse the view I seem to lose the scaling information, if I don't inverse its all backwards. Reapplying the scaling doesn't work. How is this done? I suspect I'm going the wrong way about it or I need to do some form of manual matrix manipulation.
void CHud::update(float elapsedTime)
{
	//change health pics, weapon icons ect.

	D3DXMATRIX viewMatrix;
	m_device->GetTransform(D3DTS_VIEW,&viewMatrix);
	D3DXMatrixInverse(&viewMatrix,NULL,&viewMatrix);

	D3DXMATRIX handsTransform = (*m_handsMesh->getTransform());
	handsTransform *= viewMatrix;

	m_handsMesh->FrameMove(elapsedTime, &handsTransform);

}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this