Пример #1
0
    def __generateMesh( self, mesh, positions, radius, iteration ):
        
        instanceGroup   = pm.group( empty = True, name = "meshInstanceGroup" )

        positionsLength = len( positions )
        instances       = [ None ] * positionsLength

        for i in range(0, positionsLength):

            position = scaleVector( positions[ i ], radius )

            if i == 0:

                meshInstance = mesh
                meshInstance[ 0 ].setTranslation( position )

            else:

                meshInstance = pm.instance( mesh[ 0 ] )
                meshInstance[ 0 ].setTranslation(position)

            instances[ i ] = meshInstance[ 0 ]

        pm.parent( instances, instanceGroup, add = True )

        return combineClean( instanceGroup, "Sierpinski_Iteration_%i" % iteration ) 
Пример #2
0
    def __generateMesh( self, mesh, height, radius, sideLength, positions, iteration ):
       
        instanceGroup = pm.group( empty = True, name = "meshInstanceGroup" )
        
        x = 0
        y = positions[ 0 ].y 
        z = 0

        # vertex indices's
        # [ 0 ] is right
        # [ 1 ] is left
        # [ 2 ] is front
        # [ 3 ] is top

        backVtx = positions[ 1 ]
        
        # Top
        meshInstance1 = pm.PyNode( mesh[ 0 ] )
        meshInstance1.setTranslation( [ x, y + height, z ] )
        
        # Right
        meshInstance2 = pm.instance( mesh[ 0 ] )
        meshInstance2[ 0 ].setTranslation( [ backVtx.x, y, -backVtx.z ] )

        # Left
        meshInstance3 = pm.instance( mesh[ 0 ] )
        meshInstance3[ 0 ].setTranslation( [ backVtx.x, y, backVtx.z ] )
        
        # Front
        meshInstance4 = pm.instance( mesh[ 0 ] )
        meshInstance4[ 0 ].setTranslation( [ radius, y, z ] )
                            
        pm.parent( [ meshInstance1, meshInstance2[ 0 ], meshInstance3[ 0 ], meshInstance4[ 0 ] ], instanceGroup, add = True )        
        
        return combineClean( instanceGroup, "Sierpinski_Iteration_%i" % iteration )
Пример #3
0
    def __generateMesh( self, mesh, height, radius, iteration ):

        instanceGroup = pm.group( empty = True, name = "meshInstanceGroup" )

        x = 0
        y = 0
        z = 0
            
        # Top
        meshInstance1 = mesh
        meshInstance1[ 0 ].setTranslation( [ x, height, z ] )        
        
        # Right
        meshInstance2 = pm.instance( mesh[ 0 ] )
        meshInstance2[ 0 ].setTranslation( [ radius, y, z ] )
        
        # Back
        meshInstance3 = pm.instance( mesh[ 0 ] )
        meshInstance3[ 0 ].setTranslation( [ x, y, -radius ] )           
        
        # Left
        meshInstance4 = pm.instance( mesh[ 0 ] )
        meshInstance4[ 0 ].setTranslation( [ -radius, y, z ] )
        
        # Front
        meshInstance5 = pm.instance( mesh[ 0 ] )
        meshInstance5[ 0 ].setTranslation( [ x, y, radius ] )          
        
        # Bottom
        meshInstance6 = pm.instance( mesh[ 0 ] )
        meshInstance6[ 0 ].setTranslation( [ x, -height, z ] ) 
                
        pm.parent( meshInstance1[ 0 ], meshInstance2[ 0 ], meshInstance3[ 0 ], meshInstance4[ 0 ], meshInstance5[ 0 ], meshInstance6[ 0 ], instanceGroup, add = True )        

        return combineClean( instanceGroup, "Sierpinski_Iteration_%i" % iteration )
Пример #4
0
    def __generateMesh(self, mesh, positions, radius, iteration):

        instanceGroup = pm.group(empty=True, name="meshInstanceGroup")

        positionsLength = len(positions)
        instances = [None] * positionsLength

        for i in range(0, positionsLength):

            position = scaleVector(positions[i], radius)

            if i == 0:

                meshInstance = mesh
                meshInstance[0].setTranslation(position)

            else:

                meshInstance = pm.instance(mesh[0])
                meshInstance[0].setTranslation(position)

            instances[i] = meshInstance[0]

        pm.parent(instances, instanceGroup, add=True)

        return combineClean(instanceGroup,
                            "Sierpinski_Iteration_%i" % iteration)
