1
\$\begingroup\$

I have objects that hold their own transform matrix (calculated every frame by the physics system) held in a linear array of floats as follows:

[m0, m1,  m2,  m3]
[m4, m5,  m6,  m7]
[m8, m9, m10, m11]

How can I assign this matrix to D3D's world matrix for use in rendering the objects?

\$\endgroup\$
4
  • \$\begingroup\$ Basically, you make the matrix available to your vertex shader through shader variables and then transform every vertex via multiplication. \$\endgroup\$
    – user13213
    Commented May 5, 2012 at 4:20
  • \$\begingroup\$ isn't there some way that I can just override the values of a world matrix with the values of the array without having to go through shaders. it just seems a little convoluted to just set a matrix to specific values. \$\endgroup\$
    – gardian06
    Commented May 5, 2012 at 15:47
  • \$\begingroup\$ That really depends if you are working with the fixed function pipeline or not. I only have experience with the programmable pipeline. \$\endgroup\$
    – user13213
    Commented May 5, 2012 at 17:15
  • 1
    \$\begingroup\$ "know the last four elements by default so they are not stored no scaling, or skewing will be taking place" The last four elements of the matrix have nothing to do with scaling or skewing. At least, not in the usual meaning of those terms. \$\endgroup\$ Commented May 6, 2012 at 21:51

1 Answer 1

1
\$\begingroup\$

If you are using the effect interface, you'll need to obtain a D3DXHANDLE to your world matrix variable (for example, by calling GetParameterBySemantic on the effect.

You can then either convert your matrix to a D3DXMATRIX and use the matrix-setting call or leave the value in its raw form and call the raw value setter. Note that to do the latter you'll need to extend your array anyway, to include the missing elements, otherwise they may be unspecified values.

If you're not using the effect framework, convert your matrix to a D3DMATRIX use the SetTransform method on your device using D3DTS_WORLD as the matrix type.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .