• ### Announcements

#### Archived

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

# D3DTS_WORLDMATRIX

## Recommended Posts

Someone can explain me the function of the D3DTS_WORLDMATRIX macro ? What''s the meaning of the following code? m_pD3DDevice->SetTransform( D3DTS_WORLDMATRIX(0), &mtx1); m_pD3DDevice->SetTransform( D3DTS_WORLDMATRIX(1), &mtx2); m_pD3DDevice->SetTransform( D3DTS_WORLDMATRIX(2), &mtx3);

##### Share on other sites
Its for bending bones and the like.

Its really kinda hard to explain without some graphics, but I''ll try my best.

Lets say you have a hose and each = sign below is its own seperate polygon in a model:

===============================

Lets say you want to make it so the right side of the hose moves independently from the left side like a fire hose might, but this is 1 model. And you want the rest of the hose to move/stretch correctly automatically in 3d hardware.

What you would have to do is have 2 matrixes. One for left side, another matrix for the right side, and move them independently.

You do this by using the WORLDMATRIX macro. The left side would be WORLDMATRIX(0), the right side WORLDMATRIX(1)

But in order to make it work, you need to assign each polygon in the model a seperate weight. Or blend factor. The left side would have a weight of 0, the right side 1... That means the polygons on the right side use 100% of the worldmatrix(1), and the left would use 100% of the worldmatrix(0)... You would also assign a weight for each polygon in the middle a number between 0 and 1 depending on how much you want it to use the certain world matrix.

For each bend you need another WORLDMATRIX() to be added, and another BLEND factor included in the vertex data. The example you show would have 2 bends while my example had 1 bend.

I hope that helps...

##### Share on other sites
Hmm I have never used the macros, even though I have studied them before... I just use the ordinary WORLDMATRIX transform-mode, and use D3DX Matrix stacks to move my articulated objects..

www.cppnow.com

##### Share on other sites
I know how a matrix bone works.. but so, i must associate every matrix bones to a D3DTS_WORLDMATRIX(...) ??? If i have 100 bones i will have to put a code like this ??

for(i = 0;i < 100;i++)
m_pD3DDevice->SetTransform( D3DTS_WORLDMATRIX(i), &mtx1);

???

Correct me if i''m wrong..

• ### Forum Statistics

• Total Topics
627749
• Total Posts
2978913

• 10
• 10
• 21
• 14
• 14