void rebuildMatrices() { if (!needsRebuild) { return; } needsRebuild = false; warp_Vector forward, up, right; forward = warp_Vector.sub(lookat, pos); if (Math.Abs(forward.x) < 0.001f && Math.Abs(forward.z) < 0.001f) { right = new warp_Vector(1f, 0f, 0f); if (forward.y < 0) { up = new warp_Vector(0f, 0f, 1f); } else { up = new warp_Vector(0f, 0f, -1f); } } else { up = new warp_Vector(0f, 1f, 0f); right = warp_Vector.getNormal(up, forward); up = warp_Vector.getNormal(forward, right); } forward.normalize(); normalmatrix = new warp_Matrix(right, up, forward); if (rollfactor != 0) { normalmatrix.rotate(0, 0, rollfactor); } matrix = normalmatrix.getClone(); matrix.shift(pos.x, pos.y, pos.z); matrix = matrix.inverse(); normalmatrix = normalmatrix.inverse(); if (isOrthographic) { projmatrix.m00 = screenwidth / orthoViewWidth; projmatrix.m03 = halfscreenwidth; projmatrix.m11 = -screenheight / orthoViewHeight; projmatrix.m13 = halfscreenheight; projmatrix.m22 = 1.0f; } else { float screenscale = (screenwidth < screenheight) ? screenwidth : screenheight; projmatrix.m00 = screenscale / fovfact; projmatrix.m03 = 0; projmatrix.m11 = -screenscale / fovfact; projmatrix.m13 = 0; projmatrix.m22 = 1.0f; } matrix = warp_Matrix.multiply(projmatrix, matrix); }
public void project(warp_Matrix m) { matrix2 = m.getClone(); matrix2.transform(m); v2 = v.transform(matrix2); }