I was looking for an idea of a game that would be hard to build if it was not for 3D printing. A 3D maze came to mind. I used to make those out of legos with marbles when I was a kid: place the marble at one end, and tilt the maze to direct the ball all the way to the exit. For extra difficulty, make the maze opaque: you do not really know the structure inside, but you can use the sound of the marble hitting walls to get an idea of where it is.
Before moving on to fully three dimensional mazes, let's start with printing a 2D maze. I decided to model the maze in Blender using the scripting language so that I could make arbitrarily large and complex mazes later.
ASCII Art maze:
Those 'W' become little cubes to make the walls. Then we add a floor and a ceiling. And finally a couple of curved walls at the exits to avoid losing the ball (after losing a couple...).
Blender script is not entirely obvious when it comes to Boolean operations. Here is what it looks like to subtract a cylinder from another one in Blender 2.73a. This is one step towards building the little walls at he exits. Note the bolded line, which is a bit unintuitive since other operations only require setting 'selected', not 'active'.
# One Cylinder
bpy.ops.mesh.primitive_cylinder_add(
radius=1, depth=0.5, location=(0,0,0))
cyl1 = bpy.context.object
# Another one, smaller in radius but taller
bpy.ops.mesh.primitive_cylinder_add(
radius=0.8, depth=1.0, location=(0,0,0))
cyl2 = bpy.context.object
# Add a diff modifier
diff1 = cyl1.modifiers.new('Diff1', 'BOOLEAN')
diff1.object = cyl2
diff1.operation = 'DIFFERENCE'
# Apply the modifier and get rid of the extra object.
bpy.context.scene.objects.active = cyl1
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Diff1")
scene.objects.unlink(cyl2)
And here is the result! It is quite fun to play with. Showing the internal structure on top makes it challenging but not overly difficult.
Next step: a real 3D maze...
No comments:
Post a Comment