public void testOrtho2() { AndroidRenderNode androidRenderNode = new AndroidRenderNode(1080, 1920); Camera camera = androidRenderNode.findCamera(); TouchToRay touchToRay = new TouchToRay(1080, 1920); Ray ray = touchToRay.getRay(camera, 0, 960); float left = camera.getFrustrum().getLeft(); float near = camera.getFrustrum().getNear(); /** Touch at left/center. The ray should strike the left frustrum plane. */ Vec3 rayDirection = new Vec3(); Vec3.createVecFromPoints(new Vec3(0, 0, 0), new Vec3(left, 0, -near), rayDirection); rayDirection.norm(); ray.getOrigin(mOrigin); ray.getDirection(mDirection); assertEquals(2.9f, mOrigin.z, FloatUtil.EPS); assertTrue(mDirection.equals(rayDirection)); }
public void testProj4() { Camera camera = new Camera(); camera.lookAt(0, 0, 3, 0, 0, -1); camera .getFrustrum() .setPerspectiveProjection(90, Frustrum.FovType.AUTO_FIT, 0.1f, 10, 1080, 1920); TouchToRay touchToRay = new TouchToRay(1080, 1920); Ray ray = touchToRay.getRay(camera, 0, 960); float left = camera.getFrustrum().getLeft(); float near = camera.getFrustrum().getNear(); /** Touch at left/center. The ray should strike the left frustrum plane. */ Vec3 rayDirection = new Vec3(); Vec3.createVecFromPoints(new Vec3(0, 0, 0), new Vec3(left, 0, -near), rayDirection); rayDirection.norm(); ray.getOrigin(mOrigin); ray.getDirection(mDirection); assertEquals(2.9f, mOrigin.z, FloatUtil.EPS); assertTrue(mDirection.equals(rayDirection)); }