示例#1
0
def AddLight():

    bpy.ops.mesh.primitive_circle_add(vertices=12,
                                      radius=1,
                                      fill_type='TRIFAN',
                                      view_align=False,
                                      enter_editmode=False,
                                      location=(0, 0, 0))

    bpy.ops.object.mode_set(mode='EDIT')

    bpy.ops.mesh.select_all(action='SELECT')

    bpy.ops.mesh.cast_loop()

    corners = 3
    falloff_scale = 1.0
    # 		('STR', 'Straight',''),		('SPI', 'Spike',''),		('BUM', 'Bump',''),		('SWE', 'Sweep',''),
    scale_falloff = 'STR'

    bmesh_extras.cast_loop(corners=corners,
                           falloff_scale=falloff_scale,
                           falloff_shape=scale_falloff)

    bpy.ops.object.mode_set(mode='OBJECT')

    return
示例#2
0
	def __init__(self, context, shape,scale,scale_falloff, corner_group):
	
	
		if shape == 'TRI':
			corners = 3;
		elif shape == 'SQA':
			corners = 4
		else:
			corners = 0;
		
		bmesh_extras.cast_loop(corners=corners, falloff_scale=scale,falloff_shape=scale_falloff,corner_group=corner_group)
		return
示例#3
0
    def __init__(self, context, shape, scale, scale_falloff, corner_group):

        if shape == 'TRI':
            corners = 3
        elif shape == 'SQA':
            corners = 4
        else:
            corners = 0

        bmesh_extras.cast_loop(corners=corners,
                               falloff_scale=scale,
                               falloff_shape=scale_falloff,
                               corner_group=corner_group)
        return
