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

Slowly learning to disturb the Matrix.
Continuation of the "Parametric Snippet" series. This is part 3. A collection of random, less complex compound of nodes, where sometimes I just wrote about a single node in particular. Sometimes I do escalate and scale the complexity for each simple idea.

THE ART OF EMPTY-NESS



We will take respect to EMPTY object and will use this Empty with Sverchok to make something.

Before I start, sometimes I accidentally called "Empty" in Blender as "Locator" (just like in Maya), I apologize beforehand.

Today, let's talk about how we can use Empty Object in 3D scene and how we can use it inside Sverchok.

Empty is an object in computer graphics commonly use to refer to something that only have Transformation data. It does not render. It is great as reference for marking a position in 3D space. Useful when rigging and dealing with Constraints because we can see Empty in 3D view as some kind of shape.

Empty object, when brought into Sverchok, does not have Vertex, Edges, Faces data, but it actually has Matrix Transformation data. Which is actually cool.



Using Empty we can kind of have "direct control" of the Matrix in normal 3D environment, while at the same time, we can

This is a little bit similar to what happened if we are using Vertex Parent or Parent to Empty in Blender Edit Mode to control Mesh in Object Mode. But we can do more because we can start with nothing in Sverchok and output something.

We will embrace the art of nothingness or Empty-ness.

Empty => Object In => Matrix Out

Using the above recipe, we could extract Matrix information from an Empty object. This means we can get the Location, Scale, and Rotation data values.

NOTE: One thing to be aware of, when dealing with a changing Matrix, we may need to MANUALLY UPDATE the Sverchok node tree to see the result updating.

Either by disconnect and reconnect on of the noodle, or I usually have Blender playback running while moving around the Empty to update the transformation Matrix.

If we have Empty A and Empty B object, we could bring those two couple and marry them as a Line like below. The Edge data is all we need.




Moving Empty A and B in 3D View (Blender) and we have direct control over the ghost Line Start and End, inside Sverchok.

Next, I will duplicate the Node Tree above and I will create Empty C and Empty D objects.

This is just a tiny screen capture, you should be able to guess what I am doing here. Just duplicate the previous node tree and connect Empty C and Empty D as a line. 


  • Empty A + B = Blue Line
  • Empty C + D = Red Line

Those 2 ghost Lines are inside Sverchok, they are not yet exist in Blender 3D View. You could use BMesh node to output the line if you like.

However, what I want to do is to demo this cool INTERSECT EDGES node.

This INTERSECT EDGES node does exactly what you guess it to do: to return intersection point based on edges that are intersecting.

This node has a bit of quirks:
1. It stores some garbage Point data from the input, so we need to clean it up using Remove Doubles.

CORRECTION:
All edges that result from the mass intersection are stored as separate entities. Not removing doubles gives us the option to do other things with those edges. To keep it a general node, it doesn't assume we want any particular type of output -- just performs the operation as efficiently as possible. Effectively letting us choose if we want doubles or not. (thanks Dealga McArdle for this important correction!)

2. It needs data in to be joined using MESH JOIN node.
This is the expectation of the node because there is already another node that does the job. I believe this INTERSECT EDGES is one of very interesting "COMPOUND NODE" put together into a single node because Sverchok cannot do Node Grouping yet, because we are waiting for bigger thing.

If we take care the "quirks", we can get back the intersection points. At this moment, I think the Intersect Edges is returning the "result" of Points + Edge DATA altogether. If we want just the intersecting Points DATA, we need to filter it ourselves.




Ok, let's put INTERSECT business aside for now.

I move the Empty A-B-C-D into position like this. What I will do now is to create some POINTS in between Empty A-B and Empty C-D.


You know how to do this already from previous. I will show you again. Use EVALUATE LINE node. And for the Factor, we can give some values between 0 and 1 and it will further "divide" the points in between. This is great for laying out FENCES or legs for BRIDGES.


Will do the same thing for Empty C and D:


Now, what can we do with them?

LINE CONNECT simple example:

If you want to output a nice clean Polygon, use data from PLANE node. Don't directly use Line Connect "Do Polygons" unless you know what you are doing and can clean it up later.

Of course with data from PLANE, we need to ensure the DATA that goes in is "good" meaning it matches the TOPOLOGY output that you want.

This is a CLEAN result.

SNIPPET EXAMPLE FROM NIKITRON

In this example Nikitron made, we can see how we could create plane using Line and Clones from Matrix.


Line Connect node got updated and now has "circle first-last" option. I don't know what it does yet, but will certainly need to check that soon.

MORE THAN JUST MESH

Now, what if we don't really want to output just another Mesh Plane because that is kind of boring (although an interesting to study)? We can certainly do that.

I want to do more with INTERCONNECTING EDGES. Because this is something that is usually hard to do in Blender without scripting.

We can start doing something funny like below:

More Random Lines Connection

LIST SHUFFLE example:




This is also pretty basic, we have the PAIR connecting edges, but simpler and more expandable. If we provide REAL DATA that connects 2 Points in a Map, we can actually get an interesting data visualization.

