How to covert world coord. to pixels

Started by
2 comments, last by Trajar 23 years, 8 months ago
I want to move a D3DVERTEX 32px up and 16 left (for tiling demo). Right now I am using VECTORS, but a vector of (-16, 32, 0) is not quite the same I realize that depending on the z-buffer, a pixel is different depending on how close your are ''zooming in'', so with this aside, how would you do the conversion? Or do I need to come up with another way of doing things? Thanks in advance
Advertisement
I don''t sure about you want, but the viewmatrix may use.


-eng3d.softhome.net-
-----------------------------------------------"Cuando se es peon, la unica salida es la revolución"
The problem doesn''t lie in the Z buffer but in the way you create your projection matrix and where you put the surface you probably apply a texture to.
You need to know some matrix math for this, which I don''t I''m afraid.
OK.. I guess my first post was a little unclear. When I create a box (for example) I want it to be a rombus the same size as the 30x30 texture I''m slapping on to it. So, at the origin (z=0) I want the box to be 30x30.

If I create the boxes 4 vertices with vectors

D3DVECTOR p1 = D3DVECTOR( 0, 30,0);
D3DVECTOR p2 = D3DVECTOR( 30, 0,0);
D3DVECTOR p3 = D3DVECTOR( -30, 0,0);
D3DVECTOR p4 = D3DVECTOR( 0, -30,0);
D3DVECTOR n = Normalize ( D3DVECTOR(1,1,1) );
Vertex[0] = D3DVERTEX( p1, n, 0.0f, 1.0f);
Vertex[1] = D3DVERTEX( p2, n, 0.0f, 1.0f);
Vertex[2] = D3DVERTEX( p3, n, 0.0f, 1.0f);
Vertex[3] = D3DVERTEX( p4, n, 0.0f, 1.0f);

I get a HUGE shape that covers the screen even as I back the camera up a few thousand points back alond the z-axis. However, if I use small numbers like 0.5f I get better results?

How is the math different? What am I not grasping?

Thanks,
Alex

This topic is closed to new replies.

Advertisement