示例#4
0
	def executeDNA(self, string, baseGroups, baseWeight):
		
		pad = str(' ').rjust(string['level'], ' ')
		
		# Stop if the limit is reached! (mostly for debugging)
		if self.steplimit and string['number'] >= self.steplimit:
			print(pad,' # Reached steplimit',self.steplimit,'>> RETURNING')
			return
		'''		
		if string['number'] == 5 or string['number'] == 6:
			return	
		'''
		#print(pad,'1 makegroups')
		newGroups, formmatrix, growmatrices = self.makeAffectedGroups(string, baseGroups)
		groupLen = len(newGroups)
		
		# Temporary halt!
		#return
		
		#if string['number'] == (self.steplimit-1):
		#	print(pad,' # Reached steplimit',self.steplimit,'>> RETURNING')
		#	return
		
		idText = 'limb '+misc.nr4(string['number'])+' '+string['name'].ljust(10, ' ')
		#print(pad,idText)
		
		# only if we made a group with something in it do we continue
		if not groupLen:
			print(pad,' ### No group!')
		else:
				
			# Loop through all the groups
			for i, group in enumerate(newGroups):
					
				# The step number to print out
				stepText = misc.nr4(i+1)+' of '+misc.nr4(groupLen)
			
				# We need a check matrix only if we're not on the head or body
				if string['name'] == 'head' or string['name'] == 'body' or True:
					try:
						del(self.ob['formmatrix'])
					except:
						pass
				# If not... then just try to get rid of it
				else:
					self.ob['formmatrix'] = formmatrix
			
				# Body gets a set matrix (so it grows nice and straight)
				if string['name'] == 'head':
					growmatrix = mathutils.Matrix(((1.0,0.0,0.0),(0.0,0.0,1.0),(0.0,-1.0,0.0))).transposed()
					
				# Head gets a set matrix (so it grows nice and straight)
				elif string['name'] == 'body':
					growmatrix = mathutils.Matrix(((-1.0,0.0,0.0),(0.0,0.0,1.0),(0.0,1.0,0.0))).transposed()
					
				# In all other cases the matrix can be dealt with by the grow addon
				else:
					growmatrix = growmatrices[i]
					
				self.ob['growmatrix'] = growmatrix
			
				# Select a group
				#print(pad,'2 select groups')
				select_bmesh_faces.go(mode='GROUPED', group=group.index)
				
				#print('sel-',len(mesh_extras.get_selected_polygons()),group.name)
				

				
				mesh_extras.smooth_selection()

				# No need to continue if we have no selected polygons
				if not mesh_extras.contains_selected_item(self.me.polygons):
					print(pad,'skip ',stepText,'no selection',string['action']['name'])
					
				else:
					
					action = string['action']
						
					if action['type'] == 'grow':
							
						# Check for mirroring
						right = mathutils.Vector((1.0,0.0,0.0))
						check = mathutils.Vector(growmatrix[2])
						
						# If we're aiming left we "invert" the rotation
						if right.dot(check) < 0.0:
							rot = mathutils.Vector((-action['rotation'][0],action['rotation'][1],-action['rotation'][2]))
						else:
							rot = action['rotation']
					
						# Add relative intensity here (half the original + half the weight)
						weight = baseWeight * self.getWeight(groupLen, action['scalin'])
					
					print(pad,'step ',stepText,action['name'], string['number'])

						
					# Cast the selection to the correct shape please
					bmesh_extras.cast_loop(corners=action['loop_corners'], falloff_scale=action['loop_scale'], falloff_shape=action['loop_shape'],corner_group='corner')
					
					bpy.ops.object.mode_set(mode='EDIT')
					
					
					if action['type'] == 'bump':
					
						bpy.ops.mesh.bump(
							type=action['bumptype'],
							scale=action['bumpscale'],
							steps=True,
							)
							
					else:
					
						bpy.ops.mesh.grow(
							translation=action['translation'],
							rotation=rot,
							rotation_falloff=action['rotation_falloff'],
							scale=action['scale'],
							scale_falloff=action['scale_falloff'],
							retain=True,
							steps=True,
							debug=False,
							)
					
					bpy.ops.object.mode_set(mode='OBJECT')
					
					select_bmesh_faces.go(mode='GROUPED', group=group.index)
					
					bmesh_extras.color_limb(col=action['vertexcolor'], jon=action['jointcolor'], hard=action['colorstyle'])
					
					# RESELECT GROUPED...
					select_bmesh_faces.go(mode='GROUPED', group=group.index)
					
					bmesh_extras.crease_edges(sharpness=action['crease'], group='corner')						
					
					select_bmesh_faces.go(mode='GROUPED', group=group.index)
					
					# Remove new stuff from all but the current group
					self.cleanGroup(group)
					
					select_bmesh_faces.go(mode='GROUPED', group=group.index)
					# Keep track of how much steps we've taken
					self.dnaStep += 1
					
					# Redraw hack to see what is happening
					#bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
					
					# If there's a sub string and we're allowed deeper... lets do that
					if len(string['strings']):
						for s in string['strings']:
							if s['number'] < self.steplimit or not self.steplimit:
								#print('going sub', string['name'], s['name'])
								self.executeDNA(s, [group], weight)
