Package ca.eandb.jmist.framework

Examples of ca.eandb.jmist.framework.Intersection


      return null;
    }
    Scene scene = pathInfo.getScene();
    Ray3 ray = sr.getRay();
    SceneElement root = scene.getRoot();
    Intersection x = NearestIntersectionRecorder
        .computeNearestIntersection(ray, root);
    if (x != null) {
      ShadingContext context = new MinimalShadingContext(Random.DEFAULT);
      x.prepareShadingContext(context);
      context.getModifier().modify(context);
      return new SurfaceNode(this, sr, context, ru, rv, rj);
    } else {
      return new BackgroundNode(this, sr, ru, rv, rj);
    }
View Full Code Here


      super.intersect(index, ray, rec);

      if (rec.isEmpty()) {
        break;
      }
      Intersection x = rec.nearestIntersection();
      MinimalShadingContext ctx = new MinimalShadingContext(Random.DEFAULT);
      x.prepareShadingContext(ctx);
      Point2 uv = ctx.getUV();
      if (trim.opacity(new Point2(uv.x(), 1.0 - uv.y())) > 0.5) {
        recorder.record(x);
        if (!recorder.needAllIntersections()) {
          break;
        }
      }
      ray = ray.advance(x.getDistance());
      I = new Interval(0, I.maximum() - x.getDistance());
    } while (true);

  }
View Full Code Here

      super.intersect(ray, rec);

      if (rec.isEmpty()) {
        break;
      }
      Intersection x = rec.nearestIntersection();
      MinimalShadingContext ctx = new MinimalShadingContext(Random.DEFAULT);
      x.prepareShadingContext(ctx);
      Point2 uv = ctx.getUV();
      if (trim.opacity(new Point2(uv.x(), 1.0 - uv.y())) > 0.5) {
        recorder.record(x);
        if (!recorder.needAllIntersections()) {
          break;
        }
      }
      ray = ray.advance(x.getDistance());
      I = new Interval(0, I.maximum() - x.getDistance());
    } while (true);

  }
View Full Code Here

      /* Loop through each intersection. */
      while (i.hasNext()) {

        CsgIntersection      x        = i.next();
        Intersection      inner      = x.getInnerIntersection();

        assert(x.getArgumentIndex() < nArgs);

        args.set(x.getArgumentIndex(), inner.isFront());
        toInside = isInside(nArgs, args);

        /* If the intersection represents the traversal from
         * outside the geometry to inside, or vice versa, then the
         * intersection is at the boundary of the combined geometry.
         * Only consider this intersection if it is within the
         * range expected by the recorder.
         */
        if (fromInside != toInside
            && recorder.interval().contains(inner.getDistance(), inner.getTolerance())) {

          /* The intersection is a front intersection if the ray
           * is passing into the geometry.
           */
          x.setFront(toInside);
View Full Code Here

    Vector3      N = this.plane.normal();

    double      ndotv    = N.dot(ray.direction());
    int        surfaceId  = (ndotv < 0.0) ? POLYGON_SURFACE_TOP : POLYGON_SURFACE_BOTTOM;

    Intersection  x = super.newIntersection(ray, t, ndotv < 0.0, surfaceId)
                .setLocation(p)
                .setUV(inversion)
                .setBasis((surfaceId == POLYGON_SURFACE_TOP) ? this.basis : this.basis.opposite())
                .setNormal((surfaceId == POLYGON_SURFACE_TOP) ? N : N.opposite());
View Full Code Here

          u /= 2.0;
          if (!fromTop)
            u += 0.5;
        }

        Intersection x = super.newIntersection(ray, t, true, fromTop ? RECTANGLE_SURFACE_TOP : RECTANGLE_SURFACE_BOTTOM)
          .setLocation(p)
          .setUV(new Point2(u, v));

        recorder.record(x);
View Full Code Here

    int id = (twoSided && RandomUtil.coin(xj))
        ? RECTANGLE_SURFACE_BOTTOM
        : RECTANGLE_SURFACE_TOP;

    Intersection x = newSurfacePoint(p, id);
    x.prepareShadingContext(context);
  }
View Full Code Here

             */
            double cx = (p.x() - p00.x()) / (p10.x() - p00.x());
            double cz = (p.z() - p10.z()) / (p11.z() - p10.z());

            if (cx > cz) {
              Intersection x = newIntersection(ray, t, ray.direction().dot(plane.normal()) < 0.0)
                .setBasis(Basis3.fromW(plane.normal(), Basis3.Orientation.RIGHT_HANDED))
                .setLocation(p);

              recorder.record(x);

              hit = true;
            }
          }

          plane = Plane3.throughPoints(p00, p11, p01);
          t = plane.intersect(ray);

          if (I.contains(t)) {
            Point3 p = ray.pointAt(t);

            /* Get the normalized (x,z) coordinates, (cx, cz),
             * within the bounds of the cell.  If cx < cz, then
             * the intersection hit the triangle, otherwise, it hit
             * the plane, but on the other half of the cell.
             */
            double cx = (p.x() - p00.x()) / (p10.x() - p00.x());
            double cz = (p.z() - p10.z()) / (p11.z() - p10.z());

            if (cx < cz) {
              Intersection x = newIntersection(ray, t, ray.direction().dot(plane.normal()) < 0.0)
                .setBasis(Basis3.fromW(plane.normal(), Basis3.Orientation.RIGHT_HANDED))
                .setLocation(p);

              recorder.record(x);

View Full Code Here

    private final EnumMap<ScatteredRay.Type, Integer> depth = new EnumMap<ScatteredRay.Type, Integer>(ScatteredRay.Type.class);
    private int totalDepth = 0;
    private final Stack<Medium> media = new Stack<Medium>();

    public Color castPrimaryRay(Ray3 ray, WavelengthPacket lambda) {
      Intersection x = NearestIntersectionRecorder.computeNearestIntersection(ray, root);

      if (x != null) {
        LocalContext local = new LocalContext();
        local.ray = ray;
        local.distance = x.getDistance();
        local.front = x.isFront();
        local.medium = Medium.VACUUM;
        local.importance = lambda.getColorModel().getWhite(lambda);

        stack.push(local);
        x.prepareShadingContext(this);

        Color color = shade();

        stack.pop();
        return color;
View Full Code Here

    }

    public Color castRay(ScatteredRay sr) {
      ScatteredRay.Type type = sr.getType();
      Ray3 ray = sr.getRay();
      Intersection x = NearestIntersectionRecorder.computeNearestIntersection(ray, root);

      if (x != null) {
        totalDepth++;
        depth.put(type, getPathDepthByType(type) + 1);

        boolean pop = false;
        Medium popped = null;
        if (sr.isTransmitted()) {
          if (isFront()) {
            media.push(getMaterial());
            pop = true;
          } else if (!media.isEmpty()) {
            popped = media.pop();
          }
        }

        Medium ambientMedium;
        Medium medium = media.isEmpty() ? Medium.VACUUM : media.peek();
        if (x.isFront()) {
          ambientMedium = medium;
        } else {
          ambientMedium = media.size() > 1 ? media.elementAt(media.size() - 2) : Medium.VACUUM;
        }

        LocalContext local = new LocalContext();
        local.ray = ray;
        local.distance = x.getDistance();
        local.front = x.isFront();
        local.medium = ambientMedium;
        local.importance = sr.getColor().times(stack.peek().importance);

        stack.push(local);
        x.prepareShadingContext(this);

        Color color = shade();
        color = color.times(medium.transmittance(local.ray,
            local.distance, color.getWavelengthPacket()));
View Full Code Here

TOP

Related Classes of ca.eandb.jmist.framework.Intersection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.