Examples of Vec2D


Examples of toxi.geom.Vec2D

  }

  public SlicePlane getPlanePickBuffer(int col) {
    for (int i = 0; i < this.getList().size(); i++) {
      SlicePlane curSlice = this.getList().get(i);
      Vec2D selectedVec = curSlice.sketchSpline.getVec2DpickBuffer(col);

      if (selectedVec != null)
        return curSlice;
    }
    return null;
View Full Code Here

Examples of toxi.geom.Vec2D

  public Vec2D getVec2DpickBuffer(int col) {
    for (int i = 0; i < this.getList().size(); i++) {
      SlicePlane curSlice = this.getList().get(i);

      Vec2D selectedVec = curSlice.getSketch().getVec2DpickBuffer(col);
      if (selectedVec != null)
        return selectedVec;

    }
    return null;
View Full Code Here

Examples of toxi.geom.Vec2D

  public boolean overSelectPoint(float mouseX, float mouseY) {
    for (int i = 0; i < this.getList().size(); i++) {
      SlicePlane curPlane = this.getList().get(i);

      Vec2D pointOnPlan = GLOBAL.uiTools.getPointOnPlane(new Vec2D(
          mouseX, mouseY), curPlane.getPlane());
      if (curPlane.overSelectPoint(pointOnPlan.x, pointOnPlan.y))
        return true;
    }
    return false;
View Full Code Here

Examples of toxi.geom.Vec2D

      SketchShape selectedShape, SlicePlane selectedVecPlane,
      boolean isSelectedVecOnOutline) {
    for (int i = 0; i < this.getList().size(); i++) {
      SlicePlane curSlice = this.getList().get(i);

      Vec2D selectedVec1 = curSlice.getSketch().setVec2DpickBuffer(col,
          selectedVec, selectedShape, selectedVecPlane,
          isSelectedVecOnOutline);
      if (selectedVec1 != null) {
        selectedVecPlane = curSlice;
        return selectedVec1;
View Full Code Here

Examples of toxi.geom.Vec2D

      }

    }

    if (getSketchTools().getCurrentTool() == SketchTools.LEG_TOOL) {
      Vec2D pointOnPlan = new Vec2D(mouseX, mouseY);
      if (getLastVec() != null) {
        getLastVec().set(pointOnPlan.x, pointOnPlan.y);
        getCurrentShape().offset();
      }
    }
View Full Code Here

Examples of toxi.geom.Vec2D

   

    //DRAW TOOL OPERATIONS
    if (getSketchTools().getCurrentTool() == SketchTools.DRAW_TOOL
        && getSketchTools().getMouseButton() == SketchTools.MOUSE_LEFT) {
      Vec2D pointOnPlan = new Vec2D(mouseX, mouseY);
      //alert(pointOnPlan.distanceTo(pointOnPlan.add(new Vec2D(10,10))));
      SketchPoint sp = new SketchPoint(mouseX, mouseY);
      //alert(sp.distanceTo(pointOnPlan.add(new Vec2D(10,10))));

      SketchSpline newSketch = new SketchSpline(this,
          SketchSpline.OFFSET_BOTH);
      newSketch.setOffsetSize(getSketchTools().brush_dia);
      newSketch.setCap(getSketchTools().getCurrentCapType());
      newSketch.add(new SketchPoint(mouseX, mouseY));
      newSketch.setType(SketchShape.TYPE_SPLINE);
      add(newSketch);
      setCurrentShape(newSketch);

      //if(getSketchGlobals().undo != null)
      //getSketchGlobals().undo.addOperation(new UndoAction(newSketch,UndoAction.ADD_SHAPE)); 
    }

    //LEG TOOL OPERATIONS
    if (getSketchTools().getCurrentTool() == SketchTools.LEG_TOOL
        && getSketchTools().getMouseButton() == SketchTools.MOUSE_LEFT) {

      Vec2D pointOnPlan = new Vec2D(mouseX, mouseY);

      SketchSpline newSketch = new SketchSpline(this,
          SketchSpline.OFFSET_BOTH);
      newSketch.setType(SketchSpline.TYPE_LEG);
      newSketch.setOffsetSize(getSketchTools().brush_dia
View Full Code Here

Examples of toxi.geom.Vec2D

    //OFFSETPATH TOOL
    //___________________________________________________________________________________________________

    if (getSketchTools().getCurrentTool() == SketchTools.DRAW_OFFSETPATH_TOOL) {
      boolean skip = false;
      Vec2D pointOnPlan = new Vec2D(mouseX, mouseY);

      if (getCurrentShape() != null
          && getCurrentShape().getType() == SketchShape.OFFSET_SPLINE
          && getSketchTools().getMouseButton() == PConstants.RIGHT
          && !getCurrentShape().getClosed() && !skip) {
        SketchSpline spline = (SketchSpline) getCurrentShape();
        spline.getCentrePath().remove(spline.getCentrePath().getLast());
        getCurrentShape().setClosed(true);
        spline.offset();
        skip = true;
      }

      if (getCurrentShape() != null
          && (getCurrentShape().getType() != SketchShape.OFFSET_SPLINE || getCurrentShape()
              .getClosed())
          && getSketchTools().getMouseButton() == PConstants.LEFT
          && !skip) {

        SketchSpline sketch = new SketchSpline(this);
        sketch.setType(SketchShape.OFFSET_SPLINE);
        sketch.autoSmooth = false;
        sketch.setOffsetSize(this.getSketchTools().brush_dia);
        sketch.setJoinType(SketchSpline.JOIN_ROUND);
        sketch.setCap(getSketchTools().getCurrentCapType());
        add(sketch);

      }

      if (getCurrentShape() == null
          && getSketchTools().getMouseButton() == PConstants.LEFT
          && !skip) {

        SketchSpline sketch = new SketchSpline(this);
        sketch.setType(SketchShape.OFFSET_SPLINE);
        sketch.autoSmooth = false;
        sketch.setJoinType(SketchSpline.JOIN_ROUND);
        sketch.setOffsetSize(this.getSketchTools().brush_dia);
        sketch.setCap(getSketchTools().getCurrentCapType());
        add(sketch);
      }

      //add a point
      if (getCurrentShape() != null
          && getCurrentShape().getType() == SketchShape.OFFSET_SPLINE
          && getSketchTools().getMouseButton() == PConstants.LEFT
          && !skip) {

        getCurrentShape().add(
            new SketchPoint(pointOnPlan.x, pointOnPlan.y));
        getCurrentShape().add(
            new SketchPoint(pointOnPlan.x + 10, pointOnPlan.y + 1));
      }

    }

   

   
   
    //PATH TOOL
    //___________________________________________________________________________________________________
    if (getSketchTools().getCurrentTool() == SketchTools.DRAW_PATH_TOOL) {

      boolean skip = false;

     
     
     
     
      //Remove vertex!
      if (!skip && (getSketchTools().getMouseButton() == PConstants.LEFT|| getSketchTools().getMouseButton() == PConstants.RIGHT)
          && getSketchTools().keyPressed
          && getSketchTools().keyCode == PConstants.CONTROL) {

        Vec2D pointOnPlane = new Vec2D(mouseX, mouseY);

        SketchPoint pathVert = getClosestPathVertex(pointOnPlane);
   
        if (pathVert != null && pointOnPlane.distanceTo(pathVert) < SETTINGS_SKETCH.select_dia) {
          removeVertex(pathVert);
          skip = true;
        }

      }

      //check to see if we are adding a new point to an existing path
      if (!skip && (getSketchTools().getMouseButton() == PConstants.LEFT || getSketchTools().getMouseButton() == PConstants.RIGHT)
          && getSketchTools().keyPressed
          && getSketchTools().keyCode == PConstants.CONTROL) {

        Vec2D pointOnPlane = new Vec2D(mouseX, mouseY);

        if (addPointAlongPath(pointOnPlane.x, pointOnPlane.y))
          skip = true;

      }


        Vec2D pointOnPlan = new Vec2D(mouseX, mouseY);
       
       
        /*
        if (getSketchTools().getMouseButton() == PConstants.RIGHT && !skip) {

          SketchPoint pathVert = getClosestPathVertex(pointOnPlan);

         
          if (pathVert != null
              && pointOnPlan.distanceTo(pathVert) < SETTINGS_SKETCH.select_dia) {
            removeVertex(pathVert);
            skip = true;
          }
         
        }
        */

        if (getCurrentShape() != null
            && getCurrentShape().getType() == SketchShape.TYPE_PATH
            && getSketchTools().getMouseButton() == PConstants.LEFT
            && !skip) {

          SketchPath sketchP = (SketchPath) getCurrentShape();
          if (sketchP.getClosed()) {

            SketchPath sketch = new SketchPath(this);
            sketch.setType(SketchShape.TYPE_PATH);
            add(sketch);
            getCurrentShape().add(
                new SketchPoint(pointOnPlan.x, pointOnPlan.y));

          }
        }

        if (getCurrentShape() == null
            || getCurrentShape().getType() != SketchShape.TYPE_PATH
            && getSketchTools().getMouseButton() == PConstants.LEFT
            && !skip) {

          SketchPath sketch = new SketchPath(this);
          sketch.setType(SketchShape.TYPE_PATH);
          sketch.setClosed(false);
          add(sketch);
          getCurrentShape().add(
              new SketchPoint(pointOnPlan.x, pointOnPlan.y));

        }

        if (getCurrentShape().getType() == SketchShape.TYPE_PATH
            && getSketchTools().getMouseButton() == PConstants.LEFT
            && !skip) {

          if (getCurrentShape().getLength() > 2) {

            Vec2D firstPoint = (Vec2D) ((SketchPath) getCurrentShape())
                .get(0);
            Vec2D mousePos = new Vec2D(mouseX, mouseY);
           
            //mousePos = GLOBAL.uiTools.getPointOnPlane(mousePos, getCurrentShape().getParentSketch().getOnSketchPlane().getPlane());
            if (firstPoint.distanceTo(mousePos) < SETTINGS_SKETCH.MIN_CLOSE_SHAPE_DIST) {
              SketchPath path = (SketchPath) getCurrentShape();
              path.remove(path.getLast());
View Full Code Here

Examples of toxi.geom.Vec2D

  public void update() {
    //buildOutline();
    //sketchShapes.update();

    Vec2D pointOnPlan = new Vec2D(getSketchTools().mouseX,
        getSketchTools().mouseY);

    //#IF JAVA
    if (getOnSketchPlane() != null)
      pointOnPlan = GLOBAL.uiTools.getPointOnPlane(pointOnPlan,
          getOnSketchPlane().getPlane());
    //#ENDIF JAVA
   
    //OFFSETPATH TOOL
    // Update paths position to show under mouse
    //___________________________________________________________________________________________________

    if (getSketchTools().getCurrentTool() == SketchTools.DRAW_OFFSETPATH_TOOL) {
      boolean skip = false;

      if (getCurrentShape() != null
          && getCurrentShape().getType() == SketchShape.OFFSET_SPLINE
          && !getCurrentShape().getClosed() && !skip) {
        SketchSpline spline = (SketchSpline) getCurrentShape();
        spline.getCentrePath().getLast().set(pointOnPlan);
        spline.offset();
      }
    }

    if (getSketchTools().getCurrentTool() == SketchTools.DRAW_PATH_TOOL) {

     
      this.getSketchTools().drawPathToolState = SketchTools.DRAW_PATH_TOOL_STATE_NORMAL;

     
      if(getSketchTools().keyPressed
      && getSketchTools().keyCode == PConstants.CONTROL) {
       
        this.getSketchTools().drawPathToolState = SketchTools.DRAW_PATH_TOOL_STATE_ADD;
        
       
        if(pointOnPlan.distanceTo(sketchShapes.getClosestPathVertex(pointOnPlan)) < SETTINGS_SKETCH.select_dia){
          this.getSketchTools().drawPathToolState = SketchTools.DRAW_PATH_TOOL_STATE_REMOVE;

        }
       
View Full Code Here

Examples of toxi.geom.Vec2D

  }

  public static float angleOfDot(Vec2D v1) {
    v1.normalize();

    float an = (float) Math.acos(v1.dot(new Vec2D(0, 0)));

    return (float) Math.atan2(v1.y, v1.x);

  }
View Full Code Here

Examples of toxi.geom.Vec2D

    return (a << 24) | (x << 16) | (y << 8) | z;

  }

  public static Vec2D rotate(Vec2D curVec, Vec2D center, float r) {
    Vec2D returnVec = curVec.copy();
    returnVec.subSelf(center);
    returnVec.rotate(r);
    returnVec.addSelf(center);
    return returnVec;
   
   
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.