示例#5
0
	def executeDNA(self, string, baseGroups, baseWeight):
		
		pad = str(' ').rjust(string['level'], ' ')
		
		# Stop if the limit is reached! (mostly for debugging)
		if self.steplimit and string['number'] >= self.steplimit:
			print(pad,' # Reached steplimit',self.steplimit,'>> RETURNING')
			return
		'''		
		if string['number'] == 5 or string['number'] == 6:
			return	
		'''
		#print(pad,'1 makegroups')
		newGroups, formmatrix, growmatrices = self.makeAffectedGroups(string, baseGroups)
		groupLen = len(newGroups)
		
		# Temporary halt!
		#return
		
		#if string['number'] == (self.steplimit-1):
		#	print(pad,' # Reached steplimit',self.steplimit,'>> RETURNING')
		#	return
		
		idText = 'limb '+misc.nr4(string['number'])+' '+string['name'].ljust(10, ' ')
		#print(pad,idText)
		
		# only if we made a group with something in it do we continue
		if not groupLen:
			print(pad,' ### No group!')
		else:
				
			# Loop through all the groups
			for i, group in enumerate(newGroups):
					
				# The step number to print out
				stepText = misc.nr4(i+1)+' of '+misc.nr4(groupLen)
			
				# We need a check matrix only if we're not on the head or body
				if string['name'] == 'head' or string['name'] == 'body' or True:
					try:
						del(self.ob['formmatrix'])
					except:
						pass
				# If not... then just try to get rid of it
				else:
					self.ob['formmatrix'] = formmatrix
			
				# Body gets a set matrix (so it grows nice and straight)
				if string['name'] == 'head':
					growmatrix = mathutils.Matrix(((1.0,0.0,0.0),(0.0,0.0,1.0),(0.0,-1.0,0.0))).transposed()
					
				# Head gets a set matrix (so it grows nice and straight)
				elif string['name'] == 'body':
					growmatrix = mathutils.Matrix(((-1.0,0.0,0.0),(0.0,0.0,1.0),(0.0,1.0,0.0))).transposed()
					
				# In all other cases the matrix can be dealt with by the grow addon
				else:
					growmatrix = growmatrices[i]
					
				self.ob['growmatrix'] = growmatrix
			
				# Select a group
				#print(pad,'2 select groups')
				select_bmesh_faces.go(mode='GROUPED', group=group.index)
				
				#print('sel-',len(mesh_extras.get_selected_polygons()),group.name)
				

				
				mesh_extras.smooth_selection()

				# No need to continue if we have no selected polygons
				if not mesh_extras.contains_selected_item(self.me.polygons):
					print(pad,'skip ',stepText,'no selection',string['action']['name'])
					
				else:
					
					action = string['action']
						
					if action['type'] == 'grow':
							
						# Check for mirroring
						right = mathutils.Vector((1.0,0.0,0.0))
						check = mathutils.Vector(growmatrix[2])
						
						# If we're aiming left we "invert" the rotation
						if right.dot(check) < 0.0:
							rot = mathutils.Vector((-action['rotation'][0],action['rotation'][1],-action['rotation'][2]))
						else:
							rot = action['rotation']
					
						# Add relative intensity here (half the original + half the weight)
						weight = baseWeight * self.getWeight(groupLen, action['scalin'])
					
					print(pad,'step ',stepText,action['name'], string['number'])

						
					# Cast the selection to the correct shape please
					bmesh_extras.cast_loop(corners=action['loop_corners'], falloff_scale=action['loop_scale'], falloff_shape=action['loop_shape'],corner_group='corner')
					
					bpy.ops.object.mode_set(mode='EDIT')
					
					
					if action['type'] == 'bump':
					
						bpy.ops.mesh.bump(
							type=action['bumptype'],
							scale=action['bumpscale'],
							steps=True,
							)
							
					else:
					
						bpy.ops.mesh.grow(
							translation=action['translation'],
							rotation=rot,
							rotation_falloff=action['rotation_falloff'],
							scale=action['scale'],
							scale_falloff=action['scale_falloff'],
							retain=True,
							steps=True,
							debug=False,
							)
					
					bpy.ops.object.mode_set(mode='OBJECT')
					
					select_bmesh_faces.go(mode='GROUPED', group=group.index)
					
					bmesh_extras.color_limb(col=action['vertexcolor'], jon=action['jointcolor'], hard=action['colorstyle'])
					
					# RESELECT GROUPED...
					select_bmesh_faces.go(mode='GROUPED', group=group.index)
					
					bmesh_extras.crease_edges(sharpness=action['crease'], group='corner')						
					
					select_bmesh_faces.go(mode='GROUPED', group=group.index)
					
					# Remove new stuff from all but the current group
					self.cleanGroup(group)
					
					select_bmesh_faces.go(mode='GROUPED', group=group.index)
					# Keep track of how much steps we've taken
					self.dnaStep += 1
					
					# Redraw hack to see what is happening
					#bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
					
					# If there's a sub string and we're allowed deeper... lets do that
					if len(string['strings']):
						for s in string['strings']:
							if s['number'] < self.steplimit or not self.steplimit:
								#print('going sub', string['name'], s['name'])
								self.executeDNA(s, [group], weight)