Beispiel #1
0
    def calculateTextureCoordinates(self, realSize):
        textureCoords = coin.SoTextureCoordinate2()

        for face in self.faces:
            face.appendTextureCoordinates(textureCoords, realSize)

        return textureCoords
Beispiel #2
0
    def setupGroundNode(self):
        groundNode = coin.SoSeparator()

        self.groundCoordinates = coin.SoCoordinate3()

        self.groundTexture = coin.SoTexture2()
        self.groundTexture.filename = py2_utils.textureFileString(
            self.Object.GroundImage)
        self.groundTexture.model = coin.SoMultiTextureImageElement.REPLACE

        groundTextureCoordinates = coin.SoTextureCoordinate2()
        groundTextureCoordinates.point.set1Value(0, 0, 0)
        groundTextureCoordinates.point.set1Value(1, 1, 0)
        groundTextureCoordinates.point.set1Value(2, 1, 1)
        groundTextureCoordinates.point.set1Value(3, 0, 1)

        faceset = coin.SoFaceSet()
        faceset.numVertices.set1Value(0, 4)

        groundNode.addChild(self.groundCoordinates)
        groundNode.addChild(groundTextureCoordinates)
        groundNode.addChild(self.groundTexture)
        groundNode.addChild(faceset)

        return groundNode
Beispiel #3
0
    def setupSkyNode(self):
        skyNode = coin.SoSeparator()

        self.skyCoordinates = coin.SoCoordinate3()

        self.skyTexture = coin.SoTexture2()
        self.skyTexture.filename = py2_utils.textureFileString(
            self.Object.SkyImage)
        self.skyTexture.model = coin.SoMultiTextureImageElement.REPLACE

        self.skyTextureCoordinates = coin.SoTextureCoordinate2()

        faceset = coin.SoFaceSet()
        faceset.numVertices.set1Value(0, 4)
        faceset.numVertices.set1Value(1, 4)
        faceset.numVertices.set1Value(2, 4)
        faceset.numVertices.set1Value(3, 4)
        faceset.numVertices.set1Value(4, 3)
        faceset.numVertices.set1Value(5, 4)

        skyNode.addChild(self.skyCoordinates)
        skyNode.addChild(self.skyTextureCoordinates)
        skyNode.addChild(self.skyTexture)
        skyNode.addChild(faceset)

        return skyNode
Beispiel #4
0
    def printData(self, realSize=None):
        if DEBUG:
            print('   atOriginVertices:')
            for vertex in self.atOriginVertices:
                print('    %s' % (vertex, ))

            print('   rotatedVertices:')
            for vertex in self.rotatedVertices:
                print('    %s' % (vertex, ))

            print('   positiveAxisVertices:')
            for vertex in self.positiveAxisVertices:
                print('    %s' % (vertex, ))

            print('   vertices:')
            for vertex in self.vertices:
                print('    %s' % (vertex, ))

            print('    positiveTransform: %s' % (self.positiveTransform, ))
            print('    swapAxis: %s' % (self.shouldSwapAxis(realSize), ))
            print('    overrides: %s' % (self.overrides, ))

        textureCoords = coin.SoTextureCoordinate2()
        self.appendTextureCoordinates(textureCoords, realSize)

        normalizedCoords = coin.SoTextureCoordinate2()
        self.appendTextureCoordinates(normalizedCoords, None)

        print('   originalVertices:')
        for vertex in self.originalVertices:
            normalizedIndexCoords = normalizedCoords.point.getValues()[
                vertex['index']].getValue()
            indexCoords = textureCoords.point.getValues()[
                vertex['index']].getValue()

            print('    %s' % ({
                'index': vertex['index'],
                'vector': vertex['vector'],
                'normalizedCoords': normalizedIndexCoords,
                'coords': indexCoords
            }, ))

        print('    length: %s, height: %s' % (self.length, self.height))
        print('    scaleFactor: %s' % (self.calculateScaleFactor(realSize), ))
        print('    textureRotation: %s' %
              (self.calculateScaleFactor(realSize), ))
    def attach(self, vobj):
        self.ViewObject = vobj
        self.Object = vobj.Object
        self.LithophaneImage = self.Object.Proxy

        self.Object.setEditorMode("UpdateNotifier", 2)

        self.imageNode = coin.SoSeparator()

        self.coords = coin.SoCoordinate3()
        self.coords.point.set1Value(0, 0, 0, -1)
        self.coords.point.set1Value(1, 1, 0, -1)
        self.coords.point.set1Value(2, 1, 1, -1)
        self.coords.point.set1Value(3, 0, 1, -1)

        textureCoords = coin.SoTextureCoordinate2()
        textureCoords.point.set1Value(0, 0, 0)
        textureCoords.point.set1Value(1, 1, 0)
        textureCoords.point.set1Value(2, 1, 1)
        textureCoords.point.set1Value(3, 0, 1)

        faceset = coin.SoFaceSet()
        faceset.numVertices.set1Value(0, 4)

        # This makes it possible to select the object in the 3D View
        selectionNode = coin.SoType.fromName("SoFCSelection").createInstance()
        selectionNode.documentName.setValue(FreeCAD.ActiveDocument.Name)
        selectionNode.objectName.setValue(self.Object.Name)
        selectionNode.subElementName.setValue("Face")
        selectionNode.addChild(faceset)

        self.texture = coin.SoTexture2()

        self.imageNode.addChild(self.coords)
        self.imageNode.addChild(textureCoords)
        self.imageNode.addChild(self.texture)
        self.imageNode.addChild(selectionNode)

        vobj.addDisplayMode(self.imageNode, "LithophaneImage")
Beispiel #6
0
    def setupPanoramaNode(self):
        panoramaNode = coin.SoSeparator()

        self.panoramaCoordinates = coin.SoCoordinate3()

        self.panoramaTextureCoordinates = coin.SoTextureCoordinate2()

        self.panoramaTexture = coin.SoTexture2()
        self.panoramaTexture.filename = py2_utils.textureFileString(
            self.Object.PanoramaImage)
        self.panoramaTexture.model = coin.SoMultiTextureImageElement.REPLACE

        faceset = coin.SoFaceSet()
        faceset.numVertices.set1Value(0, 4)
        faceset.numVertices.set1Value(1, 4)
        faceset.numVertices.set1Value(2, 4)

        panoramaNode.addChild(self.panoramaCoordinates)
        panoramaNode.addChild(self.panoramaTextureCoordinates)
        panoramaNode.addChild(self.panoramaTexture)
        panoramaNode.addChild(faceset)

        return panoramaNode