Examples of GExpressionItem


Examples of GShape.Core.Expression.GExpressionItem

  public void PerformRule(GCore core, GExpression src, GMaterial mat) {
   
    // Expression   Bsp: "Wall ; BigWall" -> GRender
    for (int i=0;i<src.Items.size();i++) {
   
      GExpressionItem item = src.Items.get(i);
      if (item.isString) {
       
        String Name = item.getString();
        // Find Object
        java.util.Vector<iGObject> arr = core.Find (Name);
        for (iGObject obj : arr)
          obj.SetMaterial(mat);
       
View Full Code Here

Examples of GShape.Core.Expression.GExpressionItem

       
        // Only one Item!!
        if (exp.Items.size() == 1 && exp.Items.get(0).isNumber) {
         
          // Item
          GExpressionItem item = exp.Items.get(0); // Bsp: "100m:70m:Lots:30%"
         
         
          // Random value 0 or 1 (width or depth)
          java.util.Random rnd = new java.util.Random ();
          int whichDirection = rnd.nextInt(2); // 0 to 1
          if (tmpWhichDirection != -1)
            whichDirection = tmpWhichDirection;
          int mirror = rnd.nextInt(2); // 0 to 1

         
          // Which direction?
          float factorX = 1;
          float factorY = 1;
          if (whichDirection == 0) // width
            factorX = Math.abs(mirror - (item.Parts.get(3).Number / 100)); // bsp 30% direction X
          else  // depth
            factorY = Math.abs(mirror - (item.Parts.get(3).Number / 100)); // bsp 30% direction Y
         

          // Create 2 new rects (only geometry first)
          float x = (oRect.p2.x - oRect.p1.x) * factorX + oRect.p1.x;
          float y = (oRect.p2.y - oRect.p1.y) * factorY + oRect.p1.y;
          float x2 = (oRect.p2.x - oRect.p1.x) * factorX + oRect.p1.x;
          float y2 = (oRect.p2.y - oRect.p1.y) * factorY + oRect.p1.y;
          if (whichDirection == 1) x2 = oRect.p1.x; else y2 = oRect.p1.y;
          rect rec1 = new rect (oRect.p1.x, oRect.p1.y, x, y, oRect.z);
          rect rec2 = new rect (x2, y2, oRect.p2.x, oRect.p2.y, oRect.z);
         
         
          // Create object and call this class recursive
          //  - if min with and min height not to small
          //  - no recursive function in else case if tmpWhichDirection != -1
          if (    item.getNumber(0, 0) < rec1.width && item.Parts.get(1).getNumber(0, 0) < rec1.depth &&
              item.getNumber(0, 0) < rec2.width && item.Parts.get(1).getNumber(0, 0) < rec2.depth     ) {
           
            PRect obj1 = new PRect (core, item.getString(), rec1, src); // Create Rect 1
            (new DivideArea ()).PerformRule(core, obj1, exp, -1);
            PRect obj2 = new PRect (core, item.getString(), rec2, src); // Create Rect 2
            (new DivideArea ()).PerformRule(core, obj2, exp, -1);
            src.Delete();
           
          } else {

View Full Code Here

Examples of GShape.Core.Expression.GExpressionItem


        // Looping new Objects:
        for (int i=0;i<exp.Items.size();i++) { // Bsp: "10:Lot"
         
          GExpressionItem item = exp.Items.get(i);
           
          if (item.isNumber) { // Bsp: 10 (multiply geometry 10 times)
           
            for (int ii=0;ii<item.getNumber(0, 0) + 1;ii++) {
                                           
              float offset, width;
              rect newRect = null;
              if (directionX) {
                offset = oRect.width * ii;
                width = offset + oRect.width;
                newRect = new rect (offset, oRect.p1.y, width, oRect.p2.y, oRect.z);
              }
              if (!directionX) {
                offset = oRect.depth * ii;
                width = offset + oRect.depth;
                newRect = new rect (oRect.p1.y, offset, oRect.p2.x, width, oRect.z);
              }
              new PRect (core, item.getString(), newRect, src);

            }
           
          }
           
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.