Package org.mt4j.components.visibleComponents.shapes

Examples of org.mt4j.components.visibleComponents.shapes.AbstractShape$TranslationAnimationListener


  public AbstractShape getShape(){
    this.endPath();
   
    ArrayList<Vertex[]> contours = this.pathHandler.getContours();
    Vertex[] allPoints = this.pathHandler.getPathPointsArray();
    AbstractShape returnComponent = null;
    //Check for convexity
    int convexity = ConvexityUtil.classifyPolygon2(allPoints.length, allPoints);
    switch (convexity) {
      case ConvexityUtil.NotConvexDegenerate:
//        logger.debug("not Convex Degenerate");
      case ConvexityUtil.NotConvex:
//        logger.debug("not convex");
        returnComponent = createComplexPoly(contours, MTComplexPolygon.WINDING_RULE_ODD);
        break;
      case ConvexityUtil.ConvexDegenerate:
//        logger.debug("convex degenerate");
      case ConvexityUtil.ConvexCW:
//        logger.debug("convex clockwise");
      case ConvexityUtil.ConvexCCW:
//        logger.debug("convex counterclockwise");
        returnComponent = createPoly(allPoints);
        break;
      default:
        break;
    }
   
    //Create some default texture coords
    if (returnComponent != null && returnComponent.hasBounds() && returnComponent.getBounds() instanceof BoundsZPlaneRectangle){
      BoundsZPlaneRectangle bounds = (BoundsZPlaneRectangle) returnComponent.getBounds();
      float width = bounds.getWidthXY(TransformSpace.LOCAL);
      float height = bounds.getHeightXY(TransformSpace.LOCAL);
      float upperLeftX = bounds.getVectorsLocal()[0].x;
      float upperLeftY = bounds.getVectorsLocal()[0].y;
      Vertex[] verts = returnComponent.getVerticesLocal();
      for (int i = 0; i < verts.length; i++) {
        Vertex vertex = verts[i];
        vertex.setTexCoordU((vertex.x-upperLeftX)/width);
        vertex.setTexCoordV((vertex.y-upperLeftY)/height);
        //System.out.println("TexU:" + vertex.getTexCoordU() + " TexV:" + vertex.getTexCoordV());
      }
      returnComponent.getGeometryInfo().updateTextureBuffer(returnComponent.isUseVBOs());
    }
    return returnComponent;
  }
View Full Code Here


  private TileSide getBottomOfUpperTile(List<AbstractShape> list, int currentI, int currentJ){
    if (currentI-1 < 0){
      return TileSide.linear;
    }
    for (Iterator<AbstractShape> iterator = list.iterator(); iterator.hasNext();) {
      AbstractShape tile = (AbstractShape) iterator.next();
      int i = (Integer) tile.getUserData("i");
      int j = (Integer) tile.getUserData("j");
      if (i == currentI -1 && j == currentJ){
        return (TileSide) tile.getUserData("bottom");
      }
    }
    return TileSide.linear;
  }
View Full Code Here

  private TileSide getRightOfLeftTile(List<AbstractShape> list, int currentI, int currentJ){
    if (currentJ-1 < 0){
      return TileSide.linear;
    }
    for (Iterator<AbstractShape> iterator = list.iterator(); iterator.hasNext();) {
      AbstractShape tile = (AbstractShape) iterator.next();
      int i = (Integer) tile.getUserData("i");
      int j = (Integer) tile.getUserData("j");
      if (i == currentI && j == currentJ-1){
        return (TileSide) tile.getUserData("right");
      }
    }
    return TileSide.linear;
  }
View Full Code Here

    MTComponent[] tags = tagContainer.getChildren();
    float scX = 1f/scale;
    for (int i = 0; i < tags.length; i++) {
      MTComponent baseComponent = tags[i];
      if (baseComponent instanceof AbstractShape) {
        AbstractShape shape = (AbstractShape) baseComponent;
//        System.out.println("Scaling: " + scX + " " + scY);
//        shape.scale(scX, scY, 1, shape.getCenterPointGlobal(), TransformSpace.GLOBAL);
        shape.scale(scX, scX, 1, shape.getCenterPointRelativeToParent(), TransformSpace.RELATIVE_TO_PARENT);
      }
    }
  }
