STL Loading in XNA

I’ve recently been doing some playing around with a Makerbot Replicator 2, which has been pretty nifty. Before I got my hands on the 3D printer, though, I wanted to learn more about the STL file format that seems to be used by all of them. I did some reading, and figured out that there are basically two styles of STL file – binary and text. I wrote an STL file loader in XNA, just to see how difficult it was to parse the files. (It’s been a while since I have done something like that, and was itching to do it). You can read about the STL file format here. I’ve hacked together a small STL file loader in XNA, which you can find here. The included STL files came from Thingiverse. The included code should be reasonably straightforward. The only tricky bit was getting XNA to render inside a Winforms app. (Digging through the XNA examples, I hacked apart the one windows form example and got it working). That, and the camera code is pretty screwed up, so feel free to ignore/replace it. (I was experimenting with some 3D camera movement at the same time). Also, the various triangles are randomly colored, just to make it easy to see everything that is being loaded.

STL Loader 1

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s