Saturday, May 14, 2011

Idea for body making.

Well, the details making method is good. And next, the 'body'.
Till today, I put an object that was set some vertex groups already. But if I could a body( = seed object ) from one cube without preset vertex groups, it's very wonderful.

Now, this is the first idea for it.


From one cube object, I try to generate a belly and a head.

<CODE>

# bellyMaker ------------------------------------------------------>
def bellyMaker(vGroup, step, distArray, distRandom, scaleArray, scaleRatioArray, scaleRandom, rotArray, rotRandom, axisArray, ):
newGroup = ob.vertex_groups.new(vGroup)
bpy.ops.object.mode_set(mode='OBJECT')
# Lets loop through all the faces in the mesh
for f in ob.data.faces:
# See if the current face's centre is above 0.0 on the Z axis
if f.center[1] > 0.1:
# Set select to true
f.select = True
else:
f.select = False
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.object.vertex_group_set_active(group=vGroup)
bpy.ops.object.vertex_group_assign(new=False)
transformFaces(vGroup, step, distArray, distRandom, scaleArray, scaleRatioArray, scaleRandom, rotArray, rotRandom, axisArray)
bpy.ops.object.vertex_group_remove(all=False)

# bellyMaker(END) -------------------------------------------------<

# headMaker ------------------------------------------------------>
def headMaker(vGroup, step, distArray, distRandom, scaleArray, scaleRatioArray, scaleRandom, rotArray, rotRandom, axisArray, ):
newGroup = ob.vertex_groups.new(vGroup)
bpy.ops.object.mode_set(mode='OBJECT')
# Lets loop through all the faces in the mesh
for f in ob.data.faces:
# See if the current face's centre is above 0.0 on the Z axis
if f.center[1] < -0.1:
# Set select to true
f.select = True
else:
f.select = False
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.object.vertex_group_set_active(group=vGroup)
bpy.ops.object.vertex_group_assign(new=False)
transformFaces(vGroup, step, distArray, distRandom, scaleArray, scaleRatioArray, scaleRandom, rotArray, rotRandom, axisArray)
bpy.ops.object.vertex_group_remove(all=False)
newGroup = ob.vertex_groups.new('mouth')
bpy.ops.object.vertex_group_set_active(group='mouth')
bpy.ops.object.vertex_group_assign(new=False)

# headMaker(END) -------------------------------------------------<


</CODE>

There are two functions, bellyMaker() and headMaker(). How come two functions? Because, the condition for selection of each first face are different, (y > 0.1) and (y < -0.1). So I made the functions separately. 
After generation belly and head, make 'mouth', and add subSurf modifier.
Now I got this result. How about it?


No comments:

Post a Comment