Halloween Costume ideas 2015
Articles by "flicker"
@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

Thanks to Python and Blender, orchestrating and flipping many cards is a breeze.

While exploring and researching on NLA (Non Linear Animation) in Blender — which will actually be my next article topic — I stumbled on my old post on Flipping Card animation:
http://blendersushi.blogspot.com.au/2012/02/vfx-multilayers-triggering-of-effects.html

In the past, the setup of Flipping Cards thing was done manually.

Now, since we have a bit of knowledge of Python, I think we could improve the workflow of Flipping Cards and take it further.

FLIPPING CARDS CASE STUDY

This effect of Flipping Cards is actually a really good and fun exercise in thinking about Python programming, Blender and technical animation because it provides multiple layers of interesting problems that can and should be tackled using Python and some motion graphics thinking:
1. Many objects needs to be animated or orchestrated in a certain way.
2. Need a simple control.
3. It needs to be robust enough to give variations of flipping cards.
4. The texturing of both side of cards.

From my old article, we know that the trick here is to use these features in Blender:

  • Transformation Constraint
  • Vertex Groups
  • Displace Modifier
  • Dynamic Paint
We will use the same techniques, but with additional enhancement. We want to put all of them together in a nicest possible way.

PROBLEM 001: Placing Cards in a Grid

How to easily create multiple Cards in a grid?

There are many ways to do this in Blender, but the simplest way is to use Grid object.


You can also use:
  • Blender Particle Instancer to duplicate and place objects in grid
  • Using Python to create row and column of objects

IMPORTANT UPDATE 20130514:

SPECIAL PROBLEM: The Sorting of Cards (or Mesh Faces)
This is something that I just found out, but VERY IMPORTANT. Please read.

While going through all the process again, I figure out that the Sorting of Face Index is very important.

By default Blender Grid Face Index is NOT in Order.



You can see what I mean by going to Edit Mode, and back to Object mode and run the script below:

import bpy

'''
Check Active Face Index
'''

object = bpy.context.active_object

faces = object.data.polygons

#for face in faces:
#    print(face.select)

for i in range(len(faces)):
    #print(i, faces[i].select)
    if (faces[i].select == True):
        print(i)

You can also use Bartious Script to display the Index of Mesh Components:

...an information that we can actually activate DEBUG mode that allows us to check Index (Indices) of Components:

bpy.app.debug = True
By activating that DEBUG via Python Consode, Blender can actually display Face and Vertex Index in Edit Mode by default. Which is neat, I only figure it out today.

While doing this below will give you a lot more informations that will give feedback for every bpy.ops you do on windows console:
bpy.app.debug_wm = True

Anyways, you must the Face Indices to have everything works correctly. You need to do this more importantly on the Grid of Cards.

A better and sorted, but still not 100% correct. Read below. The most correct sorting that will work with my script will have the number goes from 0 at top right corner and going down, and then continue on to the left.

Below is few methods to sort the card grid.

SOLUTION ONE:
Do Mesh Sorting before you continue with all the steps below.
When you are in Edit Mode, notice that you can select all Component, tap on Spacebar, and run "Sort Mesh Elements" function.

This does not always work the way you want it, so try multiple time from different 3D View angle, play around with the option from the Tool Bar (left side), eventually you get the right sorting.

This is key to make your mesh properly sorted.

The MOST correct sorting is like below:
This is really the MOST CORRECT and guarantee to work nicely with the Template object.

SOLUTION TWO: Use Houdini

Houdini is probably the best package out there to handle Component Level, simply by connecting nodes. It has this Sort SOP node that does the job.

Blender's own Component Sorting function does not always work properly, I tried many times. But occasionally you get it right.

Use Houdini instead. It allows you to import and export OBJ and sort the component easily.

SOLUTION THREE: Create the Grid by using Particles
Create the Grid of Cards using Particle and Instance on every Vertex. This way, you actually will end up with a correct face ordered TEMPLATE + GRID.

If you are still confused, feel free to leave comments below.