Let say Facebook Data, we have list of NAMES of FRIENDS. We could laid out the information like above to see which one connect to which.

Maybe Google Map data and to see the Intersection points where the lines would meet.

Big Data Management = start to deal with complexity

Prettier Lines

Can those lines be PRETTIER? Yes, probably if we "smooth" the lines. Instead of LINEAR like now, we like it to be smooth and SPLINY (like a spline). In such case, we can just OFFSET push the lines from original using Vector Move, then add extra lines before the connecting lines.



Bake Out, combine, remove doubles, then Subdivision Modifier. You get a nicer prettier looking spline connectivity.

Prettiful Lines.


This Line Intersect idea can be used to generate a complex pattern. Read a bit of this thread at GitHub:
https://github.com/nortikin/sverchok/issues/181

SEPARATE LOOSE & BOUNDING BOX

We have 2 new nodes that are very handy when we really need them:
SEPARATE LOOSE and BOUNDING BOX.

SEPARATE LOOSE can separate a joined Mesh into separate array of data.

In Blender, we can have an object combined or joined together and often we like to separate them by loose. For every mesh that is loose (no lined points via edges or faces), it will be a separate mesh.


Above, you see many objects joined as single object. When brought into Sverchok, they are combined and seen as a single object with a single Matrix data.

Use SEPARATE LOOSE and you will see the Data got filtered or re-vectorized back each into separate LIST ala Sverchok.


At the moment, I am writing this, the Separate Loose does not have Matrix output. It would be nice to have the Center Matrix from each separate loose so we could disturb and push the Matrix of each object at will (another cool way to say: Transform each object separate).

We can "cheat" and get the center matrix using the BOUNDING BOX node.


Bounding Box node also does not give us the Center Pivot point. We could try to find a way to get the Center position. A quick trick is by selecting the MIN and MAX corner position from Bounding Box and then the point position in between = is our CENTER PIVOT.

The Bounding Box output is interesting, it is definitely 8 points. But the FIRST and LAST are our MIN and MAX points.



It works for 1 object, does it work on VECTORIZED DATA? Or ARRAY? We are lucky, it does work with multiple data coming in.




Knowing all these, we can have more control over the MATRIX position(s) of combined object(s). What does this mean?

We can use our own Matrix and re-position each separate objects at will.


TRICK: You could create Houdini's EXPLODED VIEW node using this idea.

Continue reading below for something more interesting.

ARRAY MODIFIER x SVERCHOK

If you are using ARRAY MODIFIER using normal Blender environment, you can work it together with Sverchok in unusual way, especially knowing that we have ability to control each Matrix for each separate objects (in the past, we can only do this for Polygon Faces component).



Few facts allowing us to do something like this:
1. Object In - Post Modifier option
2. Separate Loose node, to re-separate objects into ARRAY when DATA comes in as 1 object.

I thought this is simple, but quite powerful once again. We starting to have more control over the array of data, this time as Objects.

NOTE:
I am still waiting on the update of Bounding Box node or Separate Loose node to include the Matrix out to get the Center Position more easily.

A little bit stuck below where I cannot get each "Separated Mesh" into their Center Pivot.







However, below is an example node tree of how we can "explode the matrix", using Empty. In which the Position of Empty and the Scaling will affect the Matrix position of each object coming in.

Another step to create the "Exploded View" node ala Houdini 3D.



This node setup is not perfect, but also not completely failed because this is working to certain extent, however it can be slow if we have over 50000 points. Slow to bake, I mean. But 100000 points calculation is still pretty fast and will get faster, I am sure.



DISTURBING THE MATRIX

I sense the disturbance in the Matrix, just like what Yoda said:

"Great disturbance in the force I feel" - Yoda

Well, not exactly the same, but anyway, below is an example where we can use SEPARATE LOOSE and then feeding in some new array of Matrix data.

TEXT OBJECT x SVERCHOK



From what we know above, even though the node tree is not "perfect" we can do something like below:



I thought that was pretty cool. The Text Object is still alive and we can feed that into Sverchok and disturb the position of each text.

INTERESTING LINKS

http://www.blurrypaths.com/tagged/coding
http://wiki.scipy.org/Numpy_Example_List#head-528347f2f13004fc0081dce432e81b87b3726a33
http://ftp.mainframe.co.uk/mash/docs/MASH-3.0-Documentation.html

UPDATE:

Linus has added Mean and Center output port for Bounding Box! Thanks Linus! So that means our node tree is simplified and we don't need to find the Center Point manually ourselves.

Ok, I realized the node setup below does not give the perfect result, something is not quite right with the Matrix. I will have to investigate and will update again when I found the better solution.

I use Random Vector at the moment, but feel free to use Noise as well.



UPDATE AGAIN:

Apparently we can solve the little "glitch" using Vector Drop.

LINUS:
Separate meshes lives at the location they come from. However we do already have node for that for realign with zero, Vector Drop.


However, Vector Drop seems to have effect on rotation of each object. So the MOST CORRECT SOLUTION and CLEAR is as below, using VECTOR MATH-ADD, we substract the position to zero out each object, before we move them again! Isn't this Vector thing fun?


