Archived

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

CGameProgrammer

Transforming D3DIM polygons

Recommended Posts

How do you do it? I''m not using any helper libraries. The books and tutorials I''m using either don''t cover it (inexplicably) or are simply wrong. I''m trying to get a simply triangle displayed on the screen. I can do it with a TLVERTEX structure where I specify the screen coordinates, but when I try setting up the world, view, and projection matrices and display a LVERTEX triangle, it isn''t displayed. ~CGameProgrammer( );

Share this post


Link to post
Share on other sites
Hi

First there is Documentation about using the Matrices for transforming your Vertices in the SDK Docs.
NOw to your Problem, did u build all Matrices Completely without helper Functions ? If so first set your World and ViewMatrix to the Identity,and position your Triangle at a Position in the positive z-Direction. If the Problem still exists, then it is the Projection Matrix (it is mostly the Projection Matrix) Look if you did specify all needed Values, and if they specified correct. The Projection Matrix is good documented in the SDK.
If you don''t find the Error, try to create one with an Helper function, and look what differences it has.

If the Matrices aren''t the Problem, than maybe you have set the wrong Flags in your DrawPrimitive Function ?

Lars

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by CGameProgrammer

How do you do it? I''m not using any helper libraries. The books and tutorials I''m using either don''t cover it (inexplicably) or are simply wrong. I''m trying to get a simply triangle displayed on the screen. I can do it with a TLVERTEX structure where I specify the screen coordinates, but when I try setting up the world, view, and projection matrices and display a LVERTEX triangle, it isn''t displayed.

~CGameProgrammer( );






SetTransform() the world matrix with a matrix.
then DrawPrimitive() the vertices and stuff
does that book teach you anything about matrices?

D3DMATRIX mat;

mat = identity();
/* makes a diag row of 1 in a 4 by 4 array.

mat._11 = mat._22 = mat._33 = mat._44 = 1;
mat.12 = mat.13 = mat.14 = 0;
mat.21 = mat.23 = mat.24 = 0;
...
...

mat looks like
[1, 0, 0, 0]
[0, 1, 0, 0]
[0, 0, 1, 0]
[0, 0, 0, 1]
*/

//if you wanna draw the object at the world coordinate (x,y,z) you change mat._41 mat._42 and mat._43

mat._41 = x;
mat._42 = y;
mat._43 = z;

//for rotation and other stuff look it up in the book or on this site.

pd3dDevice->SetTransform(D3DTRANSFORMSTATE_WORLD, &mat);
pd3dDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_LVERTEX, &verts[0], 4, 0);

Share this post


Link to post
Share on other sites