{"id":683,"date":"2010-09-02T17:33:08","date_gmt":"2010-09-03T01:33:08","guid":{"rendered":"http:\/\/technofovea.com\/blog\/?p=683"},"modified":"2010-09-02T17:34:00","modified_gmt":"2010-09-03T01:34:00","slug":"binary-parsing-in-java","status":"publish","type":"post","link":"http:\/\/technofovea.com\/blog\/archives\/683","title":{"rendered":"Binary parsing in Java"},"content":{"rendered":"<p>Well, PackBSP 2.0.4 may be delayed a bit due to extra complications in parsing the MDL files&#8230; In addition, I&#8217;m revisiting the idea of using <a href=\"http:\/\/preon.codehaus.org\/\">Preon<\/a> to more-easily program in the parsing rules. I tried it out a few months ago but decided to avoid it due to some blocking bugs. Now, however, with it getting a bit more activity and I want to see if it can replace some of my serviceable but-not-that-pretty code.<\/p>\n<p>Here&#8217;s a quick (incomplete) bit of sample code for MDL parsing. The Java class is being annotated so that the Preon framework can semi-magically shove data into it.<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npublic class Mdl {\r\n\r\n    @BoundString(match = &quot;IDST&quot;, size = &quot;4&quot;)\r\n    protected String magicHeader;\r\n    @BoundNumber\r\n    protected int version;\r\n    @BoundNumber\r\n    protected int checksum;\r\n    @BoundString(size = &quot;64&quot;)\r\n    protected String modelName;\r\n    @BoundNumber\r\n    protected int dataLength;\r\n    @BoundObject\r\n    protected Vector3f eyePosition;\r\n    @BoundObject\r\n    protected Vector3f illumposition;\r\n    @BoundObject\r\n    protected Vector3f hull_min;\r\n    @BoundObject\r\n    protected Vector3f hull_max;\r\n    @BoundObject\r\n    protected Vector3f view_bbmin;\r\n    @BoundObject\r\n    protected Vector3f view_bbmax;\r\n\r\n    @BoundList(size=&quot;4&quot;)\r\n    protected byte[] flags; \/\/FIXME: Use boolean or bitset\r\n\r\n\r\n\r\n    @BoundNumber\r\n    protected int boneCount;\r\n    @BoundNumber\r\n    protected int boneIndex;\r\n\r\n    @BoundList(offset=&quot;boneIndex&quot;,size=&quot;boneCount&quot;)\r\n    protected Bone[] bones;\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Well, PackBSP 2.0.4 may be delayed a bit due to extra complications in parsing the MDL files&#8230; In addition, I&#8217;m revisiting the idea of using Preon to more-easily program in the parsing rules. I tried it out a few months ago but decided to avoid it due to some blocking bugs. Now, however, with it [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[17,20],"_links":{"self":[{"href":"http:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/posts\/683"}],"collection":[{"href":"http:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/comments?post=683"}],"version-history":[{"count":11,"href":"http:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/posts\/683\/revisions"}],"predecessor-version":[{"id":699,"href":"http:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/posts\/683\/revisions\/699"}],"wp:attachment":[{"href":"http:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/media?parent=683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/categories?post=683"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/technofovea.com\/blog\/wp-json\/wp\/v2\/tags?post=683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}