D3DXMESH per vertex normal...
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
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
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
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...
thx!
edwinz
[edited by - edwinnie on July 7, 2003 2:17:04 AM]
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...
thx!
edwinz
[edited by - edwinnie on July 7, 2003 2:17:04 AM]
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?!
-Nims
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?!
-Nims
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement