Skip to main content
gamedev.net
🔒 Locked

Vertex format

Started by giugio 9 replies 2.2k views
Original Post
giugio
giugio
Hy. I have this vertex format: DWORD FVF = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1; and i would set a vertex format for a skeleton animation with 3 blend indexes(3 bones index that influence each vertex) and 3 weight. The index are INT and the weights are 3 FLOAT. Thanks.
Rewdew
Rewdew
Quote:
and i would set a vertex format for a skeleton animation with 3 blend indexes(3 bones index that influence each vertex) and 3 weight.
The index are INT and the weights are 3 FLOAT.

This article should help (for more than just the FVF): http://msdn.microsoft.com/en-us/library/bb174594(VS.85).aspx
If you need something more flexible (who doesn't), you might want to use vertex shaders and a vertex declaration...
giugio
giugio
Original post by Rewdew
Quote:
If you need something more flexible (who doesn't), you might want to use vertex shaders and a vertex declaration...

indeed i would use a vertex shader, but i'm don't know the right vertex declaration: i have 3 index blend(that are the only 3 major bones that influencing the vertex(3 int or array of int) and the 3 weigth relative(3 float).
how is the vertex declaration?
thanks.
FeverGames
FeverGames
return VertexFormat.Position | VertexFormat.LastBetaColor | VertexFormat.LastBetaUByte | VertexFormat.Normal | VertexFormat.Texture | VertexFormat.Tangent | VertexFormat.Binormal;

this is how it would be in SlimDX. Dunno about the language you are using though (ignore the tangent and binormal in your case)
giugio
giugio
Quote:
Original post by FeverGames
return VertexFormat.Position | VertexFormat.LastBetaColor | VertexFormat.LastBetaUByte | VertexFormat.Normal | VertexFormat.Texture | VertexFormat.Tangent | VertexFormat.Binormal;

this is how it would be in SlimDX. Dunno about the language you are using though (ignore the tangent and binormal in your case)


I'm not understand: i have this vertex declaration:
D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1;
i must declare this other declaration?

VertexFormat.Position | VertexFormat.LastBetaColor | VertexFormat.LastBetaUByte | VertexFormat.Normal | VertexFormat.Texture | VertexFormat.Tangent | VertexFormat.Binormal;

indeed in direct3d i have D3DFVF_LASTBETA_UBYTE4 for VertexFormat.LastBetaUByte and so one...is correct?

thanks.
giugio
giugio
nobody?
jollyjeffers
jollyjeffers
Your vertex declaration is NOT adequate for vertex blending, and you will need a different one.

People are a little confused or not replying because this style of vertex blending hasn't really been used for 5-7 years - its more a relic of the 20th century (!!) and the D3D7-IM API. Everyone now is more familiar with proper vertex declarations and HLSL vertex shaders - they are, quite simply, better at this.

Also, iirc, from the GeForce 4 onwards they don't allow indexed vertex blending for this reason. Why expose the FF form when a bigger/better version exists via shaders?! Also, prior to that (or also on similar ATI hw) they only allow up to 57 (iirc) indexable matrices which coincidentally matches the size of VS1 constant buffers...

I assume you've read all of Geometry Blending (Direct3D 9) in the docs?

Richard Thomson's book and samples might be of interest. Check out the "rt_Skin" entry near the bottom.

Quote:
The index are INT
So you need to use D3DFVF_LASTBETA_UBYTE4 for Indexed Vertex Blending.

Quote:
the weights are 3 FLOAT
So you'll need to use an FVF with D3DFVF_XYZB3.

At a rough guess:
DWORD fvf = D3DFVF_XYZB3 | D3DFVF_NORMAL | D3DFVF_TEX1 |  D3DFVF_LASTBETA_UBYTE4struct Vertex{    D3DXVECTOR3 position;    D3DXVECTOR3 normal;    float[2] weights; // the third weight is implicit    DWORD blendIndices;};



hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
giugio
giugio
and how 3 int are "packed" in a WORD?
DWORD blendIndices;
giugio
giugio
how i use the vertex packed in a WORD?
jollyjeffers
jollyjeffers
unsigned __int8 w[4] = { 1, 2, 3, 4 };DWORD weight = (w[3] << 24) | (w[2] << 16) | (w[1] << 8) | w[0];


Should do the trick. Use regular bitwise arithmetic in C/C++ to achieve your goal.


hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.