#### Archived

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

# Noob at Direct3D

This topic is 5468 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Does the world matrix transform all the vertices streams? and them only? What does the world matrix values stand for, which columns or rows represent which values? How would I use world matrix to rotate vertices that are of screen coordinate values? I would appreaciate help on this matter.

##### Share on other sites
The world matrix represents a new cartesian space, optionally rotated, scaled and/or transformed.

In DirectX (Vectors being pre-multiplied to matrices), the first three rows represent the x,y,z axis of this new space. The fourth column give you your translation.

Your view matrix is the inverse of a similar matrix. You can extract your x,y,z axis (your orientation) from the 1st, 2nd and 3rd column of you view matrix.

##### Share on other sites
quote:
Original post by UdayK
The world matrix represents a new cartesian space, optionally rotated, scaled and/or transformed.

In DirectX (Vectors being pre-multiplied to matrices), the first three rows represent the x,y,z axis of this new space. The fourth column give you your translation.

Your view matrix is the inverse of a similar matrix. You can extract your x,y,z axis (your orientation) from the 1st, 2nd and 3rd column of you view matrix.

I got vertices with the values of x, y, z and rhw, color.
The world matrix would change only the x, y, z values?
Then how would a 4X4 matrix change the x, y, z values of the vertics?

##### Share on other sites
If you have rhw (which is usually set to 1), your x,y define the vertex in 2d screen coordinates and the z value specify the depth value for the vertex.

For how transformations are applied, you need a good introductry tutorial to help you. Gamedev.net hosts a very good collection of the same. You should try reading them up.

##### Share on other sites
quote:
Original post by UdayK
If you have rhw (which is usually set to 1), your x,y define the vertex in 2d screen coordinates and the z value specify the depth value for the vertex.

For how transformations are applied, you need a good introductry tutorial to help you. Gamedev.net hosts a very good collection of the same. You should try reading them up.

Does the stream buffer of vertices is the final stage before rendering? or does the world matrix is implemented on all the vertices in the stream buffer before rendered?

##### Share on other sites
The world transform would be applied to all untransformed vertices you have, before they are passed down the pipeline for per-pixel operations.

If you have vertex shaders you may choose to apply the transform or forward the vertices as they came in.

##### Share on other sites
quote:
Original post by UdayK
The world transform would be applied to all untransformed vertices you have, before they are passed down the pipeline for per-pixel operations.

If you have vertex shaders you may choose to apply the transform or forward the vertices as they came in.

In code speaking,

I have created and set a vertex buffer with values:

 IDirect3DDevice9_CreateVertexBuffer(gDevice3D, 3*sizeof(CUSTOMVERTEX), 0 /* Usage */, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &gBuffer3D, NULL); IDirect3DVertexBuffer9_Lock(gBuffer3D, 0, sizeof(gvertices), (void**)&pVertices, 0 ); memcpy( pVertices, gvertices, sizeof(gvertices) ); IDirect3DVertexBuffer9_Unlock(gBuffer3D); IDirect3DDevice9_SetStreamSource(gDevice3D, 0, gBuffer3D, 0, sizeof(CUSTOMVERTEX) ); IDirect3DDevice9_SetFVF(gDevice3D, D3DFVF_CUSTOMVERTEX );
Then I have set a world matrix:

IDirect3DDevice9_SetTransform(gDevice3D, D3DTS_WORLD, &matWorld );

The rendering loop look like this:
 IDirect3DDevice9_Clear(gDevice3D, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 ); IDirect3DDevice9_BeginScene (gDevice3D); IDirect3DDevice9_DrawPrimitive(gDevice3D, D3DPT_TRIANGLELIST, 0, 1 ); IDirect3DDevice9_EndScene (gDevice3D); IDirect3DDevice9_Present (gDevice3D, NULL, NULL, NULL, NULL);

Will the world matix have any effect on the vertices I have set?

##### Share on other sites
It depends on the format of the vertices. If the rhw flag is set, then d3d doesn''t modify your vertices.

-Nik

##### Share on other sites
what is D3DFVF_CUSTOMVERTEX set to?

##### Share on other sites
quote:
Original post by Nik02
It depends on the format of the vertices. If the rhw flag is set, then d3d doesn''t modify your vertices.

-Nik

it is set to D3DFVF_XYZRHW|D3DFVF_DIFFUSE.
Why would the rhw coordinate prevent from the world matrix to change the x, y, z coordinates?
As far as I understand the rhw coordinate is the surface color coordinate, or strength.

About the 4*4 world matrix, tell me if I am right...
The first 3 rows of the matrix are the axis(orientation and scaling) of the space represented by the matrix and the fourth row is the transformation of the space(origin point).
The fourth column has no role?

1. 1
2. 2
3. 3
4. 4
Rutin
12
5. 5

• 12
• 18
• 10
• 14
• 10
• ### Forum Statistics

• Total Topics
632662
• Total Posts
3007702
• ### Who's Online (See full list)

There are no registered users currently online

×