Procedural Ant Animation +.Blend! Download!

Hi have decided to release my Ant Rig for you all to use and have some fun with!
Only Works in Blender 2.4X

Here are the rig controls:
http://i43.photobucket.com/albums/e353/MCHammond/3D%20Work/AntAnimation.gif

How it works:
I have seen solutions that use heavy maths to calculate when to start the next step but for this solution I have adopted a much simplier method.

Each leg has a rest position “Master” and a “Target” Posistion. The Rest postion is Parented the to body so when I move the body the rest postion follows! The Target postion is not parented to anything so when you move the Ant is gets left behind.

This is where the python comes in, it works out the average distance the Targets are from the rest postions and when they are at 2 times the Max Distance they are moved to the rest postion. But to provent the legs from just poping back into place, I have assigned a Driver so that when the distance equals the Max Distance the leg starts moving to the Rest postion meaning by the time the leg is about to pop back the leg has just got back itself on a smoth curve!

To keep the timings correct Even legs are controled by the Odd Legs Driver and average distance, they only use the Target bones for location.

Hope that helps!

Plaese Read Instructions in the .Blend.

Here are some Rig Demonstation Movies:
Rig Demo
Lots of Ants

And sone Animations:
AnimationA
AnimationB

.Blend:
.Blend

1 Like

It would be nice to see the script. Are you going to make it available?

Atom:
I Uploaded the .Blend :stuck_out_tongue:

hallo, can you do me the favour and give some hints
how you did the smooth “snapping” of the feets?
(i tried, but did not understand this in 2.49 - whats about this curves?)
I made a first part in blender 2.5
short blendfile with one snapping foot is here:
http://blenderartists.org/forum/showpost.php?p=1652893&postcount=33

it is the “scripted_driver3.blend”
blend-file is for blender-2.53.0 (latest download from blender.org)
/uploads/default/original/4X/1/1/c/11c6fdceb1680aca32583afaffa3d1f60599a009.blendd=1282758838

the foot snapps to the new position in my little test, but i dont realize where to setup the ?delayed movement - how to modify the “influence-slider” over time for every snapping step?

Hi I’m not using Blender 2.5 yet so I cant help with an 2.5 related problems but I can tell you my approach!

Basicaly you have a bone that you move “Master”, and a bone that is not parented to anything “Target”. So when you move the Master the Target gets left behind. You then use python to calculate the distance between the Master and Target Trigonometry! When this distance is X2 the Step Distance you get python to snap the Target bone to the Master bones location.

The trick to get a smooth transition is to use an IPO Driver on a Copy location constraint! Use the distance between the Master and Target as the Driver! so that once the the Target bone Goes past the Step Distance the Goal bone begins to move to the Master bone, and by the time the Taget bone is about to snap back “ie its at 1.999 times the Step Distance” the goal has just arrived!

hope that helps.

I have this almost figured out in 2.5 using your ant model (that I completely re-rigged it from scratch, sorry) but it needs a patched build since there is no way to call a python function on a frame change event – hence the need for a patch.

Hopefully once I have it finished I can use it as a demo to convince The Powers That Be™ the patch is worth of inclusion into blender since they were less than impressed when I mentioned it before.

Assuming you don’t mind my using your model as a pawn in my crazy schemes of course…

–edit–

Actually, now that I reread the last post it may be possible to do this in 2.5 without needing a patch using just drivers.

Just an idea, but while you are at it: do you thinks it’s possible to add a slight degree of randomness to the length of the steps so it seems more natural?

hi UncleEntity,
you may look at my blend-file with a working script executet at every frame for blender-2.53.0 in the posting above.
it is the “scripted_driver3.blend”
blend-file is for blender-2.53.0 (latest download from blender.org)
/uploads/default/original/4X/1/1/c/11c6fdceb1680aca32583afaffa3d1f60599a009.blendd=1282758838

its a very small blend-file, because it has only a simple armature with 6 “target” bones (called foot.1/2/3…) and 6 “master” bones (called aim.1/2/3…). It uses the execution via “scripted driver expression” from another object, a simple Empty, that triggers the execution at every movement.

I have to look into McHammonds hint to use a driver for the influence-slider of the copy-location-contstraint of the snapping leg-bone. I only noticed some shape-like movement curves in his example and did not see something like a pydriver.

You did solve this in 2.5?

and last, thanks to McHammond for his answer, … i have to look close to this

edit: arrgh, thanks again McHammond, now i have seen it, … need to popup the
“Transform Properties Window” for the constraint in the ipo-curve-editor to see the entry. I had forgotten this for 2.4x blender.

Uncle Entity: Feel free to use the Ant Model to demo the use of the FrameChange or Redraw Event, I can sign something if you need?

