Direct3D, D3DFVF_XYZ ignores my Z value

Started by
18 comments, last by kauna 14 years, 1 month ago
Quote:
If he's translating the whole triangle on the Z axis.
But if you hard-code the coordinates (one vertex Z100, other Z-100) and then run the application, it won't be very evident which triangle VERTEX is "smaller" and which "bigger" ;)


Well, prove it :) I guess it depends greatly on the units he is using. 100 meters vs 100 cms vs 100 mm. Anyhow, the triangle shape would change.

Cheers!
Advertisement
The triangle shape would change (a bit), yes. My point is that if you set some coordinates, start the application, check the triangle, stop the application, change the Z coordinates, start and check again, you can easily fail to notice the difference, becase the Z coord won't have such a great effect if you're looking down the Z axis.
Btw, I don't know what you meant by the units (m, cm, mm), D3D doesn't use physical units. A box 1.0 x 1.0 x 1.0 with the same camera settings will look the same whether it represents a 1 mm large dust seed or a 1 m crate.

Anyway, back to the topic - prux, have you advanced anyhow? Have you confirmed that the Z coordinate REALLY doesn't have any effect, regardless how it seems to be? ;)
Set this matrix before your draw calls.
D3DXMATRIX mat(    1.0, 0.0, 0.1, 0.0,    0.0, 1.0, 0.1, 0.0,    0.0, 0.0, 1.0, 0.0,    0.0, 0.0, 0.0, 1.0,);pDevice->SetTransform(D3DTS_D3DTS_VIEW, &mat);

If the triangles change it means that andrew1b is right an you should check your transformations again.
Quote:
The triangle shape would change (a bit), yes. My point is that if you set some coordinates, start the application, check the triangle, stop the application, change the Z coordinates, start and check again, you can easily fail to notice the difference, becase the Z coord won't have such a great effect if you're looking down the Z axis.


Possibly, but in this case I trust in Prux's observations and by looking the code links he provided I am strongly on the opinion that basically this thread is all about projection and camera matrices and between perspective/orthogonal projection.

Quote:
Btw, I don't know what you meant by the units (m, cm, mm), D3D doesn't use physical units. A box 1.0 x 1.0 x 1.0 with the same camera settings will look the same whether it represents a 1 mm large dust seed or a 1 m crate.


Units are something that the developer decide. It is true that Direct3D isn't based on any particular unit system. However, in order to make any sense in a 3d world, one must decide what 1 (D3D) unit represents.
For example, in one of my projects I used 1 (d3d)unit = 1 meter. So, moving 200 units in that scale system makes a huge difference compared to another project where I used 1 unit = 1 cm. Practically, this is all about the proportions and the distance of the camera to the object, but still it makes a difference.

Quote:
Anyway, back to the topic - prux, have you advanced anyhow? Have you confirmed that the Z coordinate REALLY doesn't have any effect, regardless how it seems to be? ;)


Anyway, back to the topic ... any success with your triangle? It may help to draw several triangles at different locations in 3d space when beginning to work with the view/projection/world matrices, since black screen is always confusing. Also, consider implementing some camera functionality to rotate the view in case the initial camera direction is looking into empty space.

Good luck!

trying that matrix, I get this: http://img163.imageshack.us/img163/3939/image1ypb.jpg

even I set all the Z to 0, its the same.
Quote:Original post by prux
trying that matrix, I get this: http://img163.imageshack.us/img163/3939/image1ypb.jpg

even I set all the Z to 0, its the same.

I see. That is exactly how it should be. Now try a little bit different matrix and set your viewport rectangle to the output window dimensions (Please make sure that the width and height correspond to the real values.).
D3DVIEWPORT9 vp;vp.X      = 0;vp.Y      = 0;vp.Width  = // ouput window widthvp.Height = // output window heightvp.MinZ   = 0.0f;vp.MaxZ   = 1.0f;// The matrix is now transposedD3DXMATRIX mat(    1.0, 0.0, 0.0, 0.0,    0.0, 1.0, 0.0, 0.0,    0.1, 0.1, 1.0, 0.0,    0.0, 0.0, 0.0, 1.0,);pDevice->SetTransform(D3DTS_D3DTS_VIEW, &mat);pDevice->SetViewport(&vp);

hmm the error must be somewhere elsewhere... if I change the fov, etc (D3DTS_PROJECTION) it doesnt have any effect. I will have to check my vertexes
ok, the error was: I used D3DXSPRITEs, in begin/end pairs. This spoils the 3D renderering. Now I use 0.5, 0.75 etc coordinates. Fine. Solved :]
one more thing, if I turn the stencilbuffer on (AutoDepthStencilFormat:= D3DFMT_D16; EnableAutoDepthStencil:= TRUE;) it shows nothing. When I turn it off, everything works good, now with my camera system I can move in my 3D world greatly. Any idea with the stencilbuffer maybe?
Quote:Original post by prux
one more thing, if I turn the stencilbuffer on (AutoDepthStencilFormat:= D3DFMT_D16; EnableAutoDepthStencil:= TRUE;) it shows nothing. When I turn it off, everything works good, now with my camera system I can move in my 3D world greatly. Any idea with the stencilbuffer maybe?


Quote from msdn

Quote:
If EnableAutoDepthStencil is true, AutoDepthStencilFormat must be a valid depth stencil format.


It seems that AutoDepthStencilFormat:= D3DFMT_D16 isn't valid depth stencil format, which is logical since D3DFMT_D16 is a depth only format.

Cheers!

This topic is closed to new replies.

Advertisement