Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


D3DXMESH per vertex normal...

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

ok! after doing this D3DXComputeNormals(), suppose if i want to extract a normal for each vertex, how do i do it? need some advice... edwinz

Share this post

Link to post
Share on other sites
1. ID3DXBaseMesh::GetFVF to get the FVF code for the mesh.

2. D3DXGetFVFVertexSize() to find the size of each vertex in the mesh based on its FVF.

3. ID3DXBaseMesh::LockVertexBuffer to get the vertices used in the mesh.

4a. Take a look at the FVF layout chart in the docs:
DirectX Graphics ->
Programming Guide ->
Getting Started with Direct3D ->
Vertex Formats

4b. All components of FVF vertex buffers will be layed out in the order shown in that chart, so using the FVF code obtained in step 1, you can find the offset of the normal from the start of each vertex in memory.

4c. IIRC there''s a piece of code called something like "crack FVF" in the "Shader Workshop" source code from Meltdown 2001, it''s also on the msdn.microsoft.com/directx website.

Simon O''Connor
ex -Creative Asylum
Programmer &
Microsoft MVP

Share this post

Link to post
Share on other sites
hmm...okie thx!

aniwae i was wondering if this is still correct?
i queried each vertex for their uv,
u seems to give a value >0 but <1
but v seems to give a value <0 but >-1

does this sound logical?

oh ya, i was wondering if the surface(a surface can have >1 faces) normal can be found by aggretating the face normals and averaging them?

need some more advice...


[edited by - edwinnie on July 7, 2003 2:17:04 AM]

Share this post

Link to post
Share on other sites
About the FVF, after you have extracted the FVF, to find out if it contains a specific element or not, just logically AND the specific elemnt with the FVF you obtained.
If the result is not zero (it is either zero or the value of the flag) then it means that it contains that value, make a loop that goes through all of these values and then finds the offset from the start (as S1CA said)

Just be careful that an FVF cannot have D3DFVF_TEX1 and D3DFVF_TEX2 or D3DFVF_TEX3 at the same time, It can only have one. On my experiment, It strangly turned out that the fvf include TEX1 3 and 5 but the correct one was TEX1 so in your loop, you have to stick to the first texture corrdinate you find valid in the FVF.

I wish they made a function that you could get individual vertices out of meshes. I mean ... Isn''t that sometimes awfully neccessary?!


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!