You see this kind of workflow carries the essence of good programming:
1. It is definitely alright to make errors, knowing we will find a better solution later. Don't leave bugs, but do try things.
2. There are many solutions to one problem. 
3. Work iteratively but as a whole. Continuous refinement.
4. Ask and search around for answers. Maybe it is already answered before.

Everything seems good now, we can proceed to the next stage!


Exploded View reborn.

Yummy Voronoi Cell with Random Color (using Python)

PYTHON WITH THE SPEED OF LIGHT
Are we ready to continue and dig deeper into Blender using Python? Maybe!

I said "maybe" here because probably it is better to familiarize with the simple things first. Sometimes we tend to go a little fast. With programming, I realized that it is better to go slow but steady. Like a snail.

I am both advising you and keep questioning myself.

  • Have I really fully understand the concept of programming? Pretty much.
  • Have I understand the Python programming language in general? A little.
  • Have I really understand the BPY (Blender Python)? Starting to.
  • Have you studied some elegant Python scripts out there? These days, I am searching for it.
At this moment, I kind of just started to understand more.

Suddenly I can do a lot of things that I never thought before, but more than often I have to fall back so many steps because apparently I did not quite understand the fundamentals or there are another way or better way to do things more elegantly.

I found programming is really quite funny after all:
  1. The language itself can be twisted in the way it looks elegant or horrible. The program may still work.
  2. It is not the language, but how you use the language that really matters in the end.
  3. It continue to evolves.
  4. It is really interesting when programming language is used outside the usual context.
  5. It is addictive.
In the past few weeks, I have started to dig a lot of Python and Blender Python codes. Whenever I like to do something using Python, the answers are usually out there, but really all over the place. Sometimes it took me hours just to understand or to do a simple thing, because there is simply not enough documentation.

There are many high-end Python coders out there writing some random Python codes, but more often really hard to understand for beginners. The codes vary too: some obsolete for old Blender, some for newer Blender API but no longer working or needs some updating, to latest Blender API, which we are probably trying to learn now.

Sometimes, the older code and documentation can still be helpful to understand the logic and the flow of data. Such as:
http://www.blender.org/documentation/blender_python_api_2_59_0/info_overview.html

Heap loads of information out there. Our task is to structure and organize it somewhat.

HELPS ARE AROUND
Luckily, there are also some brilliant Python coders that does blog and document their code nicely and explain it for beginner coders like me:, such as Dealga from blenderscripting.blogspot.com.au and Crouch from https://sites.google.com/site/bartiuscrouch/

That Blender Scripting blog really helps tremendously in understanding the fundamental of Blender Python. And I also talked to another Blender Coders, such as Liero from Blender Artist, he is also really helpful.

I am also started to get better understanding of Python recently, while doing this CG Workshop on Maya Python with Shaun Friedberg. The workshop helps to force myself to do some exercise, to understand what you can do with Python and scripting. Even though the workshop is for Maya, it is really applicable to Blender.

One needs to be active and pro-active in finding the answers. Sometimes it is good to stop and think. When asking questions, it is also good to ask question that gives you the understanding, not just the answer.

PYTHON IN BLENDER VS PYTHON IN MAYA
I found that Python implementation in Blender is more elegant and complete compared to Maya. Blender one just needs more complete documentation. Python in Maya is still just a wrapper of MEL (Maya Embedded Language).

It is pretty overwhelming once we understand how Blender Data is stored and we can access the Data and manipulate it using Python.

However having Python language that goes around the API, allowing a lot of flexibility in Maya in term of Data flow. That is how I see it. Same thing with Python in Blender.

Python really rocks.

WHAT YOU CAN ALREADY DO WITH PYTHON THUS FAR 
By now, I am guessing we should pretty much understand how to:
  • List. Get and Query information or data from inside Blender or outside data
  • Randomize values and list
  • Transform values
  • Passing, Filtering and Processing data
  • Create or Add Values
  • Modify or Replace or Combine Values
  • Iterate through many objects
  • Creating own Functions based on Blender Python API
Those are the basic logic bricks we can use to construct some useful codes. We have not really touch on how to create UI for the script, but that will come a bit later.

Now, I am going to share with you some of my random research and findings and show you some more example scripts to manipulate Object and Component Data inside Blender.

Below scripts are probably rough and mostly I did not even make them into elegant functions yet. They are just a once off script.

In the future, I promise to tidy up some of the scripts and add UI.

OBJECT AND COMPONENT DATA
We need to make distinction between OBJECTS and COMPONENTS. Object will usually deal with Transformation (Location, Rotation, Scale) and keyable attributes in Object Mode. While Component is more like what is happening in Edit Mode (Vertex, Edges, Face) or Paint Mode, or even things like UV information.

A. RANDOMIZE TRANSFORMATION (SCALE, ROTATION, LOCATION)
Let's do a simple exercise. This example is one of the simplest and most popular example. Ability to quickly randomize the transform of 3D objects.

I made a quick doodle script like below, but it can probably be enhanced:

SCRIPT: Randomize Scale of Selected Objects


import bpy
import random





# Define a function to randomize scale



def randomizeScale (minScale, maxScale):

