• Create Account

### #ActualKaptein

Posted 30 September 2012 - 06:33 PM

you mean the last element?
its calculated like this:
element[15] += element[3] * x + element[7] * y + element[11] * z

the reason for += is because you also add element[15] * w, but here we assume w to be 1.0f

so... if you are only translating x and y, then z would be 0, and thus:
element[15] += element[3] * x + element[7] * y

nevermind, i just noticed you said -Rotate-XY
let's see....

in this code sx is sin(x), sy is sin(y), and cx is cos(x), finally cy is cos(y)

// left vector
m_Element[0] =  cy;
m_Element[1] =  sx * sy;
m_Element[2] = -cx * sy;
m_element[3] = 0.0f; // w1

// up vector
m_Element[4] = 0.0f;
m_Element[5] = cx;
m_Element[6] = sx;
m_element[7] = 0.0f; // w2
// forward vector
m_Element[ 8] =  sy;
m_Element[ 9] = -sx * cy;
m_Element[10] =  cx * cy;
m_element[11] = 0.0f; // w3

// translation
m_element[12] = 0.0f; // tx
m_element[13] = 0.0f; // ty
m_element[14] = 0.0f; // tz
m_element[15] = 1.0f; // w4


i haven't really optimized this, and as you can see this only creates a 2D rotation matrix
i think it's probably best for each rotation to make a matrix and multiply together to make a complete transformation

### #1Kaptein

Posted 30 September 2012 - 06:27 PM

you mean the last element?
its calculated like this:
element[15] += element[3] * x + element[7] * y + element[11] * z

the reason for += is because you also add element[15] * w, but here we assume w to be 1.0f

so... if you are only translating x and y, then z would be 0, and thus:
element[15] += element[3] * x + element[7] * y

PARTNERS