0
$\begingroup$

I need to prepare an abstract still image that is going to include numerous little cubes, let's say 100, organized in a stream-like order. While on the left, they should be disorganized - meaning various rotation and distorted location, the cubes on the right should be perfectly aligned. I suppose this should be somehow possible to achieve in Blender without having to manually position each cube, but I'm not sure how. I realize I could use a modifier to change the rotation and position of cubes in an array, but do not know how to make the cubes get into "orderliness" on the right side.

If someone more versed in Blender could point me to the right direction, I would be very grateful.

The picture below is a simple PowerPoint illustration of what I need to achieve. Of course, we're talking about cubes and not rectangles, but the idea is hopefully clear.

enter image description here

$\endgroup$
2
  • $\begingroup$ so do your cubes intersect or are they at different Z levels? $\endgroup$
    – moonboots
    Apr 28, 2022 at 12:34
  • $\begingroup$ It can be either way. Ideally, they could intersect AND be on different Z levels, if there was enough of them. $\endgroup$
    – Ondrej
    Apr 28, 2022 at 12:43

2 Answers 2

2
$\begingroup$

linear

enter image description here

Cubic

enter image description here

Rotate effect

enter image description here

import bpy, random

objs = bpy.data.objects
# select and delete all object
if objs:
    bpy.context.view_layer.objects.active = objs[0]
    bpy.ops.object.mode_set(mode='OBJECT')
    bpy.ops.object.select_all(action = "SELECT")
    bpy.ops.object.delete(use_global=True, confirm=False)

# create 12x6 cube
x, y = 0, 0
ran_fac = 0

def ran_fn(n): # random function for modify random number
    return n*n*n

for a in range(12):
    y = 0
    for b in range(6):
        bpy.ops.mesh.primitive_cube_add(size=2, enter_editmode=False, align='WORLD', location=(x, y, 0), scale=(1, 1, 1))
        cube = bpy.context.object
        cube.name = f"cube({a},{b})"
        # offset position
        ran = random.uniform(-1, 1) * ran_fn(ran_fac) # ran_fac = 0 at first, not offset for first 6 cube
        cube.location[0] += ran
        cube.location[1] += ran

        # rotate
        cube.rotation_euler[0] += ran
        cube.rotation_euler[1] += ran
        cube.rotation_euler[2] += ran

        y += 2.4
    ran_fac += 0.2
    x -= 2.4
$\endgroup$
1
  • $\begingroup$ Excellent, thank you :) $\endgroup$
    – Ondrej
    Apr 29, 2022 at 6:26
2
$\begingroup$

Using Geometry Nodes on Blenver v3.1.2

Result

Node tree

Node tree

gif

$\endgroup$
1
  • $\begingroup$ That is very impressive. Any way to affect rotation as well? $\endgroup$
    – Ondrej
    Apr 29, 2022 at 5:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .