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

How does D3D do matrix transformations?

Started by Spartacus Apr 11, 2002 at 9:39 AM 1 replies 150+ views
Original Post
Spartacus
Spartacus
Can someone please explain this to me? I know how the matrices are multiplied together and I know that D3D transforms vertices using matrices. But I just can''t understand how it is done? I know I got a vertex with three components, X, Y and Z. But how can this ever fit into a 4x4 matrix? I have read a tutorial which explaied how you can do the transformations yourself by building a matrix with 4 vertices. It looks like this: [x1, x2, x3, x4] [y1, y2, y3, y4] [z1, z2, z3, z4] [1, 1, 1, 1] This matrix is then multiplied by other matrices to apply transformations. But is this the same way D3D does things? Someone please explain this to me.
Real programmers don't document, if it was hard to write it should be hard to understand
incin
incin
i think that you add a 4th value of 1 to your vector, and then multiply like that. If you dont want to do it yourself, there is a function to do it for you.
either
D3DXVec3TransformCoord() {returns 3 component vector}
or
D3DXVec3Transform() {returns 4 component vector, includes w}

will do ya i believe. You probably want the first one.
S1CA
S1CA
Yup, you add a 4th component called W...

if you concatenate the world, view and projection matrices together to form a single matrix, you transform each vertex XYZW by it, then afterwards to go back to 3 dimensions you do:

X'' = X/W
Y'' = Y/W
Z'' = Z/W
RHW= 1/W

"Homogeneous matrices" is the search term you''re after.

In fact you don''t even have to look very far - the DirectX SDK docs contain this information!!:

DirectX 8.1 (C++) ->
DirectX Graphics ->
Programmers Guide ->
Using Direct3D ->
Vertex Data ->
Fixed Function Vertex and Pixel Processing ->
Vertex Formats ->
Transformed and Lit Vertices






--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Topic Locked

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

Sign in to reply to this topic.