Пример #5
0
    def __generateMesh( self, mesh, size, iteration ):

        instanceGroup   = pm.group( empty = True, name = "meshInstanceGroup" )
        
        instances = [ None ] * util.pow( self.grid, 3 )
        
        # Instance a sponge, position it, then add it to the group
        
        def makeInstance( levels, rows, columns, index ):

            x = ( size * 1 ) - ( rows * size )
            y = ( size * 1 ) - ( levels * size )
            z = ( size * 1 ) - ( columns * size )

            if index == 0:

                meshInstance = mesh

            else:

                meshInstance = pm.instance( mesh[ 0 ] )

            meshInstance[ 0 ].setTranslation( [ x, y, z ] )
            instances.append( meshInstance[ 0 ] )
        

        # Generate the sponge instances
        
        i = 0   
        j = 0   
        
        for levels in range( self.grid ):

            for rows in range( self.grid ):

                for columns in range( self.grid ):

                    if i not in self.holes:

                        makeInstance( levels, rows, columns, j ) 

                        j += 1

                    i += 1

        
        pm.parent( instances, instanceGroup, add = True )
        
        return combineClean( instanceGroup, "Sierpinski_Iteration_%i" % iteration, True )
Пример #6
0
    def __generateMesh(self, mesh, height, radius, iteration):

        instanceGroup = pm.group(empty=True, name="meshInstanceGroup")

        x = 0
        y = 0
        z = 0

        # Top
        meshInstance1 = mesh
        meshInstance1[0].setTranslation([x, height, z])

        # Right
        meshInstance2 = pm.instance(mesh[0])
        meshInstance2[0].setTranslation([radius, y, z])

        # Back
        meshInstance3 = pm.instance(mesh[0])
        meshInstance3[0].setTranslation([x, y, -radius])

        # Left
        meshInstance4 = pm.instance(mesh[0])
        meshInstance4[0].setTranslation([-radius, y, z])

        # Front
        meshInstance5 = pm.instance(mesh[0])
        meshInstance5[0].setTranslation([x, y, radius])

        # Bottom
        meshInstance6 = pm.instance(mesh[0])
        meshInstance6[0].setTranslation([x, -height, z])

        pm.parent(meshInstance1[0],
                  meshInstance2[0],
                  meshInstance3[0],
                  meshInstance4[0],
                  meshInstance5[0],
                  meshInstance6[0],
                  instanceGroup,
                  add=True)

        return combineClean(instanceGroup,
                            "Sierpinski_Iteration_%i" % iteration)
Пример #7
0
reload ( meshUtil )


sphere = pm.polySphere( subdivisionsAxis = 8, subdivisionsX = 8, subdivisionsY = 8, subdivisionsHeight = 8, radius = 10 )

mesh1 = pm.duplicate( sphere[ 0 ] )
mesh2 = pm.duplicate( sphere[ 0 ] )
mesh1[ 0 ].setAttr( 'translateZ', -20 )
mesh2[ 0 ].setAttr( 'translateZ', 20 )

meshUtil.polyWire( mesh1, depth = 0.9, extrudeMode = 0 )
meshUtil.polyWire( mesh2, depth = 0.9, extrudeMode = 1 )

print mesh1
print mesh2

# Result: [nt.Transform(u'pSphere2')]
# Result: [nt.Transform(u'pSphere3')]

mesh1 = pm.duplicate( sphere[ 0 ] )
mesh2 = pm.duplicate( sphere[ 0 ] )
mesh3 = pm.duplicate( sphere[ 0 ] )

mesh1[ 0 ].setTranslation( [ -20, 0, -10 ] )
mesh2[ 0 ].setTranslation( [ -20, 0, 10 ] )
mesh3[ 0 ].setTranslation( [ -20, 0, 0 ] )

meshUtil.combineClean( pm.group( mesh1, mesh2, mesh3 ), 'combineCleanResult' )

# Result: [nt.Transform(u'combineCleanResult')]
Пример #8
0
sphere = pm.polySphere(subdivisionsAxis=8,
                       subdivisionsX=8,
                       subdivisionsY=8,
                       subdivisionsHeight=8,
                       radius=10)

mesh1 = pm.duplicate(sphere[0])
mesh2 = pm.duplicate(sphere[0])
mesh1[0].setAttr('translateZ', -20)
mesh2[0].setAttr('translateZ', 20)

meshUtil.polyWire(mesh1, depth=0.9, extrudeMode=0)
meshUtil.polyWire(mesh2, depth=0.9, extrudeMode=1)

print mesh1
print mesh2

# Result: [nt.Transform(u'pSphere2')]
# Result: [nt.Transform(u'pSphere3')]

mesh1 = pm.duplicate(sphere[0])
mesh2 = pm.duplicate(sphere[0])
mesh3 = pm.duplicate(sphere[0])

mesh1[0].setTranslation([-20, 0, -10])
mesh2[0].setTranslation([-20, 0, 10])
mesh3[0].setTranslation([-20, 0, 0])

meshUtil.combineClean(pm.group(mesh1, mesh2, mesh3), 'combineCleanResult')

# Result: [nt.Transform(u'combineCleanResult')]