Package toxi.geom

Examples of toxi.geom.Plane


    return pickBuffer;
  }

  public Vec2D getPointOnPlane(Vec2D mousePoint, Plane planeIn) {

    Plane plane = new Plane(planeIn.copy(), planeIn.normal.copy());

    Vec3D mouseRayPos = new Vec3D(mousePoint.x, mousePoint.y, planeIn.z); // this only works for planes perpendicular to the screen
    Vec3D mouseRayDir = new Vec3D(0, 0, -1);

    Vec3D focusCentre = new Vec3D(
        ((GLOBAL.windowWidth / 2) - (float)GLOBAL.CAM_OFFSET_X),
        ((GLOBAL.windowHeight / 2) - (float)GLOBAL.CAM_OFFSET_Y), 0);

    //now mouse pos is refereced from the centre of the screen
    mouseRayPos.x -= (GLOBAL.windowWidth / 2);
    mouseRayPos.y -= (GLOBAL.windowHeight / 2);
    mouseRayPos.scaleSelf((float) (1 / GLOBAL.getZOOM()));

    mouseRayPos.addSelf(focusCentre);

    Ray3D ray;

    Vec3D mousePos = null;
    Vec3D intersect;
    mouseRayDir = new Vec3D(0, 0, -1);

    plane.z = 0;
    //we need to rotate the plane so that it matches the one on the draw view
    plane.normal.rotateY(GLOBAL.rotateModelsY);
    plane.normal.rotateX(GLOBAL.rotateModelsX);

    plane.addSelf(plane.normal.scale(planeIn.z));
    //mouseRayDir.rotateY(GLOBAL.rotateModelsY);
    //mouseRayDir.rotateX(GLOBAL.rotateModelsX);

    mouseRayPos.subSelf(focusCentre);
    ray = new Ray3D(mouseRayPos, mouseRayDir); // this should be the world position of the mouse poiner on the 0,0,-1 plane

    intersect = plane.getIntersectionWithRay(ray);

    if (intersect == null) {
      ray = new Ray3D(mouseRayPos, mouseRayDir.invert());
      intersect = plane.getIntersectionWithRay(ray);
    }

    ray = new Ray3D(mouseRayPos, mouseRayDir);
    ray.addSelf(focusCentre);
View Full Code Here


          .getWorldTransform(transform);
      transform.getMatrix(chairMatrix);
      chairCentreOfMass = GLOBAL.sketchChairs.getCurChair().centreOfMass;
    }

    Plane plane = new Plane(planeIn.copy(), planeIn.normal.copy());

    Vec3D mouseRayPos = new Vec3D(mousePoint.x, mousePoint.y, plane.z); // this only works for planes perpendicular to the screen
    Vec3D mouseRayDir = new Vec3D(0, 0, -1);

    Vec3D focusCentre = new Vec3D(
View Full Code Here

   * Build design from SketchShape element
   * @param shape
   */
  public SketchChair(SketchShape shape) {

    SlicePlane plane = new SlicePlane(new Plane(new Vec3D(0, 0, 0),
        new Vec3D(0, 0, -1)));
    plane.setSelected(true);
    plane.getSketch().getSketchShapes().add(shape);
    this.selectedPlanes.add(plane);
    this.mouseReleased(0, 0);
View Full Code Here

    float spacing = this.getWidth() / (numSlices);
   
   

    for (float i = (-this.getWidth() / 2); i < (this.getWidth() / 2); i += spacing) {
      SlicePlane slicePlane = new SlicePlane(new Plane(
          new Vec3D(0, 0, i), new Vec3D(0, 0, -1)));
      this.getSlicePlanesY().add(slicePlane);
    }

    //this.updateCollisionShape();
View Full Code Here

  }

  public void importSVG(String path) {
   
    if(this.selectedPlanes.size() == 0){
      SlicePlane slicePlane = new SlicePlane(new Plane(
          new Vec3D(0, 0, 0), new Vec3D(0, 0, -1)));
      slicePlane.importSVG(path);
      this.getSlicePlanesY().add(slicePlane);
     
    }else{
View Full Code Here

    int sign = 1;
    if(Math.atan2(vecDir.x, vecDir.y) < 0){
      sign = -1;
      }
   
    SlicePlane slicePlane = new SlicePlane(new Plane(vecPosStart, vecDir));
   
    slicePlane.setCrossSliceSelection(crossSliceSelection);
    //LOGGER.info("vecDir"+Math.atan2(vecDir.x, vecDir.y));
   
    SketchPath sketchPath = new SketchPath(slicePlane.getSketch());
View Full Code Here

    // TODO: option flush edges
    // Add fake profiles on the ends, this might be a option later for flush
    // edges !
    SlicePlane startSlicePlaneend1 = planesToSlice.getList().get(0);
    SlicePlane slicePlane1 = new SlicePlane(startSlicePlaneend1.getSketch()
        .clone(), new Plane(new Vec3D(0, 0,
        (startSlicePlaneend1.getPlane().z)
            - SETTINGS.chair_slatslot_end_size),
        new Vec3D(0, 0, -1)));
    planesToSlice.add(0, slicePlane1);
    // Add fake profiles on the ends
    SlicePlane startSlicePlaneend2 = planesToSlice
        .get(planesToSlice.size() - 1);
    SlicePlane slicePlane2 = new SlicePlane(startSlicePlaneend2.getSketch()
        .clone(), new Plane(new Vec3D(0, 0,
        (startSlicePlaneend2.getPlane().z)
            + SETTINGS.chair_slatslot_end_size),
        new Vec3D(0, 0, -1)));
    planesToSlice.add(slicePlane2);
    // Add fake profiles on the ends

    float coverWidth = width + (SETTINGS.chair_slatslot_end_size * 2);
    float coverLength = guideSpline.getlength()
        + (SETTINGS_SKETCH.chair_slat_end_size * 2);

    float step = crossSliceSelection.spacing / guideSpline.getlength();

    float start = Math.min(crossSliceSelection.start,
        crossSliceSelection.end);
    float end = Math
        .max(crossSliceSelection.start, crossSliceSelection.end);

    // special case for lines with 2 points
    if (guideSpline.size() == 2) {
      start += step;
      end -= step;
    }

    for (float i = start; i <= end; i += step) {

      Vec3D vecPos = new Vec3D(guideSpline.getPos(i).x,
          guideSpline.getPos(i).y, 0);
      Vec3D vecDir = new Vec3D(guideSpline.getPerpendicular(i).x,
          guideSpline.getPerpendicular(i).y, 0);

      // do we want to add a strenghtening beam to the leg
      if (crossSliceSelection.tieToLeg) {
        SketchPoint point1 = (SketchPoint) guideSpline.get(0);
        SketchPoint point2 = (SketchPoint) guideSpline.get(1);
        Vec2D dir2D = point1.sub(point2).normalize();
        dir2D.rotate((float) (Math.PI / 2));
        vecPos = new Vec3D(point2.x, point2.y, 0);
        vecDir = new Vec3D(dir2D.x, dir2D.y, 0);
      }

      SlicePlane slicePlane = new SlicePlane(new Plane(vecPos, vecDir));
      slicePlane.setCrossSliceSelection(crossSliceSelection);

      // SketchOutline sktOutline = new SketchOutline();

      List<SketchPoint> topLine = new ArrayList<SketchPoint>();
View Full Code Here

      // TODO: option flush edges
      // Add fake profiles on the ends, this might be a option later for
      // flush edges !
      SlicePlane startSlicePlaneend1 = planesToSlice.getList().get(0);
      SlicePlane slicePlane1 = new SlicePlane(startSlicePlaneend1
          .getSketch().clone(), new Plane(new Vec3D(0, 0,
          (startSlicePlaneend1.getPlane().z)
              - SETTINGS.chair_slat_end_size),
          new Vec3D(0, 0, -1)));
     
      slicePlane1.destroy();//a bit of a hack make sure that our temp slice is deleted later
     
      slicePlane1.getSketch().removeLegs(); // remove any leg shapes
      slicePlane1.getSketch().build();
      planesToSlice.add(0, slicePlane1);
      // Add fake profiles on the ends
      SlicePlane startSlicePlaneend2 = planesToSlice.get(planesToSlice
          .size() - 1);
      SlicePlane slicePlane2 = new SlicePlane(startSlicePlaneend2
          .getSketch().clone(), new Plane(new Vec3D(0, 0,
          (startSlicePlaneend2.getPlane().z)
              + SETTINGS.chair_slat_end_size),
          new Vec3D(0, 0, -1)));
      slicePlane2.destroy();//a bit of a hack make sure that our temp slice is deleted later

      slicePlane2.getSketch().removeLegs(); // remove any leg shapes
      slicePlane2.getSketch().build();
      planesToSlice.add(slicePlane2);
    }

    // Add fake profiles on the ends

    float step = crossSliceSelection.spacing / guideSpline.getlength();
    float start = Math.min(crossSliceSelection.start,
        crossSliceSelection.end);
    float end = Math
        .max(crossSliceSelection.start, crossSliceSelection.end);

    if (SETTINGS.DEBUG)
      guideSpline.debugPercent = start;

    //Clear dubugging info off planes
    if (SETTINGS.DEBUG) {
      for (int j = 0; j < planesToSlice.size(); j++) {
        SlicePlane currentPlaneY = planesToSlice.get(j);
        currentPlaneY.debugIntersectionPoints.clear();
        currentPlaneY.debugIntersectionPointsTop.clear();
        currentPlaneY.debugIntersectionPointsBottom.clear();
      }
    }

    /*
     *  Step though the spline to slice
     *                     
     * <pre>                    
     *           
     *            start      
     *             /|/|/|/|/|
     *      0.1f -----------< --- (crossSliceSelection)
     *           / / / / /
     *    0.2f -----------<
     *         / / / / /
     *  0.3f -----------<
     *       |/|/|/|/|/
     *       end
     * 
     *  </pre>
     */
    for (float i = start; i <= end; i += step) {

      if (guideSpline == null || i > 1)
        return;
      Vec2D sPos = guideSpline.getPos(i);
      if(sPos == null)
        return;
     
      Vec3D vecPos = new Vec3D(sPos.x,
          sPos.y, 0);
      Vec3D vecDir = new Vec3D(guideSpline.getPerpendicular(i).x,
          guideSpline.getPerpendicular(i).y, 0);
      vecDir = vecDir.rotateZ(crossSliceSelection.offsetRotation);
      //vecDir = vecDir.rotateZ((float) (Math.PI ));
      // do we want to add a strengthening beam to the leg
      if (crossSliceSelection.tieToLeg) {
        SketchPoint point1 = (SketchPoint) guideSpline.get(0);
        SketchPoint point2 = (SketchPoint) guideSpline.get(1);
        Vec2D dir2D = point1.sub(point2).normalize();
        dir2D.rotate((float) (Math.PI / 2));
        vecPos = new Vec3D(point1.x, point1.y, 0);
        vecDir = new Vec3D(dir2D.x, dir2D.y, 0);
      }

      SlicePlane slicePlane = new SlicePlane(new Plane(vecPos, vecDir));
      slicePlane.setCrossSliceSelection(crossSliceSelection);

      //slicePlane.getPlane().normal.rotateZ((float) -(Math.PI/2));
      SketchPath topLine = new SketchPath(null);
      SketchPath bottomLine = new SketchPath(null);
View Full Code Here

          float xmlNX = Float.valueOf(child.getAttributeValue("nx"));
          float xmlNY = Float.valueOf(child.getAttributeValue("ny"));
          float xmlNZ = Float.valueOf(child.getAttributeValue("nz"));

          Plane pl = new Plane(new Vec3D(xmlX, xmlY, xmlZ),
              new Vec3D(xmlNX, xmlNY, xmlNZ));
          this.setPlane(pl);
        } else {
          LOGGER.warning("requred data not found in XML file");
          return;
        }
      }

    }

    if (this.getPlane() == null) {
      this.setPlane(new Plane());
      LOGGER.warning("no Plane def found in XML making a defaul plane");

    }

  }
View Full Code Here

  @Override
  public SlicePlane clone() {
    SlicePlane copiedPlane = new SlicePlane(
        this.getSketch().clone(),
        new Plane(this.getPlane().copy(), this.getPlane().normal.copy()));
    return copiedPlane;
  }
View Full Code Here

TOP

Related Classes of toxi.geom.Plane

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.