Halloween Costume ideas 2015
Articles by "offset"
@dorothiar #arttips #interview 101 2 Column Template 2012 mentee 2013 2013 mentee 2014 2014 mentee 2014 Portfolio Winner 2014 SCBWI Portfolio Mentorship Winner 2015 mentee 3 Column Template 360 3d 3d print 3d printing 3delight 8bit Abbey McCulloch abstract acryla gouache acrylic action addon adobe Adobe Flash CS3 Adobe Illustrator Advanced Tutorials advection Advertising advice Agata Wierzbicka agents airplane Al Wiseman ALA Alan E. Cober Alan Lee Alex Ross Alexandra Compain-Tissier Alexandra Lekias Alexandra Levasseur Alexandre Korobov Alexis Winter algorithm alien ALT Amelie Hegardt Amit Shimoni amusement an Ana Aranda analog Andrea Hrjnak Andrea Hrnjak andrea offermann andreaoffermann andreazuill Andy Musser Angela DiTerlizzi Angelika Peißker animal logic animals animation animation nodes anime anisculpt Anja Kroencke Anna Higgie Anna Jensen Anna McKay Annabel Briens AnneBerry Anneke Krull Annu Kilpeläinen anstudy anthology António Soares ar arduino area armature arrange array array modifier arrow art art director art directors Art is fun! art reps art tools Artaksiniya arthictecture arthur rackham artists artwork ase Ashlyn Anstee Asian aspiring asset atom attribute attribute transfer audio Audrey Kawasaki augmented reality aurasma Aurelius Battaglia author illustrator automatic automation Autumn Whitehurst avatar Avrom Yanovsky AW14/15 award awards Babeth Lafon Babies baboon Baby Love Background background color bacteria bake baking ball Bamboo banner Banner images banner making Barbara Dziadosz barcode basic bbox beads beats Bec Winnel beginner Bel Johnstone Ben Denison Bernie Fuchs Berto Martinez Beth Krush better photos bge Bijou Karman Bike biscuit bishop black and white black and white art Blair Breitenstein blam blender blender game engine blender3d blending Blinkie Blinky blob blocks Blog Tips blogger Blogging Friends blogs Blonde blur effect in pixlr and photoshop blur images and pictures bmesh bmesh viewer bolognaragazziaward bombing bone bone modeling bones book book launch books boomerang bottle bounding box bowl bpy brian eno brian ormiston Brian Sanders brian won brick bridge Bridget Davies bright Brooke Boynton Hughes build modifier building burns business Buttons bvh cage Caitlin Shearer caldecott calibration camera camera settings camera tips Candle capcom card career Carole Wilmet cartoony Cassandra Rhodin cast Catherine Campbell Cecilia Carlstedt cell center pivot centipede cg cg photography chair challenge Chanel changin color in pixlr changing color chaos character Character Bible character development charcoal charles Charlie Dot Charlie Hebdo Children children's book illustration chocolate Christina Drejenstam christina forshay Christina K christinaforshay Christmas Cindy Derby circle circle dance city cityengine clock clones cloning cloth Cloud based clover CMYK Coco Chanel Cody and the Fountain of Happiness coffee collect collection Collections collision color color balance color cast color correction color mode color study colorful Commercial Use complexity component compositing composition computational thinking computer concept art Condensed Posts conference connect connect the dot connection Connie Lim Conrad Roset constrain constrast contagion content Contest contracts control converter copy copyright Corinna Luyken count Courtney Brims crack Craft craftsmanship Craig & Karl creative creativity creature cricket Cristina Garcia Martin critic criticism critique Crop Crop Tool cross section crowd csv cubism curve curve modifier custom Custom Blog Design Custom Blog Design Tutorial Custom Blog Designers Custom Illustration custom properties Custom Signature custom xml cut cutting plane cycle cycles dae Damien Florébert Cuypers Dan Hillier dance Daniel Egnéus Daniel Segrove Danny Roberts Daren Newman Dasha Tolstikova data data path David Blossom david diaz David Shrigley David Stone Martin Dean Hardscrabble Debbie debbie ohi debbieohi deform deformer degrees deleting background in pixler demo demoscene desaturation of images design design by numbers design process Design Tips dictionaries dictionary Different Text Writing in Pixlr digital digital paint Digital Scrapbook Freebies Digital Scrapbooking disk distance distractions distribute diversion DIY DIY Contest Dolf Veenvliet Doll Doll Bones dolls domino domino effect doodle Doodles door doraemon Doris Jackson Dorothia Rohner dots dpi draw drawing drill driven driver drivers dual versions dummy duplicate duplicates duplication dupliframe dvd dynamic dynamic paint dynamic text E Simms Campbell Easy easy pixlr Easy Tutorials Ed Graham Ed Vebell editing editing photos editors education effect effects ego Eleanor Dalton electric Elia Fernández eliza wheeler Elizabeth Mayville elizawheeler Emily Forgot Emma Zanelli emoticon happy-face Emotional storytelling empathetic characters empty entoforms envy epicycloid EPS Illustration Epson scanner erasers Erin Armstrong Erin Petson erinoshea ernest shepard Esra Roise euler evaluate line Eveline Tarunadjaja evenly spacing vertex event everywhere door exhibition Expandable Posts experiments explode exploded view export expression extrude eye eye color in pixlr eye trick eyeball face rig facial expressions facial setup factory Faiyaz Jafri Families fashion illustration fashion week fcurve feature Featured Fee Harding Feedback fence Fernanda Guedes fibonacci Fifi Lapin file File Types Finalists Finding Nemo fire fix photos Flash Tutorials flicker flip flip flop floor flop flow flower Flowers fnmatch focal point follow up font Fontaine Anderson Fonts food footage For Sale force form formula fractal fracture frame Frames Francois Berthoud Frank Bellamy Frank Furlong Franklin McMahon freckles Fred Steffen FrederiqueBertrand Free for Commercial Use Free for Personal Use Free Stock Photography Free transform tool Freebies Frenchillustration Fritz Siebel frosted mylar fruit ninja Fumi Mini Nakamura Fun function futurism FW2017 fx Gabriel Moreno Gabriella Ibarra game game animation gameart gamma gangnam style Garance Doré Gary Fernandéz gel medium generate generative generator geometric geometry Gerald Lazare Géraldine Georges GIF Gildo Medina Girl Giuseppe Castellano Giveaway glorar goals golden ratio google google docs Google Tools Grant Young graph graphite graphite transfer grease pencil grid group group node growth Gucci Guest Guil Godier gustave dore hair handbook Harper's Bazaar harpercollins Harvey Schmidt Haute Couture head Headers heat map Helena Hauss hexagon hexagonal grid Hiroshi Mizuno Hiroshi Tanabe Holiday Holly Black homology honeycomb hook horror houdini how to how to blur a face or an object in pixlr How to change eye color how to delete an object how to desaturate an image how to edit a image in pixlr how to erase an object how to fix red eye problem how to fix red eyes in pixlt How to fix the parts in pixlr in photoshop How to make a banner in pixlr How to overlap the nevus how to remove a object How to remove an object in pixlr how to remove red eyes How to Remove the Background of an Image in Pixlr How to remove the parts that you don't want in pixlr and photoshop how to replace color How to write a Patterned Text in Pixlr how-to Hsiao-Ron Cheng hsv hue humor Hyshil I love illustration magazine idea ideas Igor+André illusion illustrating illustration illustration board Illustration Books Illustration Intensive Illustration Now! Fashion illustration process Illustrations Illustrative Berlin illustrator Illustrator Intensive Illustrator Tutorials iloveillustration magazine image ediditing lessons Image Ready image sequences image theft imaginative import import text import vertex color improving photos inbetween index visualizer Info Ingrid Bockting ink inktober input Inspiration inspirational quotes install instance instance switching intensive interaction Intermediate Tutorials internet interoperability interpolation intersect intersect edges intersecting intersection interview introduction invoke subprogram io ipad Irana Doucer Isabella Hemmersbach islam islamic iteration Izzie Klingels Jack Hearne Jack Tremblay James Dignan James Gurney japanese Jason Brooks Jean Kim Jeanne Detallante Jen and Chris Creed Photography jen betton Jen Rofé Jenny Mörtsell Jeremy Combot Jeslyn Kate Jesse Auersalo Jessica Jessica Lanan jessicalanan jewellery jewelry jiggle Jim Schaeffing Joe Bowler Joe Cleary Joe Isom Joe Krush Johanna Goodman john maeda John Vernon Lord joint Jordan Sondler JPEG JPG jpop juana martinez-neal juanamartinezneal Judge Judit Garcia Talavera Judith van den Hoek Judy Byron Schachner Jules Julien Julian Beever Julie Verhoeven Jump Break Tool JW Anderson K-Fai Steele Kaethe Butcher Kareem Iliya karel zeman Kate van Harreveld Kathrin Kuhn Kathryn Ault Noble Kathryn Noble Katie Kath kdtree Kei Meguro Kelly Beeman Kelly Light Kelly Smith kelly sonnack Kelly Thompson keyframe keyframing kidlit kidlitartists kimberlygee Kirkus Review Kisoo Chai Kodak Konstantin Kakanias Korean illustration Kotaro Chiba Kozue Himi Kremos Ksenia Finogeeva KT Smail kuler Kustaa Saksi Lanan Laptop larry gritz lasso tool latte lattice Laura Callaghan Laura Laine Lauren Rille layer layering Layla Holzer layout leaf learning learning blender LED Leendert meets Ingrid lego length Leonard Starr lessons levels LFW A/W 14 liangzhu liero lightbox lighting lightning Lina Bodén Lina Ekstrand Linda Dorn line line connect line drawing lines Links Linky Love Linn Olofsdotter Lionel Gilbert Lisa Anchin Lisa Billvik Lisa Krannichfeld lisaanchin lisbeth zwerger Liselotte Watkins list list comprehension List First Last listing locator lofting logo Logo Design Lola Dupré London Fashion Week loop looping loops looptools Lorraine Fox lossless lossy lost weekend lostweekend lotte reininger Louis Glanzman louis vuitton Luciana Rondolini luciograph LULU* lv Lynnie Zulu Mac macgyver macouno maeda Magda Antoniuk magic Magnus Voll Mathiassen mailing mailings maker Makiko Sugawa making banners Malika Favre MAMP mandala manga map map range maplelam mapping Marcel George Maren Esdar Margot Macé Margot van Huijkelom Maribeth Olson Marie El-Ahmar Marilyn Conover Marina Esmeraldo Marine Marbleindex mario Marlies Niemeijer Marsha Riti Martha Rago Martin Krusche Martine Johanna mask masking material materials math matrix matrix apply matryoshka Matt Baker matte medium Matthew Woodson maya maze mdd Meagan Morrison measure megaman Megan Hess Meizhen Xu Mel Crawford memory mentee mentees mentors mentorship program Mercer Mayer Meridth McKean Gimbel mesh mesh cutter meshlab Meta Tags metal gear rising Meyoko Mia Overgaard Micca mice Michael Sanderson Michela Picchi middle grade midi miku Milan milipede minidom Minima Mio Matsumoto mirror cut Misc Miss Blackbirdy miss maple's seeds Miss Take Mitchell Hooks mixamo mixing Mobile Apps mocap mod model modeling modifier modular modulation modulus mold molecule molly idle Molly Ruttan Molly Ruttan Illustration money monitors monkey mono-zero monster monster university morph morpher mosaic mosquito motion motion capture motion capture mouse motion trail moto360 mountain muji Muriel Wood Murray Tinkelman mushroom Music and Podcasts My dead pony Nadia Flower Naiad Einsel Naja Conrad-Hansen Natalie Brockett Natalie Foss nathan vegdahl nautilus Nav Bar navigation needle-felting negotiating Neil Boyle neon nescbwi14 nested New Blogger Questions New Blogger Template Tutorials new user pixlr new year new york New York Fashion week Newbery nicholas nicholas bishop Nicholas Hong Niki Pilkington Niso Ramponi nla No Software node node-based nodebox noise non linear animation Non-Web Font normal Noumeda Carbone npr number NURBS NYFW object object color change object info octopus offset Ola Volo Olaf Hayek old formats opaque projector open movie open shading language open source openshadinglanguage opensoundcontrol optical organization origami original art show Ornaments osc Oscar Schlienger osipa osl outline outliner output Pages paint paint weight painting painting on illustration board painting on wood painting with movie painting with numbers Pair pandas panorama Paper paper lantern parabola parametric parent parenting particle particle info node particles pat david Pat Zietlow Miller pattern Patterned Text Paul Faassen Paul X. Johnson Paula Sanz Caballero PC pdb pebbles pencil Pencil Sketch pencils Penguin perfume perlin Peter Helck Photo CD.8B photo editing software Photo Reference Photobucket photographing art Photographs photography photomerge photoshop Photoshop Brushes Photoshop CS3 Photoshop elements photoshop pixlr desaturaion Photoshop tips Photoshop Tutorials Picture Book Builders picture books Pierre Louis Mascia Piet Paris Pietari Posti pingpong pinnochio pipes pixar pixel pixel art pixel generator pixlr Pixlr advanced Pixlr blog pixlr desaturate keep a colorful part pixlr editting pixlr express Pixlr forum Pixlr free transform Pixlr Lesson Pixlr lessons Pixlr mobile Pixlr resizing images pixlr shortcuts Pixlr tools pixlr tutorial pixlr tutorial with pictures Pixlr Tutorials pixlr white black pixlr.com plant plot plotting ply PNG PNG Illustration podcast point point color pointilism polka dots polyCut polygon Pomme Chan pop-overs portfolio Portfolio award portfolio showcase portfolio-advice portrait position Post Dividers postcard poster Posting pot powdered graphite powerhousemuseum Prada presentation print printmaking Prize procedular procedural process processing programming projection Promotion property prototype PSD psy publishing pulse puppet puppetry pydriver pydrivers pyhandler pyhandlers pyramide python quad quick select set quick tips qumarion Rabbit Moon Rachel Ryle radians radius ramp random random motion randomization randomize range float raspi Ray Houlihan reading reading XML READY-TO-WEAR realflow Rebecca Clarke rebecca dautremer Rebecka Skog rebuild recursive recursivedrawing red eye remove reducing glare reference referencing release remesh modifier remix removal remove remove red eyes remove unwanted objects Removing backgroung render rendering renderman repeat repeater repeating replace replacement replacing color representation rerouter resample resampling research Resizing image resolutions retopology retro review revolve rgb rib Ricardo Fumanal Richard Scarry rig rigging rigify Rikke Jorgensen ring ripple roadkill Robert Heindel Robert J. Lee Robert McCloskey Robert Shore Roberta Zeta Robin Rosenthal robot robotic rocks Rodolfo Montalvo Roller Coaster rotation Rousseau rsl Rubin Pfeffer ruler tool Russ Mills russian rut S/S14 S/S15 S/S16 Sabine Pieper sadako Saftey Pins Sainte Maria Sale Sam Weber Sanda Suy Sandy Kossin santoso Sara Andreasson Sara Singh Sarah Jacoby saturation artist tools scan scanners scanning scatter scbwi SCBWI 2015 mentee SCBWI conference scbwi germany SCBWI mentorship scbwi-la scratch scratchboards screensaver screw screw modifier script scrub sculpting seamless Seamless Patterns Search Engines select by material select by name select by type SEO sequence series set keyframe set keyframes shader shading shadow Shannon Stirnweis shape grammars shape key shapekeys shapes shards shatter Sheilah Beckett shell ship shipping shipwright Shoes SHOWstudio shuffle Sid Barron Sidebar Titles Signature Silja Goetz silkworm Simon and Schuster Simon Varela simple simplicity simulation sine Site Engine Optimization Sjoukje Bierma sketch Sketches sketching skin skin modifier skinning slice slicing slides sloth slow parent smoke smoothstep SN snake Sneek Peek snippet Snow Snow White Snowflakes soccerball social media Social Media Buttons Social Networking society of illustrators Society6 soft body softbody Sonia Menti sound sound wave space spaceship sparta special spider spiderman spiderweb spin spiral Spiros Halaris Spiros Halaris x Urban Decay spline Spot Healing Tool spreadsheet SS16 stack stacking stair stamp Stan Galli star starfish stencyl step Steven G. Dobson still Stina Persson stone stones storytelling strand strand info strands street art string stripes structure studies studio style stylistic summary Summary Posts Summer sun supplies surface Susan Farrington suzanne Suzanne Kaufman sverchok swatch switch sydney system table table of contents take out background Tal Drori tangent tangled Taschen teaching teapot Template Templates tentacle Tess Jacobson Tex Avery text text editor Text Formats Text Styles in Pixlr texture texturing The Cartorialist The Grudge Keeper The Purple Book thinker1 Thomas B. Sawyer thread TIFF tile tilecam tiling time time code Tina Berning Tina Kugler tips tips for artists Toby Neilan Tom Baxter Tom Bjarnason tombow tomie depaola tool tools topology tower Tracy Turnbull Train transfer drawing transferring sketch transform transformation transit travel triangle wave Tricia Springstubb trigger tris tristan lock tube tubes Tutorials twitter type tool typeface typography unbake unity3d universal unquad utah uv valentine Valentino Valerie Servais vanilla variable variation variety vase vector vectorized Velwyn Yossy venus Veronica Ballart Lilja vertex vertex color vertex group vertex paint vertex weight VFX Victoria Boysen video Videos viewer Vintage virtual virtual studio visualization vivid vividfestival VOGUE volumetric voronoi Vote voxel voxelated voxelation walking teapot Walter Einsel wand tool water soluble graphite watercolor wav wave we need diverse books web webbing Week Themes weight welcome Wendy magazine Wendy Plovmand what casues red eyes What is Pixlr Wherever You Go Wide Awake Bear wiggle Will Davies Winner Winnie Fitch Winnie Truong Winter wire wired wireframe wolfram Woman wood woodwork wool wooly wordpress work workflow World writing writing XML www.pixlr.com XML YA yayoi kusama Yelena Bryksenkova yoda Yoko Furusho Yuliya zaha hadid zen zsphere

PYTHON AND ANIMATION PIPELINE


You can skip all my rambles to the actual topic by direcly go to (*) below.

Few days ago, I was watching this 2 hours video regarding "Python and CG Pipeline. There is one part about ANIMATION that I am interested in: A mention of MDD Cache for animation transfer between softwares.

You can watch the video here: (original video is in Russian by Russian TD, then translated by another Technical Director)
https://vimeo.com/88080700

Basically this Technical Director (TD) was giving an example scenario where Python might be useful to pass on DATA between softwares, like in this case from Maya to Houdini (it can be IN and OUT from and into Blender too of course).

FBX format is apparently (still) not perfect for exporting and importing. Houdini FBX Import from Maya does not guarantee a fully compatible correctly read data. This is a common situation in any production, the format conversion is often not perfect out of the box. Using Python, the TD wrote this "translator" that export out MESH data as BGEO format (Houdini native, more robust than the basic OBJ) and the ANIMATION data as MDD Cache.

I remember that Blender has a pretty good MDD tool built in, and it is part of Blender's Modifier. Cool, let's talk how this later relate to the AN business.

ROUGH PIPELINE SUMMARY

I will try to explain a bit of summary about "CG Pipeline":
In CG Production, there will always be a stage where everything is "baked" prepared for (Final) Rendering. Asset and Rig are baked, Camera animation is baked, Shader is baked, Character animation is baked, VFX is baked, and so on.

