cppstudent
cppstudent

Reputation: 33

How to build XMMATRIX using four FMVECTOR

Is it possible to build XMMATRIX using four FMVECTOR ? I took the idea from Frank Luna's book and I tried to build something around that but unfortunately it is clear that I did not grasp the concept well. Here it is what I wrote. Ok, I know that this code sucks but I am one of those who wants to learn everything ( and possibly even more ) so I tried.

XMVECTOR MyArray[4];
XMMATRIX() {}

XMMATRIX MyMatrix(FXMVECTOR MyArray0, FXMVECTOR MyArray1, FXMVECTOR MyArray2, CXMVECTOR My Array3 )
{
    r[0] = MyArray1;  r[1] = MyArray1; r[2] = MyArray1; r[3] = MyArray1;
}

float MyArray1[4] = { 1.0f, 3.0f, 6.0f, 5.0f };
float MyArray2[4] = { 4.0f, 3.0f, 3.0f, 7.0f };
float MyArray3[4] = { 1.0f, 3.0f, 6.0f, 3.0f };
float MyArray4[4] = { 1.0f, 0.0f, 6.0f, 0.0f };

Upvotes: 0

Views: 326

Answers (1)

mylibh
mylibh

Reputation: 153

There is a constructor you need, as said here.

Usage example:

XMVECTOR vec_array[4] = 
{
    { 1.0f, 3.0f, 6.0f, 5.0f },
    { 4.0f, 3.0f, 3.0f, 7.0f },
    { 1.0f, 3.0f, 6.0f, 3.0f },
    { 1.0f, 0.0f, 6.0f, 0.0f }
}; 

XMMATRIX matrix(vec_array[0], vec_array[1], vec_array[2], vec_array[3]);

Upvotes: 1

Related Questions