use of org.rajawali3d.math.Matrix4 in project Rajawali by Rajawali.
the class Renderer method unProject.
public Vector3 unProject(double x, double y, double z) {
x = mDefaultViewportWidth - x;
y = mDefaultViewportHeight - y;
final double[] in = new double[4], out = new double[4];
Matrix4 projectionMatrix = getCurrentCamera().getProjectionMatrix().clone();
Matrix4 MVPMatrix = projectionMatrix.multiply(getCurrentCamera().getViewMatrix());
MVPMatrix.inverse();
in[0] = (x / mDefaultViewportWidth) * 2 - 1;
in[1] = (y / mDefaultViewportHeight) * 2 - 1;
in[2] = 2 * z - 1;
in[3] = 1;
Matrix.multiplyMV(out, 0, MVPMatrix.getDoubleValues(), 0, in, 0);
if (out[3] == 0)
return null;
out[3] = 1 / out[3];
return new Vector3(out[0] * out[3], out[1] * out[3], out[2] * out[3]);
}
use of org.rajawali3d.math.Matrix4 in project Rajawali by Rajawali.
the class WorkaroundScreenQuad method render.
public void render(Camera camera, final Matrix4 vpMatrix, final Matrix4 projMatrix, final Matrix4 vMatrix, final Matrix4 parentMatrix, Material sceneMaterial) {
final Matrix4 pMatrix = mCamera.getProjectionMatrix();
final Matrix4 viewMatrix = mCamera.getViewMatrix();
mVPMatrix.setAll(pMatrix).multiply(viewMatrix);
super.render(mCamera, mVPMatrix, projMatrix, viewMatrix, null, sceneMaterial);
}
use of org.rajawali3d.math.Matrix4 in project Rajawali by Rajawali.
the class WorkaroundScreenQuad method init.
private void init(boolean createVBOs) {
mCamera = new Camera2D();
mCamera.setProjectionMatrix(0, 0);
mVPMatrix = new Matrix4();
float[] vertices = new float[] { -.5f, .5f, 0, .5f, .5f, 0, .5f, -.5f, 0, -.5f, -.5f, 0 };
float[] textureCoords = new float[] { 0, 1, 1, 1, 1, 0, 0, 0 };
float[] normals = new float[] { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1 };
int[] indices = new int[] { 0, 2, 1, 0, 3, 2 };
setData(vertices, normals, textureCoords, null, indices, createVBOs);
vertices = null;
normals = null;
textureCoords = null;
indices = null;
mEnableDepthTest = false;
mEnableDepthMask = false;
}
Aggregations