Exemplo n.º 1
0
  public void test3() {
    Vec3 camPos = new Vec3(0, 0, 3);
    Vec3 camLookPos = new Vec3(-3, 0, 0);

    Camera camera = new Camera();
    camera.lookAt(camPos, camLookPos);
    Log.d("Peter100", "camera \n" + camera.getViewMatrix());

    Matrix33 tmp = new Matrix33();
    camera.getViewMatrix().getRotation(tmp);

    Vec3 pos = new Vec3();
    camera.getViewMatrix().get3x1Translation(pos);
    pos.transform(tmp);

    Log.d("Peter100", "pos = " + pos);
    //        assertEquals(camPos.x, pos.x, EPS);
    //        assertEquals(camPos.y, pos.y, EPS);
    //        assertEquals(camPos.z, pos.z, EPS);
  }
Exemplo n.º 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));
  }
Exemplo n.º 3
0
  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));
  }
Exemplo n.º 4
0
  public void testProj3() {
    Camera camera = new Camera();
    camera.lookAt(0, 0, -30, 0, 0, 0);
    camera
        .getFrustrum()
        .setPerspectiveProjection(90, Frustrum.FovType.AUTO_FIT, 0.1f, 10, 1080, 1920);

    TouchToRay touchToRay = new TouchToRay(1080, 1920);

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

    ray.getOrigin(mOrigin);
    ray.getDirection(mDirection);
    assertEquals(-29.9f, mOrigin.z, FloatUtil.EPS);
    assertTrue(mDirection.equals(new Vec3(0, 0, 1)));
  }