Sign in to follow this  

Mesh & Camera issue

Recommended Posts

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;

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

	m_handsMesh->FrameMove(elapsedTime, &handsTransform);


Share this post

Link to post
Share on other sites
I'm not sure it's clear what you are asking...

The view matrix should be calculated per frame base on the position of the camera. You say you are multiplying the model transform by the inverse view. Well again, that statement by definition means that you have already calcualte the view..?? And I have no idea what that resulting matrix would be good for.

If you want to have the camera follow some model at an offset, it's pretty simple.

1)Define your offset.
2)Place the camera position at the offset then multiple by the model transform.
3)Define the direction of the camera by the orientation of the model.
4)Set the Camera offset.
5)Do the same for the camera up if necessary but probably not.

Share this post

Link to post
Share on other sites
Hi, sorry I didn't explain myself very well.
What I actually meant was the other way around. A mesh to follow the camera movements. The mesh is actually a set of hands and a gun for an first person shooter. The hands/gun obviously need to follow where the camera is looking at all times.

I have actually got this to work, I exported a new version of the mesh and it started behaving as expected with the previous code.

The issue I have now is that it the mesh makes very jerky movements when the camera is rotated, I need a way to smooth it out.

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