I've still got one problem:
using the equations and rendering a quad with an image it seems that the rotation around z-axis is not right, because the image looks like to be rotated 90° to right (around z-axis).
So instead of rendering an image with arrow on it like this
^
|
|
|
its rendered like this:
------>
Here is my camera (view matrix) update code:
float cos_pitch = cosf(pitch);
float sin_pitch = sinf(pitch);
float cos_roll = cosf(roll);
float sin_roll = sinf(roll);
_forward.x = cos_pitch * sin_roll;
_forward.y = -sin_pitch;
_forward.z = cos_pitch * cos_roll;
_forward.Normalise();
_up.x = sin_pitch * sin_roll;
_up.y = cos_pitch;
_up.z = sin_pitch * cos_roll;
_up.Normalise();
_right = _up ^ _forward;
if (_right.IsZero())
_right.x = 1.0f;
else
_right.Normalise();
_up = _forward ^ _right;
_view_mat.m[0][0] = _right.x; _view_mat.m[0][1] = _right.y; _view_mat.m[0][2] = _right.z;
_view_mat.m[1][0] = _up.x; _view_mat.m[1][1] = _up.y; _view_mat.m[1][2] = _up.z;
_view_mat.m[2][0] = _forward.x; _view_mat.m[2][1] = _forward.y; _view_mat.m[2][2] = _forward.z;
and here is my quad rendering code:
// x,y,z : top left, verts go counter-clockwise
void RenderQuad(float x, float y, float z, float w, float h)
{
static CIwFVec3 verts[4];
verts[0] = CIwFVec3(x, y, z);
verts[1] = CIwFVec3(x, y-h, z);
verts[2] = CIwFVec3(x+w, y-h, z);
verts[3] = CIwFVec3(x+w, y, z);
IwGxSetVertStreamWorldSpace(s_Verts, 4);
// texture-atlas 512x512 , image on tex-atlas at (0,0) -> (63,63)
static CIwFVec2 uvs[4];
uvs[0] = CIwFVec2(0.0f, 0.0f);
uvs[1] = CIwFVec2(0.0f, 63.0f/512.0f);
uvs[2] = CIwFVec2(63.0f/512.0f, 63.0f/512.0f);
uvs[3] = CIwFVec2(63.0f/512.0f, 0.0f);
IwGxSetUVStream(uvs);
static uint16 strips[4];
strips[0] = 0;
strips[1] = 1;
strips[2] = 3;
strips[3] = 2;
IwGxDrawPrims(IW_GX_QUAD_STRIP, strips, 4);
}