Archived

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

Dogen

Transforming vertices different within the same triangle.

Recommended Posts

Dogen    122
Hello there I am currently trying to make a 3d model to move according to a bone structure. Each bone in the bone structure has its own matrix to represent its position and rotation. In my 3d model each vertex belongs to one bone. When I draw my model I use DrawPrimitiveUP(D3DPT_TRIANGLELIST...); When I do it like this it quite often is the case that the points in one triangle will belong to different bones and therefor different matrices. So I wonder if someone has some idea of how to draw a triangle with points that can be affected by different matrices. I guess that you could use ProcessVertices to process the vertices with different matrices and then just draw them but as I understood it, it is software based and therefor quite slow. There must some other way to do this with hardware support. By the way I use C++ and DirectX 9 /dogen

Share this post


Link to post
Share on other sites
Muhammad Haggag    1358
You can use zero-weight indexed vertex blending. Basically, you set a matrix palette (a large matrix table) using SetTransform( D3DTS_WORLDMATRIX( n ), &mat );
where n ranges from 0 - 255 with SWVP, and from 0 - Caps.MaxVertexBlendIndex on HWVP.

You''ll also need to add to your FVF: D3DFVF_XYZB1 | D3DFVF_LASTBETA_UBYTE4
which tell d3d that you have a blending weight in your vertex (b1), and that the last blending weight (and in our case, the only one) is going to be used as a matrix index.

With the FFP, the weight comes after the position, before the normal as far as I recall (you''d want to check the docs to make sure).

Muhammad Haggag
MHaggag''s corner

Share this post


Link to post
Share on other sites