Esempio n. 1
0
    public CubeFaceMapper(
        final ImageProcessor frontSource,
        final ImageProcessor backSource,
        final ImageProcessor leftSource,
        final ImageProcessor rightSource,
        final ImageProcessor topSource,
        final ImageProcessor bottomSource,
        final PanoramaCamera<?> camera) {
      this.frontSource = frontSource;
      this.backSource = backSource;
      this.leftSource = leftSource;
      this.rightSource = rightSource;
      this.topSource = topSource;
      this.bottomSource = bottomSource;
      this.camera = camera;
      this.front = new RectlinearCamera();
      front.setCamera(camera);

      /* cubefaces have a width and height of +1px each for off-range interpolation */
      front.setSourceWidth(frontSource.getWidth() - 1);
      front.setSourceHeight(frontSource.getHeight() - 1);
    }
Esempio n. 2
0
    @Override
    public final void map(final ImageProcessor target) {
      front.setTargetWidth(target.getWidth());
      front.setTargetHeight(target.getHeight());

      front.setCamera(camera);
      final RectlinearCamera face = front.clone();
      face.resetOrientation();
      target.reset();
      if (interpolate) /* TODO This is stupid---the mapping should have the interpolation method as a state */ {
        mapping.getTransform().set(front);
        mapping.mapInterpolated(frontSource, target);

        face.pan(Math.PI / 2.0);
        face.preConcatenateOrientation(front);
        mapping.getTransform().set(face);
        mapping.mapInterpolated(rightSource, target);

        face.resetOrientation();
        face.pan(Math.PI);
        face.preConcatenateOrientation(front);
        mapping.getTransform().set(face);
        mapping.mapInterpolated(backSource, target);

        face.resetOrientation();
        face.pan(3.0 * Math.PI / 2.0);
        face.preConcatenateOrientation(front);
        mapping.getTransform().set(face);
        mapping.mapInterpolated(leftSource, target);

        face.resetOrientation();
        face.tilt(Math.PI / 2.0);
        face.preConcatenateOrientation(front);
        mapping.getTransform().set(face);
        mapping.mapInterpolated(topSource, target);

        face.resetOrientation();
        face.tilt(-Math.PI / 2.0);
        face.preConcatenateOrientation(front);
        mapping.getTransform().set(face);
        mapping.mapInterpolated(bottomSource, target);
      } else {
        mapping.getTransform().set(front);
        mapping.map(frontSource, target);

        face.pan(Math.PI / 2.0);
        face.preConcatenateOrientation(front);
        mapping.getTransform().set(face);
        mapping.map(rightSource, target);

        face.resetOrientation();
        face.pan(Math.PI);
        face.preConcatenateOrientation(front);
        mapping.getTransform().set(face);
        mapping.map(backSource, target);

        face.resetOrientation();
        face.pan(3.0 * Math.PI / 2.0);
        face.preConcatenateOrientation(front);
        mapping.getTransform().set(face);
        mapping.map(leftSource, target);

        face.resetOrientation();
        face.tilt(Math.PI / 2.0);
        face.preConcatenateOrientation(front);
        mapping.getTransform().set(face);
        mapping.map(topSource, target);

        face.resetOrientation();
        face.tilt(-Math.PI / 2.0);
        face.preConcatenateOrientation(front);
        mapping.getTransform().set(face);
        mapping.map(bottomSource, target);
      }
    }