Wednesday, October 27, 2010

Creating a brick wall with Blender 2.54

I have been wanting to create a brick wall with Blender. I found this tutorial to be very helpful. It works well if the camera is not very close to the wall. It is fast and easy to put together.

It is also possible to put together a brick wall with an array modifier. But what really inspired me was the example script for creating castle walls available here. That script did not work for the current Blender 2.54 Beta version. So I thought I would work on creating my own script.

Here is a development version of my script. I thought I would post it here so that others looking for Blender 2.54 Beta scripting examples could find it

 import bpy 
 row_count = 8        # Number of rows
 bricks_per_row = 15  # Number of bricks in each row
 cube_x = .25         # Length of each brick
 cube_y = .25         # Width of wall
 cube_z = .125        # Height of each brick
 row_gap = .01        # Gap between each row
 brick_gap = .01      # Gap between each brick
 # Calculated values
 offset_amount = cube_x/2    # Staggers bricks
 rescaling_factor_x=cube_x/2 # Used to size the brick
 # Loop for each row
 for row in range(row_count):
     # Calculate if we stagger this row
     offset = row % 2 * offset_amount
     # Loop for each brick
     for index in range(bricks_per_row):
         # Add the brick
             row *(cube_z + row_gap)))
         # Resize the brick
         # Bevel the brick