Beispiel #1
0
    def replace(self, meshIn):
        newMesh = Mesh()
        for face in meshIn.faces:
            taperFace = face
            for j in range(self.iterations):
                normal = taperFace.getNormal()

                center = taperFace.getCenterAverage()
                normal.mult(self.extrude)
                rV = PVector(
                    random(-self.extrude * self.rnd, self.extrude * self.rnd))
                normal.add(rV)
                normal.setMag(self.extrude)
                #center.add(normal)

                newNodes = []
                for node in taperFace.points:
                    dir = PVector.sub(center, node)
                    dir.mult(self.offset)
                    dir.add(node)
                    dir.add(normal)
                    newNodes.append(Node(dir))
                for i in range(taperFace.getNumPoints()):
                    n1 = taperFace.getPoint(i)
                    n2 = taperFace.getPoint((i + 1) % taperFace.getNumPoints())
                    n3 = newNodes[(i + 1) % taperFace.getNumPoints()]
                    n4 = newNodes[(i) % taperFace.getNumPoints()]
                    newFace = newMesh.addFace(n1, n2, n3, n4)
                    newFace.inheritPropertiesFrom(face)
                taperFace = Face(newNodes)
            if self.close:
                newFace = newMesh.addFace(taperFace)
                newFace.inheritPropertiesFrom(face)
        newMesh.constructTopology()
        return newMesh
Beispiel #2
0
 def replace(self, oldMesh):
     # clone the old mesh
     # oldMesh.getCopy()
     bounds = oldMesh.getBounds()
     newMesh = Mesh()
     newNodes = [None] * oldMesh.points.size()
     for node in oldMesh.points:
         newNodes[node.id] = Node(node)
     for face in oldMesh.faces:
         newFace = Face()
         newMesh.addFace(newFace)
         for node in face.points:
             newFace.points.add(newNodes[node.id])
     newMesh.constructTopology()
     # make a backup of the normals, not necessary if this is a copy of new mesh
     normalBackup = [None] * newMesh.points.size()
     for node in newMesh.points:
         normalBackup[node.id] = node.getNormal()
     # shift the nodes
     for node in newMesh.points:
         #nml=normalBackup[node.id]
         nml = oldMesh.getPoint(node.id).getNormal()
         translateMap = 30 * sin(map(node.y, bounds.y1, bounds.y2, 0, 30))
         nml.mult(translateMap)
         node.add(nml)
     return newMesh
Beispiel #3
0
 def replace(self, mesh):
     newMesh = Mesh()
     newNodes = []
     for n in mesh.points:
         normal = n.getNormal()
         normal.setMag(self.offset)
         node = Node(n)
         node.add(normal)
         newNodes.append(node)
     for oldFace in mesh.faces:
         newFace = Face()
         for node in oldFace.points:
             newFace.addPoint(newNodes[node.id])
         newFace.inverse()
         newMesh.addFace(newFace)
         newMesh.addFace(oldFace)
     if self.closeSides == True:
         for face in mesh.faces:
             edges = face.getEdges()
             for e in edges:
                 if e.f1 == None or e.f2 == None:
                     newMesh.addFace(e.n2, e.n1, newNodes[e.n1.id],
                                     newNodes[e.n2.id])
     newMesh.constructTopology()
     return newMesh