selected_objects = bpy.context.selected_objects

for object in selected_objects:
randX = random.uniform (minScale, maxScale)
randY = random.uniform (minScale, maxScale)
randZ = random.uniform (minScale, maxScale)

object.scale = (randX, randY, randZ)


# Example how you would run the function and giving it required arguments
# which is the two value minScale and maxScale



randomizeScale(0.3, 2)




  • With above example, I am actually defining a simple function that does the job and calling the function at the bottom. You don't really need to create a function, but it is a lot nicer because by doing that we can reuse it later. You will find this kind of function creations really often with Blender Python.
  • The breakdown of above script:
    1. User needs to select some objects. I did not write error checking.
    2. Tell Blender to put selected objects into a variable named "selected_objects".
    3. Do an iteration loop that will create random value in X, Y, Z and then tell Blender to scale the object with those random values in 3 different XYZ axis.

Very simple beginner script.

In fact, Blender already have Built In Script and Function that does above and more, if you search inside Blender bundle, there is a Python script named: object_randomize_transform.py.

It is a very good idea to look at that script and see the construct. I actually felt embarrassed when I look at that Blender provided script and compare it with my own script above! :) This means there are still a lot to learn, which is good.

The  object_randomize_transform.py is an example of very mature script and you can learn a lot. If you understand the script inside-out, you can certainly modify it for your own usage, maybe you could further improve it.



The resulting Random Transform using object_randomize_transform.py can also be adjusted once via the UI Tool Panel. Neat.



B. SELECT OBJECTS BASED ON DISTANCE TO EMPTY
Based on Example Script "Python In Maya" by Shaun Friedberg.
http://www.pyrokinesis.co.nz 



SCRIPT: Select Meshes Within Specific Distance of Empty



import bpy

def selectMeshBasedOnDistance(distance, empty):
"""
A simple script to calculate the distance of all
mesh in the scene relative to the selected camera
"""

# Firstly, deselect all objects in the scene
bpy.ops.object.select_all(action='DESELECT')

# Get all objects in the scene of type 'MESH'
meshes = []
for item in bpy.data.objects:
if item.type == 'MESH':
meshes.append(item)

# Check if empty argument given is a type of empty
if empty.type != 'EMPTY':
print("Please specify an empty!")

# Create and clear an array to store mesh within the specified distance
meshToSelect = []
del(meshToSelect[:])
print(meshToSelect)

# Get the camera positions in world space
#emptyXform = empty.matrix_world * empty.location
emptyXform = empty.location

# Get the mesh xform and distance from camera
for mesh in meshes:
#meshXform = mesh.matrix_world * mesh.location
meshXform = mesh.location
meshDistanceFromEmpty=(meshXform-emptyXform).length
print(mesh, meshDistanceFromEmpty)
if meshDistanceFromEmpty < distance:
meshToAdd = []
meshToAdd = mesh
meshToSelect.append(meshToAdd)
print(meshToSelect)

# adding if for error checking, Python does not like selecting empty list
if(len(meshToSelect))>0:
for item in meshToSelect:
item.select=True

# My Test 1:
# selectMeshBasedOnDistance(20, bpy.context.selected_objects[0])

# My Test 2:
selectMeshBasedOnDistance(5, bpy.data.objects['Empty'])






  • Basically, we specify a distance value, and then the Python script will check for objects within that radius distance from Empty and select those objects.
  • It will measure from the center origin of the mesh.

C. SHUFFLE OBJECTS TRANSFORMATION USING PYTHON
Based on Example Script "Python In Maya" by Shaun Friedberg.
http://www.pyrokinesis.co.nz 






SCRIPT: Shuffle the Positions of Selected Mesh Objects


import bpy
import random

def completeShuffle(listToShuffle):
'''
'''

#
if not isinstance(listToShuffle, list):
raise RuntimeError ('Please provide a list of items to shuffle: {listToShuffle}'.format(listToShuffle = list) )


# Get the length of the list
numOfListItems = len(listToShuffle)

# Loop over the list until none are left
while numOfListItems > 1:

# Decrement numOfListItems
numOfListItems = numOfListItems - 1

# Select an item randomly and shuffle
randomItem = random.randrange(numOfListItems)
listToShuffle[randomItem], listToShuffle[numOfListItems] = listToShuffle[numOfListItems], listToShuffle[randomItem]

# Return our shuffled list
return listToShuffle

# USAGE testList = [1,2,3,4,5]


def randomlySwapSelectedMesh():
meshes = {}
meshes['transforms'] = []
meshes['mesh'] = bpy.context.selected_objects

# Check if there is more than one mesh selected
if not len(meshes['mesh']) > 1:
raise RuntimeError('Please select more than one mesh to swap!')

print('ORIGINAL POSITION')

# LIERO: don't append object location to the list, use location.copy()

for mesh in meshes['mesh']:
#meshes['transforms'].append(mesh.location)
meshes['transforms'].append(mesh.location.copy())
print('Mesh: ', mesh)
print('Old Location: ', mesh.location)

print('-----------' * 5)

# Shuffle the list of transforms
#random.shuffle(meshes['transforms'])
completeShuffle(meshes['transforms'])

