Sign in to follow this  
XiotexStudios

software transform

Recommended Posts

Hi, I have a need in my project to 'software transform' some vertices before sending them down to the T&L hw for final transform and projection. However, its been ages since I had to do this (back in the Amiga and 386 days!) and I have obviously forgotten the old skills :( Here is the code: // Transform the normal D3DXVec3Transform(&vec,&Vertex.m_vNormal,&mat); Vertex.m_vNormal.x = vec.x; Vertex.m_vNormal.y = vec.y; Vertex.m_vNormal.z = vec.z; D3DXVec3Normalize&Vertex.m_vNormal,&Vertex.m_vNormal); // Add in translation and scale D3DXMatrixScaling(&scale,0.5f,0.5f,0.5f); D3DXMatrixTranslation(&translation,fX,fY,0.0f); D3DXMatrixMultiply(&mat,&mat,&scale); D3DXMatrixMultiply(&mat,&mat,&translation); // transform the coordinates D3DXVec3Transform(&vec,&Vertex.m_vPos,&mat); Vertex.m_vPos.x = vec.x; Vertex.m_vPos.y = vec.y; Vertex.m_vPos.z = vec.z; And I render the above lot with a identity world matrix so in theory should mean that the end result is transformed by view and projection. Now, if I render the above with the software transform the lighting is darker than without the software transform (with the same rotation/scaling/translation parameters). I am obviously munging up the normal transformation or my basic assumptions are just plain wrong... Can anyone spot the error?

Share this post


Link to post
Share on other sites
I can't say I quite understand what you're trying to do, but it seems like you are attempting to transform a normal. Theres a function specifically for that - D3DXVec3TransformNormal, which behaves a bit differently. Note: this matrix should be given the Transpose of the transformation matrix.

Also, when I'm transforming 3 component vectors, I usually get the results I want from using D3DXVec3TransformCoord. Maybe that's the one you mean to be using?

Hope this helps.

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