MY POINT IS:
Basically, the Face Indices of the Grid of Cards and Template object MUST be in order for you to get the proper Flip Card Effects.

    PROBLEM 002: Separate Each Face

    From the Grid object, we want to turn every face into row and column of cards. In Blender terminology, we like to simply separate every face component of the mesh.

    How do we go about doing this in Blender?
    • Mark (Edge) Sharp
    • Edge Split Modifier
    Go to Component Mode of your Grid (hit Tab), select all Edges (or Faces) and Mark Sharp.


    Back to Object Mode (toggle by hitting Tab again), and Apply Edge Split Modifier.


    Make sure you click on "Apply" button to confirm the modifier. Default setting is fine.

    You can check now that each faces have been separated.


    PROBLEM 003: Object Level Control for Every Face

    In Blender, we know that there is a handy tool called Hook that is able to give the user Control over Component (Vertex, Edge, Face) in Object Mode.

    That is exactly what we will use in here.

    To give this a try, go to Edit Mode, select a Face, and CTRL+H to setup a Hook.


    Now, back in Object Mode, you will see an Empty that controls the Face (you can do all kind of transformation, translate, rotate, scale):


    For our purpose, we need to do this for every Face, here Python comes to the rescue.

    BLENDER SUSHI SCRIPT: Hook Every Face of Mesh



    ## HOOK EVERY FACE OF MESH

    import bpy

    """
    Hook every selected Faces. This works best for object
    with all faces separated.

    Copyright (c) 2013 Jimmy Gunawan at Blender Sushi Blog
    Name: hookEveryFace.py
    Version: 001
    Author: Jimmy Gunawan
    Contact: blendersushi@gmail.com
    Date Created: 2013.05.12

    How to use the script:
    1. Select object which every face will be booked
    2. Run the script

    """

    # Get current active object
    object = bpy.context.active_object
    object_name = object.name
    print(object_name)


    # Get all faces
    faces = bpy.context.active_object.data.polygons

    # This is less Pythonic but works.

    for i in range(len(faces)):

    # Deselect Everything in Edit Mode
    bpy.ops.object.mode_set(mode = 'EDIT')
    bpy.ops.mesh.select_all(action = 'DESELECT')
    bpy.ops.object.mode_set(mode = 'OBJECT')

    # Select a face
    bpy.context.active_object.data.polygons[i].select = True

    # Hook face to new object
    bpy.ops.object.mode_set(mode = 'EDIT')
    bpy.ops.object.hook_add_newob()

    # Reselect original object
    bpy.context.scene.objects.active = bpy.data.objects[object_name]


    # Deselect everything in Edit Mode
    bpy.ops.object.mode_set(mode = 'EDIT')
    bpy.ops.mesh.select_all(action = 'DESELECT')
    bpy.ops.object.mode_set(mode = 'OBJECT')

    """

    # More Pythonic, but failed to work, I do not know why

    for face in faces:

    # Deselect Everything in Edit Mode
    bpy.ops.object.mode_set(mode = 'EDIT')
    bpy.ops.mesh.select_all(action = 'DESELECT')
    bpy.ops.object.mode_set(mode = 'OBJECT')

    # Select a face
    face.select = True

    # Hook face to new object
    bpy.ops.object.mode_set(mode = 'EDIT')
    bpy.ops.object.hook_add_newob()

    # Reselect original object
    bpy.context.scene.objects.active = bpy.data.objects[object_name]

    face.select = False

    """







    Use the script above to set Hook on every face.


    PROBLEM 004: Simple Control for Flipping of Many Objects

    This is probably the trickiest part. However, we already know the solution from previous post: Vertex Group of another object can be referenced by Transformation Constraint.

    What do we need? Another Object that will act as our Flip Cards Controller, let's name it "Template".

    In our case, our Control Object is quite special, in which we will create Vertex Group for every Vertex of that mesh, this will be referenced by our Card Grid Objects via Transformation Constraint.

    The "Template" Object
    If we have 12 x 12 grid, our Template Object just need to be 11 x 11 grid, so that the Vertex Total Number will match to the number of Card Grids (Total Number of Faces).

    Let's just create Grid with 1 less number in row and column, and name it "Template" object.


    I made the "Template" object Display as Wire and to display All Edges.

    Next, we need to assign Vertex Group for every Vertex of our Template object. For this, we also use Python script:

    BLENDER SUSHI SCRIPT: Vertex Group Every Vertex



    ## Vertex Group Every Vertex





    import bpy





    '''


    Assigning each and every vertex of a mesh into own Vertex Group


    '''



    # Specify Object to Create Group
    obj = bpy.context.scene.objects.active

    # Make Specified Object Active
    # bpy.context.scene.objects.active = obj

    # Accessing Vertex Groups Data
    # obj.vertex_groups

    # Get total vertex number
    total_vertices = len (obj.data.vertices)

    # Create Vertex Group based on total vertex number
    for i in range(total_vertices):
    vg = obj.vertex_groups.new(name='groupy.%03d' % i)

    # Assign each Vertex to Vertex Group
    vg.add([i], 1, "ADD") # index, weight, operation


    # http://www.blender.org/forum/viewtopic.php?t=25776&sid=a7610ca4988d2ad669308cc517d104c9








    Select the "Template" object, and run the script, you should then end up with Vertex Group (VG) for every vertex of the "Template" mesh.

    With my rough script above, I use a hardcoded name for the Vertex Group called "groupy.###", you can change this if you like.

    PROBLEM 005: Power of many Transformation Constraint

    Now that we have the "Template" Control ready, we simply need to connect it to our Flip Cards object.

    Transformation Constraint is the man for this job and we need many Transformation Constraints, each for every Card and we tell Blender to reference Vertex Groups of "Template".

    Transformation Constraint is interesting because it has plenty of options to set whether we like to: Translate, Rotate, or Scale the constrained object.

    With our purpose we want it to Flip (Rotate) the constrained object, based on reference. As shown in my previous post, the setup for flip rotation using Transformation Constraint is like below:
    FLIP EFFECT

    I hard-coded the Python script below that will create multiple Transformation Constraints for our Flip Cards object that references the Vertex Groups of "Template" object, which will give the Flipping effect.

    Watch this Transformation Constraint carefully and modify the script as you need.

    If you setting up the Transformation Constraint like this, you get the Scale and Reveal kind of effect:

    SCALE AND REVEAL EFFECT
    The script below will give you Flip Effect in certain axis direction. Feel free to modify some of the number below to give you other kind of effects:

    BLENDER SUSHI SCRIPT: Add Transformation Constraint to Selected Objects



    import bpy

    '''
    Add Transformation Constraint for every selected objects
    '''


    objs = bpy.context.selected_objects

    # Need a way to sort dictionary/reference via name
    # I do a quick hack in here
    # http://blenderartists.org/forum/showthread.php?194818-Python-Sort-Problem

    newList = []

    for num, obj in enumerate(objs):
    print (num,obj)
    newList.append(obj.name)

    newList.sort()
    #print(newList)

    newObjs = []

    for item in newList:
    newObjs.append(bpy.data.objects[item])

    #print(newObjs)



    for num, obj in enumerate(newObjs):

    # Make each object Active one at a time
    bpy.context.scene.objects.active = obj

    # Assign Transformation Constraints
    bpy.ops.object.constraint_add(type='TRANSFORM')

    current_constraint = bpy.context.object.constraints["Transformation"]

    # Assign Target Object
    current_constraint.target = bpy.data.objects["Template"]

    # Assign Vertex Group Target
    current_constraint.subtarget = "groupy.%03d" % num


    # Setup Attributes for Flip Effects
    current_constraint.from_max_z = 1
    current_constraint.map_to_y_from = 'Z'
    current_constraint.map_to = 'ROTATION'
    current_constraint.to_max_y = 180
    current_constraint.target_space = 'LOCAL'






    We want to apply the script above to every EMPTY that is in fact controlling each Face of Flip Card.

    You can Box Select every EMPTY objects, but you can also use Python script that I made to select all objects named "Empty*":

    ### HARD CODED SCRIPT TO QUICKLY SELECT EVERY EMPTY

    import bpy
    import fnmatch

    # Get All Meshes Objects
    objects = bpy.data.objects


    ## LIST COMPREHENSION STYLE
    myListX = fnmatch.filter( [objects [i].name for i in range(len(objects ))] , 'Empty*')

    for item in myListX:
        bpy.data.objects[item].select = True


    ### HARD CODED SCRIPT TO QUICKLY MODIFY CONSTRAINT MODIFIER


    import bpy

    '''
    Modify Transformation Constraint for every selected object
    '''


    objs = bpy.context.selected_objects


    for num, obj in enumerate(objs):
        
        # Make each object Active one at a time
        bpy.context.scene.objects.active = obj
        
        current_constraint = bpy.context.object.constraints["Transformation"]
        

        # Setup Attributes for Scale Reveal

        current_constraint.from_max_z = 1
        current_constraint.map_to_x_from = 'Z'
        current_constraint.map_to_y_from = 'Z'
        current_constraint.map_to = 'SCALE'
        current_constraint.to_min_x = 0
        current_constraint.to_max_x = 1
        current_constraint.to_min_y = 0
        current_constraint.to_max_y = 1
        current_constraint.to_min_z = 0
        current_constraint.to_max_z = 1
        current_constraint.target_space = 'LOCAL'

        


    TIPS:
    It would be nicer if we name every component of our Flip Card setup properly for future modification. Maybe we could also Group them.

    Select every Empty objects in the scene and then apply Transformation Constraint script above.

    WATCH OUT:
    Be careful in matching the Row and Column of our "Template" object and the Flip Cards object. If the number is not sorted properly, we will not get the perfect Ripple of Flip Cards. Keep this in mind. Maybe I have to re-write the script to make sure this is taken care.

    Ok, we are almost done here with the complex setup, but you see how every step is rather simple and Python helps a lot with the hard repetitive task.

    If you move the Template object up and down in Z axis, the Flip Cards object will flips, but all at the same time. How do make this more irregular? Continue to the next step.


    PROBLEM 006: Orchestrating Many Objects with Displace Modifier

    Problem 006 is NOT really a problem anymore because we have gone through all the complex setup. Problem 006 is the most fun.

    Simply apply Displace Modifier to our "Template" object, assign a Texture (Cloud, Image, Voronoi, Blend Ramp/Gradient, etc) and move the "Template" up and down in Z axis.

    Depending on the Texture and how it affect the displacement of mesh, you will get different Ripple effect of the Flip Cards.

    Using Cloud Texture for Displace Modifier
    Using Blend (Ramp/Gradient) texture.
    Using Marble (Stripes) texture

    PROBLEM 007: Double Sided Material

    For Double Sided Material, we can use Solidify Modifier. You get everything basically for free and easy to setup 3 Different Materials: Front Material, Rim Material, and Back Material.



    The result can be seen right away:

    If simple Material is what you need, your work is really pretty much done. You can use Blender Cycles to continue polishing the look.

    However if you want to use proper UV and Texture, you have the last problem:

    PROBLEM 008: UV and Texture for Scrambled Flip

    Our Flip Cards object is only a single object. By having this, we can easily apply 3 materials using Solidify Modifier above.

    We could apply a single UV Texture, but we actually need 2 UV Textures to make it work. Why? Because the other side of Texture is Scrambled.

    I will give you an example with this photo of Dog (Woofy) and Cat texture on Front and Back side of the Flip Card object.

    Firstly, do the UV Layout for the object. Hit TAB, tap U, select all Faces (tap A) and Spacebar "Unwrap" (this is the quickes way). That UV is fine for the normal Flip Cards, before being flipped.

    I assign 2 Textures (Cat and Dog) to the Flip Cards.
    • FRONT: Dog (Woofy)
    • BACK: Cat



    The Front looks fine:

    Now we flip the cards....

    But the Back is scrambled:

    How do we fix and unscramble the texture?

    I think, we could use multiple UV. However, for simplicity sake, we just provide Blender with pre-scrambled texture that will be unscrambled later.

    What do I mean here is just to "Project" and render the pre-scrambled texture of the photo and use this for our purpose.


    Now, when we flip the cards, the Texture is correct from this Front Camera Point of View.


    PROBLEM 010: Multiple Texture Changing

    We have Front and Back texture, but what if we want to change many textures? Not just 2 textures? The magic is in Keyframing the Texture Visibility ON and OFF:


    Kind of hacky, but it works. You could probably setup Driver Control that make it easier for Animator to animate the flipping cards, which takes me to the last problem.

    PROBLEM 010: Flip Cards Control Rig For Animator

    How is the best way to pass this Flip Card setup for animator? This is one unsolved problem for this Flip Cards setup. 

    I would like to contain all the Empty and hide all kind of complex mechanical objects, and giving ability to move around the Flip Cards. So far, I am not sure how to do this. Because simply parenting the Empty which has Constrains does not actually work. Wonder if I could use Armature hierarchy.

    PROBLEM 011: Python Script and GUI

    One day I will create a nice GUI for this to help the setup and automate the whole steps. Or maybe you can do it yourself.


    VIDEO TUTORIAL


    I made a quick video tutorial that takes you through all the steps. I also added additional setup using Dynamic Paint.

    I made few hickups during recording:
    1. UV was not laid properly because I missed to select Faces, hence the Black appearance of Material. I did figure it out and fix it in the video.
    2. I assigned Dynamic Paint to the wrong object. Supposedly for the "Template" object, and not the Flipcards object. However, I also fix this issue as you can see in the video.
    3. You might notice that the Flipping Card ripple is not 100% perfect. This is because of the Sort Ordering of the Grid Face is not properly setup. I need to look into this further.
    4. The back Texture is scrambled. This will happen, you need to "unscramble" it using a pre-rendered texture that is actually scrambled so that it looks correct when flipped. Got it?

    Hope this is a useful technique for you! Maybe in near future we can use similar technique to trigger Crowds Wave kind of effects.

    In next post, I like to cover NLA Action Animation together with this technique.

    UPDATE 20130515

    BLENDER SUSHI SCRIPT: Uber Flip Cards Effect



    import bpy
    import fnmatch

    # HELPER FUNCTIONS

    def hookEveryFace():
    ## HOOK EVERY FACE OF MESH


    """
    Hook every selected Faces. This works best for object
    with all faces separated.

    Copyright (c) 2013 Jimmy Gunawan at Blender Sushi Blog
    Name: hookEveryFace.py
    Version: 001
    Author: Jimmy Gunawan
    Contact: blendersushi@gmail.com
    Date Created: 2013.05.12

    How to use the script:
    1. Select object which every face will be booked
    2. Run the script

    """

    # Get current active object
    object = bpy.context.active_object
    object_name = object.name
    print(object_name)


    # Get all faces
    faces = bpy.context.active_object.data.polygons

    # This is less Pythonic but works.

    for i in range(len(faces)):

    # Deselect Everything in Edit Mode
    bpy.ops.object.mode_set(mode = 'EDIT')
    bpy.ops.mesh.select_all(action = 'DESELECT')
    bpy.ops.object.mode_set(mode = 'OBJECT')

    # Select a face
    bpy.context.active_object.data.polygons[i].select = True

    # Hook face to new object
    bpy.ops.object.mode_set(mode = 'EDIT')
    bpy.ops.object.hook_add_newob()

    # Reselect original object
    bpy.context.scene.objects.active = bpy.data.objects[object_name]


    # Deselect everything in Edit Mode
    bpy.ops.object.mode_set(mode = 'EDIT')
    bpy.ops.mesh.select_all(action = 'DESELECT')
    bpy.ops.object.mode_set(mode = 'OBJECT')

    """

    # More Pythonic, but failed to work, I do not know why

    for face in faces:

    # Deselect Everything in Edit Mode
    bpy.ops.object.mode_set(mode = 'EDIT')
    bpy.ops.mesh.select_all(action = 'DESELECT')
    bpy.ops.object.mode_set(mode = 'OBJECT')

    # Select a face
    face.select = True

    # Hook face to new object
    bpy.ops.object.mode_set(mode = 'EDIT')
    bpy.ops.object.hook_add_newob()

    # Reselect original object
    bpy.context.scene.objects.active = bpy.data.objects[object_name]

    face.select = False

    """


    def quickSeparateFace():
    # Select the mesh
    # Get current active object
    object = bpy.context.active_object
    object_name = object.name

    # Go to Edit Mode

    # Select Toggle All Faces
    bpy.ops.object.mode_set(mode = 'EDIT')
    bpy.ops.mesh.select_all(action = 'SELECT')

    # Mark Sharp every Face
    bpy.ops.mesh.mark_sharp(clear=False)

    # Back to Object Mode
    bpy.ops.object.mode_set(mode = 'OBJECT')

    # Assign and Apply Edge Split Modifier
    bpy.ops.object.modifier_add(type='EDGE_SPLIT')
    bpy.ops.object.modifier_apply(apply_as='DATA', modifier="EdgeSplit")


    def VGVertex():
    '''

    Assigning each and every vertex of a mesh into own Vertex Group

    '''


    # Specify Object to Create Group
    obj = bpy.context.scene.objects.active

    # Make Specified Object Active
    # bpy.context.scene.objects.active = obj

    # Accessing Vertex Groups Data
    # obj.vertex_groups

    # Get total vertex number
    total_vertices = len (obj.data.vertices)

    # Create Vertex Group based on total vertex number
    for i in range(total_vertices):
    vg = obj.vertex_groups.new(name='groupy.%03d' % i)

    # Assign each Vertex to Vertex Group
    vg.add([i], 1, "ADD") # index, weight, operation


    # http://www.blender.org/forum/viewtopic.php?t=25776&sid=a7610ca4988d2ad669308cc517d104c9



    def getAllEmpty():
    # Get All Meshes Objects
    objects = bpy.data.objects

    ## LIST COMPREHENSION STYLE
    myListX = fnmatch.filter( [objects [i].name for i in range(len(objects ))] , 'Empty*')


    for item in myListX:
    bpy.data.objects[item].select = True

    def constraintAllEmpty():
    '''
    Add Transformation Constraint for every selected objects
    '''


    objs = bpy.context.selected_objects

    # Need a way to sort dictionary/reference via name
    # I do a quick hack in here
    # http://blenderartists.org/forum/showthread.php?194818-Python-Sort-Problem

    newList = []

    for num, obj in enumerate(objs):
    print (num,obj)
    newList.append(obj.name)

    newList.sort()
    #print(newList)

    newObjs = []

    for item in newList:
    newObjs.append(bpy.data.objects[item])

    #print(newObjs)



    for num, obj in enumerate(newObjs):

    # Make each object Active one at a time
    bpy.context.scene.objects.active = obj

    # Assign Transformation Constraints
    bpy.ops.object.constraint_add(type='TRANSFORM')

    current_constraint = bpy.context.object.constraints["Transformation"]

    # Assign Target Object
    current_constraint.target = bpy.data.objects["Template"]

    # Assign Vertex Group Target
    current_constraint.subtarget = "groupy.%03d" % num


    # Setup Attributes for Flip Effects
    current_constraint.from_max_z = 1
    current_constraint.map_to_y_from = 'Z'
    current_constraint.map_to = 'ROTATION'
    current_constraint.to_max_y = 180
    current_constraint.target_space = 'LOCAL'


    # FINAL CODE

    # Ask User to select FlipCards Object, so it is active
    user_grid = bpy.context.active_object

    # Oops ... Hard Coded
    user_template = bpy.data.objects['Template']

    # Select FlipCards Object
    bpy.ops.object.select_all(action='DESELECT')
    bpy.context.scene.objects.active = user_grid

    quickSeparateFace()
    hookEveryFace()

    # Select Template Object and do the VG for every vertex
    bpy.ops.object.select_all(action='DESELECT')
    bpy.context.scene.objects.active = user_template
    VGVertex()

    # Select Every Empty of FlipCards Object
    bpy.ops.object.select_all(action='DESELECT')
    getAllEmpty()
    constraintAllEmpty()









    I decided to put together all the Python scripts above into a single easy to use script. One click and all connection and setup done.

    How to use:
    1. Make sure you have a Mesh Grid of Cards which Faces Indices are SORTED correctly.
    2. Also make sure that you also have the "Template" object, as specified and described above. Name it "Template" because the Script is slightly hard-coded for simplicity. 
    3. Next, you simply select the Flip Card Object and run the script.
    4. Finally, just apply Displace Modifier that will control the Flip Card. 
    5. Have fun animating Flip Cards with Texture.
    Remember it is more important to understand every steps first so that you can modify the script to your liking. You can create interesting variations using the same setup just by modifying the script for Transformation Constraint.

    ANOTHER VIDEO DEMO WITH UBER FLIP CARD SCRIPT:


    EXAMPLE BLEND FILE AT BLENDSWAP
    http://www.blendswap.com/blends/view/68139

    ADDENDUM: UV Project Modifier at Blender Cookie
    You might also want to check Blender Cookie video tutorial with Gottfried Hofmann that shows Blender UV Project Modifier:

    Not directly related, but if you are using Blender Cycles and want a quick projection, it is recommended to watch the video and use the technique.

    ADDENDUM: Sorting in Python
    This might be something you may use to sort the index of mesh components (I have not tried it yet), but I was watching this Google Python class and I guess, this could be handy:

    Nick Parlante's Class on Python Sorting: (at Google)

    # CUSTOM SORTING
    >>> myList = ['aaaa', 'bb', 'ccc', 'd']
    >>> myList
    ['aaaa', 'bb', 'ccc', 'd']

    # sort the list using 'len'
    >>> myList = sorted(e, key=len)
    >>> myList
    ['d', 'bb', 'ccc', 'aaaa']

    # create custom function to sort
    def last(s): return s[-1]

    >>> myList = sorted(e, key=last)
    >>> myList
    ['aaaa', 'bb', 'ccc', 'd']

    Thanks to Daniel Peterson for providing me with this flip card challenge!



    The next thing I am curious about is on how Blender Python does keyframing for animation.

    We already know how to LIST, how to MODIFY VALUES, now we see how we can KEYFRAME VALUES using Python.

    SIMPLE LOCATION KEYFRAME
    Reference:
    http://www.blender.org/forum/viewtopic.php?t=22602&sid=546436de57ad2f620b88ef9d8d8cfddb

    From the forum post above, we have one cool code that we can observe. The code presented seems to work on currently selected object, it basically made 1000 keyframes (for Location) of currently selected object: These 2 BPY below does the keyframing job.


    bpy.context.scene.frame_current = i 
    bpy.ops.anim.keyframe_insert(type='Location')


    I modified the script slightly, by changing the object positions using Random values.

    USING WHILE LOOP FOR KEYFRAMING RANDOM POSITION

    If we use While Loop and Random Positions:


    import bpy
    import random

    i = 0

    while(i <= 100): 
        bpy.context.scene.frame_current = i 
        bpy.ops.anim.keyframe_insert(type='Location')
        
        movx = random.uniform(-5,5)
        movy = random.uniform(-5,5)
        movz = random.uniform(-5,5)
         
        bpy.data.objects['Cube'].location = (movx, movy, movz)
        i += 1


    Using While Loop like above for keyframing animation, we basically tell Blender to step one frame and create keyframes. The result is a dense keyframes like Motion Capture data.

    Of course we can change that behaviour of keyframe stepping by changing that i += 1 expression at the bottom to a different value.


    import bpy
    import random

    i = 0

    while(i <= 100): 
        bpy.context.scene.frame_current = i 
        bpy.ops.anim.keyframe_insert(type='Location')
        
        movx = random.uniform(-5,5)
        movy = random.uniform(-5,5)
        movz = random.uniform(-5,5)
         
        bpy.data.objects['Cube'].location = (movx, movy, movz)
        i += 20



    USING FOR LOOP FOR KEYFRAMING  RANDOM POSITION
    If we use For Loop, range() function we can have different control on where Blender should create a keyframe. For this example code below, it is basically telling Blender to set keyframe every 5th of the frame between range of frames 0 - 100.


    import bpy
    import random

    for i in range(0,100,5): 
        bpy.context.scene.frame_current = i 
        bpy.ops.anim.keyframe_insert(type='Location')
        
        movx = random.uniform(-5,5)
        movy = random.uniform(-5,5)
        movz = random.uniform(-5,5)
         
        bpy.data.objects['Cube'].location = (movx, movy, movz)



    Next example below is the same code as above, but works on multiple objects (that are currently selected):



    import bpy
    import random

    objects = bpy.context.selected_objects

    for i in range(0,100,5):     
        for object in objects:    
            bpy.context.scene.frame_current = i 
            bpy.ops.anim.keyframe_insert(type='Location')
            
            movx = random.uniform(-5,5)
            movy = random.uniform(-5,5)
            movz = random.uniform(-5,5)
             
            object.location = (movx, movy, movz)




    Nothing really special here, other than the fact we can tell Blender to move forward in timeline and set keyframe. Super simple, but you can already do quite a lot with this.

    It is a good start of procedural creating animation in Python context.

    ANOTHER WAY TO SET KEYFRAME
    I just do a quick experiment, apparently you can also do keyframing by doing this:

    bpy.data.objects[NAME].keyframe_insert(DATAPATH, frame=FRAMENUMBER)

    For example:
    bpy.data.objects['Cube'].keyframe_insert('location', frame=15)
    >> Set kefyrame for object named Cube, for it's 'location' datapath, at frame 15.

    Doing this seems to be more specific and directly targeting the object.

    Let's give it a try.

    To find DATA PATH, I usually check from the Channel or Property, by RMB (right mouse button) click and Copy Data Path:


    Typical Data Path, as below:

    • 'location'
    • 'rotation_euler'
    • 'scale'
    But Data Path can be anything, including custom attributes, could be the Material and its attributes.

    RANDOM SCALE
    Below example will randomize the Scale and set key every 5 frames and I am using this different method.

    import bpy
    import random

    objects = bpy.context.selected_objects

    for i in range(0,100,5):     
        for object in objects:    
            bpy.context.scene.frame_current = i 
            #print(i)
            #bpy.ops.anim.keyframe_insert(type='Location')
            
            scalex = random.uniform(1.0,4.0)
            scaley = random.uniform(1.0,4.0)
            scalez = random.uniform(1.0,4.0)
            
            object.scale = scalex, scaley, scalez
            
            object.keyframe_insert('scale')


    Using the same pattern above, we can actually be specific on when we like to set keyframe. Let say, we want to specifically keyframe the Scale at frames: 50, 100, 150, 200, we simply change the loop like below:


    import bpy
    import random

    objects = bpy.context.selected_objects

    for i in [50,100,150,200]:     
        for object in objects:    
            bpy.context.scene.frame_current = i 
            #print(i)
            #bpy.ops.anim.keyframe_insert(type='Location')
            
            scalex = random.uniform(1.0,4.0)
            scaley = random.uniform(1.0,4.0)
            scalez = random.uniform(1.0,4.0)
            
            object.scale = scalex, scaley, scalez
            
            object.keyframe_insert('scale')



    KEYFRAMING MATERIAL PROPERTY

    Let's try applying random keyframes on Material 'diffuse_color' of selected object.

    Now, with things like these, we need to be careful and ask ourselves:

    • Does our object already have material? Should we create one using Python if the object does not have material?
    • Do we want to just give random Diffuse Color to all Material in the scene? Maybe not. We want to specifically target the Material currently applied to our selected object.
    RANDOM OBJECT COLOR
    Before going to Material, we can actually do Object Color for simplicity. Any object in the scene will have Object Color attribute by default that we can color.

    import bpy
    import random

    objects = bpy.context.selected_objects

    for i in range(0,100,5):     
        for object in objects:    
            bpy.context.scene.frame_current = i 
            #print(i)
            #bpy.ops.anim.keyframe_insert(type='Location')
            
            colorR = random.uniform(0.0,1.0)
            colorG = random.uniform(0.0,1.0)
            colorB = random.uniform(0.0,1.0)
            alpha = 1.0
            
            object.color = colorR, colorG, colorB, alpha
            
            object.keyframe_insert('color')

    They are animating and changing color.

    Object Color is interesting and so easy to access, maybe we can use it to do Animated Pixel Art?


    RANDOM MATERIAL DIFFUSE COLOR
    bpy.data.objects['Cube'].data.materials[NAME].keyframe_insert('diffuse_color')

    The above Blender Python will insert a keyframe at current frame in the timeline. As you can see, with this method you are very specific with everything.

    Let's try a code that does the keyframing of this Material Diffuse Color, of currently selected object. Usually with my code, I always start by making a Loop over every object, in selected objects, and every materials that are applied to this object. If we need to skip on anything, the code can then modified further.


    import bpy
    import random

    objects = bpy.context.selected_objects

    for i in range(0,100,5):     
        for object in objects:
            # Get all materials of currently selected object (if any)
            myMaterials = object.data.materials

            for material in myMaterials:
                        
                bpy.context.scene.frame_current = i 
                
                colorR = random.uniform(0.0,1.0)
                colorG = random.uniform(0.0,1.0)
                colorB = random.uniform(0.0,1.0)

                
                material.diffuse_color = colorR, colorG, colorB    
                material.keyframe_insert('diffuse_color')




    Maybe we can also target certain Object and Material by its name? Yes, I think we can do that using the FILTERING code that I have mentioned previously.

    CONCLUSION
    From above examples, we have learned how to do keyframing for common attributes, which values we also randomized overtime.

    Adding "animation" really makes the difference to previously static randomness.

    Of course, it is still pretty boring and linear, but you can play around with the timing of the keyframe for each loops by offsetting the FRAME slightly. You can get like Airport Flicker Board effect.

    But even for such simple animation like Scale value, from A to B, you can get pretty interesting result by offsetting the animation of an array of objects.

    For example, if we like to OFFSET keyframe for every selected object:

    import bpy

    selected_objects = bpy.context.selected_objects

    bpy.context.scene.frame_current = 1

    for object in selected_objects:
        bpy.context.scene.frame_current += 3
        object.scale = 1.01.0, 1.0
        object.keyframe_insert('scale')


    This is a kind of thing that you cannot easily achieve with manual keyframing. Easy to add complexity. But it is always better to plan things.

    There is one more thing that I have not tried:
    To be able to Offset via Blender Action. Probably something to check out next. Especially in relation to Armature to generate some kind of crowd simulations.

    To be honest, I like to do this kind of thing in more procedural way using nodes. But I guess for now, we can try setting it up using Python and maybe Dynamic Paint and Drivers.

    The procedure we applied so far is always the same:
    1. MAKE CHANGES: Randomize the value of attributes of array of objects.
    2. SET KEYFRAMES: Keyframes those particular attributes at particular frame in time --> this is the NEW thing we learned today.

    APPLICATION: Pixel Art Animation

    Alrightly, we can now revisit the Pixel Art script and modify it slightly for our purpose.

    Instead of using Vertex Color, we will simplify this further to use Object Color. We will also keyframe the Object Color.

    The process will be like this:
    - Initial Setup, the import of the grid and colorize Object Color using Pixel Art image.
    - Keyframe the Object Color at certain frame
    - Import another Pixel Art image and Modify the current setup
    - Keyframe the Object Color at certain frame

    The scripts will be something like below:

    1. Import a Pixel Art, setup initial Grid Matrix of Pixel Cube.

    import bpy

    D = bpy.data

    # Specify your image here, open it inside Blender Image Editor panel
    image_file = 'ryu_16_16.png'
    img = D.images[image_file]
    pixels = list(img.pixels)
    grouped_list = [pixels[ipx:ipx+4] for ipx in range(0, len(pixels), 4)]

    # Get width and height of image (in pixel)
    w = width = img.size[0]
    h = height = img.size[1]
    print("------LENGTH------")
    print( len(img.pixels)//4)
    print("------PIXEL------")
    print(pixels)
    print("---GROUPED-PIXEL---")
    print(len(grouped_list))

    # Create LIST of GRID XY value
    rowColList=[]
    for i in range(height):
        for j in range(width):
          rowColList.append(i)
          rowColList.append(j)

    # SPLIT the LIST of XY
    origList = rowColList
    splitList = [origList[i:i+2] for i in range(0,len(origList),2)]

    # Create a single material that respect Object Color
    mat = bpy.data.materials.new('PixelObjectColorMat')
    mat.use_object_color = True

    for number in range(len(grouped_list)):
        # Separate RGBA into each own variables
        r = grouped_list[number][0]
        g = grouped_list[number][1]
        b = grouped_list[number][2]
        a = grouped_list[number][3]
        
        # Separate XY coordinate
        x=splitList[number][0]
        y=splitList[number][1]
        
        # Create cube at location XY
        bpy.ops.mesh.primitive_cube_add(location=(x-width/2, y-width/2, 0))
        
        selectedObject = bpy.context.selected_objects
        mesh = selectedObject[0]
        mesh.name = 'pixelcube.%s' % number
        mesh.scale = 0.45, 0.45, 0.45
        
        # Keep list of our mesh for further processing, this is one big array
        #pixelCubeObjects.append(mesh)
        # bpy.data.objects[pixel'cube.1022']
        
        # Apply our special Material
        bpy.context.object.data.materials.append(mat)
        
        # Assign RGBA color to Object Color
        mesh.color = r,g,b,a
        
        # Print the chatter progress
        print ('PixelCube {number} created at:'.format(number=number), x, y, ', with RGB color', r, g, b)



    2. Set keyframes on each Pixel Cube Object Color.


    import bpy

    D = bpy.data

    # Specify your image here, open it inside Blender Image Editor panel
    image_file = 'ryu_16_16.png'
    img = D.images[image_file]
    pixels = list(img.pixels)
    grouped_list = [pixels[ipx:ipx+4] for ipx in range(0, len(pixels), 4)]

    # Get width and height of image (in pixel)
    w = width = img.size[0]
    h = height = img.size[1]

    current_frame = 1 # # SET YOUR KEYFRAME HERE

    for number in range(len( grouped_list )):
        bpy.data.objects['pixelcube.{number}'.format(number=number)].keyframe_insert('color', frame = current_frame)


    3. Modify the color of each Pixel Cube Object Color with the new Pixel Art.

    import bpy

    D = bpy.data

    # Specify your image here, open it inside Blender Image Editor panel
    image_file = 'ken_16_16.png'
    img = D.images[image_file]
    pixels = list(img.pixels)
    grouped_list = [pixels[ipx:ipx+4] for ipx in range(0, len(pixels), 4)]


    # Get width and height of image (in pixel)
    w = width = img.size[0]
    h = height = img.size[1]
    print("------LENGTH------")
    print( len(img.pixels)//4)
    print("------PIXEL------")
    print(pixels)
    print("---GROUPED-PIXEL---")
    print(len(grouped_list))

    for number in range(len( grouped_list )):
        
        r = grouped_list[number][0]
        g = grouped_list[number][1]
        b = grouped_list[number][2]
        a = grouped_list[number][3]
         
        print('-'*50)
        print(number)
        print(r,g,b,a)
        
        bpy.data.objects['pixelcube.{number}'.format(number=number)].color = r,g,b,a
         
    4. Set keyframes AGAIN on each Pixel Cube Object Color (now with new Pixel Art)

    import bpy

    D = bpy.data

    # Specify your image here, open it inside Blender Image Editor panel
    image_file = 'ken_16_16.png'
    img = D.images[image_file]
    pixels = list(img.pixels)
    grouped_list = [pixels[ipx:ipx+4] for ipx in range(0, len(pixels), 4)]

    # Get width and height of image (in pixel)
    w = width = img.size[0]
    h = height = img.size[1]

    current_frame = 60 # SET YOUR KEYFRAME HERE

    for number in range(len( grouped_list )):
        bpy.data.objects['pixelcube.{number}'.format(number=number)].keyframe_insert('color', frame = current_frame)

    .... and so on.

    SOMETHING TO THINK ABOUT
    Now that I look at the code above, I started to think that I need to apply "Top Down Design".

    The code above works okey, but in order to make it more useful and easier to use for user, I probably need to tidy them up.

    Before even thinking for creating UI, I probably need to simplify the code:
    1. IMPORT: Import Pixel Art Image, limit to 64x64? Any bigger will be user's risk.
    2. CREATE: Create 3D Cube array matrix based on Pixel Art.
    3. MODIFY: If we like to modify, we need to specify the exact same Pixel Art dimension. This is easy to do as long we can access the same array of 3D Cube.
    4. KEYFRAME: Keyframe the Object Color at certain frame.
    5. VARIATION: Things like Offset is something to think about for best implementation.


    MKRdezign

    Contact Form

    Name

    Email *

    Message *

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