Changeset View
Changeset View
Standalone View
Standalone View
add_mesh_extra_objects/mesh_discombobulator.py
| Context not available. | |||||
| """Return a vector of a random vertex on a quad-polygon""" | """Return a vector of a random vertex on a quad-polygon""" | ||||
| i = random.randint(1, 2) | i = random.randint(1, 2) | ||||
| A, B, C, D = 0, 0, 0, 0 | A, B, C, D = 0, 0, 0, 0 | ||||
| if(a == 1): | if a == 1: | ||||
| A, B, C, D = a, b, c, d | A, B, C, D = a, b, c, d | ||||
| else: | else: | ||||
| A, B, C, D = a, d, c, b | A, B, C, D = a, d, c, b | ||||
| Context not available. | |||||
| poly = obpolygon.vertices | poly = obpolygon.vertices | ||||
| if(number == 1): | if number == 1: | ||||
| divide_one(nPolygons, nVerts, verts, poly, len(nVerts)) | divide_one(nPolygons, nVerts, verts, poly, len(nVerts)) | ||||
| elif(number == 2): | elif number == 2: | ||||
| divide_two(nPolygons, nVerts, verts, poly, len(nVerts)) | divide_two(nPolygons, nVerts, verts, poly, len(nVerts)) | ||||
| elif(number == 3): | elif number == 3: | ||||
| divide_three(nPolygons, nVerts, verts, poly, len(nVerts), GetPolyCentroid(obpolygon, verts)) | divide_three(nPolygons, nVerts, verts, poly, len(nVerts), GetPolyCentroid(obpolygon, verts)) | ||||
| elif(number == 4): | elif number == 4: | ||||
| divide_four(nPolygons, nVerts, verts, poly, len(nVerts), GetPolyCentroid(obpolygon, verts)) | divide_four(nPolygons, nVerts, verts, poly, len(nVerts), GetPolyCentroid(obpolygon, verts)) | ||||
| Context not available. | |||||
| def division(obpolygons, verts, sf1, sf2, sf3, sf4): | def division(obpolygons, verts, sf1, sf2, sf3, sf4): | ||||
| """Function to divide each of the selected polygons""" | """Function to divide each of the selected polygons""" | ||||
| divide = [] | divide = [] | ||||
| if (sf1): | if sf1: | ||||
| divide.append(1) | divide.append(1) | ||||
| if (sf2): | if sf2: | ||||
| divide.append(2) | divide.append(2) | ||||
| if (sf3): | if sf3: | ||||
| divide.append(3) | divide.append(3) | ||||
| if (sf4): | if sf4: | ||||
| divide.append(4) | divide.append(4) | ||||
| for poly in obpolygons: | for poly in obpolygons: | ||||
| if(poly.select is True and len(poly.vertices) == 4): | if poly.select is True and len(poly.vertices) == 4: | ||||
| a = random.randint(0, len(divide) - 1) | a = random.randint(0, len(divide) - 1) | ||||
| dividepolygon(poly, verts, divide[a]) | dividepolygon(poly, verts, divide[a]) | ||||
| Context not available. | |||||
| verts.append(vertex.co) | verts.append(vertex.co) | ||||
| for polygon in obpolygons: | for polygon in obpolygons: | ||||
| if(polygon.select is True): | if polygon.select is True: | ||||
| if(len(polygon.vertices) == 4): | if len(polygon.vertices) == 4: | ||||
| addProtusionToPolygon(polygon, verts, minHeight, maxHeight, minTaper, maxTaper) | addProtusionToPolygon(polygon, verts, minHeight, maxHeight, minTaper, maxTaper) | ||||
| Context not available. | |||||
| i = 0 | i = 0 | ||||
| # on parcoure cette boucle pour ajouter des doodads a toutes les polygons | # on parcoure cette boucle pour ajouter des doodads a toutes les polygons | ||||
| # english translation: this loops adds doodads to all polygons | # english translation: this loops adds doodads to all polygons | ||||
| while(i < len(object1.data.polygons)): | while i < len(object1.data.polygons): | ||||
| if object1.data.polygons[i].select is False: | if object1.data.polygons[i].select is False: | ||||
| continue | continue | ||||
| doods_nbr = random.randint(dmin, dmax) | doods_nbr = random.randint(dmin, dmax) | ||||
| j = 0 | j = 0 | ||||
| while(j <= doods_nbr): | while j <= doods_nbr: | ||||
| origin_dood = randVertex(object1.data.polygons[i].vertices[0], object1.data.polygons[i].vertices[1], | origin_dood = randVertex(object1.data.polygons[i].vertices[0], object1.data.polygons[i].vertices[1], | ||||
| object1.data.polygons[i].vertices[2], object1.data.polygons[i].vertices[3], Verts) | object1.data.polygons[i].vertices[2], object1.data.polygons[i].vertices[3], Verts) | ||||
| type_dood = random.randint(0, len(bpy.context.scene.discomb.DISC_doodads) - 1) | type_dood = random.randint(0, len(bpy.context.scene.discomb.DISC_doodads) - 1) | ||||
| Context not available. | |||||
| nor_def = Vector((0.0, 0.0, 1.0)) | nor_def = Vector((0.0, 0.0, 1.0)) | ||||
| qr = nor_def.rotation_difference(normal_original_polygon.normalized()) | qr = nor_def.rotation_difference(normal_original_polygon.normalized()) | ||||
| if(test_v2_near_v1(nor_def, -normal_original_polygon)): | if test_v2_near_v1(nor_def, -normal_original_polygon): | ||||
| qr = Quaternion((0.0, 0.0, 0.0, 0.0)) | qr = Quaternion((0.0, 0.0, 0.0, 0.0)) | ||||
| # qr = angle_between_nor(nor_def, normal_original_polygon) | # qr = angle_between_nor(nor_def, normal_original_polygon) | ||||
| Context not available. | |||||
| # if(bpy.context.scene.repeatprot): | # if(bpy.context.scene.repeatprot): | ||||
| protusions_repeat(object1, mesh1, r_prot) | protusions_repeat(object1, mesh1, r_prot) | ||||
| if(len(bpy.context.scene.discomb.DISC_doodads) != 0 and bpy.context.scene.discomb.dodoodads and isLast): | if len(bpy.context.scene.discomb.DISC_doodads) != 0 and bpy.context.scene.discomb.dodoodads and isLast: | ||||
| doodads(object1, mesh1, dmin, dmax) | doodads(object1, mesh1, dmin, dmax) | ||||
| mesh2 = bpy.data.meshes.new("dood_mesh") | mesh2 = bpy.data.meshes.new("dood_mesh") | ||||
| object2 = bpy.data.objects.new("dood_obj", mesh2) | object2 = bpy.data.objects.new("dood_obj", mesh2) | ||||
| Context not available. | |||||
| @classmethod | @classmethod | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
| obj = bpy.context.active_object | obj = bpy.context.active_object | ||||
| if (obj is not None and obj.type == "MESH"): | if obj is not None and obj.type == "MESH": | ||||
| mesh = obj.data | mesh = obj.data | ||||
| for polygon in mesh.polygons: | for polygon in mesh.polygons: | ||||
| Context not available. | |||||
| ) | ) | ||||
| def execute(self, context): | def execute(self, context): | ||||
| msg = ("No doodads to remove") | msg = "No doodads to remove" | ||||
| doodadery = bpy.context.scene.discomb.DISC_doodads | doodadery = bpy.context.scene.discomb.DISC_doodads | ||||
| if len(doodadery) > 0: | if len(doodadery) > 0: | ||||
| if not self.remove_all: | if not self.remove_all: | ||||
| Context not available. | |||||