Direct3D, D3DFVF_XYZ ignores my Z value

Started by
18 comments, last by kauna 14 years, 1 month ago
Im using this article: http://www.two-kings.de/tutorials/dxgraphics/dxgraphics03.html this is how I built my program. But whatever Z value I set, the triangle remains perpendicularly to me. It ignores my Z value - what should I do? I dont touch any camera settings. And in addition, my values are bigger, about 200. Thx in advance.
Advertisement

Hi,

While looking at the link you provided, I couldn't see any mentions of setting the projection matrix.

I guess that you are using an orthographic projection which could explain the results you are having (ie. z value not having an effect).

http://msdn.microsoft.com/en-us/library/ee422164(VS.85).aspx

Cheers!

How are you changing the Z value? Do you still keep all the Z values of the vertices of a particular object (triangle/ quad) the same of did you try to make them different? Your remark about the triangle remaining perpendicular to the camera suggests the second case, imho. If this is true then I don't think it has anything to do with the orthographic projection matrix.

I would help us if you showed us the X, Y, Z values you are using and some screenshots of the result.
here is the image: http://img230.imageshack.us/img230/8610/triangler.jpg

coordinates (x,y,z and diffuse)

100,100,50, [255,0,0,255]
200,200,100, [0,255,0,255]
100,200,-100, [0,0,255,255]

I set it once
I didn't see your example, but it's probably the projection matrix. Try using a perspective matrix:

D3DXMATRIX matProj;D3DXMatrixPerspectiveFovLH(&matProj, D3DX_PI/4,	1.5f,	1.0f,	100.0f);pDevice->SetTransform(D3DTS_PROJECTION, &matProj);


According to what you described, the example might be using an orthogonal matrix.

EDIT: Anyway, if you a trying a perspective projection, a "single triangle" is not enough to notice the perspective effect. So, maybe it is working but you just couldn't notice.
...
I havent noticed, I cant be that idiot :-) when I set this matrix then only a black screen I can see.
Have you considered positioning your camera backwards?
...
Quote:Original post by prux
here is the image: http://img230.imageshack.us/img230/8610/triangler.jpg

coordinates (x,y,z and diffuse)

100,100,50, [255,0,0,255]
200,200,100, [0,255,0,255]
100,200,-100, [0,0,255,255]

I set it once


That can perfectly correspond to that image, there doesn't have to be any problem at all.
If you're looking in the direction of the Z axis, you won't be able to see whether the vertex is at Z = 50 or Z = -100.
Even perspective projection won't help you much if there's only one triangle on the screen.

If changing X and Y works, I bet also the Z changes are effective, it's just not easy to actually see it. You say it remains perpendicular to you, I say you cannot be sure about this ;)
Quote:
Even perspective projection won't help you much if there's only one triangle on the screen.


Actually it does help. With perspective projection the triangle will get smaller/bigger as the Z value is changed

Quote:
when I set this matrix then only a black screen I can see.


You are probably looking into wrong direction or the triangle is clipped by z-buffer.

see this link
for information about direct3d matrices which is must-to-know information.

Cheers!
Quote:
Actually it does help. With perspective projection the triangle will get smaller/bigger as the Z value is changed


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" ;)

This topic is closed to new replies.

Advertisement