Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 13 May 2012
Offline Last Active May 16 2012 04:05 AM

Posts I've Made

In Topic: Direct3D9 - D3DXVec3Project + WorldViewProj Matrix

14 May 2012 - 04:54 PM

Cool...very nice to know how that function works behind the scenes.

I still have a problem, though. By using the existing WorldViewProjection matrix with D3DXVec3Project, the position where the sprite is vastly incorrect (however, it still rendered at some random position depending on my camera angle). Currently I call the function as:

D3DXMATRIX matWorldViewProj;
GetVertexShaderConstantF(8, matWorldViewProj, 4);
D3DXVec3Project(&vecOutput,&vecPosition,&Viewport,&matWorldViewProj, &matIdentity, &matIdentity);

I thought that my problem had to do with the fact that normally I would call the function as:

D3DXVec3Project(&vecOutput,&vecPosition,&Viewport,&matProj, &matView, &matIdentity);

...which would be calling D3DXVec3Project with a View * Projection matrix (since World is now an identity matrix). This is how I would call it in all other games to get the desired sprite position.

I thought I was going in the right direction when comparing this with previous methods, so then I noticed that there was a World matrix register (gWorld c0 4).

So I took the inverse of that and multiplied it with WorldViewProjection because (WorldViewProjection) x ([World]-1) = (ViewProjection).

I passed that to D3DXVec3Project, tested it in-game, and nothing rendered (the x and y positions were out of screen space (coordinates of 100000+ for x and y)).

I understand why the WorldViewProjection matrix didn't work, but now I'm confused what to do since my intuition also failed.

It sucks that I don't have a ViewProj matrix like most games to work off of. All I have is a ViewInv (inversed view) matrix, a WorldViewProj matrix, and a World matrix. Is there any way to put the matricies I have together and pass them into D3DVec3Project to get my desired result? :/