BAKED DATA can be "final", but does not always mean final, meaning that artist can always go back and make edit, just in case there is an issue.

However having this BAKING STEP implementation allows for CHECKPOINT and VERSIONING before re-assembly. Definitely allows for flexibility for a lot of situations.

BAKING can sometimes expensive, especially for VFX simulations.

Ideally, the whole production is made inside "just one" software/tool that does every stage of production smoothly. For example, Blender is one tool with a complete and robust tools. Including compositing.

In typical film or game productions, many artists may use different tools:
- MODELING: ZBrush, Mudbox, Sculptris, Blender
- RIGGING: Maya, Houdini, Softimage
- ANIMATION: Maya, Houdini, Softimage
- VFX: Houdini, Maya, Softimage
- RENDERING: Arnold, Renderman, VRay, Octane
- COMPOSITING: Nuke, After Effects
- VIDEO EDITING: Premiere

Blender, I believe, WILL eventually fit every stages to help artists. If not already.

What really important is usually the way we "BAKE" animation or "TRANSFER" data between tools, along the pipeline, to ensure smooth process.

Remember this:
For any "procedural" workflow, at some point we need to bake.

WATCH OUT:
Although baking of animation is nice, sometimes this is also not always possible. Sometimes Anim Curves need to be retained and re-applied to the RIG ASSET.

I believe current convention in CG industry is to use Alembic for baking mesh data. Sometimes we actually need to bake the Animation Curves into generic data that can be passed on between softwares. All this needs to be taken into consideration.

In the past, I have experienced in using Maya and Houdini as ASSEMBLY tools. Blender actually has this potential to be the assembly tools because of its open source and always available to use in any system.

But well, it's all back to the Studio Production Pipeline.

MDD CACHE FOR BAKING ANIMATION

MDD Cache, although old and may does not seem much, has a lot of potential and advantages. It is really simple to use too.


ALEMBIC is probably the next thing to look at, once Blender implemented it (!)

Anyways, MDD Cache allows DEFORMING MESH ANIMATION to be baked fully. By doing this, we are no longer dealing with hundred of animation curves (f-curvds) which is good!

NOTE:
One note, althouth mesh caching is great for film animation, maybe not for Game Animation that requires joint, but there is always a way to "reverse engineer" MESH ANIMATION to JOINT ANIMATION.

ANIMATION NODES TO CONTROL MDD ANIMATION (*)

Ok, FINALLY ....
we got to cover the actual topic on using Animation Nodes toolset for MDD Animation.

Above, I am trying to give us a background scenario of typical MDD usage to bake animation in pipeline. Beyond that, MDD can be used to create complex animation. For examples, maybe we want to:
- Generate multiple VARIATIONS of animations
- Create OFFSET ANIMATIONS for same rig
- Have easier control over thousands of rigs (simple crowd system)

What I really want to cover here is one way we can think procedurally using nodes to offset animations :-)

Simple right? Well, apparently not that simple.

Although we already have "F-Curve Animation Offset" AN Template, that can help offset animation curves, but I believe it works only for a single object transformation, and that its function is simply to offset animation to INSTANCES (duplicate) of same object.

What if we have a rig with many controls? Do we need to deal with bunch of controls and f-curves and then re-apply it back into rig? Although this is probably possible, I think it's really too complicated for now.

That is why I am looking at MDD Cache for now.

Caching/baking animation really simplifies a lot of animation complexity. By baking, we don't have to deal with hundreds if not thousands of Animation Controls and Animation Curves and Attributes.


BLENDER ACTION BLOCKS AND NLA (Non Linear Animation)
Blender has this function built in to turn animation curves into block of animations, and we can sort of arrange and edit animation like NLE Editor.

It might be handy for certain scenario but I honestly have very little experience with Blender NLE, animation block layering, etc. I think it can do what we are trying to do (offseting animation) using block of Animation Actions, but we will take it a little further and tackle the problem procedurally using animation nodes.

I am definitely more familiar with MANUAL ANIMATION and PROCEDURAL ANIMATION, and SEMI-PROCEDURAL ANIMATION is really my desire to achieve using Blender and Animation Nodes. It needs to be simple enough concept that animators can learn in technical level.

LET'S BEGIN...

We will use a simple rig to explain this concept. By understanding this example, you will learn further about LOOP and data GENERATOR of AN.

1 Rig and Multiple Controls
You can use your own rig. Or download from Blend Swap. But basically you need a deforming mesh that you can export animation as MDD.





2 Export out MDD
Activate MDD exporter from the User Preferences. Maybe it should always be ON by default, because Blender's MDD reader is always part of Blender Modifier feature. Anyway, "Save User Settings" if you like.

Then, you select the mesh that is deforming and then export the animation as MDD.




3 Use the MDD Cache
Once you have the MDD, all you need is the "original mesh" duplicate or imported into the 3D scene, and apply Mesh Cache Modifier, read the MDD cache from disk, and to apply it to the mesh. Then you get the animation back.

The mesh needs to be identical to the mesh used for rigging and animation in term of vertex order. We will be using AN to "drive" the "Evaluation Frame", so I set it to "Custom".



WEIRD BUG:
Sometimes after you save the Blend file, and re-opening, the path into the MDD might change, for example:

Correct:
//../MDD_TEST/simple_single_surface_rig_001.mdd

Wrong: (when opened back, was working...)
//MDD_TEST/simple_single_surface_rig_001.mdd

Make sure you put the //../ dot dot.

4 Offseting MDD Cache using AN Node
This part is pretty straight forward and simple. You just need "Object Attribute Output" node that can directly drive any attribute of an object.


The DATA PATH here is: modifiers["Mesh Cache"].eval_frame.

At this stage, note that we can actually have MULTIPLE caches, different kind of objects ANIMATION. Later on below, when things get serious, you will see how we can orchestrate many objects using AN node LOOP.


5 Using Loop Node
Now, this is the FUN part.

If we were to manually connect nodes for multiple object with MDD Cache, and create offset, we might have something like below:


Above is not wrong, in many software packages (such as Maya), this is actually what is happening under the hood. It's pretty crap, however easy to connect nodes to create offset using script, user will still end up with web crap of noodles and nodes. What if we have hundreds of objects? It will be a pain to connect.

You could write Python that randomize the "Object Attribute Output" node's attribute ("Delay" attribute, in this case), but still that is not efficient.

AN actually has a nice looping system that is pretty robust, yet pretty simple to understand.

How do reduce the connections above into a nice system? First, I look at which ATTRIBUTE that will have MULTIPLE values applied FOR EACH. In the way, AN Loop is similar to Houdini's "For Each" node conceptually.

Above we can see:
- DELAY: will have different values per object. How many? As many as user wanted.
- OBJECT: will have different input, whether the user supplied objects via "Group" node, or

So, I was first experimenting with generating the random values, this will be LIST of random values we can plug into DELAY attribute. It's a floating values.


LOOP in AN will do either of below:
- To "do something" for each LIST of input
- Generating LIST with certain number of iteration

6 Loop that generates LIST of OFFSET values

Above, you see, those network in light maroon color, is responsible to generate LIST of values for our OFFSET DELAY attribute.

7 Loop that take LIST of OFFSET and apply to MANY OBJECTS with MDD


I am plugging in the OUTPUT into another LOOP. The setup will then magically takes the generated offset value, and loop iterate it for X many objects we supply via "Group".

Don't you think it's such a revelations?


At this stage, you should already see things happening. You could Blender duplicates the mesh + mdd mesh cache modifier, and each one of this object will be controlled by our setup, each being offset slightly in random fashion.

This is a rather complex setup. Well, still a "simple" basic procedural magic example. But creating this any other way probably will not be as elegant.

HEY, CAN'T ONE JUST USE PYTHON?

SURELY, you can always make Python script that generate random values and apply it ONCE OFF to randomize the offset, and then create driver expressions that drive each "Evaluation Frame" of MDD objects so that we are getting the same effect.

However, this is one ideal situation when we set everything nicely, we have full control over the whole things. And more over, you could expand from this and make all kind of tweak and variations.

I WANT MORE...
The setup can be more elegant and reusable if we maybe create an AN GROUP CONTAINER for our node. AN prodives this way of organization to reduce clutter of node noodles.

You might want to check AN Subprograms "Group". It's like a way to nodify node network and reduce it into a CUSTOM NODE container that takes INPUT(S) and spit out OUTPUT(S).

If you check some of the AN Templates, you will see this "Group" custom node is used quite often. At first, this might feel like an extra unnecessary step, but when our network grows over 100 nodes or perhaps we often use a certain node setup, this will become very helpful.

Maybe I cover that in next article.

Good luck!










Doreamon's Everywhere Doors Puzzle.

Few posts ago, I wrote a very long article about Array Drivers and Python. There are plenty of information in there and you probably will not get everything at once. Trust me, one day you will need some of those information when it comes to Drivers.

Anyway, I think it is best if we put the knowledge into practice.

WHAT WE KNOW ABOUT BLENDER DRIVERS

Blender Drivers are very useful for animation. We can setup all kinds of Drivers relationship to control almost anything that can be animated. Remember what I stated earlier: "Any keyable property can be driven".

Drivers can reduce multiple animation control into a single control.

Why do we use Drivers instead of directly adding Animation Curve or NLA Action Block? Because often we need to have some kind of additional layer of control (ideally automated) on top of MANUAL animation or animation that is ACTION based.

With Drivers in Blender, we also have potential ability to procedurally orchestrate our animation using Dynamic Paint.

Drivers is often closely related to Character Rigging / Animation Setup and that is probably the next area I would like to explore in near future.

DOMINO EFFECT = ONE-TO-MANY Driver Relationship with OFFSET
In Computer Graphics, Domino Effect Animation is probably one exercise that one will encounter. You can tackle this animation problem with all kind of ways:
1. Physic Simulation.
2. Expression Driven Animation (procedural).
3. Action Driven / NLA
4. Manual Animation (hopefully this is only the last resort).

At the moment, I happened to be enrolled in this "Houdini Intro to VFX" 8 weeks workshop with Spencer Lueders and so far I gained a bit of understanding or "proceduralism" here and there.
http://workshops.cgsociety.org/instructor.php?userid=37720

There is one class where Spencer does the Domino Effect using Houdini Expression. The advantage being Houdini is that everything can almost be 100% procedural, from the setup of Domino until final Domino animation using powerful Houdini expressions. Here, I am adapting Spencer's trick inside Blender using DRIVERS.

Just like when we do NLA animation using Python, Driving ONE-TO-MANY objects using a single control is always more interesting if we do slight OFFSET for each drive object.

NOTE:
Domino Effect is not necessary need to be DOMINO. It is basically an effect where we have one object doing something that trigger another object doing similar thing, then continue to the next object, and so on.

1. PREPARE YOUR DOMINO (Semi Procedural way)

We have discussed a way to nicely place objects along curve.
http://blendersushi.blogspot.com.au/2013/03/trick-position-along-curve-and-rebuild.html

IMPORTANT: Always watch the NAMING of array of objects.

We want to be able to quickly select objects IN ORDER. This is really important to ensure that we avoid SORTING PROBLEM and create proper matching Drivers relationship. We don't want to create wrong relationship pair, don't we?

