void player_update() { GLfloat v[3] = { player.lx - player.x, player.ly - player.y, player.lz - player.z}; GLfloat * c = player.matrix; GLfloat * v1 = player.velocity; GLfloat v2[2]; /* multiply the view vector by the transformation matrix */ v[0] = c[0] * v[0] + c[4] * v[1] + c[8] * v[2] + c[12]; v[1] = c[1] * v[0] + c[5] * v[1] + c[9] * v[2] + c[13]; v[2] = c[2] * v[0] + c[6] * v[1] + c[10] * v[2] + c[14]; /* now do the same for the velocity vector except ignore any y transforms*/ v2[0] = c[0] * v1[0] + c[8] * v1[2] + c[12]; v2[1] = c[2] * v1[0] + c[10] * v1[2] + c[14]; debug("v2=[%f, %f]", v2[0], v2[2]); player.x+=v2[0]; player.z+=v2[1]; player.lx+=v2[0]; player.lz+=v2[1]; sengine_lookat(player.x, player.y, player.z, player.x+v[0], player.y+v[1], player.z+v[2]); }