View Full Code Here

      c.destroy();
    }
    PImage p = getMTApplication().loadImage(imagesPath + imageName);
    AbstractShape[] tiles = pf.createTiles(p, this.horizontalTiles, this.verticalTiles);
    for (int i = 0; i < tiles.length; i++) {
      final AbstractShape sh = tiles[i];
      //Delay to smooth the animation because of loading hickups
      final float x = ToolsMath.getRandom(0, MT4jSettings.getInstance().getWindowWidth());
      final float y = ToolsMath.getRandom(0, MT4jSettings.getInstance().getWindowHeight());
      registerPreDrawAction(new IPreDrawAction() {
        public void processAction() {
          getMTApplication().invokeLater(new Runnable() {
            public void run() {
              registerPreDrawAction(new IPreDrawAction() {
                public void processAction() {
                  getMTApplication().invokeLater(new Runnable() {
                    public void run() {
                      puzzleGroup.addChild(sh);
                      sh.tweenTranslateTo(x, y, 0, 400, 0f, 1.0f);
                    }
                  });
                }
                public boolean isLoop() {return false;}
              });
            }
          });
        }
        public boolean isLoop() {return false;}
      });
      sh.rotateZ(sh.getCenterPointRelativeToParent(), ToolsMath.getRandom(0, 359));
    }
  }
View Full Code Here

    if (inEvt instanceof MTFiducialInputEvt) {
      MTFiducialInputEvt fEvt = (MTFiducialInputEvt)inEvt;
      int fID = fEvt.getFiducialId();
      Vector3D position = fEvt.getPosition();

      AbstractShape comp;
      switch (fEvt.getId()) {
      case MTFiducialInputEvt.INPUT_DETECTED:
        //Create a new component for the fiducial
        AbstractShape newComp = createComponent(fID, position);
        fiducialIDToComp.put(fID, newComp); //Map id to component
        //Move component to fiducial position
        newComp.setPositionGlobal(position);
        //Save the absolute rotation angle in the component for late
        newComp.setUserData("angle", fEvt.getAngle());
        //Rotate the component
        newComp.rotateZ(newComp.getCenterPointRelativeToParent(), MTApplication.degrees(fEvt.getAngle()));
        //Add the component to the canvas to draw it
        getCanvas().addChild(newComp)
        break;
      case MTFiducialInputEvt.INPUT_UPDATED:
        //Retrieve the corresponding component for the fiducial ID from the map
View Full Code Here

   * @param windingRule the winding rule
   *
   * @return the live polygon component
   */
  private AbstractShape getLivePolygonComponent(SVGOMPolygonElement polyElem, boolean noFill, int windingRule){
    AbstractShape returnComponent = null;
   
    //Create Vertex array from points
      SVGPointList pointList = polyElem.getPoints();
      Vertex[] vertices = new Vertex[pointList.getNumberOfItems()];
      for (int i = 0; i < pointList.getNumberOfItems(); i++) {
View Full Code Here

   * @param windingRule the winding rule
   *
   * @return the live path component
   */
  private AbstractShape getLivePathComponent(SVGOMPathElement pathElem, boolean noFill, int windingRule){
      AbstractShape returnComponent   = null;
      CustomPathHandler pathHandler   = new CustomPathHandler();
      PathParser pathParser       = new PathParser();
      //pathHandler.setVerbose(true);
     
      /*
 
View Full Code Here

       
        //Scale window background normally
        windowBackGround.scaleGlobal(se.getScaleFactorX(), se.getScaleFactorY(), se.getScaleFactorZ(), se.getScalingPoint());
       
        //Scale vertices of the window
        AbstractShape target = (AbstractShape)ge.getTargetComponent();
        Vertex[] verts = target.getGeometryInfo().getVertices();
        Vector3D newScalingPoint = target.globalToLocal(se.getScalingPoint());
        Matrix m = Matrix.getScalingMatrix(newScalingPoint, se.getScaleFactorX(), se.getScaleFactorY(), se.getScaleFactorZ());
        Vertex.transFormArray(m, verts);
        target.setVertices(verts);

        //Scale vertices of the clip shape
        AbstractShape clip = (AbstractShape)target.getChildClip().getClipShape();
        Vertex[] clipVerts = clip.getGeometryInfo().getVertices();
        Vertex.transFormArray(m, clipVerts);
        clip.setVertices(clipVerts);
        return false;
      }
    });
//    */
   
 
View Full Code Here

      MTComponent component = children[i];
     
      //Get vertices for convex hull of all selected components
      if (component instanceof AbstractShape){
        shapes++;
        AbstractShape shape = (AbstractShape)component;
//        Vertex[] verts = shape.getVerticesPickingWorld();
        Vector3D[] verts = null;
       
//        if (shape.isBoundingShapeSet()){
//           verts = shape.getBoundingShape().getVectorsGlobal();
//        }else{
//           verts = shape.getVerticesGlobal();
//        }
       
        if (shape.hasBounds()){
          if (shape.getBounds() instanceof BoundsZPlaneRectangle || shape.getBounds() instanceof BoundsArbitraryPlanarPolygon){
            verts = shape.getBounds().getVectorsGlobal();
          }else{
            BoundsZPlaneRectangle b = new BoundsZPlaneRectangle(shape);
            verts = b.getVectorsGlobal();
          }
        }else{
View Full Code Here

TOP

Related Classes of org.mt4j.components.visibleComponents.shapes.AbstractShape$TranslationAnimationListener

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.