Warning: technical post ahead :P

Recently buub0nik opened my eyes to the power of scripting within Blender. Behind the scenes, most of the interface and shortcuts are actually scripts. There is even a console within Blender you can open and directly input commands.

How is this helpful to us? In a stage I'm working on there is a section with a large number of moving objects. They were frustrating to deal with because if I decided to change them I had to repeat the same change for each object. Huge waste of time, and I eventually gave up fine-tuning that section. _However_, through the magical power of scripting, I can now change attributes to all of those objects at the same time.

For example, instead of manually adding a "no_grapple" flag to 30+ objects, I can write the following script:

for p in bpy.context.selected_objects:
p["no_grapple"] = 1.0;

Bam, change done! Since scripting is so deep in the Blender workflow, you aren't limited to simple operations like the above attribute change. I wrote a script earlier that swapped out shape information between objects, effectively giving them entirely new vertices. You can even create vertices programatically! Don't be surprised if you see some serious math porn tucked away in a few of the levels :3

No comments:

Post a Comment