Help with iGeo library - exporting series of pipes to OBJ
              in 
             Contributed Library Questions 
              •  
              1 year ago    
            
 
           
             Almighty Forum,
            
             
            
            
             
            
            
             
            
            
             
            
            
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
                  
             
             
              
             
             
              
             
             
              
             
             
              
             
             
                  
             
             
                
             
             
              
             
              
           
 
            
           
             I'm using the 
             iGeo library for the first time, and having a hard time deciphering the documentation and find examples lacking. I'm relatively new to Processing, so Java docs are still Greek to me. 
            
            
             I'm trying to create a series of 3D lines (called Pipes in iGeo), and export the resulting shape as an OBJ. I can see the Pipes, but can't seem to figure out how to export to OBJ. Seems like iGeo wants me to use their internal exporter function. I tried using superCAD's exporter, which worked for this sketch prior to introducing iGeo, but it didn't export a file.
            
            
             Thanks for any help. Code below.
            
            
              import processing.opengl.*;
             
             
              import processing.dxf.*;
             
             
              import superCAD.*;
             
             
              boolean record = false;
             
             
              String cadSoftware, ext;
             
             
              import igeo.*;
             
             
              String[] doc;  // holds all lines of text in the doc
             
             
              String[] s;    // used to hold one word at a time
             
             
              int x, y, z;
             
             
              int prevX = 0;
             
             
              int prevY = 0;
             
             
              int prevZ = 0;
             
             
              int lineCounter = 0;     // for each line in the txt file
             
             
              int linesPerPage = 36;   // average # of lines per page in this version of the book
             
             
              int wordsPerLine = 13;   // average number of words per line in this version of the book
             
             
              int pageNum = 1;         // start on page 1!
             
             
              int totalPages = 308;    // total # of pages in printed book
             
             
              int occurance = 0;       // keeps track of which occurance of the word "Ulysses" is currenlty being calculated. Should match totalOccurances 
             
             
              int totalOccurances = 580;  // total number of times the target String appears in the text
             
             
              int[] Xs;                // Array of x-coordinates
             
             
              int[] Ys;                // Array of y-coordinates
             
             
              int[] Zs;                // Array of z-coordinates
             
             
              void setup() {
             
             
                size(300, 500, IG.GL);
             
             
                  doc = loadStrings("Od.txt");
             
             
                //println(doc.length);   (11374)
             
             
                Xs = new int[totalOccurances];
             
             
                Ys = new int[totalOccurances];
             
             
                Zs = new int[totalOccurances];
             
             
                for (int j=0; j<doc.length; j++) {               // for every line in the document...
             
             
                  lineCounter++;                                 // keep track of the line we're on. 
             
             
                  if (lineCounter == linesPerPage+1) {
             
             
                    lineCounter = 0;                             // 1 page = 36 lines
             
             
                    pageNum++;
             
             
                  } 
             
             
                  y = lineCounter;
             
             
                  y = int(map(y, 0, linesPerPage, 0, height));  // all mapped figures are arbitrary. Can be changed.
             
             
                  z = pageNum;
             
             
                  //z = int(map(z, 0, totalPages, -100, 100));
             
             
                  s = splitTokens(doc[j]);
             
             
                  for (int i=0; i<s.length; i++) {
             
             
                    String temp_s = trim(s[i]);
             
             
                    //println(temp_s);
             
             
                    if (temp_s.contains("Ulysses")) {
             
             
                      x = (temp_s.length())*(i+1); 
             
             
                      x = int(map(x, 0, doc[j].length(), 0, width));     // arbitray limits to make sure Processing displays all values in canvas
             
             
                      Xs[occurance] = x;
             
             
                      Ys[occurance] = y;
             
             
                      Zs[occurance] = z;
             
             
                      println("Ulysses# " + occurance + " = " + Xs[occurance] + " : " +  Ys[occurance] + " : "+ Zs[occurance]);
             
             
                      occurance++;
             
             
                    }
             
             
                  }
             
             
                }
             
             
              }
             
             
              void draw() {
             
             
                //background(255);
             
             
                  translate(width/2, height/2, 0);
             
             
                  rotateY(PI * mouseX/width);
             
             
                rotateX(PI * mouseY/height);
             
             
                  translate(-width/2, -height/2, 0);
             
             
              //    if(record){
             
             
              //     beginRaw("superCAD."+cadSoftware, "odyssey11."+ext); 
             
             
              //    }
             
             
                for(int i=1; i<totalOccurances; i++){
             
             
                   ICurve curve = new ICurve(Xs[i-1], Ys[i-1], Zs[i-1],  Xs[i],Ys[i],Zs[i]).clr(0.5);
             
             
                   IG.pipe(curve,2).clr(.2);
             
             
                }
             
             
              }
             
             
              //   if(record){
             
             
              //     endRaw();
             
             
              //     record = false; 
             
             
              //    }
             
             
              //}
             
             
              //
             
             
              //void keyPressed() {
             
             
              //
             
             
              //  switch(key){
             
             
              //  case 'r': 
             
             
              //    cadSoftware = "Rhino"; 
             
             
              //    ext = "rvb"; 
             
             
              //    break;
             
             
              //  case 's': 
             
             
              //    cadSoftware = "SketchUP"; 
             
             
              //    ext = "rb";
             
             
              //    break;
             
             
              //  case 'a': 
             
             
              //    cadSoftware = "AutoLISP"; 
             
             
              //    ext = "lsp";
             
             
              //    break;
             
             
              //  case 'p': 
             
             
              //    cadSoftware = "PovRAY"; 
             
             
              //    ext = "pov";
             
             
              //    break;
             
             
              //  case 'm': 
             
             
              //    cadSoftware = "Maya"; 
             
             
              //    ext = "mel";
             
             
              //    break; 
             
             
              //  case 'o': 
             
             
              //    cadSoftware = "ObjFile"; 
             
             
              //    ext = "obj";
             
             
              //    break;       
             
             
              //  case 'c': 
             
             
              //    cadSoftware = "ArchiCAD"; 
             
             
              //    ext = "gdl";
             
             
              //    break;       
             
             
              //  }
             
             
              //  record = true;
             
             
              //}
             
             
              
              1  
            
 
            