#### QUICK SELECT BY NAME, NOW MORE PYTHONIC
import bpy

# Get all objects named "NAME*" and put it in a list
mesh = bpy.data.objects
sel = [item for item in mesh if "NAME" in item.name]

for item in sel:
    item.select = True

Below is one trick if you want to quickly rename objects with naming convention: {objectname}.{digit} for example: Sushi.000, Sushi.001, Sushi.002, Sushi.003, Sushi.004 and so on.

### QUICK RENAME HACK, NOW MORE PYTHONIC
import bpy

# Get all objects named "NAME*" and put it in a list
mesh = bpy.data.objects
sel = [item for item in mesh if "NAME" in item.name]


for item in sel:
    item.name = "newname.000"

In addition, below is a useful Python script to check the sorting of object in list.

#### RETURN INDEX NUMBER OF OBJECT BASED ON SPECIFIC NAME
bpy.data.objects.find("Cube")


### EXAMPLE LOOP TO CHECK INDEX ORDER MAYBE USEFUL FOR SORTING

import bpy

mesh = bpy.data.objects

myList = [item for item in mesh if "Cube" in item.name]

for x in myList:
    print(x.name, mesh.find(x.name))

2. DOMINO PROCEDURAL ANIMATION SETUP

Before I gave you one long example script that does the setup the Domino Procedural Animation automatically, I want to make sure you understand the concept first.

THE BASIC:
  • We want to DRIVE the rotation axis of Domino "Rotation Euler" using DRIVER value.
  • The rotation in Blender Drivers is in Radian (we need math.pi)
  • We need to also specify the MIN and MAX value. Why? Because when we setup the DRIVERS, we do not want the domino to continuously rotating given the input value.  
DRIVEN = Rotation Euler in X/Y/Z axis. Depending on your Domino object.
DRIVER = Current Frame or other value, maybe we can use an Empty Location value.

The Driver value can be the Current Frame, but can also be ANY VALUE we pipe in as INPUT.

DRIVERS MIN & MAX LIMIT, The Python Way

In Houdini, there is a handy expression that can map values based on MIN and MAX.
fit(INPUT VALUE, old min, old max, new min, new max)
fit01(INPUT VALUE BETWEEN ZERO AND ONE, min, max)

In Blender, we can actually create our own Min and Max Expression and assign it as PyDrivers.

However, we can also use Driver Animation F-Curve which we can draw manually to specify the MIN and MAX. To draw manually each time is a hassle, so we use Python script like below.

Example Driver Setup Using Python - WITHOUT MIN & MAX LIMIT:
# Select at least an object and run script below:

import bpy
import math

ob = bpy.context.object

# add driver to Rotation Y axis
myDriver = ob.driver_add('rotation_euler', 1)


# assign driver type
myDriver.driver.type = 'SCRIPTED'
myDriver.driver.show_debug_info = True
myDriver.driver.expression = 'frame * 0.1'


Example Driver Setup Using Python - WITH MIN & MAX LIMIT:
# Select at least an object and run script below:

import bpy
import math

ob = bpy.context.object

# add driver to Rotation Y axis
myDriver = ob.driver_add('rotation_euler', 1)

# remove the default fcurve modifier 'GENERATOR'
fcurvetype = ob.animation_data.drivers[0].modifiers[0]
ob.animation_data.drivers[0].modifiers.remove(fcurvetype)

# add keyframes manually --- this is MIN and MAX
ob.animation_data.drivers[0].keyframe_points.insert(0, 0)
ob.animation_data.drivers[0].keyframe_points.insert(1, 2 * math.pi)

# assign driver type
myDriver.driver.type = 'SCRIPTED'
myDriver.driver.show_debug_info = True
myDriver.driver.expression = 'frame * 0.1'

You see that with MIN & MAX Limit, the object will rotate from 0 degree to 360 degree and stop. While the one without specified MIN & MAX will continue to rotate.



BLENDER SUSHI SCRIPT: Domino Effect based on TIME (Current Frame)

import bpy
import math

# http://blenderartists.org/forum/showthread.php?278678-copy-paste-a-f-curve-driver

# Get all objects named "Cube.*" and put it in a list
mesh = bpy.data.objects
sel = [item for item in mesh if "Cube." in item.name]


# Starting OFFSET value
offset = 10

for ob in sel:
    
    myDriver = ob.driver_add('rotation_euler', 1)

    # remove the default fcurve modifier 'GENERATOR'
    fcurvetype = ob.animation_data.drivers[0].modifiers[0]
    ob.animation_data.drivers[0].modifiers.remove(fcurvetype)
    
    # add keyframes manually
    ob.animation_data.drivers[0].keyframe_points.insert(0 + offset, 0)
    ob.animation_data.drivers[0].keyframe_points.insert(1 + offset, -0.36 * math.pi)
    
    offset += 1
    
    # assign driver type
    myDriver.driver.type = 'SCRIPTED'
    myDriver.driver.show_debug_info = True
    myDriver.driver.expression = 'frame * 0.1'




 

Once you created the setup, you can easily modify and tweak the setup using the code with a slight modification, for example like below, I commented the code above that we really don't need. We will not create new variable or modifier, just modify existing elements.

import bpy
import math

# Get all objects named "Cube.*" and put it in a list
mesh = bpy.data.objects
sel = [item for item in mesh if "Cube." in item.name]


# Starting OFFSET value
offset = 1

for ob in sel:
    
    #myDriver = ob.driver_add('rotation_euler', 1)

    # remove the default fcurve modifier 'GENERATOR'
    #fcurvetype = ob.animation_data.drivers[0].modifiers[0]
    #ob.animation_data.drivers[0].modifiers.remove(fcurvetype)
    
    # add keyframes manually
    #ob.animation_data.drivers[0].keyframe_points.insert(0 + offset, 0)
    #ob.animation_data.drivers[0].keyframe_points.insert(1 + offset, -0.36 * math.pi)
    
    ob.animation_data.drivers[0].keyframe_points[0].co = 0+offset, 0
    ob.animation_data.drivers[0].keyframe_points[1].co = 5 + offset, -1 * math.pi
    
    ob.animation_data.drivers[0].keyframe_points[0].interpolation = "LINEAR"    
    ob.animation_data.drivers[0].keyframe_points[1].interpolation = "LINEAR"
    
    offset += 1
    
    # assign driver type
    ob.animation_data.drivers[0].driver.type = 'SCRIPTED'
    ob.animation_data.drivers[0].driver.show_debug_info = True
    ob.animation_data.drivers[0].driver.expression = 'frame * 0.2'

 Of course, what would be nice is actually to create FUNCTION and maybe USER INTERFACE (UI) that does all above for easy modification.

F-CURVES ANIMATION & DRIVERS ANIMATION

What also interesting is the not so distance sibling relationship between the normal F-Curve keyframe animation and the F-Curve of Drivers.

We could actually GET the list of keyframes from normal F-Curve and then SET it to Drivers quite easily using Python. This means that we can animate an object like normal where TIME is the only INPUT, and then use the Animation Curve as Drivers F-Curve.

Getting the coordinates of normal keyframe animation points will be like below:

>>> bpy.context.object.animation_data.action.fcurves[0].keyframe_points[0].co
Vector((24.0, 6.7004075050354))

>>> bpy.context.object.animation_data.action.fcurves[0].keyframe_points[1].co
Vector((49.0, 9.362730979919434))

>>> bpy.context.object.animation_data.action.fcurves[0].keyframe_points[2].co
Vector((73.0, 5.008456707000732))


This is certainly something to explore in our own time.


BLENDER SUSHI SCRIPT: Domino Effect based on Empty Location 

import bpy
import math

# Get all objects named "Cube.*" and put it in a list
mesh = bpy.data.objects
sel = [item for item in mesh if "Cube." in item.name]