print('AFTER SHUFFLE PROCESS')

# Iterate over mesh and apply new transforms
for newTransform, mesh in zip(meshes['transforms'], meshes['mesh']):
print('New Location: ', newTransform)
print('Mesh: ', mesh)
mesh.location = newTransform

print('-----------' * 5)

randomlySwapSelectedMesh()






  • You select some meshes (two or more) and shuffle the location using the script.
  • Remember that it will SHUFFLE based on mesh origin.
D. UNDERSTANDING VERTICES, EDGES, FACES OF MESH
Resources:


I sneaked in an additional Python code at the bottom of this old blog post:
http://blendersushi.blogspot.com.au/2013/03/python-mix-and-match-code.html

The code I added there will create a simple Mesh Graph (Vertices and Edges only) based on data imported from outside Blender.

The idea is really to provide and pass on some data to Blender and tell Blender to create some Mesh component (Vertex Positions, which later converted into Edges and Faces)

Let's try to deconstruct and reconstruct a mesh.


import bpy

### THE CONSTRUCT OF EDGE MESH ###

scn = bpy.context.scene

# Create Mesh Data
myMesh = bpy.data.meshes.new('myMesh')

# Vertex, Edge and Face Data
vertData = []
edgeData = []
faceData = []

# Finally putting all the information together into Mesh Object
myMesh.from_pydata(vertData, edgeData, faceData)

meshOb = bpy.data.objects.new('myOb', myMesh)

scn.objects.link(meshOb)


Below construct will create just Vertex inside Mesh Object:


import bpy

### THE CONSTRUCT OF VERTEX MESH ###

scn = bpy.context.scene

# Create Mesh Data
myMesh = bpy.data.meshes.new('myMesh')

# Passing some XYZ data for Vertex Location
vertData = [(0,0,0), (0,4,0), (4,4,0), (4,0,0)]


edgeData = ()

faceData = ()

# Finally putting all the information together into Mesh Object
myMesh.from_pydata(vertData, edgeData, faceData)

meshOb = bpy.data.objects.new('myOb', myMesh)

scn.objects.link(meshOb)


  • Creation of Vertices seems to be quite simple, we simply passing some 3 Tuple value XYZ that will later translate as Vertex Position.
  • We can leave Edge and Face data empty.
Below construct will create Edges inside Mesh Object: (Vertex data is required)


import bpy

### THE CONSTRUCT OF EDGE MESH ###

scn = bpy.context.scene

# Create Mesh Data
myMesh = bpy.data.meshes.new('myMesh')

# Passing some XYZ data for Vertex Location
vertData = [(0,0,0), (0,4,0), (4,4,0), (4,0,0)]

# Connect pair of Vertices data as Edges based on list order of vertices
edgeData = []

a=[]
b=[]

for number in range(len(vertData)-1):
a.append(number)
b.append(number+1)

edgeData = list(zip(a, b))

faceData = ()

# Finally putting all the information together into Mesh Object
myMesh.from_pydata(vertData, edgeData, faceData)

meshOb = bpy.data.objects.new('myOb', myMesh)

scn.objects.link(meshOb)


  • With Edge, I am using the zip() method to connect vertices together.
  • Edges simply requires pair of two, based on indices of Vertex in the list.

Below construct will create Faces inside Mesh Object: (Vertex data is required)



import bpy

### THE CONSTRUCT OF FACE MESH ###

scn = bpy.context.scene

# Create Mesh Data
myMesh = bpy.data.meshes.new('myMesh')

# Passing some XYZ data for Vertex Location
vertData = [(0,0,0), (0,4,0), (4,4,0), (4,0,0), (0,0,2), (0,4,2), (4,4,2), (4,0,2)]

edgeData = ()

# Normal Facing Up, Clockwise
# Normal Facing Down, Counter-Clockwise
faceData = ((0,3,2,1), (4,5,6,7))

# Finally putting all the information together into Mesh Object
myMesh.from_pydata(vertData, edgeData, faceData)

meshOb = bpy.data.objects.new('myOb', myMesh)

scn.objects.link(meshOb)








  • With Faces (polygons), we simply tell Blender to create faces based on the indices of Vertex. We can have a Face with Tris (3 vertices), we can have Quads (4 vertices), and N-Gons.
  • Face Normal is Facing Up if we go Clockwise and Face Normal is Facing Down if we go Counter-Clockwise.
Read this thread below, it is both informative and hilarious: (how to create house using Python?)
http://www.blender.org/forum/viewtopic.php?t=25794&sid=3bf3363ed465da77db483777003f1459


Anyways, continue with Mesh construction, I found it is easier to understand the Indices and Index stuff if we can visualize the Index of every Vertices.

There is this Index Visualizer from Bart Crouch:
https://sites.google.com/site/bartiuscrouch/scripts/index_visualizer_25
http://blenderartists.org/forum/showthread.php?180683-Index-Visualiser-for-Blender-2-5/page3
http://www.pasteall.org/38724/python

Further study:
http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Cookbook/Code_snippets/Meshes
http://www.blenderaddons.com/scripts/random_face_color.php
https://vimeo.com/40389198


