Jump to content
  • Advertisement
Sign in to follow this  
SpaceMonkey1000

Difference between D3DFVF_XYZ and D3DFVF_XYZRHW?

This topic is 4814 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

Hi this might seem a stupid question but iam a newby ;) If i set in my code D3DFVF_XYZRHW|D3DFVF_DIFFUSE everything works correctly but if i set in my code D3DFVF_XYZ|D3DFVF_DIFFUSE the triangle does not appear on the screen... The docu says something of untransformed vertices but what does that mean? Wky cant i use D3DFVF_XYZ? Thank you very much!!!

Share this post


Link to post
Share on other sites
Advertisement
If you use D3DFVF_XYZ, then your vertex format needs to have 3 floats in it, for x, y and z. Those are used to define a vertex position in 3D space.
If you use D3DFVF_XYZRHW, then your vertex format needs to have 4 floats in it, for x, y, z and rhw. X and Y are used to define a vertex position in 2D space, Z is ignored (I think, it may be used for fog and such, but I don't recall just now - I always set it to 0.0f), and rhw is the Reciprocal of Homogenous W - which is basically 1 / the depth of the vertex.

Usually, you use D3DFVF_XYZRHW for doing 2D, and D3DFVF_XYZ any other time. However, a lot of people just use D3DFVF_XYZ, and use an orthoganal projection matrix to make it seem 2D.

Share this post


Link to post
Share on other sites
I believe that the RHW float, when set to one, indicates that the vertice are not to be transformed. This is used for GUI developement.

ace

Share this post


Link to post
Share on other sites
Hi there space monkey,
How are you doing?

The Problem
Transformed and unTransformed vertices

The Solution
"You have to know why you will want to use Transformed vertices, They are defined in screen space and that fact you cannot change unless your transformed them to object space or world space after you have defined them. This defeats the whole purpose of using Transformed vertices anyway.

Think about it like this. Transformed vertices are used for GUI/HUD items such as your health etc... that will never be transformed by transformation matrices.

unTransformed vertices are placed in the world so that they may rotate etc.. like your meshes."


I hope this helps a bit.

Share this post


Link to post
Share on other sites
[offtopic]

Armadon - I just have to say that you are one of the most friendly guys i've seen on this forum - therefore:
 ++rating; 


[ontopic]

Yes, setting the RHW tells the direct3d pipeline NOT to apply any transformations matrices to them and you can think of them as pure 2d coords instead of 3d coords: to draw a quad that are 100 pixels wide and 100 pixels high from the upper left corner of the screen, just speficy 0, 0, 100, 100.

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!