I'm trying to read 3D models which were created for a DirectX applications, which are defined in the following way :
n
vertices are given in a linear pattern, with the fields presents according to the FVF.However, I do not know the order of these fields. The logic would be that it is defined somewhere in DirectX documentation, but I was unable to find it. For example, which of these two structures is correct with FVF = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_NORMAL
(C syntax, but this problem applies to every language) ?
// This one ?
struct vertex1
{
D3DVERTEX pos;
DWORD color;
D3DVERTEX normal;
};
// Or this one ?
struct vertex2
{
D3DVERTEX pos;
D3DVERTEX normal;
DWORD color;
};
I would like a general answer to this question with all the possible fields (for example, XYZ before DIFFUSE before NORMAL before TEX1 before TEX2
). A pointer to the right page of the documentation would be fine too as I was not able to find it :) .
I ran into the same thing myself.
I think the order of the bits is the required order. From d3d9types.h:
#define D3DFVF_RESERVED0 0x001
#define D3DFVF_POSITION_MASK 0x400E
#define D3DFVF_XYZ 0x002
#define D3DFVF_XYZRHW 0x004
#define D3DFVF_XYZB1 0x006
#define D3DFVF_XYZB2 0x008
#define D3DFVF_XYZB3 0x00a
#define D3DFVF_XYZB4 0x00c
#define D3DFVF_XYZB5 0x00e
#define D3DFVF_XYZW 0x4002
#define D3DFVF_NORMAL 0x010
#define D3DFVF_PSIZE 0x020
#define D3DFVF_DIFFUSE 0x040
#define D3DFVF_SPECULAR 0x080
#define D3DFVF_TEXCOUNT_MASK 0xf00
#define D3DFVF_TEXCOUNT_SHIFT 8
#define D3DFVF_TEX0 0x000
#define D3DFVF_TEX1 0x100
#define D3DFVF_TEX2 0x200
#define D3DFVF_TEX3 0x300
#define D3DFVF_TEX4 0x400
#define D3DFVF_TEX5 0x500
#define D3DFVF_TEX6 0x600
#define D3DFVF_TEX7 0x700
#define D3DFVF_TEX8 0x800
I'm pretty sure that the order you are looking for is:
POSITION,NORMAL,PSIZE,DIFFUSE,SPECULAR,TEX0[,TEXn...]
I wasn't able to find a definitive answer in the documentation either.
here you are
FVF (OP says the information on this page is incorrect. I dont know, didnt check if FVF positioning is correct)
Generator
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With