E. VERTEX COLORS
Resources:

Here we are going to look at the basic on how to get to Vertex Colors of a mesh.


1. Create our own Vertex Colors layer.
The Blender Python scripts below will create the default Vertex Colors layer called 'Col':

A. Via BPY OPERATOR:
bpy.ops.mesh.vertex_color_add()

B. Via  BPY DATA MESHES: 
bpy.data.meshes[0].vertex_colors.new()

Using BPY DATA MESHES is actually a much more preferable way, because it is directly accessing the component level. I keep telling myself NEVER to rely on BPY OPS.

BPY OPS is more like a shortcut for user to access the tool and commands.

2. Finding where Vertex Color data is really located.
It took me a while searching the Internet for this information. Since I cannot rely on Blender API documentation. There might be information at Blender documentation that I missed, but anyhow, in the end I found the answer by doing this kind of thing inside Blender Python Console.


We can see that the Color Data of Vertex Colors are really stored inside:
bpy.data.meshes[].vertex_colors[].data[].color

I supposed we can started to understand the pattern. We seems to always refer to the index of something.
bpy.data.meshes[0].vertex_colors[0].data[0].color

That zero there inside brackets means we are referring to the first indices of the LIST of big data that you can access in Blender.

We can also apparently get the data by using the KEYWORD:
bpy.data.meshes['Cube'].vertex_colors['Col'].data[0].color

For non-programmer like me, this is quite a big revelation. Especially when I can also use Python to dir(), list(), and ask how many total of data available by using len().



3. Display and Manipulate Vertex Color Data.
To be able to see Vertex Color in Blender 3D Viewport, we need to enable it under Material. So, once you create the Vertex Color Layer using the code above, as so:
bpy.ops.mesh.vertex_color_add()

... you need to enable Vertex Color options under Material Property tab.


You need to also adjust the 3D Viewport to display as GLSL, Textured Solid ON.


This way, we can really see the changes of Vertex Color as we modified it.

NOTE: Remember that I am using the Blender default scene for this, with the default 3D cube, just for the simplicity. You can further modify the script for your own usage.

Let's try something. The code below will apply RGB value (1.0, 0.0, 0.0) = red, to the 1st indices of the Default Cube.


import bpy



# Hard coded Mesh (pointing at Blender default cube)
mesh = bpy.data.meshes['Cube']

mesh.vertex_colors[0].data[0].color = 1.0, 0.0, 0.0


We know above that there are a total of 24 indices for Vertex Color of this default Cube with 6 Faces. Each Face of this cube has 4 different colors (from 4 vertices of single quad Face).


So if we want 1 Face to receive full color, we do something like below:



import bpy

# Hard coded Mesh (pointing at Blender default cube)
mesh = bpy.data.meshes['Cube']

mesh.vertex_colors[0].data[0].color = 1.0, 0.0, 0.0
mesh.vertex_colors[0].data[1].color = 1.0, 0.0, 0.0
mesh.vertex_colors[0].data[2].color = 1.0, 0.0, 0.0
mesh.vertex_colors[0].data[3].color = 1.0, 0.0, 0.0




We can use Python Loop to go over every indices to give the same Vertex Color like below:



import bpy

# Hard coded Mesh (pointing at Blender default cube)
mesh = bpy.data.meshes['Cube']

totalVertCol = len(mesh.vertex_colors[0].data)
colorRed = (1.0, 0.0, 0.0)

for i in range(totalVertCol):
mesh.vertex_colors[0].data[i].color = colorRed







Further on:

DOODLE SCRIPT: Applying single random color to ALL vertices to Blender Default Cube



import bpy
import random

# Create Vertex Color Layer, if not already set
# bpy.ops.mesh.vertex_color_add()


# Do this once for now

# Hard coded Mesh (pointing at Blender default cube)
mesh = bpy.data.meshes['Cube']

totalVertCol = len(mesh.vertex_colors[0].data)

colR = random.random()
colG = random.random()
colB = random.random()

for i in range(totalVertCol):
mesh.vertex_colors[0].data[i].color = colR, colG, colB



Everytime you run the script above, the Cube is getting a whole new random Vertex Color:






DOODLE SCRIPT: Applying multiple random color to ALL vertices to Blender Default Cube


import bpy
import random

# Hard coded Mesh (pointing at Blender default cube)
mesh = bpy.data.meshes['Cube']

totalVertCol = len(mesh.vertex_colors[0].data)

for i in range(totalVertCol):
colR = random.random()
colG = random.random()
colB = random.random()
mesh.vertex_colors[0].data[i].color = colR, colG, colB






UPDATE 20130326:
See also how a more experienced coder does it at Blender Scripting Blog (Dealga McArdle):
http://blenderscripting.blogspot.com.au/2013/03/vertex-color-map.html


DOODLE SCRIPT: Applying single random color to ALL vertices to Blender Default Cube



import bpy
import random

# Create Vertex Color Layer, if not already set
# bpy.ops.mesh.vertex_color_add()


# Do this once for now