offset = 0

for ob in sel:
    
    myDriver = ob.driver_add('rotation_euler', 1)

    # remove the default fcurve modifier 'GENERATOR'
    fcurvetype = ob.animation_data.drivers[0].modifiers[0]
    ob.animation_data.drivers[0].modifiers.remove(fcurvetype)
    
    # add keyframes manually
    ob.animation_data.drivers[0].keyframe_points.insert(0 + offset, 0)
    ob.animation_data.drivers[0].keyframe_points.insert(1 + offset, -0.36 * math.pi)
    
    offset += 1
    
    # assign driver type
    myDriver.driver.type = 'AVERAGE'
    myDriver.driver.show_debug_info = True

    # DRIVER VARIABLE
    
    # create new variable
    newVar = myDriver.driver.variables.new()
    
    # set new variable attributes
    newVar.name = "var"
    newVar.type = 'TRANSFORMS'
    newVar.targets[0].id = bpy.data.objects['Empty']
    newVar.targets[0].transform_type = 'LOC_X'
    newVar.targets[0].transform_space = 'WORLD_SPACE'
    


A MORE ADVANCE EXAMPLE:
Array of Doraemon's Everywhere Doors!


Here we have another example case of "Domino Effect" that is using Linked Grouped Objects which happened to be duplicated along Curve Path. This is trickier than you may think.

When bringing LINKED GROUP object to be duplicated and driven we need plan thing properly...

0. Give proper clear naming system.

1. Linked object actually comes as EMPTY + Dupli "Group"

2. When we do Dupli Frame using Curve Path, it will only duplicate the EMPTY, we need to tell Blender to do Dupli "Group"

3. Do "Make Duplicate Real" to make the actual Dupli "Group" real.. However, the Data is still shared
# this handy ops command will make DUPLI real but have to do it in order! sometimes I stay away from bpy.ops when scripting, but in this case, this is the easiest.
bpy.ops.object.duplicates_make_real(use_base_parent=False, use_hierarchy=False)

4. Tap L to Make Local - "Object, Data, Material". This to ensure Blender did not crash when we do the next step.

5. Finally do "Make Single User" to all the Dupli "Group".

6. If all good and naming system works for every animated object, we can simply run the Driver script. Careful with naming so that ANIMATION ARRAY DRIVEN IS OFFSET nicely.

WHEN ARRAY SORTING IS AN ISSUE... DYNAMIC PAINT COMES TO THE RESCUE!

Sometimes it can be really difficult to keep all the array objects sorted. In such case, we can setup Drivers that does not rely on the order but still controllable. We need DYNAMIC PAINT Driver Setup. It is quite simple as I have explained it below. We simply just have some kind of trigger mechanism based on Distance.

A more complex setup probably involving a better trigger mechanism and NLA Action Editor. Because we don't always want to map "Animation Sequence" directly to the "normalized Distance". This is still a concept, but really, I think maybe in Blender 3.0, when BGE becoming more like Interactive mode, all this will be easier, I reckoned.

A. PREPARE OUR ARRAY OBJECT
1. Pre-created Objects, each with variation + similar attribute to drive
2. Create or duplicate object on EVERY POINT OF ARRAY as needed


B. SET EMPTY STATE A AND B - Parent to Cloud
Run the automatic "Parent to Vertex" by Liero to create State A and State B of array.

It will be nice to convert each as Empty, instead of duplication of object.

# CREATE EMPTY ON EVERY OBJECT
import bpy

sel = bpy.context.selected_objects

for ob in sel:
    
    bpy.context.scene.objects.active = ob
    
    # get ob digit    
    digit = ob.name.split('.')[-1]
    
    newname = "emptyB"
    
    # get location
    loc = ob.location
    wmtx = ob.matrix_world
    
    # create locator
    bpy.ops.object.empty_add(type='PLAIN_AXES', view_align=False, location=loc)
    
    # while still active, rename locator
    selectedObject = bpy.context.selected_objects
    selectedObject[0].scale = 0.25,0.25,0.25
    selectedObject[0].name = "{newname}.{digit}".format(newname=newname, digit=digit)
    

C. SET DRIVER
Create Driver setup for each object that keep track of DISTANCE between State A and State B

import bpy

# Assign driver to every selected object
# of particular channel

sel = bpy.context.selected_objects


for ob in sel:
    digit = ob.name.split('.')[-1]
    
    bpy.context.scene.objects.active = ob
    
    # single driver for scale X
    myShapekey = ob.data.shape_keys.key_blocks['Key 1']
    myDriver = myShapekey.driver_add('value')
    
    # by default should be 'SCRIPTED', but in case you want to change 
    # the driver type, you have other option
    # ('AVERAGE', 'SUM', 'SCRIPTED', 'MIN', 'MAX')
    myDriver.driver.type = 'AVERAGE'
    
    
    # enable Debug Info
    myDriver.driver.show_debug_info = True
    
    
    # DRIVER VARIABLE
    
    # create new variable
    newVar = myDriver.driver.variables.new()
    
    # variable name
    newVar.name = "distance"
    
    # variable type
    
    # PLEASE PICK ONE
    #newVar.type = 'TRANSFORMS'
    #newVar.type = 'ROTATION_DIFF'
    #newVar.type = 'LOC_DIFF'
    #newVar.type = 'SINGLE_PROP'
    
    newVar.type = 'LOC_DIFF'
    newVar.targets[0].id = bpy.data.objects['EmptyA.{digit}'.format(digit=digit)]
    newVar.targets[0].data_path = 'location.z'
    newVar.targets[0].transform_type = 'LOC_Z'
    newVar.targets[0].transform_space = 'WORLD_SPACE'
    newVar.targets[1].id = bpy.data.objects['EmptyB.{digit}'.format(digit=digit)]
    newVar.targets[1].data_path = 'location.z'
    newVar.targets[1].transform_type = 'LOC_Z'
    newVar.targets[1].transform_space = 'WORLD_SPACE'


D. DO DYNAMIC PAINT
Set Canvas and Brush.

The Canvas will be one of the Empty that is parented to Point Cloud, it will be driven by Displace Modifier, which is affected by Texture and finally Dynamic Paint.

OTHER SCRIPTS SNIPPET THAT MIGHT BE USEFUL FOR YOU

SCRIPT: Create Empty On Every Vertex of Mesh

import bpy

# for every point, create Empty and do vertex parent

# FIRST ATTEMPT
#ob = bpy.context.object
#verts = ob.data.vertices

#for num, vert in enumerate(verts):
#    print(vert.co)

# Set active scene and object
activeScene = bpy.context.scene
currentObjs = bpy.context.selected_objects

for item in currentObjs:

    print(item.name)
    if item.type == 'MESH':
        # Make meshdata
        # this is important!
        # we create a fake object for Blender (Apply Mesh Location)
        meshdata = item.to_mesh( scene=activeScene, apply_modifiers=True, settings='PREVIEW' )

        vert_list = [vertex.co for vertex in meshdata.vertices]
        for vert in vert_list:
            vert = item.matrix_world * vert # this is important!

            # Create Empty At Vertex Location
            bpy.ops.object.empty_add(type='PLAIN_AXES', location=vert)
            
            # Rename every Empty right after being created
            selectedObject = bpy.context.selected_objects
            selectedObject[0].name = "emptyB.000"
            

        # Remove meshdata data
        bpy.data.meshes.remove(meshdata)

# there will be some array of EmptyOrig (PARENTED TO VERTEX) and EmptyDisplaced

# do vertex parenting

# each will have attribute driver that measure the Distance between

# let the value drive other attribute as needed


SCRIPT: Create Cube On Every Vertex of Selected Meshes

import bpy

# Set active scene and object
activeScene = bpy.context.scene
currentObjs = bpy.context.selected_objects

