Jump to content
  • Advertisement
Sign in to follow this  
prux

Direct3D, D3DFVF_XYZ ignores my Z value

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
I havent noticed, I cant be that idiot :-) when I set this matrix then only a black screen I can see.

Share this post


Link to post
Share on other sites
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 ;)

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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" ;)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!