{"id":643,"date":"2006-09-22T07:01:11","date_gmt":"2006-09-22T12:01:11","guid":{"rendered":"http:\/\/www.shamusyoung.com\/twentysidedtale\/?p=643"},"modified":"2006-09-24T11:51:36","modified_gmt":"2006-09-24T16:51:36","slug":"animated-figures","status":"publish","type":"post","link":"https:\/\/www.shamusyoung.com\/twentysidedtale\/?p=643","title":{"rendered":"Animated Figures"},"content":{"rendered":"<p>I&#8217;ve alluded to this a bit over the past few days, but my current non-work project is to make a program for animating 3d characters.  At work, I maintain software that does this already, but I didn&#8217;t write that part of the code.  For the most part, the character animation is driven by <a href=\"http:\/\/www.renderware.com\/\">Renderware<\/a>, which a fairly large and popular cross-platform graphics engine.  It&#8217;s nice to be able to hand off complex tasks to a graphics engine and say &#8220;make all of this confusing stuff work and don&#8217;t trouble me with the details.&#8221;  When developing commercial software on a schedule and a budget, it&#8217;s just the thing.<\/p>\n<p>But I&#8217;m filling in various gaps in my knowledge and so I want to know how to do this myself, from the ground up.  This means putting some of my crude, self-taught trigonometry to use.  It also means getting some 3d data to work with.<\/p>\n<p><table width='256'  cellpadding='0' cellspacing='0' border='0' align='right'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/figure_model.jpg' class='insetimage' width='256' alt='3d character, Vertices, Lines, Triangles' title='3d character, Vertices, Lines, Triangles'\/><\/td><\/tr><tr><td class='insetcaption'>Top: Vertices are the dots that give the figure shape. Bottom: Triangles are lists of points to connect, which will eventually turn this thing into a solid shape.<\/td><\/tr><\/table>Unlike my <a href=\"?p=141\">Terrain Project<\/a>, where my input data was just a couple of bitmaps and a few nice shading tricks, I need <em>real<\/em> data for this one.  I need a low-polygon (less than 5,000 polys) humanoid figure with skeletal info so that the points can be moved around to make the figure walk \/ run \/ fall down \/ etc. I also need a system of scripting body movements so that I&#8217;ll know how to adjust the position of the figure to create the illusion of walking. This is a lot of very complex data. In a real game company, it would take between two and five artists to come up with this data.  Luckily, I have enough 3d art background that I can make this stuff myself as long as I&#8217;m not too picky about quality.<\/p>\n<p>So now I need to decide what 3d program to use to make this stuff. Part of this decision will involve what sorts of 3d files the program can save.  3D models are made up of predictable things.  There are points (verticies) and there are triangles (each of which plays connect-the dots with 3 particular points) uv values (information about how the texture lines up on the model) the skeleton (another collection of points, which define all of the joints in the body, where their pivot points are, and how they relate to each other).  There is lots of other interesting data, but this is the critical stuff that every program needs before it can draw a 3d model. <\/p>\n<p>Every 3d program has its very own file format, a method for storing all of this stuff.  Some are very nice to use. It&#8217;s just a list of verices, followed by a list of triangles, etc.  Others are more obscure, or have lots of extraneous data mixed in that must be weeded out.  Still other files formats are &#8220;closed&#8221;: Nobody outside of their creators know how they work, so they can&#8217;t be read by any external programs.  Such as mine. Some are dense, complex, tricky, poorly documented, or otherwise difficult to read.  Some are easy to read but don&#8217;t preserve the most complex data &#8211; the information that ties the body to the skeleton.  Since that&#8217;s the whole point of the project, I can&#8217;t go with any file format that leaves this out.  File formats that are both robust AND easy to read do exist, but they are rare and not all programs support them.  So, this is going to be tricky.<\/p>\n<p>My budget right now is $0.00, and 3d programs tend to hail from the $500+ price range, so there&#8217;s another snag.  Even if I <em>do<\/em> find a program that supports an easy-to-read, well-documented format that has what I need, it might be way out of my price range. <\/p>\n<p>Well, Let&#8217;s see&#8230;<\/p>\n<h3>Truespace<\/h3>\n<p>I own a copy of <a href=\"http:\/\/www.caligari.com\/\">Truespace<\/a>, so it&#8217;s &#8220;free&#8221;, but I&#8217;m not going to use it for this unless I have no other choice.  It&#8217;s a poor tool for this particular task, and the file format is difficult.  It&#8217;s nice to know I have this to fall back on, but I&#8217;d like to see if I can find a better tool for the job. <\/p>\n<h3>Poser<\/h3>\n<p>Content Paradise had a promotion where they were giving Poser 5 away for free, and I managed to grab a copy.  As of right now the free promotion is over, but <a href=\"http:\/\/www.contentparadise.com\/us\/user\/poser_5_english_full_version_product_22249\">they are selling the program for $20<\/a>.  That is $230 less than the usual price.  I don&#8217;t know what inspired this fire sale, but that&#8217;s still a good deal.<\/p>\n<p>Poser isn&#8217;t a 3d modeling program per se.  It&#8217;s for posing very realistic super high-polygon figures.  Not really ideal, but it does have moving 3d human models and an export feature.  It should at least give me my 3d figures, although I&#8217;ll have to look elsewhere for the animations that drive them.<\/p>\n<p>I was able to export one of the low-poly models into 3DS format. (Pictured above) 3DS files are a bit unwieldy.  They certainly aren&#8217;t a nice neat list of points, triangles, and such. The 3DS file is packed with useless stuff about window layout, light placement, camera settings, and a bunch of crazy stuff that I don&#8217;t want or need.  Still, the <a href=\"http:\/\/www.martinreddy.net\/gfx\/3d\/3DS.spec\">format is documented<\/a>, so I sit down and spend a few hours implementing my own code to read 3DS files.<\/p>\n<p>At the end of a lot of confusion I discover a nasty little secret:  Poser leaves the skeleton off when it exports.  Suddenly this animated 3d guy turns into an unmoving statue, and the data to get it moving is <em>gone<\/em>.  Some Googling reveals that this is the case for all formats for all versions of Poser.  The program leaves this info out on purpose. <\/p>\n<p>Sigh.<\/p>\n<p>Well, at least I didn&#8217;t pay $250 for it.<\/p>\n<h3>Blender<\/h3>\n<p>I tried Blender, and eventually dismissed it for reasons <a href=\"?p=641\">belabored<\/a> <a href=\"?p=642\">elsewhere<\/a>.  I really, really did think this was the right program for the job, which is why I gave it so many second chances. It&#8217;s open source.  It LOOKS impressive. It&#8217;s feature-rich.  And if you want an open file format, then an open-source program should be the place to go, right?<\/p>\n<p>In the end all those second, third, tenth chances only fueled my rage and led to my intemperate and (I hoipe) uncharacteristic posts.  I should have given up much earlier on.  It was clear the thing just wasn&#8217;t going to cut it and I just had a mental block about the thing.  I just couldn&#8217;t imagine OS software that was this bad.  I must be missing something? Doing something wrong? It can&#8217;t be this useless, can it?<\/p>\n<p>Yes. Yes it can.  This is not the program you&#8217;re looking for.  Move along.<\/p>\n<h3>Maya<\/h3>\n<p><a href=\"http:\/\/usa.autodesk.com\/adsk\/servlet\/index?siteID=123112&#038;id=7635018\">Maya<\/a> retails for about $400 or so, but Unreal Tournament 2004 came with a special limited version of Maya that had some of the high-end features disabled, and it put an annoying watermark over the 3d viewports.  It was like looking at your work through a stenciled window.  These programs are tough enough without <em>that<\/em> visual distraction.  Also, I think the export functionality was crippled or removed in this evaluation \/ learning version. <\/p>\n<p>I like the idea of a learning version, but this isn&#8217;t going to meet my needs.  The $400 price point is WAY out of my budget, so I have to give this one a pass.<\/p>\n<h3>Milkshape<\/h3>\n<p><a href=\"http:\/\/www.swissquake.ch\/chumbalum-soft\/\">Milkshape<\/a> is an odd duck.  <a href=\"http:\/\/wonderduck.mu.nu\/\">(No offense)<\/a>. Instead of being aimed at professionals, it is aimed at home-brew developers making game mods.  Where most 3d programs have export options for various obscure file formats, Milkshape has stuff like, &#8220;Export to Doom 3&#8221;, &#8220;Export to Half-Life&#8221;, &#8220;Export to Max Payne&#8221; and so on.  <\/p>\n<p>The interface is alarmingly simple:<\/p>\n<p><table width='532'  cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/milkshape1.jpg' class='insetimage' width='532' alt='Milkshape' title='Milkshape'\/><\/td><\/tr><tr><td class='insetcaption'>Milkshape isn&#8217;t fancy.  She might not look like much, but she&#8217;s got it where it counts.  Here you can see I&#8217;m adding a skeleton to the model so that it will move.  The model is bent oddly because I did something wrong and the skeleton isn&#8217;t properly attached yet.  When it&#8217;s working right, the skeleton will stay inside of the model!<\/td><\/tr><\/table><\/p>\n<p>Still, simple is good. Building a full 3d human with this would be really tough.  Blender seems geared to very low-poly work, like making models in the 1,000 polygon range.  That&#8217;s about the polygon budget of games released around 1999 and 2000.  However, Milkshape <em>does<\/em> import 3DS files.  So, I can take my non-animated guy from Poser, bring him into Milkshape, and manually re-create the skeleton.  It&#8217;s dull work, but it will get me where I want to go and save me the time I was going to have to spend modeling a human.  <\/p>\n<p>But what about saving? All of this does no good if I can&#8217;t save in a format that my program can read.  Well, it turns out that Milkshape has a wonderful text-based format.  There is documentation on it, but I hardly need it.  After a a quick read through a file I can intuit what the numbers mean.  It&#8217;s all very easy and sensible.<\/p>\n<p>The price point is $25, which is very reasonable.  I know this project has a budget of zero, but I think this program is worth $25.  Even if it doesn&#8217;t pan out, this thing looks to be a labor of love and has more than $25 worth of features.  So, I found my 3d program.  <\/p>\n<p>After days of work, I&#8217;m finally ready to start!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve alluded to this a bit over the past few days, but my current non-work project is to make a program for animating 3d characters. At work, I maintain software that does this already, but I didn&#8217;t write that part of the code. For the most part, the character animation is driven by Renderware, which [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-643","post","type-post","status-publish","format-standard","hentry","category-projects"],"_links":{"self":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/643","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=643"}],"version-history":[{"count":0,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/643\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}