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.

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 on other sites
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 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 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 on other sites
I'd like to add that it's of course also possible to rotate in RHW, by using simple cos/sin fucntions.

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.

1. 1
Rutin
38
2. 2
3. 3
4. 4
5. 5

• 12
• 15
• 12
• 14
• 9
• Forum Statistics

• Total Topics
633354
• Total Posts
3011494
• Who's Online (See full list)

There are no registered users currently online

×