Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Processing 2: Creative Coding Hotshot

You're reading from   Processing 2: Creative Coding Hotshot Learn Processing with exciting and engaging projects to make your computer talk, see, hear, express emotions, and even design physical objects

Arrow left icon
Product type Paperback
Published in May 2013
Publisher Packt
ISBN-13 9781782166726
Length 266 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Nikolaus Gradwohl Nikolaus Gradwohl
Author Profile Icon Nikolaus Gradwohl
Nikolaus Gradwohl
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Processing 2: Creative Coding Hotshot
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Romeo and Juliet FREE CHAPTER 2. The Stick Figure Dance Company 3. The Disco Dance Floor 4. Smilie-O-Mat 5. The Smilie-O-Mat Controller 6. Fly to the Moon 7. The Neon Globe 8. Logfile Geo-visualizer 9. From Virtual to Real Index

Exporting the object


We have created a 3D object in our previous task that can be changed using some sliders, but to print the object on a 3D printer, we have to save the object in a format that a 3D printer understands. Our current task is to add an export function that saves the object to an STL (STereo Lithography) file. This file format was originally invented to serve as an input format for Stereo Lithograph machines (hence the name), but nearly every currently available 3D software can import these files. The file stores the coordinates of triangles and a normal vector for each of these triangles. This is why the format has the nickname Triangle Soup.

An STL file has an 80-byte header that is ignored by every known 3D program, so we set it to 0. Then, we need to write the count of the triangles as a four-byte unsigned long. This is followed by 12 float values for each triangle, which contain the normal vector and the coordinates of the vertices. Each triangle ends with a two-byte zero...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image