{"id":866,"date":"2011-07-11T06:10:55","date_gmt":"2011-07-11T06:10:55","guid":{"rendered":"http:\/\/www.funkboxing.com\/wordpress\/?p=866"},"modified":"2021-01-03T18:12:03","modified_gmt":"2021-01-03T18:12:03","slug":"progranimals-physics-based-locomotion","status":"publish","type":"post","link":"http:\/\/funkboxing.com\/wordpress\/?p=866","title":{"rendered":"ProgrAnimals &#8211; A framework for physics based creatures"},"content":{"rendered":"<p><a href=\"http:\/\/www.funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/07\/progranimalsCastweb.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-906\" title=\"progranimalsCastweb\" src=\"http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/07\/progranimalsCastweb.jpg\" alt=\"\" \/><\/a><\/p>\n<p><iframe loading=\"lazy\" src=\"http:\/\/www.youtube.com\/embed\/Jy_CeRcNfM4?hl=en&amp;fs=1\" frameborder=\"0\" width=\"425\" height=\"349\"><\/iframe><\/p>\n<p><a href=\"http:\/\/blenderartists.org\/forum\/showthread.php?224316-ProgrAnimals-Pose-Control-Procedural-Animation\">BA Thread<\/a><\/p>\n<p><span style=\"text-decoration: underline;\">What it Is<\/span> &#8211; ProgrAnimals is an initial framework for variable morphology pose-controlled physics-based animation in Blender, whatever that means.<\/p>\n<p><span style=\"text-decoration: underline;\">What it Does<\/span> &#8211; In simplest terms this script creates a game-engine physics based &#8216;walking ragdoll&#8217; from a user-defined armature, from humanoid biped to something much more bizarre. I think the game &#8216;Spore&#8217; is probably the best analogy, where people can make creatures and they sort of walk or hobble based on how they&#8217;re built. This is the same notion, except much less automatic right now. The user has to define a little more about structure, muscles, and gait.<\/p>\n<p><span style=\"text-decoration: underline;\">Why it Be<\/span> &#8211; This is inspired first and foremost by my enduring love of doing horrible things to ragdolls, for which I make no excuses or apologies. The implementation is inspired especially by Cartwheel-3d, SIMBICON, and Philippe Beaudoin, and also by Ari Shapiro&#8217;s DANCE. The future goals of this are somewhere between Endorphin, Spore, and may also include possible robotics integration with Arduino. Ultimately I&#8217;d like to create a break-dancing robot army to help me stamp out tyranny, oppression, and tired dance moves.<\/p>\n<p>This is the unexpected result of some of what I learned from the whole <a href=\"http:\/\/www.funkboxing.com\/wordpress\/?p=267\" target=\"_blank\" rel=\"noopener noreferrer\">progranimation<\/a> thing. I thought I would make a more complex pose-control system, but I ended up wanting to make a more generalized system that could work with arbitrary leg configurations. Originally I think it had something to do with making circuit components walk around on a circuit board but that&#8217;s another story, might still do that though. Anyway- this is actually a vastly simplified controller compared to Uno and Deuce in progranimation. No balance feedback, no uprightness vector, not even a collision sensor on the feet, it&#8217;s just proportional derivative controllers and a timed state-machine. It&#8217;s about the most bare-bones pose-controller I think you could make, but it&#8217;s still hilarious to watch it make stuff walk around. I hope to expand from here by giving the torso and legs considerable options as far as number of states, balance sensors, state-switching reactions, etc. First I wanted to get something functional and this is it.<\/p>\n<p>I hope this will be useful and interesting, but it may take a little time to get a creature working. That said, it can be very fun and I hope I&#8217;ve made it easy enough to use that most Blender users can figure it out. Here are a couple of walk-throughs that demonstrate how the process works.<\/p>\n<p style=\"text-align: center;\">&#8212;<\/p>\n<p><strong>I. EDITING WALK STYLES<\/strong> &#8211; Changing the gait of a pre-made biped rig.<\/p>\n<p>1) Download this file <a title=\"ProgrAnimalsBiped\" href=\"http:\/\/www.funkboxing.com\/wordpress\/wp-content\/blendfiles\/ProgrAnimals-I-biped.blend\">ProgrAnimals-I-biped.blend<\/a> and open in Blender2.58a<\/p>\n<p><a href=\"http:\/\/www.funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/07\/ProgrAnimalsI1.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-880\" title=\"ProgrAnimalsI1\" src=\"http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/07\/ProgrAnimalsI1.jpg\" alt=\"\" \/><\/a><\/p>\n<p>2) Press &#8216;P&#8217; to run game engine. Watch as very little happens. Press &#8216;ESC&#8217; to stop game.<\/p>\n<p>3) Select the <em>iARMa-pg-0<\/em> armature (pose-goal armature). Switch to POSE MODE, and change the pose to something approximating this screenshot.<\/p>\n<p><a href=\"http:\/\/www.funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/07\/ProgrAnimalsI3.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-881\" title=\"ProgrAnimalsI3\" src=\"http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/07\/ProgrAnimalsI3.jpg\" alt=\"\" \/><\/a><\/p>\n<p>[Exact settings: BONE x|y|z rotation : THIGH0 -45|0|0 | SHIN0 90|0|0 : THIGH1 15|0|0]<\/p>\n<p>4a) Run game again (P).<\/p>\n<p>EXPLANATION: The left leg in the pose-goal armature is the &#8216;Swing Leg&#8217;, the right is the &#8216;Stance Leg&#8217;. They are the pose-goals that the leg will try to assume when in this state. Poses can also be stored in poseLib for convenience.<\/p>\n<p>4b) while not bored: change settings; run game again (P).<\/p>\n<p>5) Select the <em>iARMa<\/em> armature and switch to EDIT MODE.<\/p>\n<p>6) Select each THIGH bone, change the bones Custom Property\u00a0<em>legstate<\/em> = 0 on both.<\/p>\n<p><a href=\"http:\/\/www.funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/07\/ProgrAnimalsI6.jpg\"><img decoding=\"async\" class=\"alignnone size-large wp-image-882\" title=\"ProgrAnimalsI6\" src=\"http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/07\/ProgrAnimalsI6-1024x615.jpg\" alt=\"\" \/><\/a><\/p>\n<p>7a) Switch to OBJECT MODE. Run game again (P).<\/p>\n<p>EXPLANATION: <em>legstate<\/em> defines if the leg starts on swing or stance, setting both to the same makes the ragdoll jump.<\/p>\n<p>7b) Change one thigh back to <em>legstate<\/em> = 1 (make the ragdoll walk again)<\/p>\n<p>8} Select the <em>iARMa-THIGHl-k<\/em> empty (best to select from outliner). Look at the Scale values in the &#8216;N&#8217; properties view. Change the &#8216;X&#8217; scale to 10. Do the same on <em>iARMa-THIGHr-k<\/em>.<a href=\"http:\/\/www.funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/07\/ProgrAnimalsI8.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-883\" title=\"ProgrAnimalsI8\" src=\"http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/07\/ProgrAnimalsI8.jpg\" alt=\"\" \/><\/a><\/p>\n<p>9) Run game again<\/p>\n<p>EXPLANATION: The scale setting on these empties define the stiffness and damping parameters for their joints. See <a title=\"Progranimation \u2013 A study in physics based animation\" href=\"http:\/\/www.funkboxing.com\/wordpress\/?p=267\" target=\"_blank\" rel=\"noopener noreferrer\">progranimation<\/a> for a better explanation of PD controllers)<\/p>\n<p>10) Edit the iARMa armature. Select the TORSO bone &#8211; change the bones Custom Properties: statetimer = .25; zgoal = &#8216;BALL&#8217;<\/p>\n<p><a href=\"http:\/\/www.funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/07\/ProgrAnimalsI10.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-884\" title=\"ProgrAnimalsI10\" src=\"http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/07\/ProgrAnimalsI10.jpg\" alt=\"\" \/><\/a><\/p>\n<p>11) Switch to OBJECT MODE. Run game again (P)<\/p>\n<p>EXPLANATION: <em>statetimer<\/em> times the switch between states, <em>zgoal<\/em> defines the heading goal of the character. <em>zgoal<\/em> can be the name of an object or an angle in degrees using the prefix &#8216;a:&#8217; ex. a:45<\/p>\n<p>&nbsp;<\/p>\n<p><strong>II. SETTING UP A NEW CREATURE<\/strong><\/p>\n<p>1) Download this file <a title=\"ProgrAnimalsQuad\" href=\"http:\/\/www.funkboxing.com\/wordpress\/wp-content\/blendfiles\/ProgrAnimals-II-quad.blend\">ProgrAnimals-II-quad.blend<\/a> and open in Blender2.58a.<\/p>\n<p>2) Select the <em>iARMq<\/em> armature.<\/p>\n<p>3) In the script editor make sure the variable setupSEQ = 0. Run the script ALT-P. This script will add custom properties to the bones of this armature based on the names of the bones.<\/p>\n<p><a href=\"http:\/\/www.funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/07\/ProgrAnimalsII3.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-885\" title=\"ProgrAnimalsII3\" src=\"http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/07\/ProgrAnimalsII3.jpg\" alt=\"\" \/><\/a><\/p>\n<p>BONE SETUP\/NAMES:<br \/>\nThe script will use bone names as a starting point to setup constraints with axis and angle limits for standard joints. see code for values. THIGH, SHIN, FOOT, TOE, REVKNEE, just use these strings somewhere in the bone. The names aren&#8217;t necessary but they make setup much easier as they add the necessary Custom Properties to the bones.<\/p>\n<p>CUSTOM PROPERTIES ADDED TO BONES:<br \/>\nTORSO<br \/>\n<em> statetimer<\/em>: time to switch states<br \/>\n<em> zgoal<\/em>: goal in degress &#8216;a:45&#8217; or object name &#8216;Cube&#8217;<br \/>\nTHIGHS<br \/>\n<em>legstate<\/em>: leg start state (0-swing\/1-stance)<br \/>\n<em> legtype<\/em>: type of leg config (for multi leg setups)<br \/>\nALL BONES:<br \/>\n<em>usebone<\/em>: create box for this bone<br \/>\n<em>xyzmin<\/em>\/<em>xyzmax<\/em>: values to be used to create 6dof rigid body joints<br \/>\n*<em>usebone<\/em> and <em>legtype<\/em> are the only values that cannot be modified after this step<\/p>\n<p>4) Select the armature, enter EDIT MODE. Make sure Custom Properties were added to bones. Select the THIGH bones. Change the value of <em>legtype<\/em> so the front legs are &#8216;0&#8217; and the back legs are &#8216;1&#8217;. This will let the program distinguish between the different types of legs and will create pose-goal armatures for each leg type. You can have as many types of legs as you want, but for now they only have 2 states each: swing\/stance.<a href=\"http:\/\/www.funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/07\/ProgrAnimalsII4.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-886\" title=\"ProgrAnimalsII4\" src=\"http:\/\/www.funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/07\/ProgrAnimalsII4.jpg\" alt=\"\" width=\"332\" height=\"224\" \/><\/a><\/p>\n<p>5) Switch to OBJECT MODE. Select the armature. In the script editor set variable setupSEQ = 1. Run the script. This will create the boxes and empties for each bone. Boxes are game objects connected by rigid body constraints. Empties define stiffness\/damp gains at each joint with their xyz scale values.<\/p>\n<p><a href=\"http:\/\/www.funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/07\/ProgrAnimalsII5.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-887\" title=\"ProgrAnimalsII5\" src=\"http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/07\/ProgrAnimalsII5.jpg\" alt=\"\" \/><\/a><\/p>\n<p>6) Select the armature.\u00a0In the script editor set variable setupSEQ = 2. This will create pose goal armature(s) to be used to define swing\/stance state pose goals for each leg type.<\/p>\n<p><a href=\"http:\/\/www.funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/07\/ProgrAnimalsII6.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-888\" title=\"ProgrAnimalsII6\" src=\"http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/07\/ProgrAnimalsII6.jpg\" alt=\"\" \/><\/a><\/p>\n<p>7) Adjust pose-goal armature poses as desired. Press &#8216;P&#8217; to run game engine.<\/p>\n<p>8} Design a crazy five-legged monster and make it chase some other crazy thing around.<\/p>\n<p>9) Game&gt; Record Animation. Rinse, Repeat.<\/p>\n<p>NOTES FOR MAKING YOUR OWN CREATURE:<br \/>\n*Legs must at least have a thigh, the rest is optional. Feet are good to have though.<br \/>\n*Legs can be nearly any config as long as they do not branch (no double-footed legs or anything like that, a long tail is fine though).<br \/>\n*Use very short names on armature or bones, under 5 chars each (sorry).<br \/>\n*Do not use &#8216;-&#8216; (dashes) in the names of bones or armatures. I need those.<br \/>\n*The mass of each bone-box is determined by the length of the bone. This can make for very heavy limbs so you might want to adjust this. You may also want to change the shape of certain bone-boxes, that should work as long as you don&#8217;t change the origin.<br \/>\n*The settings created for THIGH, SHIN, FOOT, etc. are generic and can be changed to anything. The settings for each joint are combination of the rigid body constraint settings and the stiff\/damp parameters. The initial setup of the rigid body constraint is defined by the xyzmin\/xyzmax setting on the bone, you can change these Custom Properties before you create this bone-boxes, or you can adjust them in the constraint settings after they&#8217;re created.<br \/>\n*Characters should be created facing Y+ forwards.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>III. TIMER OFFSET <\/strong>&#8211; Offsetting state switch timing.<strong><\/strong><\/p>\n<p>This is a little cheat that offsets the state switch timing for a leg by a given amount. This allows sequential legs like the centipede guy, and galloping quadrupeds and whatnot. Setting it up can be a little tricky and depends on the creature design and the walk style you&#8217;re looking for.<strong><\/strong><\/p>\n<p><a href=\"http:\/\/www.funkboxing.com\/wordpress\/wp-content\/blendfiles\/progranimalsDemo.blend\">Here is the .blend file<\/a> with script with the <em>timeroffset<\/em> feature added. The example files for the previous tutorials do not have it. This file also contains all the creatures used in the demo video.<\/p>\n<p>The <em>timeroffset<\/em> property is added to each leg bone in the armature when the first part of the setup is run (setupSEQ = 0). When the game objects are created the legs will use this bone property offset when that state is triggered.<\/p>\n<p>That&#8217;s about it for the offset. It was a lot cheaper than breaking into more than two states and it works pretty well considering how simple it was to implement.<strong><\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><strong>IV. BIG WARNING &#8211; BUGS and ERRORS and CRASHES! OH MY!<\/strong><strong><\/strong><\/p>\n<p>Creating the pose-goal armature in the setup (setupSEQ = 2) turned out to be a total fiasco. I had to con bpy.ops into making some bones for me and every once in awhile it just refuses. It&#8217;s a context thing but I never could figure out why it works sometimes and sometimes doesn&#8217;t. So enjoy that. If you have a problem with a rig, try it 3 more times, if it still wont work feel free to contact me, I&#8217;ll try to help you sort it out.<strong><\/strong><\/p>\n<p><strong><br \/>\n<\/strong><\/p>\n<p><strong>V. STUFF I HAVEN&#8217;T THOUGHT OF YET<\/strong><\/p>\n<p>I may add notes here in the future when I think of them.<\/p>\n<p>Hey, here&#8217;s something- you can &#8216;deadleg&#8217; a creature by turning all the <em>usebone<\/em> bone properties to False in a leg. I guess you could make a limping zombie character or something, though you&#8217;ll have to compensate the stiff\/damp on the other leg so it&#8217;s strong enough to carry the weight and the poses will have to be offset so he stays sort of balanced.<\/p>\n<p style=\"text-align: center;\">&#8212;<\/p>\n<p><span style=\"text-decoration: underline;\">Notes<\/span> &#8211; Once you start playing with pose-goals you may notice that there is something horribly wrong with the joint torques. An extreme pose can lift the character off the ground and fly (not in a cool superman way, more like falling up). Clearly this is not physics. Working on that.<\/p>\n<p>Also the feet didn&#8217;t stick to the ground like I&#8217;d expect\u00a0so i added a hack where the obj.setLinVel.x.y = 0 on the last object in the chain of the stance leg, which ends up being the toe if you have one. So even in flight forward momentum is lost to this bs-friction-hack. Later I might try adding material friction to the feet or something.<\/p>\n<p>In the future I&#8217;d really like to improve the whole implementation in Blender but I think the key will be porting it to the animation system once we get rigid body dynamics in the physics system. It would be great to have these rigs interact more cleanly with other dynamics. I love the game engine but the &#8216;Record Animation&#8217; thing makes this a really weird workflow, glad it&#8217;s there though.<\/p>\n<p><span style=\"text-decoration: underline;\">Why No UI?<\/span> &#8211; mostly because the whole setup script is kind of sketchy as it is, it randomly crashes if\u00a0 you keep remaking ragdolls from the same armature for some reason. Plus these are program driven animations so I think if you&#8217;re going to use this for anything you&#8217;re going to have to get into the code eventually anyway.<\/p>\n<p><span style=\"text-decoration: underline;\">Personal Request<\/span> &#8211; If you make a cool critter with this please show me! A render is worth a thousand comments. Hope you enjoy!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>BA Thread What it Is &#8211; ProgrAnimals is an initial framework for variable morphology pose-controlled physics-based animation in Blender, whatever that means. What it Does &#8211; In simplest terms this script creates a game-engine physics based &#8216;walking ragdoll&#8217; from a user-defined armature, from humanoid biped to something much more bizarre. I think the game &#8216;Spore&#8217; <a href='http:\/\/funkboxing.com\/wordpress\/?p=866' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,5,47],"tags":[28,30],"_links":{"self":[{"href":"http:\/\/funkboxing.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/866"}],"collection":[{"href":"http:\/\/funkboxing.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/funkboxing.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/funkboxing.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/funkboxing.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=866"}],"version-history":[{"count":6,"href":"http:\/\/funkboxing.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/866\/revisions"}],"predecessor-version":[{"id":2619,"href":"http:\/\/funkboxing.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/866\/revisions\/2619"}],"wp:attachment":[{"href":"http:\/\/funkboxing.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=866"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/funkboxing.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=866"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/funkboxing.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=866"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}