コード例 #1
0
  protected void setSurfaceV(float min, float max, PlotterSurface surface) {
    float fade = (max - min) / 10f;

    switch (((GeoQuadric3D) getGeoElement()).getType()) {
      case GeoQuadricNDConstants.QUADRIC_CYLINDER:
        surface.setV(min, max);
        surface.setNbV(3);
        surface.setVFading(fade, fade);
        break;

      case GeoQuadricNDConstants.QUADRIC_CONE:
        if (min * max < 0) {
          surface.setV(min, 0);
          surface.setNbV(2);
          surface.setVFading(fade, 0);
          surface.draw();
          surface.setV(0, max);
          surface.setNbV(2);
          surface.setVFading(0, fade);
          surface.draw();
        } else {
          surface.setV(min, max);
          surface.setNbV(3);
          surface.setVFading(fade, fade);
          surface.draw();
        }
        break;
    }
  }
コード例 #2
0
  /**
   * update the geometry
   *
   * @return true
   */
  protected boolean updateGeometry() {

    Renderer renderer = getView3D().getRenderer();
    GeoPlane3D geo = (GeoPlane3D) getGeoElement();
    CoordSys coordsys = geo.getCoordSys();

    float xmin1 = (float) geo.getXmin(), xmax1 = (float) geo.getXmax(), xdelta1 = xmax1 - xmin1;
    float ymin1 = (float) geo.getYmin(), ymax1 = (float) geo.getYmax(), ydelta1 = ymax1 - ymin1;

    // plane
    PlotterSurface surface = renderer.getGeometryManager().getSurface();

    surface.start(geo, getReusableSurfaceIndex());

    surface.setU(xmin1, xmax1);
    surface.setNbU(2);
    surface.setV(ymin1, ymax1);
    surface.setNbV(2);

    if (!getView3D().useClippingCube()) {
      float fading;
      fading = xdelta1 * geo.getFading();
      surface.setUFading(fading, fading);
      fading = ydelta1 * geo.getFading();
      surface.setVFading(fading, fading);
    }
    surface.draw();
    setSurfaceIndex(surface.end());

    // grid
    if (isGridVisible()) {

      PlotterBrush brush = renderer.getGeometryManager().getBrush();

      if (hasTrace()) {
        brush.start(-1);
      } else {
        brush.start(gridIndex);
      }
      removeGeometryIndex(gridIndex);
      float thickness =
          brush.setThickness(getGeoElement().getLineThickness(), (float) getView3D().getScale());

      brush.setColor(getGeoElement().getObjectColor());

      double dx = geo.getGridXd();
      geo.getGridYd();
      double dy;
      if (Double.isNaN(dx)) {
        dx = getView3D().getNumbersDistance();
        dy = dx;
      } else {
        dy = geo.getGridYd();
      }

      brush.setAffineTexture((0f - xmin1) / ydelta1, 0.25f);
      int i0 = (int) (ymin1 / dy);
      if (ymin1 > 0) i0++;
      for (int i = i0; i <= ymax1 / dy; i++)
        brush.segment(
            coordsys.getPointForDrawing(xmin1, i * dy), coordsys.getPointForDrawing(xmax1, i * dy));
      // along y axis
      brush.setAffineTexture((0f - ymin1) / xdelta1, 0.25f);
      i0 = (int) (xmin1 / dx);
      if (xmin1 > 0) i0++;
      for (int i = i0; i <= xmax1 / dx; i++)
        brush.segment(
            coordsys.getPointForDrawing(i * dx, ymin1), coordsys.getPointForDrawing(i * dx, ymax1));

      gridIndex = brush.end();

      brush.start(gridOutlineIndex);
      removeGeometryIndex(gridOutlineIndex);

      boolean showClippingCube = getView3D().showClippingCube();

      // draws the rectangle outline
      if (showClippingCube) {
        brush.setAffineTexture((0f - xmin1) / ydelta1, 0.25f);
      } else brush.setPlainTexture();
      brush.segment(
          coordsys.getPointForDrawing(xmin1, ymax1 - thickness),
          coordsys.getPointForDrawing(xmax1, ymax1 - thickness));
      brush.segment(
          coordsys.getPointForDrawing(xmin1, ymin1 + thickness),
          coordsys.getPointForDrawing(xmax1, ymin1 + thickness));

      if (showClippingCube) {
        brush.setAffineTexture((0f - ymin1) / xdelta1, 0.25f);
      }
      brush.segment(
          coordsys.getPointForDrawing(xmin1 + thickness, ymin1),
          coordsys.getPointForDrawing(xmin1 + thickness, ymax1));
      brush.segment(
          coordsys.getPointForDrawing(xmax1 - thickness, ymin1),
          coordsys.getPointForDrawing(xmax1 - thickness, ymax1));

      gridOutlineIndex = brush.end();
    }

    return true;
  }