Archived

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

flukus

Having problems with my translation matrix

Recommended Posts

I''m trying to make a pnog type game with DX8 and I''m having trouble trying to get the paddle to move using a Translation Matrix. The paddle will draw fine but if I try to move it ti will disapper from the screen. The code seems fairly straight forward enough:
void TexturedQuad::Move(float x, float y)
{
	D3DXMATRIX matTranslation, matIdentity;

	d3dd->SetStreamSource(0, pVertBuffer, sizeof(Vertex));
	d3dd->SetVertexShader(D3DFVF_MYVERTEX);

	D3DXMatrixTranslation(&matTranslation, x, y, 0.0f);
	D3DXMatrixIdentity(&matIdentity);
	D3DXMatrixMultiply(&matIdentity, &matIdentity, &matTranslation);

	d3dd->ProcessVertices(0, 0, 4, pVertBuffer, D3DFVF_MYVERTEX);
}

Could the problem be that I''m using the same buffer for the stream source and destination buffer? Any help is appreciated.

Share this post


Link to post
Share on other sites
That code you''ve posted is very odd. Here''s a list of things you need to address:

1) Why are you creating an identity matrix?

2) Why are you multiplying the translation matrix by the identity matrix?

3) You haven''t called IDirect3DDevice8::SetTransform to set the translation matrix for your quad (paddle).

4) I have no idea why you''re using ProcessVertices, but what the heck... The destination vertex buffer for ProcessVertices must contain transformed vertices (i.e. the FVF must contain D3DFVF_XYZRHW). The source vertex buffer for ProcessVertices must contain untransformed vertices (i.e. D3DFVF_XYZ). By this requirement alone, your call to ProcessVertices is surely failing. You''d know that if you bothered to look at the return value from the API, or the debug messages output by the debug D3D runtime.

5) Why are you passing D3DFVF_MYVERTEX as the Flags parameter to ProcessVertices? The Flags parameter may either be 0, or D3DPV_DONOTCOPYDATA. This should also cause ProcessVertices to fail.

Good luck!

Share this post


Link to post
Share on other sites