for item in currentObjs:

    print(item.name)
    if item.type == 'MESH':
        # Make meshdata
        # this is important!
        # we create a fake object for Blender (Apply Mesh Location)
        meshdata = item.to_mesh( scene=activeScene, apply_modifiers=True, settings='PREVIEW' )

        vert_list = [vertex.co for vertex in meshdata.vertices]
        for vert in vert_list:
            vert = item.matrix_world * vert # this is important!
            print(vert)

            # Create Boxes At Vertex Location
            bpy.ops.mesh.primitive_cube_add(location=vert)
            selectedObject = bpy.context.selected_objects
            selectedObject[0].name = 'jimmy.000'            
            selectedObject[0].scale = 0.1,0.1,0.1


        # Remove meshdata data
        bpy.data.meshes.remove(meshdata)


SCRIPT: Set Drivers for Material

# http://www.blenderartist.org/forum/showthread.php?287330-Adding-driver-to-pose-bone-constraint-through-Python

import bpy


# select bunch of objects to drive
# each object has naming convention with number
# need to be sorted
# DRIVER and connection will be added based on number

# get the number string
# blah.split('.')[-1]

# we do not care the name 
# (assume the name of object is the same): cube.001, cube.002


def driveManyToMany(num='000'):
    
    # DRIVING THE SCALE XYZ OF ONE OBJECT USING OTHER 
    
    # ADDING DRIVER VIA SCRIPTING
    
    # add driver for location X of currently active selected object
    # locXDriver = bpy.context.object.driver_add('location', 0)
    
    myDriver = bpy.context.object.active_material.driver_add('diffuse_intensity')
    
    # by default should be 'SCRIPTED', but in case you want to change 
    # the driver type
    
    # ('AVERAGE', 'SUM', 'SCRIPTED', 'MIN', 'MAX')
    
    myDriver.driver.type = 'AVERAGE'
    ####myDriver.driver.type = 'SCRIPTED'
    
    # enable Debug Info
    myDriver.driver.show_debug_info = True
    
    # scripted expression
    ####myDriver.driver.expression = 'var'
    
    #bpy.context.object.animation_data.drivers[0].driver.expression = '#jimmy'
    
    # DRIVER VARIABLE
    
    # create new variable NUMBER 1
    newVar = myDriver.driver.variables.new()
    
    # variable name
    newVar.name = "varA"
    
    # variable type
    
    # PLEASE PICK ONE
    #newVar.type = 'SINGLE_PROP'
    #newVar.type = 'TRANSFORMS'
    #newVar.type = 'ROTATION_DIFF'
    #newVar.type = 'LOC_DIFF'
    
    newVar.type = 'LOC_DIFF'
    newVar.targets[0].id = bpy.data.objects['emptyA.{num}'.format(num=num)]
    newVar.targets[0].data_path = 'location.z'
    newVar.targets[0].transform_type = 'LOC_Z'
    newVar.targets[0].transform_space = 'WORLD_SPACE'
    newVar.targets[1].id = bpy.data.objects['emptyB.{num}'.format(num=num)]
    newVar.targets[1].data_path = 'location.z'
    newVar.targets[1].transform_type = 'LOC_Z'
    newVar.targets[1].transform_space = 'WORLD_SPACE'
    

objs = bpy.context.selected_objects

for obj in objs:
    
    bpy.context.scene.objects.active = obj

    # get that string number thing of currently active object
    myNum = obj.name.split('.')[-1]

    driveManyToMany(num=myNum)

CONCLUSION

What started as simple Driver setup now become slightly complex. I have done hundred of trials and errors for every procedural script. With great power really comes great responsibility.

What to do next is probably to create a nice UI or some kind of easy ways to modify the setup.

I found that the most stressful part when coding Blender Python is to convert bpy.ops into proper bpy.data flow. Sometimes documentation is next to nothing, however in recent version if you look through the methods or functions attached to certain functions, it will give you nice description. What would be nice is some examples.

Anyways, after sometimes, digging functions and data becoming a little bit more fun.

SOME MORE INTERESTING DRIVER RELATED PYTHON PROCEDURAL ANIMATION

http://funkboxing.com/wordpress/?p=236

ALL POTENTIALLY RELATED LINKS


In this article, I am sharing my research and notes on Blender NLA (Non Linear Animation) and write on how we could also use Python to orchestrate the animation of MANY objects in context of NLA.

NOTE: It comes to my own surprise that I only found out about the POWER of Blender NLA just recently.

NLA INTRO

I would start by reading these:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Animation/Editors/NLA
http://aligorith.blogspot.com.au/2010/10/clarifying-animation-workflow-in.html

In short, I am seeing NLA as a way to non-linearly edit normal Animation(s) keyframes into a Strip of Action(s) just like any non-linear editor. A single Action animation can be offset, sliced, blended in time.

NLA workflow is great for Game Animation where one may reuse animations (Idle, Walk, Run) or to specifically trigger an Action Animation based on Event.

On top of that, I believe NLA is also useful for LOOPING kind of animation, usually for musical score that has beats and loops. Not only that, NLA has tremendous potential to create a lot of interesting "wave motion" animation effects.

Keep in mind that NLA is NOT complex NOR super technical, in fact I think Blender NLA is pretty intuitive and very simple to use.

I have not looked at NLA thoroughly, but I believe there are few different NLA types:
  • NLA for normal object transformation
  • NLA for Armature
  • NLA for Materials
  • etc
I am not yet 100% understand how NLA data block works in relation to each other, but I will touch on the basic first. For example, I am wondering whether it is possible to "drive" Material animation using Actions of Transform, apparently cannot. I am guessing we need Blender Drivers for that.


NLA BASIC

Let's do a little experiment.

1. MANUAL ANIMATION
Create a simple animation of a block going from position A to position B. Maybe just an animation of a Cube going from original position and go up few units in Z axis.
  • Single keyframe Position of Cube in Z axis at frame 1.
  • Move the frame in timeline, lift up the Cube in Z axis, and keyframe at frame 20.
2. SWITCH TO NLA EDITOR
Next, we like to switch panel to NLA Editor. I usually do this inside Blender Animation layout. But feel free to modify your current layout so you can get to NLA Editor panel.


3. NLA EDITOR
Now, we are ready to turn the animation into Strip. You simple click on tiny Snowflake button to freeze the animation and work in NLA kind of way.


By doing the freeze, we now get Strip named "CubeAction". NLA Track is also automatically created.


4. EDIT THE ACTION STRIP
To Edit the action like normal, we can apparently do that quickly by hitting TAB while selecting the Action Strip:

We hit TAB again to go out from the Action Edit Mode.

5. APPLY ACTION STRIP TO OTHER OBJECT aka INCLUDE SELECTED OBJECTS
Next, let say we want to apply the same animation to other object. Firstly, I created a few other objects. 

What we need to do next is to create NLA track for the objects. But as you may notice we don't have any listing of new objects. We need to Include Selected Objects inside NLA first, before we are able to add NLA Tracks and Action Strips.


Handy Shorcuts:
  • Shift+A while hovering on the NLA left panel to add NLA Track 
  • Shift+A while hovering on the NLA right panel to add Action.
  • X to quickly delete NLA Track
  • Ctrl+LMB click on the name of object to quickly rename the object name inside NLA
5. EDITING ACTIONS STRIPS IN NLA CONTEXT
Next thing you probably want to explore yourself is how you can edit and modify the strip inside NLA Editor. There are a lot of interesting NLE features that I did not even think that they are existed before, such as: Trimming, Muting, Splitting, Holding, Retiming, Combo-ing and Layering animations. 


What I am even more interested is how we can use Python to actually do some automation inside NLE that we may want to know especially when we are doing Motion Graphics type of work.

STUDY: FLIP ANIMATION WITH NLA AND PYTHON

