Loading...
Logo
Processing Forum
Hi All,

I am new to Processing and am using this for a project I am working on: I wish to import a simple STL object (produce by 3D Studio MAX) into Processing, unwrap it into a 2D plane so I can run agents on whole the surface across the edges. The result is then exported to be use as a texture in another 3D rendering software for wrapping.

People have recommended me to use Toxiclib's WETriangleMesh to represent the object in Processing, this way the vertices connection can be saved when I unwrap the mesh. 

As I am new to Processing (I am discovering new things to help with each step I make), I only have a vague idea how each step would work and not certain where to start. 

As a starting point, I looked up Toxiclib's STLImportTest example and successfully imported a test box object as a TriangleMesh. I am stuck on how to convert that into a WETriangleMesh class.

Any help or suggestion will be greatly appreciated.

Cheers
Mani 

Replies(3)

Do you mean Flatworld? I don't see any unwrap functionality in the WETriangleMesh.

With regard to your specific question, I guess like this...
Copy code
  1. // Sligthly adapted Toxiclibs STLImportTest example to WETriangleMesh
  2.  
  3. import toxi.geom.*;
  4. import toxi.geom.mesh.*;
  5. import toxi.processing.*;
  6.  
  7. WETriangleMesh mesh;
  8. ToxiclibsSupport gfx;
  9.  
  10. void setup() {
  11.   size(600, 600, P3D);
  12.   TriangleMesh tmesh = (TriangleMesh) new STLReader().loadBinary(sketchPath("mesh.stl"), STLReader.TRIANGLEMESH);
  13.   mesh = new WETriangleMesh();
  14.   mesh.addMesh(tmesh);
  15.   gfx=new ToxiclibsSupport(this);
  16. }
  17.  
  18. void draw() {
  19.   background(51);
  20.   lights();
  21.   translate(width/2, height/2, 0);
  22.   rotateX(mouseY*0.01);
  23.   rotateY(mouseX*0.01);
  24.   gfx.origin(new Vec3D(), 200);
  25.   noStroke();
  26.   gfx.mesh(mesh, false, 10);
  27. }

Thank your for your quick reply! Through this post surfaced a more direct way, see reply below.

I haven't used flatworld before, thank you for the pointer. This should be me going to a while.

Cheers,
Mani
STLReader can load into WETriangleMesh instances directly, no need to go the addMesh() route... just change the mesh type parameter for loadBinary():
Copy code
  1. WETriangleMesh mesh;
  2. ....

  3. mesh = (WETriangleMesh) new STLReader().loadBinary(sketchPath("mesh.stl"), STLReader.WEMESH);
Btw. Some people were asking me why the explicit type cast is needed with this and the various .toMesh() methods ( example). The reason for that is architecture. In order to support different mesh types, all those methods return only the generic Mesh3D interface and for a lot of cases this is sufficient. However, if you later need to access type specific features (e.g. WETriangleMesh.subdivide()) then you need to cast the returned mesh into the specific type.

Second part, Flatworld: At current complete mesh unwrapping is not yet supported, although a partly implemented version exists outside the library codebase. This project is in dire need to be updated with all these new things, but can't give you a schedule yet. The next toxiclibs release & documentation system is currently more important (and getting there)...