Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

software transform

Started by XiotexStudios May 17, 2006 at 12:55 PM 3 replies 450+ views
Original Post
XiotexStudios
XiotexStudios
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?
Byron Atkinson-JonesXiotex Studioswww.xiotex.com
sirob
sirob
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.
Sirob Yes.» - status: Work-O-Rama.
XiotexStudios
XiotexStudios
I completely missed those functions - gotta learn to read correctly!

BTW.. Just in case - I missed this out but the lighting model is a directional light.
Byron Atkinson-JonesXiotex Studioswww.xiotex.com
XiotexStudios
XiotexStudios
Made the changes but the results are same as without the changes.
Byron Atkinson-JonesXiotex Studioswww.xiotex.com
XiotexStudios
XiotexStudios
Actually - I take that back.

I removed the final normalize is was doing on the normal and all is fine.

Thanks for the help!
Byron Atkinson-JonesXiotex Studioswww.xiotex.com

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.