This found video at Eibriel blog is a good inspiration for what we are trying to do:
http://www.eibriel.com/2012/01/30/working-with-blender-python-nla/

Some times ago, I created a complex setup using Dynamic Paint to trigger flipping animation:
http://blendersushi.blogspot.com.au/2012/02/vfx-multilayers-triggering-of-effects.html

Last time on my blog post, I did the same thing using Python to set it up.

Now we are revisiting the idea once more, using NLA. Setting up repeating tasks is a breeze with Python scripting. Although it does require some hours of R&D.

Let's try to achieve the flipping animation of many objects using Python and NLA.

We basically need to "propagate" a single animation into many objects, with certain OFFSET value. Because a single repeating animation that starts and ends at the same time is kind of boring. While many same animation with offset is usually slightly more interesting.

Our animation in this case is just a flipping object, very simple. And we like to do that for many objects. The process will be like this:

1. Create a flipping animation, freeze and turn it into NLA Action Strip. This animation can be applied using any object. We just care about the Action.
2. Create some bunch objects that we like to flip.
3. Use Python to "copy" those Actions.

NOTE:
Before running the script below, you want to make sure that you have "Include Selected Objects" inside NLA Editor. Read "INCLUDE SELECTED OBJECT" topic above.

BLENDER SUSHI SCRIPT: Apply Action To Many Objects With Frame Offset


import bpy

# Initial setup
ACTION = "CubeAction" # Specify name of action to be copied here
START = 1 # Action Strip will be propagated starting with this frame number
OFFSET = 10 # How much frame offset
NEWTRACK = "MyTrack01" # Name of new NLA track for every object

# http://blenderartists.org/forum/showthread.php?233608-activate-NLA-track

sce = bpy.context.scene # get the scene
rig = bpy.context.active_object

objs = bpy.context.selected_objects

# get name to make active
names = []
for obj in objs:
names.append(obj.name)

# reverse order of selected objects
names.reverse()

# For every ACTIVE OBJECT

for i, name in enumerate(names):
bpy.context.scene.objects.active = bpy.data.objects[name]
rig = bpy.context.active_object

#get or create a new track called MyTrack

if NEWTRACK in rig.animation_data.nla_tracks:
NLATrack = rig.animation_data.nla_tracks[NEWTRACK]
else:
NLATrack= rig.animation_data.nla_tracks.new()
NLATrack.name = NEWTRACK

action = bpy.data.actions[ACTION] # your action

#sce.frame_set(frame=1)

startframe = START + OFFSET * i
actionstartframe = 1

MyNLAStrip = NLATrack.strips.new("MyStripName",start=startframe,action=action)






VIDEO DEMO

Here is an example how you can use the script above:





That simple script should show you a simple implementation of Python inside NLA. This one works only for Transform (Translate, Rotate, Scale). If you like to do the same thing on other context like Materials, Shapekeys, etc, keep reading.

NLA ACTION SCRIPT IN OTHER OBJECT TYPE CONTEXT

Further on in my curiosity toward the data flow in NLA and how we can access the data using Python, I also did a quick look and study on Shape Keys and Materials in context of NLA.

I dig and test inside Python Console and started to see some kind of interesting data pattern.

MATERIAL ---> NLA 
bpy.data.materials[MATERIALNAME].animation_data.nla_tracks.new()
bpy.data.materials['Material.001'].animation_data.nla_tracks['NlaTrack'].select = True
bpy.data.materials['Material.001'].animation_data.nla_tracks['NlaTrack'].select = False

SHAPE KEYS  ---> NLA 
# Create new NLA Track
bpy.data.shape_keys[KEY].animation_data.nla_tracks.new()

# Change the Frame Start and End Example
bpy.data.shape_keys[KEY].animation_data.nla_tracks[NLATRACK].strips[KEYACTION].frame_start = 1
bpy.data.shape_keys[KEY].animation_data.nla_tracks[NLATRACK].strips[KEYACTION].frame_end = 40

So if it is for Armature or for other Object Type, we can access and modify the Action Data just like above.

This is actually a new revelation for me in term of my understanding of Python Object Oriented Programming (OOP) in Blender and how the data is really stored inside Blender.

With this knowledge, we could actually further improve the script above to work on existing Strip Animation Data. So, instead of just assigning Strip, we can simply Query the current Script and maybe:

  • Randomize
  • Offset
  • Add, Combine, and Mix Strip with other actions.
A slight modifiaction from above script if this was for Object Material:

BLENDER SUSHI SCRIPT: Propagate Speificed Action To Selected Object Materials


import bpy

# Initial setup
ACTION = "MaterialAction" # Specify name of action to be copied here
START = 1 # Action Strip will be propagated starting with this frame number
OFFSET = 10 # How much frame offset
NEWTRACK = "MyTrack01" # Name of new NLA track for every object

# Get Active Material for every selected objects

objs = bpy.context.selected_objects

# Get Materials name, sort them in a list, and activate Animation Data for each one of them
mat = []
mat_names = []

for obj in objs:
# Query Material of every object
mat.append(obj.data.materials)
mat_names.append(obj.data.materials[0].name)

# Sort Animation Name
mat_names.sort()
mat_names.reverse()

# Create Animation Data
obj.data.materials[0].animation_data_create()

# Get Object to make active
names = []
for obj in objs:
names.append(obj.name)

# reverse order of selected objects
names.reverse()

# For every ACTIVE OBJECT

for i, name in enumerate(names):
bpy.context.scene.objects.active = bpy.data.objects[name]
rig = bpy.context.active_object.data.materials[0]

#get or create a new track called MyTrack

if NEWTRACK in rig.animation_data.nla_tracks:
NLATrack = rig.animation_data.nla_tracks[NEWTRACK]
else:
NLATrack= rig.animation_data.nla_tracks.new()
NLATrack.name = NEWTRACK

action = bpy.data.actions[ACTION] # your action

#sce.frame_set(frame=1)

startframe = START + OFFSET * i
actionstartframe = 1

MyNLAStrip = NLATrack.strips.new("MyStripName",start=startframe,action=action)







NOTE:
Notice that in this second script, we improve the code slightly so that we don't have to do "Include Selected Objects" thingy. We just simply run the script and it is accessing the Material, add Animation Action from the back door.

What you need to take care is the name of specified Material Action that you would like to propagate to every Object's Material. So you need to make sure you know the name of Action. In the script, I hardcoded "MaterialAction" as the action to be "copied" to every Material.

RENAMING ACTION EXAMPLE
bpy.data.actions['Material.004Action'].name = "MaterialAction"


MORE THAN JUST DOMINO EFFECT

At this moment, all we get with the script above is this DOMINO EFFECT where one action leads to another action and all the actions are the same. What would be nice is is we could create a condition where the action only happens when triggered by a certain condition, or another action.

I really like the idea of "triggering" of actions based on distance approximation, for example. Something that Dynamic Paint does it well for Vertex Weighting.

Maybe I can do something like this:
1. Query some kind of STATE or CONDITION that Blender can write out or save in memory.
2. Based from that query, we then apply second code that will BORN NLA animation at that certain point.

I am sure that this can be done easily in BGE (Blender Game Engine) environment. At some point, I have to find out the relations between BGE and the normal Blender animation environment and hook them together.


OTHER REFERENCES

http://blenderartists.org/forum/showthread.php?248442-NLA-Editor-Make-a-strip-active
http://blenderartists.org/forum/showthread.php?233608-activate-NLA-track
http://blenderartists.org/forum/showthread.php?225783-How-do-I-emulate-the-quot-Snowflake-button-quot-in-the-NLA-in-python-code
https://sites.google.com/site/makehumandocs/blender-export-and-mhx/mocap-tool/combining-actions-in-nla-editor

MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget