I ended up with alternating rows of taller rectangles, with tiny square hats on the smaller ones, and alternating cone hats on the front row. The code i used was
import maya.cmds
#For every warrior we want in out army
for z_position in range(20):
for x_position in range(20):
#if the z position is even
if z_position%2 == 0:
maya.cmds.polyCube(w=0.75, h=3, d=0.75)
#spawn a cube in a different height
maya.cmds.xform(t=(x_position-10, 1.5, z_position-10))
else:
#Create a cube
maya.cmds.polyCube(w=0.75, h=2, d=0.75)
#Positionh the cube in a formation
maya.cmds.xform(t=(x_position-10, 1, z_position-10))
#if this is the first cube in a row
#create a cone above it
if x_position ==0:
if z_position%2 ==0:
maya.cmds.polyCone(r=0.25, h=2)
maya.cmds.xform(t=(x_position-10, 3.5, z_position-10))
else:
maya.cmds.polyCone(r=0.25, h=1)
maya.cmds.xform(t=(x_position-10, 2.5, z_position-10))
else:
maya.cmds.polyCube(w=0.25, h=0.25, d=0.25)
maya.cmds.xform(t=(x_position-10, 2.125, z_position-10))
This is a useful skill to me that i'm looking to develop much further and hopefully take into scripting and dynamics next semester. It will help me speed up my work pipeline in 3D modelling and rigging by allowing me to use code to do menial repetitive tasks.
My copy of "Maya Python for Games and Film" has arrived , so i will start reading through it.
No comments:
Post a Comment