Example #1
0
    def __init__(self, context, type, scale, steps):

        self.ob = context.active_object
        bpy.ops.object.mode_set(mode='OBJECT')

        translate = mesh_extras.get_average_outer_edge_length()
        #inset = mesh_extras.get_shortest_outer_edge_length() * 0.25

        translate *= scale

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

        stepped = 0

        # Simple... we just do a bunch of steps... set in stone... easy!
        if type == 'BUM':

            self.extrude()

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

            self.shrink(-translate)
            self.shrink(translate * 0.3)

            stepped += 1

        # Spike!
        elif type == 'SPI':

            for i in range(3):

                self.extrude()

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

                if not i:
                    f = 0.5
                elif i == 1:
                    f = 0.3
                elif i == 2:
                    f = 0.2

                t = translate * f

                self.shrink(-t)
                self.shrink(t * (2 * f))

                stepped += 1

        # Dimple!
        elif type == 'DIM' or type == 'PIM':

            self.extrude()
            bpy.ops.object.mode_set(mode='OBJECT')
            bpy.ops.object.mode_set(mode='EDIT')

            self.shrink(-translate * 0.2)

            self.extrude()
            bpy.ops.object.mode_set(mode='OBJECT')
            bpy.ops.object.mode_set(mode='EDIT')

            self.shrink(translate * 0.2)
            self.shrink(-translate * 0.2)

            if type == 'PIM':
                self.extrude()
                bpy.ops.object.mode_set(mode='OBJECT')
                bpy.ops.object.mode_set(mode='EDIT')

                self.shrink(-translate * 0.2)
                stepped = 3
            else:
                stepped = 2

        if steps:
            self.ob['growsteps'] = stepped
Example #2
0
	def __init__(self, context, translation, rotation, rotation_falloff, scale, scale_falloff, retain, steps, debug):
		
		self.startTime = time.time()
		self.markTime = self.startTime
		self.debug = debug
		
		self.context = context
		self.ob = context.active_object
		self.selectNr = len(mesh_extras.get_selected_polygons())
		
		if not self.selectNr:
			print('Grow error no polygons selected')
			return
			
		if steps:
			self.ob['growsteps'] = 0
		
		self.factor = 0.0
		
		self.iteration = 0
		self.reachedGoal = False
		
		self.translated = 0.0
		self.currentX = 0.0
		self.averagelength = 0.0
		
		# Go into object mode for the initial stages
		bpy.ops.object.mode_set(mode='OBJECT')
		self.averageLength = mesh_extras.get_average_outer_edge_length()
		# Now this is an added bit only for use with entoform.py
		
		# This matrix may already be set by a previous grow function running making this shape (just being consistent)
		try:
			self.transformMatrix = mathutils.Matrix((self.ob['growmatrix'][0],self.ob['growmatrix'][1],self.ob['growmatrix'][2]))
		except:
			self.transformMatrix = mesh_extras.get_selection_matrix()
			
		# This matrix is just there to check whether the "directions" are correct
		try:
			self.checkMatrix = mathutils.Matrix((self.ob['formmatrix'][0],self.ob['formmatrix'][1],self.ob['formmatrix'][2]))
			print('GOT checkmatrix')
		except:
			self.checkMatrix = False
		
		# Make the actions
		actions = []
		actions.append({'type': 'extrude'})
		actions.append({'type': 'scale', 'vector': scale, 'falloff': scale_falloff})
		actions.append({'type': 'rotate', 'vector': mathutils.Vector(rotation), 'falloff': rotation_falloff})
		actions.append({'type': 'translate', 'vector': translation})
			
		# Add the extrude at the start (doing it this way in case we'd like to invert the list)
		#actions.insert(0, {'type': 'extrude'})
		
		# Loop through all the actions
		bpy.ops.object.mode_set(mode='EDIT')
		self.mark('startloop')
		
		while not self.reachedGoal:
		
			self.mark('step '+str(self.iteration))
			
			# Window redraw nice as a hack!
			#bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
			#time.sleep(0.5)
			
			# Figure out how much to translate and where we are on the curves
			self.currentX = self.translated / translation
			self.translated += self.averageLength
			self.newX = self.translated / translation
			
			self.mark('transcal')
			
			# Lets check.. if we move beyond the wanted result in this step... we quit!
			if self.translated == translation:
				self.reachedGoal = True
			elif self.translated > translation:
				self.reachedGoal = True
				self.newX = 1.0
				break
			
			self.mark('actions')
			for action in actions:
				self.mark(action['type']+' start')
				self.spurt(action)
				self.mark(action['type']+' end')
				
			self.iteration += 1
			if steps:
				self.ob['growsteps'] = self.iteration
					
		# Save this matrix, in case we grow again...
		if retain:
			self.ob['growmatrix'] = self.transformMatrix
		else:
			try:
				del(self.ob['growmatrix'])
			except:
				pass

		self.mark('end')
