3D Printing Day 9: Picking a Software, Processing
TL;DR
Processing isn't a software; it is a programing language based on Java and a community. Learning how to wrangle 3D models in Processing can lead to the development of a stand alone piece of software capable of generating STL files based on parameter input by novice users. Or it can enable the creation of sculptures based on data. What Processing is not designed for is banging out one-off models quickly.
At the very least, using Processing to develop 3D models inculcates the coder with an appreciation of all the hard work put into existing 3D software.
Start Here
I hadn't played with Processing for a while so the whole process took me 6+ hours worth of work. It will take me the rest of the day to document/comment the code, etc.
If you aren't sure what the point would be of bothering to learn 3D rendering in Processing, check out some examples of what is possible by way of inspiration.
- Interactive Vase Suite: http://www.thingiverse.com/thing:6576
- Blobby: http://www.thingiverse.com/thing:6571
- Cookie Cutter: http://www.thingiverse.com/thing:14868
- Anything by Marius Watz: http://www.thingiverse.com/watz
Next read the MakerBot curriculum section on Processing.
Help can be hard to find because the name of the language is a real word. While doing this write up I found one 3rd party video overview on 3D in Processing but I haven't watched the whole thing: Processing Tutorial 5 - Basic 3D by by Joseph Boston
The 4 main 3D libraries for processing are:
I only used 2 of them in my 4 step process to make a workable file to print from.
Step 1: Shapes 3D Library
Shapes 3D library has a javadoc reference online and the S3D4P_Showcase example included with the library is very useful. I appropriated it for my first attempt at a model. It requires the PeasyCam Library.
The problem I ran into repeatedly is that the Yogurt Cup SIP is not a solid primitive, it is a hollow primitive with a wall thickness. If I was adding up solid primitives building a model would have been much easier.
Cylinders in the S3D4P are called Tubes and the visibility of their ends can be turned on and off.
iBasket.drawMode(Shape3D.SOLID, Tube.E_CAP); iBasket.drawMode(Shape3D.WIRE, Tube.S_CAP); boolean vis = false; iBasket.visible(vis, Tube.S_CAP); //iBasket.visible(vis, Tube.BOTH_CAP) //turn them both off
First thing I made two nested baskets, one each for the interior and exterior walls. The gap between them indicated the wall thickness. After I got that far I realized I had no idea how to punch a hole for drainage.
The next approach was making a collection of tubes, but I wasn't sure how to go about connecting them up, so I moved on to see if the primitives in a different library were better.
Step 2: ModelBuilder Library
The ModelBuilder library has some primitives associated with it, but more importantly it will export information held within an instance of it's UGeometry object to an STL file.
The examples are robust but not heavily commented. That is why I started with Shapes3D. I couldn't parse what I was looking at initially but with one round under my belt the example code became clearer. I used the mb_02_primatives_01 example as my start point.
With the ModelBuilder primitives I stalled in the exact same place as I did with Shapes3D. I could only figure out how to make a collection of unattached cylinders. The interior wall isn't lining up correctly. I didn't bother to fix it.
Step 3: Building my own primitives
I found an excellent tutorial by Jan Vantomme on how to roll your own 3D primitives (specifically a cone). The Learning section of the Processing site also has an example of implementing vertices as a cylinder and there is an alternative method for building a cylinder on the Processing wiki. Vantomme's, however is the clearest.
I used his example to write my own primitives using vertices ( See beginShape() and vertex() ) that aren't just shells but have thicknesses.
- void drawThickCylinder( int sides, float r1, float r2, float h, float t)
- void drawCup( int sides, float r1, float r2, float h, float t)
- void drawDrainCup( int sides, float r1, float r2, float h, float t, float d)
- void drawDrainCupWithLip( int sides, float r1, float r2, float h, float t, float d, float l)
Not the cleverest of names but they work.
Step 4: Combine my own primitives back over to ModelBuilder
Since I was so close I decided to go all the way and integrate drawDrainCupWithLip with the mb_01_vertexlist_03_ribbon3D ModelBuilder library example. That function became buildDrainCupWithLip().
The first version of the code actually rendered a number of the surfaces inside-out. I know because I snuck a peak in MeshLab which will be the topic of the next post. The first two pictures are what the model looked like with inside out faces. The third and fourth pictures are of the final fix.
The rules for making faces that actually face the right direction:
- For upward faces: draw out to in
- For downward faces: draw in to out
- For outward walls: draw bottom to top
- For inward walls: draw top to bottom
The Stats
The stats seem hardly fair given how unique Processing is in this context, but I'll give a stab.
- Ideal Object - Abstarct objects
- Ideal User - Advanced computer user/programer
- OpenSource - Yes
- Free - Yes
- Premium Version - No
- Linux Version - Yes
- Browser Based - No
- Requires Internet Acces - No
- StalkerWare - No
- Private Files - Yes
- Official Community Repository - No where I found (Other than Thingiverse)
- Instashare - No
- Collaborative Editing: What works for code works for Processing
- Official Tutorials - Good on core functions, Libraries' official could be better
- Community Tutorials - bad to excellent
- How many tutorials/videos to build first project - looked at 6-10 examples and reference documentation.
- Default Bkg Color - As you wish
- Good for Computer Beginners - No
- Requires 3 Button Mouse - No
- Real-world units - No
- Numeric controls - Yes
- WYSIWYG - If you build it
- Scripting - Yes - it's code
- Plugins & Extensions - Lots of Libraries and example code out there to help
- Format Types: Up to you to find it or write it
- Direct to STL - Library exists (ModelBuilder)
- Format Types: Up to you to find it or write it
- Adjust scale on output - Up to you tow write it if you want it
- Direct to Printing Service - No


