Order of data in vertex?

Started by
2 comments, last by DarkZoulz 19 years, 6 months ago
I want to load a mesh into a direct3dx mesh object and then be able to lock it's vertex buffer and get the data in it. For that to work I need to get the FVF that was used when building the vertex buffer, and that's no problem with GetFVF(). I get the total size of the FVF with D3DXGetFVFVertexSize(). But I would like to know in what order the data is in, so I can parse it. Any ideas?
Advertisement
Vertex data that is compatible with the fixed function pipeline has it's elements arranged in the same order. So if the FVF had D3DFVF_XYZ then that would always be first, and textures would always be last. There used to be a page in the sdk docs about the order in which fvf data must be declared in, but I can't find it anymore. Off the top of my head however it's

xyz or xyzrhw (cant have both)
normal
point size
color
specular
tex coordinates
[size=2]aliak.net
While it is possible to calculate the component's offsets manually (like IFooBar said), D3DX already has a function for this purpose - D3DXDeclaratorFromFVF(). It returns an array of D3DVERTEXELEMENT9 structures, which contain comprehensive info about the vertex components, including their offsets.

Niko Suni

Ok, thanks. I'll check the SDK. It probably is in there. :)

This topic is closed to new replies.

Advertisement