Hoverkraft: You can animate any change in Step Distance by scaling the green controle on the top of the rig, if you are thinking of a more subtle randomness, it might work if you applied a noise modifer to it? but with it being stuck in 2.4X you might have to key it by hand!

test-dr: hope you get it sorted, I have added a .Blend that has just the bit in question setup in a simple script and rig! just move the master bone and you should get the Stepped thin your after, but only in 2.4X.

I was thinking could you not make a script that at the begining reads the Current Frame stores it an then proforms an action and then only preforms the action again if the current frame is <> the Stored frame ie:

if CurrentFrame != StoredFrame:
#Do Action
StoredFrame = CurrentFrame
else:
#Do Nothing

The whole point is to find an acceptable solution so you don’t have to do something like

float(exec("
".join([l.line for l in bpy.context.main.texts["FRAME"].lines]))==None)

to get a script to run on a frame change event.

Well that and it’s a good challenge to try to reproduce this from scratch.

On the driver for the copy location constraint for the leg I did this http://www.<The Site Which Must Not Be Named>.org/pic/show.php?id=5340 (replace <> with paste all – no space) which didn’t require any python-fu.

Uncle Entity: Feel free to use the Ant Model to demo the use of the FrameChange or Redraw Event, I can sign something if you need?

Hoverkraft: You can animate any change in Step Distance by scaling the green controle on the top of the rig, if you are thinking of a more subtle randomness, it might work if you applied a noise modifer to it? but with it being stuck in 2.4X you might have to key it by hand!

test-dr: hope you get it sorted, I have added a .Blend that has just the bit in question setup in a simple script and rig! just move the master bone and you should get the Stepped thin your after, but only in 2.4X. .Blend
I was thinking could you not make a script that at the begining reads the Current Frame stores it an then proforms an action and then only preforms the action again if the current frame is <> the Stored frame ie:

if CurrentFrame != StoredFrame:
      #Do Action
      StoredFrame = CurrentFrame
 else:
      #Do Nothing

@McHammond,
thanks - i found the driver setup in your original file
and made some first steps to use a scaled-bone as source.
I will have a look at your example.
I did use this temp.-store of the current-framenumber already,
i set the y-translation of the empty to the current-frame, so
the main-calculation is only executed if the y-position is not the
same like the frame-number.
But now - when i wanted to make the first recording -
the recording breaks with an python-error.
I can only do the recording of the 3-D-window (like the ant
in your anim. with the shape of the armature).
I dont know why there is no error running the animation
with ALT-A or doing the recording of the 3d-animation-window.
There seems to be a difference for the scripted-driver-execution
when doing the full-render. (looks like its still too much beta …
and i dont know if this is a bug and/or to sign a bug-message)

edit Update: i found the “context” is not the same when running
the animation in the 3d-window (without an error) and
later running the full-render (with python error)
for the 2.5x programmers the error is:
SystemError: Operator bpy.ops.object.mode_set.poll() failed, context is incorrect

  • looks like its allowed only in the 3d-window-animation-run…?

Now with added Spider goodness Link!

Ragdoll walking in BGE: http://blenderartists.org/forum/showthread.php?t=192289
Interesting with walking bipeds too.

Eh, success…

http://vimeo.com/14510810

nice,
did you use your posted ******** setup with bone-diffs and sum?
And you did not use the shape keys from McHammonds drivers?

I noticed in 2.53 setting the size of a bone and use this as the driver for the influence-slider is always one frame too late. If the size ist 0.5 the influence-slide will update to this value on the next frame.

And last - my example with the script evalueted at every frame did break when doing a full animation render. I solved its context error by not using the context data-parts.
For example, i used
bpy.data.scenes[“Scene”].frame_current
instead of the bpy.context.scene…
and i did not change the object-mode or tried to change the active-object,
then the render-generation worked like the alt-a to play the anim.

Now i have the “funny” blender-crash at some times, looks like blender tries to execute at once the script and then crashes at startup.
And i still play around the setting of the shape-key-driver.

Yep, also has a driver which is almost identical that drives the y-axis of the foot IK bone – things just kind of worked themselves out with the copy location/y-axis drivers so the foot has a nice arc to it.

And you did not use the shape keys from McHammonds drivers?
Nope, just used the model itself.

Didn’t even know there were shape keys before now…

Hi, new to blender, trying out your ant but his legs just stuck. help, ???

That is some pretty spiffy stuff there. Thanks for sharing!

This is very cool, but with all these bugs crawling around we need some kind of defense.
http://www.funkboxing.com/wordpress/wp-content/blendfiles/BUGSPRAY.blend