コード例 #1
0
 def execute(self, context):
     splRes = context.scene.curvetools.SplineResolution
     selCurves = Util.GetSelectedCurves()
     
     for blCurve in selCurves:
         for spline in blCurve.data.splines:
             spline.resolution_u = splRes
     
     return {'FINISHED'}
コード例 #2
0
 def execute(self, context):
     threshold = context.scene.curvetools.SplineRemoveLength
     selCurves = Util.GetSelectedCurves()
     
     for blCurve in selCurves:
         curve = Curves.Curve(blCurve)
         nrSplines = curve.nrSplines
         
         nrRemovedSplines = curve.RemoveShortSplines(threshold)
         if nrRemovedSplines > 0: curve.RebuildInScene()
         
         self.report({'INFO'}, "Removed %d of %d splines" % (nrRemovedSplines, nrSplines))
     
     return {'FINISHED'}
コード例 #3
0
 def execute(self, context):
     selCurves = Util.GetSelectedCurves()
     
     for blCurve in selCurves:
         curve = Curves.Curve(blCurve)
         nrSplines = curve.nrSplines
         
         threshold = context.scene.curvetools.SplineJoinDistance
         startEnd = context.scene.curvetools.SplineJoinStartEnd
         mode = context.scene.curvetools.SplineJoinMode
         
         nrJoins = curve.JoinNeighbouringSplines(startEnd, threshold, mode)
         if nrJoins > 0: curve.RebuildInScene()
         
         self.report({'INFO'}, "Applied %d joins on %d splines; resulting nrSplines: %d" % (nrJoins, nrSplines, curve.nrSplines))
     
     return {'FINISHED'}
コード例 #4
0
 def execute(self, context):
     selCurves = Util.GetSelectedCurves()
     
     for blCurve in selCurves:
         curve = Curves.Curve(blCurve)
         nrSplines = curve.nrSplines
         
         splinesToRemove = []
         for spline in curve.splines:
             if len(spline.segments) < 1: splinesToRemove.append(spline)
         nrRemovedSplines = len(splinesToRemove)    
             
         for spline in splinesToRemove: curve.splines.remove(spline)
         
         if nrRemovedSplines > 0: curve.RebuildInScene()
         
         self.report({'INFO'}, "Removed %d of %d splines" % (nrRemovedSplines, nrSplines))
     
     return {'FINISHED'}
コード例 #5
0
 def poll(cls, context):
     return Util.Selected1Curve()
コード例 #6
0
 def poll(cls, context):
     return Util.Selected1OrMoreCurves()
コード例 #7
0
 def poll(cls, context):
     return Util.Selected3Curves()
コード例 #8
0
    def InitGlobals():
        CurvesIntersector.ResetGlobals()

        algo = bpy.context.scene.curvetools.IntersectCurvesAlgorithm
        if algo == 'From View':
            regionView3D = Util.GetFirstRegionView3D()
            if regionView3D is None:
                print("### ERROR: regionView3D is None. Stopping.")
                return

            viewPerspective = regionView3D.view_perspective
            print("--", "viewPerspective:", viewPerspective)

            if viewPerspective == 'ORTHO':
                viewMatrix = regionView3D.view_matrix
                print("--", "viewMatrix:")
                print(viewMatrix)

                global algoDIR
                algoDIR = Vector(
                    (viewMatrix[2][0], viewMatrix[2][1], viewMatrix[2][2]))
                print("--", "algoDIR:", algoDIR)

            # ## TODO: doesn't work properly
            if viewPerspective == 'PERSP':
                viewMatrix = regionView3D.view_matrix
                print("--", "viewMatrix:")
                print(viewMatrix)

                global algoPOV
                algoPOV = regionView3D.view_location.copy()
                print("--", "algoPOV:", algoPOV)

                otherPOV = Vector(
                    (viewMatrix[0][3], viewMatrix[1][3], viewMatrix[2][3]))
                print("--", "otherPOV:", otherPOV)

                localPOV = Vector((0, 0, 0))
                globalPOV = viewMatrix * localPOV
                print("--", "globalPOV:", globalPOV)

                perspMatrix = regionView3D.perspective_matrix
                print("--", "perspMatrix:")
                print(perspMatrix)

                globalPOVPersp = perspMatrix * localPOV
                print("--", "globalPOVPersp:", globalPOVPersp)

            if viewPerspective == 'CAMERA':
                camera = bpy.context.scene.camera
                if camera is None:
                    print("### ERROR: camera is None. Stopping.")
                    return

                print("--", "camera:", camera)
                cameraData = camera.data
                print("--", "cameraData.type:", cameraData.type)

                cameraMatrix = camera.matrix_world
                print("--", "cameraMatrix:")
                print(cameraMatrix)

                if cameraData.type == 'ORTHO':
                    cameraMatrix = camera.matrix_world

                    global algoDIR
                    #algoDIR = Vector((cameraMatrix[2][0], cameraMatrix[2][1], cameraMatrix[2][2]))
                    algoDIR = Vector((-cameraMatrix[0][2], -cameraMatrix[1][2],
                                      -cameraMatrix[2][2]))
                    print("--", "algoDIR:", algoDIR)

                if cameraData.type == 'PERSP':
                    global algoPOV
                    algoPOV = camera.location.copy()
                    print("--", "algoPOV:", algoPOV)