# Hard coded Mesh (pointing at Blender default cube)
mesh = bpy.data.meshes['Cube']

totalVertCol = len(mesh.vertex_colors[0].data)

colR = random.random()
colG = random.random()
colB = random.random()

for i in range(totalVertCol):
mesh.vertex_colors[0].data[i].color = colR, colG, colB




Now, let's tweak the code to be more useful and can be applied to ONE or MANY objects at the same time. Instead of hard-coding it to default Blender scene with default Cube above.

FINAL SCRIPT: Give Random Vertex Color for EVERY Selected Meshes

Basically we wanted to iterate over every object that is selected by user and applying random Vertex Color, this means, we need to create Vertex Color Layer beforehand and then apply the Vertex Color.


import bpy
import random

# Get selected objects
selected_meshes = bpy.context.selected_objects

# Add Materials that respects the Vertex Color for
# each selected and active objects

for mesh in selected_meshes:
mat = bpy.data.materials.new('VertexMat')
mat.use_vertex_color_paint = True
mat.use_vertex_color_light = True
mesh.data.materials.append(mat)

# Tell Blender to Update the Material
bpy.data.materials.is_updated = True

for mesh in selected_meshes:
# Create Vertex Color for each selected meshes
# bpy.context.selected_objects[0].data.vertex_colors
mesh.data.vertex_colors.new()

# Get Total Length of Vertex Colors for each selected meshes
# len(bpy.context.selected_objects[0].data.vertex_colors[0].data)
totalVertCol = len(mesh.data.vertex_colors[0].data)

# Iterate over every mesh vertex color and give it a single colour

colR = random.random()
colG = random.random()
colB = random.random()

for i in range(totalVertCol):
mesh.data.vertex_colors[0].data[i].color = colR, colG, colB






In order for the code to work right away (without user needing to tick some options from every Material), we need to also make sure that each object is assigned a Material which respects the Vertex Color Layer.

So we probably want to automate that using Python script as well. I actually already added extra code above that does exactly that:

for mesh in selected_meshes:
    mat = bpy.data.materials.new('VertexMat')
    mat.use_vertex_color_paint = True
    mat.use_vertex_color_light = True
    mesh.data.materials.append(mat)

I separated the code into its own block for clarity. You can actually put the whole block into one.

Make sure that you change the 3D Viewport to reflect the Vertex Color applied:





It will render fine for good old Blender Internal renderer. Below is 9 x 9 = 81 Poly Cube Objects, each of them is assigned Vertex Color 'Col' layer and random color for all faces.


The above script works fine on multiple Objects.

If you want to give random Vertex Color for every Faces of selected objects (must be in quads), you can use the script below:


SCRIPT: Give Random Vertex Color for EVERY FACES of Selected Meshes

NOTE: This script works only for mesh with Quads faces only. Suzanne the Monkey for example, has some meshes that are not Quad. But you can Subdivide it once to make sure ever face is Quads.



'''
NOTE: The Script only works on surface with Quads Faces ONLY
'''

import bpy
from random import *

# Get selected objects
selected_objects = bpy.context.selected_objects

# Create a single Material that respect Vertex Color
mat = bpy.data.materials.new('VertexMat')
mat.use_vertex_color_paint = True
mat.use_vertex_color_light = True

for object in selected_objects:

# Get Mesh Data instead of Objects
mesh = object.data
object.data.materials.append(mat)

print('-'*5, ' START ','-'*5 )

# Create new 'Col' Vertex Color Layer
mesh.vertex_colors.new()

# Vertex colour data
vertexColour = mesh.vertex_colors[0].data
faces = mesh.polygons

# Create random vertex colours
vColour = [(random(),random(),random()) for i in mesh.vertices]

#print(len(vColour))
#print(vColour)

#print(len(vertexColour))g

#vertexColour[2].color = 1,1,1
#vertexColour[6].color = 1,1,1
#vertexColour[7].color = 1,1,1
#vertexColour[3].color = 1,1,1

# asign colours to verts
for i in range(len(faces)):
v = vertexColour[i]
f = faces[i].vertices

print(f[0])
print(f[1])
print(f[2])
print(f[3])

print(vColour[i])

vertexColour[i*4 + 0].color = vColour[i]
vertexColour[i*4 + 1].color = vColour[i]
vertexColour[i*4 + 2].color = vColour[i]
vertexColour[i*4 + 3].color = vColour[i]


print('-'*5, ' END ','-'*5 )









The script above is the update and combination of the scripts suggested below. I still don't understand the whole thing 100% yet, but I will improve the script in the future.


References:


The script above is basically looping over many things (objects, mesh faces, mesh vertices) and finally assign the color into the Vertex Colour.

We know that for Quad, we always 4 vertices to worry about. And for Vertex Colors, it is really expecting 4 Vertex Color, one for every vertex inside Face. So the script can be made simpler like above. If the mesh contains Tris, N-Gons, we have to take that into consideration.

Maybe in near future, we should improve the script so that it will cleverly and nicely loop over the face vertex and assign the color into Vertex Color Array.





MATERIAL COLOR, OBJECT COLOR, VERTEX COLORS

