Created
July 30, 2020 09:37
-
-
Save takawo/7279a4bcee4e1d83f9c7b4ef91fd86d3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bpy | |
| import random | |
| cells = random.randint(5,10) | |
| size = 15 | |
| def map(sensor_val, in_from, in_to, out_from, out_to): | |
| out_range = out_to - out_from | |
| in_range = in_to - in_from | |
| in_val = sensor_val - in_from | |
| val=(float(in_val)/in_range)*out_range | |
| out_val = out_from+val | |
| return out_val | |
| for i in range(0,cells): | |
| for j in range(0,cells): | |
| for k in range(0,cells): | |
| x = map(i,0,cells-1,-size,size) | |
| y = map(j,0,cells-1,-size,size) | |
| z = map(k,0,cells-1,-size,size) | |
| rx = random.randint(0,8) * 360/8; | |
| ry = random.randint(0,8) * 360/8; | |
| rz = random.randint(0,8) * 360/8; | |
| mat_name = "mat" + str(random.randint(0,4)) | |
| bpy.ops.mesh.primitive_cube_add(rotation=(rx,ry,rz),location=(x,y,z)) | |
| bpy.context.object.active_material=bpy.data.materials[mat_name] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment