Пример #1
0
    def __init__(self):
        ompy.MUserData.__init__(self, False)
        self.setDeleteAfterUse(False)  # don;t delete after draw
        self.shapes = []  #vector<int>
        self.coords = ompy.MFloatVectorArray()  #MFloatVectorArray
        self.screenSpaceOffsets = ompy.MFloatVectorArray()  #MFloatVectorArray
        self.sizes = []  #vector<float>
        self.thicknesses = []  #vector<float>
        self.colors = ompy.MFloatPointArray()  #MFloatPointArray
        self.pColors = []  #vector<MFloatPointArray>
        self.names = []  #vector<MString>
        self.fills = []  #vector<bool>
        self.spaces = []  #vector<int>
        self.maxMemorys = []  #vector<int>
        self.projPlanes = []  #vector<int>
        self.drawPlaneMode = 0  #int
        self.cameraPath = ompy.MDagPath()  #MDagPath

        self.attrMatrix = ompy.MFloatMatrix()  #MFloatMatrix
        self.attrNames = []  #vector<MString>
        self.attrValueType = []  #vector<MString>
        self.attrValueInt = []  #vector<int>
        self.attrValueFloat = []  #vector<float>
        self.attrValueDouble = []  #vector<double>
        self.attrValueEnum = []  #vector<MString>
Пример #2
0
    def addUIDrawables(self, objPath, drawManager, frameContext, data):
        DEBUG_C = 1

        if (DEBUG_C):
            print(
                "glDrawDrawOverride________________________________________addUIDrawables - GET DATA"
            )

        #glDrawData* data = (glDrawData*)dataRaw;
        #if (!data) { return; }

        cameraFn = ompy.MFnCamera(data.cameraPath)
        cameraTrsf = ompy.MFnDagNode(cameraFn.parent(0))
        camMatrix = MMatrixToMFloatMatrix(cameraTrsf.transformationMatrix())
        camPlaneNearDistance = cameraFn.nearClippingPlane
        camPlaneFarDistance = cameraFn.farClippingPlane

        if (DEBUG_C):
            print(
                "glDrawDrawOverride________________________________________addUIDrawables - DRAW"
            )
        drawManager.beginDrawable()

        iCoords = 0
        exitDrawing = False

        for i in range(0, len(data.shapes)):
            #________________________________________GET COORDS FOR BUILDING ONE SHAPE

            nbrElementForBuild = self.shapeToNbrElemForBuild[data.shapes[i]]

            coordsForBuild = ompy.MFloatPointArray()
            ssOffsetsForBuild = ompy.MFloatVectorArray()
            for j in range(0, nbrElementForBuild):
                if (len(data.coords) <= iCoords):
                    exitDrawing = True
                    break

                coordsForBuild.append(data.coords[iCoords])
                ssOffsetsForBuild.append(data.screenSpaceOffsets[iCoords])
                iCoords += 1

            if (exitDrawing == True): break

            #________________________________________DRAW BUILD CONVERT COORDS

            distIncr = 0.001
            foregroundDist = camPlaneNearDistance + 0.02
            backgroundDist = camPlaneFarDistance - 0.02

            coords = ompy.MFloatPointArray()
            size = 1.0
            thickness = 1.0
            if ((data.drawPlaneMode == 1)
                    and (0 < coordsForBuild.length())):  #FOREGROUND

                coords = snapCoordsOnCameraPlane(camMatrix, foregroundDist,
                                                 coordsForBuild)
                size = snapLengthOnCameraPlane(camMatrix, foregroundDist,
                                               coordsForBuild[0],
                                               data.sizes[i])
                #thickness = data.thicknesses[i]
                foregroundDist += distIncr

            elif ((data.drawPlaneMode == 2)
                  and (0 < coordsForBuild.length())):  #sBACKGROUND

                coords = snapCoordsOnCameraPlane(camMatrix, backgroundDist,
                                                 coordsForBuild)
                size = snapLengthOnCameraPlane(camMatrix, backgroundDist,
                                               coordsForBuild[0],
                                               data.sizes[i])
                #thickness = data.thicknesses[i]
                backgroundDist -= distIncr

            else:

                coords = coordsForBuild
                size = data.sizes[i]
                #thickness = data.thicknesses[i]

            ssOffsets = ompy.MFloatVectorArray(ssOffsetsForBuild)

            #________________________________________DRAW SHAPE

            if (self.shapesNames[data.shapes[i]] == "segment"):
                glDrawSegments(drawManager, camMatrix, coords, ssOffsets,
                               data.colors[i], 0, 1.0)
            elif (self.shapesNames[data.shapes[i]] == "triangle"):
                pass  #glDrawTriangles(      drawManager, camMatrix, coords, ssOffsets, data.colors[i],    data.pColors[i])
            elif (self.shapesNames[data.shapes[i]] == "pointTriangle"):
                pass  #glDrawPointTriangle(  drawManager, camMatrix, coords, ssOffsets, data.colors[i],    data.fills[i], size, thickness)
            elif (self.shapesNames[data.shapes[i]] == "pointSquare"):
                pass  #glDrawPointSquare(    drawManager, camMatrix, coords, ssOffsets, data.colors[i],    data.fills[i], size, thickness)
            elif (self.shapesNames[data.shapes[i]] == "pointCircle"):
                pass  #glDrawPointCircle(    drawManager, camMatrix, coords, ssOffsets, data.colors[i],    data.fills[i], size, thickness)
            elif (self.shapesNames[data.shapes[i]] == "pointStar"):
                pass  #glDrawPointStar(      drawManager, camMatrix, coords, ssOffsets, data.colors[i],    data.fills[i], size, thickness)
            elif (self.shapesNames[data.shapes[i]] == "pointCross"):
                pass  #glDrawPointCross(     drawManager, camMatrix, coords, ssOffsets, data.colors[i],    data.fills[i], size, thickness)
            elif (self.shapesNames[data.shapes[i]] == "vector"):
                pass  #glDrawVector(         drawManager, camMatrix, coords, ssOffsets, data.colors[i],    data.fills[i], size, thickness)
            elif (self.shapesNames[data.shapes[i]] == "text"):
                glDrawText(drawManager, camMatrix, coords, ssOffsets,
                           data.names[i], data.colors[i], True, size, 1.0)

        drawManager.endDrawable()