Jump to content

  • Log In with Google      Sign In   
  • Create Account






And Now For Something Completely Different

Posted by Dancin_Fool, 13 July 2012 · 684 views

allspark binary pdo pepakura file formats
This is a repost from my external blog http://codingintransit.blogspot.ca

I have something totally different for you this week. To give you some background, my other hobby is costuming, and on top of that it's mostly armor based costuming. I build things like, transformers, Iron man, that sort of thing. The piece of software I use to do this is called Pepakura Designer. It allows a user to "unfold" a 3d model into 2 dimensions so that it can be printed out on cardstock and re-assembled. The problem is that it's been designed with building little papercraft model's not costuming. This results in a lot of little things I don't like about the software. Now rather than just accept those things I started planning out a better piece of software more designed for costuming in mind.

The problem with this though is that even if I built out this piece of software noone is going to use it because all of the existing content is built for pepakura. So I decided the number one thing I needed was in importer that could load pdo( the pepakura file format ) files into my software. The problem with doing this though is that pdo files are a closed format and besides one hacked together python script I found that could import parts of the 3d data there wasn't really any information about the format out there in the wild.

So I set about reverse engineering the format and started building up a spec of how it was layed out in memory. I've never done anything like this before and so it was a slippery slope trying to figure out where to begin. I've done lots of work with binary files though so I have a pretty solid grounding in how a lot of different formats are layed out so it gave me a bit of a base to start from. So I started with a simple box model and just started poking and prodding in a hex editor. Change a vertex, re-export see what changed. Change a color, re-export see what changed. Slowly but surely a picture started to emerge. Within a few days I had a clear picture of what the 3d data looked like in memory. One thing that really held me up was that I expected all of the floating point data to be stored as floats, but they decided to store them as doubles, I can't imagine why they would think they would really need that level of precision, were they thinking someone would be trying to unfold an earth sized object? Another thing that held me up a bit was that the strings are encoded. I saw patterns that looked like null terminated strings, a string length, a set of characters ending with a 0. When I looked at the data though the strings were jibberish. With a bit of fiddling around though I figured out that if I subtracted a constant from each element of the string I could decode it into the original string value. Turned out though that this constant changes from file to file. The good thing though was after a quick search of the header I found out one of the blocks of data I was unsure about stored the decoder value.

So that was about as far as I got a few months ago I got distracted by other things and there it lied dormant. A couple weeks ago though I got the itch again. So for the last couple weeks I've been poking and prodding at the data structures and finally have an almost complete picture of how everything is stored. I've also set up a pdo viewer option in my project for viewing pdo files. Now the next big question for me is do I go back to my voxel earth project or do I put some love into my costume designer project I planned out so many months ago.

Anyways, I've compiled how things are layed out in memory, it can be found on my external blog here

http://codingintrans...completely.html.

Everything that's important for rendering a pdo is there, there's a few odd and end flags that haven't been decoded yet. If anyone has any questions or feedback on what some of those unknown fields do, please leave a comment.

Posted Image
Model almost decoded.

Posted Image
There we go model decoded

Posted Image
Hmm those unfolds don`t quite look right

Posted Image
Hmm the bounding boxes are looking right

Posted Image
Hey there we go, unfolds rendering correctly

Posted Image
Found the normals for them model!

Posted Image
FIgured out which edges were the internal edges.




July 2014 »

S M T W T F S
  12345
6789101112
13141516171819
20212223242526
27 28 293031  

Recent Entries

Recent Comments

PARTNERS