Example #3
0
	def __init__(self, context, translation, rotation, rotation_falloff, scale, scale_falloff, retain, steps, debug, animate):
		
		self.startTime = time.time()
		self.markTime = self.startTime
		self.debug = debug
		self.animate = animate
		
		self.context = context
		self.ob = context.active_object
		self.selectNr = len(mesh_extras.get_selected_polygons())
		
		if not self.selectNr:
			print('Grow error no polygons selected')
			return
			
		if steps:
			self.ob['growsteps'] = 0
		
		self.factor = 0.0
		
		self.iteration = 0
		self.reachedGoal = False
		
		self.translated = 0.0
		self.currentX = 0.0
		self.averagelength = 0.0
		
		# Go into object mode for the initial stages
		bpy.ops.object.mode_set(mode='OBJECT')
		self.averageLength = mesh_extras.get_average_outer_edge_length()
		if self.averageLength == 0.0:
			print('ERROR NO OUTER EDGES FOUND')
			return
			
		# Now this is an added bit only for use with entoform.py
		
		# This matrix may already be set by a previous grow function running making this shape (just being consistent)
		try:
			self.transformMatrix = mathutils.Matrix((self.ob['growmatrix'][0],self.ob['growmatrix'][1],self.ob['growmatrix'][2]))
		except:
			self.transformMatrix = mesh_extras.get_selection_matrix()
			
		# This matrix is just there to check whether the "directions" are correct
		try:
			self.checkMatrix = mathutils.Matrix((self.ob['formmatrix'][0],self.ob['formmatrix'][1],self.ob['formmatrix'][2]))
			print('GOT checkmatrix')
		except:
			self.checkMatrix = False

		
		# Make the actions
		actions = []
		actions.append({'type': 'extrude'})
		actions.append({'type': 'scale', 'vector': scale, 'falloff': scale_falloff})
		actions.append({'type': 'rotate', 'vector': mathutils.Vector(rotation), 'falloff': rotation_falloff})
		actions.append({'type': 'translate', 'vector': translation})
			
		# Add the extrude at the start (doing it this way in case we'd like to invert the list)
		#actions.insert(0, {'type': 'extrude'})
		
		# Loop through all the actions
		bpy.ops.object.mode_set(mode='EDIT')
		self.mark('startloop')
		
		while not self.reachedGoal:
		
			self.mark('step '+str(self.iteration))
			
			# Window redraw nice as a hack!
			#bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
			#time.sleep(0.5)
			
			# Figure out how much to translate and where we are on the curves
			self.currentX = self.translated / translation
			self.translated += self.averageLength
			self.newX = self.translated / translation
			
			self.mark('transcal')
			self.mark(self.translated)
			self.mark(translation)
			
			# Lets check.. if we move beyond the wanted result in this step... we quit!
			if self.translated == translation:
				self.reachedGoal = True
			elif self.translated > translation:
				self.reachedGoal = True
				self.newX = 1.0
				break
			
			self.mark('actions')
			for action in actions:
				self.mark(action['type']+' start')
				self.spurt(action)
				self.mark(action['type']+' end')
				
			self.iteration += 1
			if steps:
				self.ob['growsteps'] = self.iteration
			
			
			scene_update.go(False, self.animate)
			
		# Save this matrix, in case we grow again...
		if retain:
			self.ob['growmatrix'] = self.transformMatrix
		else:
			try:
				del(self.ob['growmatrix'])
			except:
				pass

		
		self.mark('end')
Example #4
0
	def __init__(self, context, type, scale, steps):
	
		self.ob = context.active_object
		bpy.ops.object.mode_set(mode='OBJECT')
		
		translate = mesh_extras.get_average_outer_edge_length()
		#inset = mesh_extras.get_shortest_outer_edge_length() * 0.25
		
		translate *= scale
		
		bpy.ops.object.mode_set(mode='EDIT')
		
		stepped = 0
	
		# Simple... we just do a bunch of steps... set in stone... easy!
		if type == 'BUM':
		
			self.extrude()
			
			bpy.ops.object.mode_set(mode='OBJECT')
			bpy.ops.object.mode_set(mode='EDIT')
			
			self.shrink(-translate)
			self.shrink(translate*0.3)
			
			stepped += 1
		
		# Spike!
		elif type == 'SPI':
		
			for i in range(3):
		
				self.extrude()
				
				bpy.ops.object.mode_set(mode='OBJECT')
				bpy.ops.object.mode_set(mode='EDIT')
				
				if not i:
					f = 0.5
				elif i == 1:
					f = 0.3
				elif i == 2:
					f = 0.2
				
				t = translate * f
				
				self.shrink(-t)
				self.shrink(t * (2 * f))
				
				stepped += 1
				
		# Dimple!
		elif type == 'DIM' or type == 'PIM':
		
			self.extrude()
			bpy.ops.object.mode_set(mode='OBJECT')
			bpy.ops.object.mode_set(mode='EDIT')
			
			self.shrink(-translate * 0.2)
			
			self.extrude()
			bpy.ops.object.mode_set(mode='OBJECT')
			bpy.ops.object.mode_set(mode='EDIT')
			
			self.shrink(translate * 0.2)
			self.shrink(-translate * 0.2)
			
			if type == 'PIM':
				self.extrude()
				bpy.ops.object.mode_set(mode='OBJECT')
				bpy.ops.object.mode_set(mode='EDIT')
			
				self.shrink(-translate * 0.2)
				stepped = 3
			else:
				stepped = 2
			
			
			

		if steps:
			self.ob['growsteps'] = stepped