Remember that the above is NOT Material Color, NOR Object Color, it is Vertex Color layer that is being assigned. Make sure you understand the differences.

Object Color will simply kind override the Material Color. It is there for convenient, I supposed. Just for 3D Viewport color.

If you want to access Object Color via Python, you can too. You can supply R, G, B, and Alpha value.



Example doodle Python script to randomize Object Color of currently selected Objects:


import bpy
import random

selected_objects = bpy.context.selected_objects

for object in selected_objects:
    redValue = random.random()
    greenValue = random.random()
    blueValue = random.random()
    alphaValue = 1.0

    object.color = (redValue, greenValue, blueValue, alphaValue)






Will it render? Yes, somewhat you can. If you turn on "Object Color" option under Material that you assigned to that object.

Only works for Blender Internal renderer. Unless I am wrong and you can actually render in Cycles... No idea, how about you?

EXTRA: RGB and HSV COLOR CONVERSION

If you are tired to see the ugliness of random color from RGB, you can instead use random HSV color, which usually gives you a much nicer visual color range.

Since we are still doing Object Color and it is really simple to change, we can touch a bit on HSV Color.


SCRIPT: Example on using HSV Color instead of RGB Color


import bpy
import random
import colorsys


selected_objects = bpy.context.selected_objects

for object in selected_objects:

randomHueValue = random.uniform(0.0,0.5)

convertedRGBvalue = colorsys.hsv_to_rgb(randomHueValue, .6, 1.0)
# This will return Tuple of (R,G,B), you need to extract them using Index

alphaValue = 1.0

object.color = (
convertedRGBvalue[0],
convertedRGBvalue[1],
convertedRGBvalue[2] ,
alphaValue)










The secret is to use Python built-in colorsys module to convert HSV into RGB:


Really handy and you will see a much nicer random Color result because it goes around Color Spectrum.

It could be tricky to play with numbers using Python to get the random color variation that you want. Sometimes I jump into procedural visual programming tools like Houdini or NodeBox3 just to help with it.
http://nodebox.net/node/documentation/tutorial/getting-started.html


It is possible using Python and colorsys module to generate Color Range very specifically, such as:
  • Give 10 random colors within range of minValue and maxValue of Hue.
  • Give me 24 random colors within range of minValue and maxValue of Saturation
Guaranteed you will get a nicer random colors that way.

Remember that you can also specifically give a very specific List of Colors (that you have chose or selected from something like Kuler) to use to be assigned to the objects.

Below is an example Doodle Python script that does more specific color picker to be randomly assigned to selected mesh:



import bpy
import random
import colorsys
import math

# Define Python code to create list of range of specific Random Float Value

def frange5(limit1, limit2 = None, increment = 1.):
  """
  Range function that accepts floats (and integers).

  Usage:
  frange(-2, 2, 0.1)
  frange(10)
  frange(10, increment = 0.5)

  The returned value is an iterator.  Use list(frange) for a list.
  """

  if limit2 is None:
    limit2, limit1 = limit1, 0.
  else:
    limit1 = float(limit1)

  count = int(math.ceil(limit2 - limit1)/increment)
  return (limit1 + n*increment for n in range(count))


# Create Specific List of Values
randomHueValue = list(frange5(0.0, 1.0, increment=0.25))


# Now, do some stuff in Blender

selected_objects = bpy.context.selected_objects

for object in selected_objects:
    
    convertedRGBvalue = colorsys.hsv_to_rgb(randomHueValue[random.randrange(0,4)], .8, 1.0)
    # This will return Tuple of (R,G,B), you need to extract them using Index
    
    alphaValue = 1.0
    
    object.color = (
                    convertedRGBvalue[0], 
                    convertedRGBvalue[1], 
                    convertedRGBvalue[2] , 
                    alphaValue)
 
 

It gets a bit complicated, but you will get it eventually.

Understand more about Color Theory using Blender:

BACK TO VERTEX COLORS...
Below is the proof that if I am giving a random Vertex Color inside the iteration loop for every vertex:


Example above is very generic, but it opens up a lot of possibility once you understand it.

Also one important point to note: With the above script, I am assigning every object with its own unique Material, so we end up with many materials.

But for things like Object Color and Vertex Color, we could actually assigning a Single Material for All, each with its own Vertex Color Data. This is probably much more efficient for some cases.

For example: with Pixel Python Script that I did in previous post, instead of having thousands of Materials with different Diffuse Color, we could just have a single Material, and thousands of Vertex Color layer for each object.

Below is a Single Glass Material for Cycles, with random Vertex Colors.



NOTE: Remember also that for this Vertex Color thingy to work with Cycles, remember you need to pass on the "Col" Attribute Data inside the material in the Node Editor.

Here is Suzanne with each Vertex Color assigned different color:




SELF-CHALLENGE:

  • How do we create Python script that Randomize every color of the face using Vertex Color then? It should be smart enough to get N-gons Face and iterate over every Vertices under that Face.
  • Apply the knowledge above and optimize the Pixel Scripts.
Random Color on Cell Fracture + Blender Bullet Physics



MKRdezign

Contact Form

Name

Email *

Message *

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