Monday, February 22, 2016

Speed Scripting: Cube... Clouds.

I was thinking "I really need to get started using Blender again, it's been a week or so."

And I had an idea I wanted to pop out, and a few minutes of time.

So I made it; here it is!

The Random Cube Cloud Generator

It makes cloud-ish clusters like this:



What it does is basically create random cube clusters in random locations within a certain area.



You can determine how many clusters, the size of the clusters, how many cubes per cluster, the size of the cubes, and the size of the area in which the clusters spawn.

It could be modified to make clouds, weird terrain, or... something. I'll probably play with it and post about it later.

To use:

 

1. Copy/Paste all the text from the file to your blender python interpreter.

2. The following is how to use the script:

cubouds(quantity, range, cluster size, quantity of cluster cubes, cube size)

So an example you could copy/paste is this:

cubouds(15,20,5,7,.5)    #Just play with these parameters.


Here's a download link:



Stay tuned for more awesomeness!!! 

Friday, January 22, 2016

Voxel Landscape Script

Cubes. YAY.

Yes. It happened. I was playing with cubes, it was bound to happen. 

I messed with the Voxel Blob script and managed to create a funky landscape tool.

It looks really awesome...



Since I built it off of my voxel blob script, I can also use addbase() to create custom start locations!!

Progress 1
Progress 2

AND if you want to save memory (or cubes) you can create a plane or whatever shape you want in any spot, and it will refuse to place cubes beyond that point. So I can use a plane to keep the script from needlessly a pile of awesome where I'm not going to see it.










Progress 3
OH and I should mention I made a script for assigning awesome colors to objects in a scene based on elevation. I'll post that if you want too.


You can user that in conjunction with anything really, not just voxel stuff. Here's a scene I made via the landscape tool, and that colorizer;


ALSO... the landscape generator actually has this behavior where it tries reach upward until the cubes reach about 9 blender units on Z, where it then pans out horizontally, and then begins reaching upward again around 12 blender units on the z axis. You can see in the image above where it tries to thin out and reach up, and where it tries to pan out and cover a wider area.

The best way to achieve this result is by using addbase() to create base points around the area where it tries to pan out, (0, 10, & 16 are the points where it pans out.) otherwise it just gets stunted and makes funky mountains and... tower things. Still pretty cool.



So to USE the Voxel Landscape tool, simply add as many base cubes as you like with;

addbase(x,y,z) #This is used to add custom start locations

Then use the following to generate cubes;

cubecraft(quantity)     #You can use this repeatedly to add more and more.

I usually generate larger stuff in smaller increments just so I don't irreversibly freeze Blender over.

Here's the download link for the Voxel Landscape Generator. The color assignment script download and tutorial will be in the next section...

Download Voxel Generator
 

MAKE COLORS...

NOW, for the color assignment script, what it does is assign a number of materials you've created to several objects. Based on how far up the Z axis on the object is, is what will determine which material is assigned. There were several examples of this above, but here's another one;


For this I created 18 materials. One for each Blender unit on the Z axis. It always starts with zero. You could change that if you want, but for now it starts on zero.

To use it you it simply select whatever objects in a scene you want colorized, and copy these first 3 lines into Blenders python interpreter;

#Get the objects you want colored selected before running this.
golst = []       
for x in bpy.context.selected_objects:
    golst.append(x)

Then go ahead and either select a totally hidden object, or create one that's meant to be disposed of later and create every material you want in the scene. Starting with whatever material is lowest on the Z axis, and ascending to the whatever material will be highest on the Z axis.

Once you've finished creating the materials, make sure the same object containing the materials is selected, and run the next 3 lines;

john = []
for x in bpy.context.object.data.materials:
    john.append(x) 

Then go ahead and run the following lines;

for x in golst:        #The bottom colors go first.
    loc = x.location.z
    for r in range(len(john)):
        if loc > r-.5 and loc < r+.5:
            x.data.materials.append(john[r])


BAM!!! ENTER COLOR!!!

You can download the whole color script here: 

Download Color Assignment

Voxel Blob V.2

I totally remade the Voxel Blob script. It behaves slightly differently, and It just works in a much simpler, faster, and more manageable manner.

You can see it's a bit more compact. The first one looked almost like voxelated coral. -Which was cool I might add, but this version is designed for customizability.
And I also added a little function to add base cubes wherever you like, for the sake of having SOME control over how it produces itself. It merely determines start locations. You can use more then one at a time. (As many times as you like!)

Here's a couple rounds of addbase()
Here is what came of it.
I AM DONE WITH GREY.


If you'd like to play with it, (It's much easier to manipulate then my previous version) (And it has comments this time!) here's how to use it, and a download link:

First just copy all the text in the .py file to your blender python console,

To add base cubes just type;

addbase(x,y,z)

To add a heaping voxel blob onto your base cubes, (Without any base cubes, it just starts at (0,0,0)) just type;

cubecraft(quantity)

And that's it! You can continue to uses cubecraft() as many times as you like to continually add onto your... blob. Your awesome blob. Awesome Bob.

 - Download Here -



Stay tuned for whatever!!