http://forum.thegamecreators.com/?m=forum_view&t=166930&b=1
The Flexible Vertex Format is a way of telling DX what format your vertices are stored as. The most common one is 274, which is 32 bytes per vertex. The second most common one contains a diffuse value as well and is known as 338, which makes each vertex 36 bytes.
The default DBP FVF is 274, so lets see how that is calculated.
#constant FVF_XYZ = 0x002
#constant FVF_XYZ = 0x002
#constant FVF_XYZRHW = 0x004
#constant FVF_XYZB1 = 0x006
#constant FVF_XYZB2 = 0x008
#constant FVF_XYZB3 = 0x00A
#constant FVF_XYZB4 = 0x00C
#constant FVF_XYZB5 = 0x00E
#constant FVF_NORMAL = 0x010
#constant FVF_PSIZE = 0x020
#constant FVF_DIFFUSE = 0x040
#constant FVF_SPECULAR = 0x080
#constant FVF_TEX0 = 0x000
#constant FVF_TEX1 = 0x100
#constant FVF_TEX2 = 0x200
#constant FVF_TEX3 = 0x300
#constant FVF_TEX4 = 0x400
#constant FVF_TEX5 = 0x500
#constant FVF_TEX6 = 0x600
#constant FVF_TEX7 = 0x700
#constant FVF_TEX8 = 0x800
Every vertex in DBP has:
-3 floats for coordinates in 3D space
-3 floats for normal data
-2 floats for UV data
So:
myFVF = FVF_XYZ || FVF_NORMAL || FVF_TEX1
Or in other words:
myFVF = 0x002 + 0x010 + 0x100 = 0x112 =
274
If you want your vertex to support diffuse, you just add that flag as well:
myFVF = FVF_XYZ || FVF_NORMAL || FVF_DIFFUSE || FVF_TEX1
myFVF = 0x002 + 0x010 + 0x040 + 0x100 = 0x152 =
338
You have to make sure to change the vertex size in the memblock header as well.
rem using FVF 274
write memblock dword memID, 0, 274
write memblock dword memID, 4, 32 : rem size of 32 is required with FVF 274
rem using FVF 338
write memblock dword memID, 0, 338
write memblock dword memID, 4, 36 : rem size of 36 is required with FVF 338
The sizes can be looked up
here.
You may also want to convert objects between two formats, in which case you may use the command:
TheComet
Private CARROT() As Char = {"^"c} - The codebase