#### Archived

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

# getting normals out of vertexbuffer

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

## Recommended Posts

I have vertex buffer from D3DXMesh. I have FVF for it. How do I get normals of this vertex buffer? I want to know offset of normal component in each vertex in buffer. The FVF is not constant, so I have to caclulate offset of normal. How?

##### Share on other sites
Just clone the mesh to a KNOWN FVF, then it will be the same everytime.

##### Share on other sites
Hi - even though the FVF will change, the relative position of the normals in the vertex structure will not.

For example, if the FVF flag is D3DFVF_XYZ Or D3DFVF_NORMAL Or D3DFVF_TEX1

Then the structure that holds the vertex definition will look like this:

Type CustomVertexx as single             ''(0-3)y as single             ''(4-7) z as single             ''(8-11)nx as single            ''(12-15)ny as single            ''(16-19)nz as single            ''(20-23)tu as single            ''(24-27)  tv as single            ''(28-31)end type

Since each element takes up four bytes, then you can extract the normals by copying bytes 12-15, 16-19, and 20-23 respectively.

The same would hold true for difference variations on the FVF structure. Although the members of the structure can change, they always have to be in the same relative order (if you declared a structure that put the texture members before the position members, then the structure wouldn''t work correctly).

Once you figure out what elements the FVF structure has, then you can easily figure out where the normal info is stored.

Hope this helps-

BM

1. 1
2. 2
3. 3
4. 4
Rutin
18
5. 5

• 11
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631420
• Total Posts
2999990
×