示例#1
0
  public void testOrtho1() {
    AndroidRenderNode androidRenderNode = new AndroidRenderNode(1080, 1920);
    Camera camera = androidRenderNode.findCamera();

    TouchToRay touchToRay = new TouchToRay(1080, 1920);

    Ray ray = touchToRay.getRay(camera, 540, 960);

    ray.getOrigin(mOrigin);
    ray.getDirection(mDirection);
    assertEquals(2.9f, mOrigin.z, FloatUtil.EPS);
  }
示例#2
0
  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));
  }