Changeset View
Changeset View
Standalone View
Standalone View
mesh_carver.py
| Context not available. | |||||
| DrawLeftText(BoolStr, xLeftP, yCmd - yInterval, IFontSize, Color1, self) | DrawLeftText(BoolStr, xLeftP, yCmd - yInterval, IFontSize, Color1, self) | ||||
| #---BRUSH DEPTH: | #---BRUSH DEPTH: | ||||
| if (self.ObjectMode): | if self.ObjectMode: | ||||
| TypeStr = "Brush Depth [" + context.scene.Key_Depth + "] : " | TypeStr = "Brush Depth [" + context.scene.Key_Depth + "] : " | ||||
| BoolStr = str(round(self.ObjectBrush.data.vertices[0].co.z, 2)) | BoolStr = str(round(self.ObjectBrush.data.vertices[0].co.z, 2)) | ||||
| OpsStr = TypeStr + BoolStr | OpsStr = TypeStr + BoolStr | ||||
| Context not available. | |||||
| # Cut Line | # Cut Line | ||||
| if self.CutMode == LINE: | if self.CutMode == LINE: | ||||
| if (self.shift) or (self.CreateMode and self.Closed): | if self.shift or (self.CreateMode and self.Closed): | ||||
| bgl.glColor4f(UIColor[0], UIColor[1], UIColor[2], 0.5) | bgl.glColor4f(UIColor[0], UIColor[1], UIColor[2], 0.5) | ||||
| bgl.glBegin(bgl.GL_POLYGON) | bgl.glBegin(bgl.GL_POLYGON) | ||||
| Context not available. | |||||
| bgl.glColor4f(1.0, 0.8, 0.0, 1.0) | bgl.glColor4f(1.0, 0.8, 0.0, 1.0) | ||||
| bgl.glBegin(bgl.GL_LINE_STRIP) | bgl.glBegin(bgl.GL_LINE_STRIP) | ||||
| idx = 0 | idx = 0 | ||||
| CRadius = ((bbox[7] - bbox[0]).length) / 2 | CRadius = (bbox[7] - bbox[0]).length / 2 | ||||
| for i in range(int(len(self.CLR_C) / 3)): | for i in range(int(len(self.CLR_C) / 3)): | ||||
| vector3d = (self.CLR_C[idx * 3] * CRadius + self.CurLoc.x, self.CLR_C[idx * 3 + 1] | vector3d = (self.CLR_C[idx * 3] * CRadius + self.CurLoc.x, self.CLR_C[idx * 3 + 1] | ||||
| * CRadius + self.CurLoc.y, self.CLR_C[idx * 3 + 2] * CRadius + self.CurLoc.z) | * CRadius + self.CurLoc.y, self.CLR_C[idx * 3 + 2] * CRadius + self.CurLoc.z) | ||||
| Context not available. | |||||
| DEG2RAD = math.pi / (180.0 / self.stepAngle[self.step]) | DEG2RAD = math.pi / (180.0 / self.stepAngle[self.step]) | ||||
| if self.ctrl: | if self.ctrl: | ||||
| self.stepR = (self.mouse_path[1][1] - self.mouse_path[0][1]) / 25 | self.stepR = (self.mouse_path[1][1] - self.mouse_path[0][1]) / 25 | ||||
| shift = (math.pi / (360.0 / self.stepAngle[self.step])) * (self.stepR) | shift = (math.pi / (360.0 / self.stepAngle[self.step])) * self.stepR | ||||
| else: | else: | ||||
| shift = (self.mouse_path[1][1] - self.mouse_path[0][1]) / 50 | shift = (self.mouse_path[1][1] - self.mouse_path[0][1]) / 50 | ||||
| Context not available. | |||||
| CLRaw = [] | CLRaw = [] | ||||
| Angle = 0.0 | Angle = 0.0 | ||||
| self.NbPointsInPrimitive = 0 | self.NbPointsInPrimitive = 0 | ||||
| while(Angle < 360.0): | while Angle < 360.0: | ||||
| self.CircleListRaw.append(math.cos(math.radians(Angle)) * _radius) | self.CircleListRaw.append(math.cos(math.radians(Angle)) * _radius) | ||||
| self.CircleListRaw.append(math.sin(math.radians(Angle)) * _radius) | self.CircleListRaw.append(math.sin(math.radians(Angle)) * _radius) | ||||
| self.CircleListRaw.append(0.0) | self.CircleListRaw.append(0.0) | ||||
| Context not available. | |||||
| DirV = Dir.normalized() | DirV = Dir.normalized() | ||||
| cosTheta = ObjectV.dot(DirV) | cosTheta = ObjectV.dot(DirV) | ||||
| rotationAxis = mathutils.Vector((0.0, 0.0, 0.0)) | rotationAxis = mathutils.Vector((0.0, 0.0, 0.0)) | ||||
| if (cosTheta < -1 + 0.001): | if cosTheta < -1 + 0.001: | ||||
| v = mathutils.Vector((0.0, 1.0, 0.0)) | v = mathutils.Vector((0.0, 1.0, 0.0)) | ||||
| rotationAxis = ObjectV.cross(v) | rotationAxis = ObjectV.cross(v) | ||||
| rotationAxis = rotationAxis.normalized() | rotationAxis = rotationAxis.normalized() | ||||
| Context not available. | |||||
| starty = start + ((widthy + gapy) * row) | starty = start + ((widthy + gapy) * row) | ||||
| #---Add random rotation | #---Add random rotation | ||||
| if (self.RandomRotation) and not (self.GridScaleX or self.GridScaleY): | if self.RandomRotation and not (self.GridScaleX or self.GridScaleY): | ||||
| rotmat = mathutils.Matrix.Rotation(math.radians(360 * random.random()), 4, 'Z') | rotmat = mathutils.Matrix.Rotation(math.radians(360 * random.random()), 4, 'Z') | ||||
| for v in obverts: | for v in obverts: | ||||
| v.co = v.co * rotmat | v.co = v.co * rotmat | ||||
| verts.extend([((v.co.x - startx, v.co.y - starty, v.co.z)) for v in obverts]) | verts.extend([(v.co.x - startx, v.co.y - starty, v.co.z) for v in obverts]) | ||||
| faces.extend([[v + numface * lenverts for v in p.vertices] for p in obfaces]) | faces.extend([[v + numface * lenverts for v in p.vertices] for p in obfaces]) | ||||
| numface += 1 | numface += 1 | ||||
| Context not available. | |||||
| region_types = {'WINDOW', 'UI'} | region_types = {'WINDOW', 'UI'} | ||||
| win = context.window | win = context.window | ||||
| for area in win.screen.areas: | for area in win.screen.areas: | ||||
| if area.type in ('VIEW_3D'): | if area.type in 'VIEW_3D': | ||||
| for region in area.regions: | for region in area.regions: | ||||
| if not region_types or region.type in region_types: | if not region_types or region.type in region_types: | ||||
| region.tag_redraw() | region.tag_redraw() | ||||
| Context not available. | |||||
| if event.type == 'SPACE' and event.value == 'PRESS': | if event.type == 'SPACE' and event.value == 'PRESS': | ||||
| if self.ObjectMode or self.ProfileMode: | if self.ObjectMode or self.ProfileMode: | ||||
| # If grid, remove double with intersect meshes | # If grid, remove double with intersect meshes | ||||
| if ((self.nbcol + self.nbrow) > 3): | if (self.nbcol + self.nbrow) > 3: | ||||
| # Go in edit mode mode | # Go in edit mode mode | ||||
| bpy.ops.object.mode_set(mode='EDIT') | bpy.ops.object.mode_set(mode='EDIT') | ||||
| # Remove duplicate vertices | # Remove duplicate vertices | ||||
| Context not available. | |||||
| else: | else: | ||||
| # Solidify | # Solidify | ||||
| if (self.ObjectMode or self.ProfileMode) and (self.SolidifyPossible): | if (self.ObjectMode or self.ProfileMode) and self.SolidifyPossible: | ||||
| solidify = True | solidify = True | ||||
| if self.ObjectMode: | if self.ObjectMode: | ||||
| Context not available. | |||||
| # Undo | # Undo | ||||
| if event.type == 'Z' and event.value == 'PRESS': | if event.type == 'Z' and event.value == 'PRESS': | ||||
| if self.ctrl: | if self.ctrl: | ||||
| if (self.CutMode == LINE) and (self.bDone): | if (self.CutMode == LINE) and self.bDone: | ||||
| if len(self.mouse_path) > 1: | if len(self.mouse_path) > 1: | ||||
| self.mouse_path[len(self.mouse_path) - 1:] = [] | self.mouse_path[len(self.mouse_path) - 1:] = [] | ||||
| else: | else: | ||||
| Context not available. | |||||
| v.co.z += (event.mouse_region_x - self.am[0]) / fac | v.co.z += (event.mouse_region_x - self.am[0]) / fac | ||||
| self.am = event.mouse_region_x, event.mouse_region_y | self.am = event.mouse_region_x, event.mouse_region_y | ||||
| else: | else: | ||||
| if (self.GridScaleX): | if self.GridScaleX: | ||||
| self.gapx += (event.mouse_region_x - self.am[0]) / 50 | self.gapx += (event.mouse_region_x - self.am[0]) / 50 | ||||
| self.am = event.mouse_region_x, event.mouse_region_y | self.am = event.mouse_region_x, event.mouse_region_y | ||||
| update_grid(self, context) | update_grid(self, context) | ||||
| return {'RUNNING_MODAL'} | return {'RUNNING_MODAL'} | ||||
| elif (self.GridScaleY): | elif self.GridScaleY: | ||||
| self.gapy += (event.mouse_region_x - self.am[0]) / 50 | self.gapy += (event.mouse_region_x - self.am[0]) / 50 | ||||
| self.am = event.mouse_region_x, event.mouse_region_y | self.am = event.mouse_region_x, event.mouse_region_y | ||||
| update_grid(self, context) | update_grid(self, context) | ||||
| Context not available. | |||||
| bpy.ops.object.mode_set(mode='EDIT') | bpy.ops.object.mode_set(mode='EDIT') | ||||
| bpy.ops.mesh.select_all(action='SELECT') | bpy.ops.mesh.select_all(action='SELECT') | ||||
| bpy.ops.mesh.select_mode(type="EDGE") | bpy.ops.mesh.select_mode(type="EDGE") | ||||
| if (self.snapCursor == False) or (self.ForceRebool): | if (self.snapCursor == False) or self.ForceRebool: | ||||
| bpy.ops.transform.translate(value=self.ViewVector * objBBDiagonal * subdivisions) | bpy.ops.transform.translate(value=self.ViewVector * objBBDiagonal * subdivisions) | ||||
| bpy.ops.mesh.extrude_region_move( | bpy.ops.mesh.extrude_region_move( | ||||
| TRANSFORM_OT_translate={"value": -self.ViewVector * objBBDiagonal * subdivisions * 2}) | TRANSFORM_OT_translate={"value": -self.ViewVector * objBBDiagonal * subdivisions * 2}) | ||||
| Context not available. | |||||