コード例 #1
0
ファイル: octahedron.py プロジェクト: HadibOo/Forms
    def generate( self, radius = 10, iterations = 1 ):
        
        self.radius     = radius
        self.iterations = iterations
        
        print( "%s radius %f iterations %i" % ( self.__class__.__name__, self.radius, self.iterations ) )

        octahedronRadius = float(self.radius) / util.pow( float(2), float(self.iterations ) )
        octahedron       = self.mesh( radius = octahedronRadius )
        octahedra        = [ octahedron ]
        
        pm.polySoftEdge( angle = 0 )   

        octahedronHeight = octahedron[ 1 ].getSideLength() / util.sqrt( 2 )
    
        for i in range( iterations ):
            
            mesh = self.__generateMesh( octahedra[ 0 ], octahedronHeight, octahedronRadius, ( i + 1 ) )
            
            octahedronHeight *= 2            
            octahedronRadius *= 2            
            
            octahedra = [ mesh ]
        

        pm.xform( mesh[ 0 ], centerPivots = True )

        print( "Construction complete" )
        
        return mesh
コード例 #2
0
    def generate(self, radius=10, iterations=1):

        self.radius = radius
        self.iterations = iterations

        print("%s radius %f iterations %i" %
              (self.__class__.__name__, self.radius, self.iterations))

        octahedronRadius = float(self.radius) / util.pow(
            float(2), float(self.iterations))
        octahedron = self.mesh(radius=octahedronRadius)
        octahedra = [octahedron]

        pm.polySoftEdge(angle=0)

        octahedronHeight = octahedron[1].getSideLength() / util.sqrt(2)

        for i in range(iterations):

            mesh = self.__generateMesh(octahedra[0], octahedronHeight,
                                       octahedronRadius, (i + 1))

            octahedronHeight *= 2
            octahedronRadius *= 2

            octahedra = [mesh]

        pm.xform(mesh[0], centerPivots=True)

        print("Construction complete")

        return mesh
コード例 #3
0
ファイル: tetrahedron.py プロジェクト: n1ckfg/Forms
    def generate( self, radius = 10, iterations = 1 ):
        
        self.radius     = radius
        self.iterations = iterations
        
        print( "%s radius %f iterations %i" % ( self.__class__.__name__, self.radius, self.iterations ) )

        tetrahedronRadius = float(self.radius) / util.pow( float(2), float(self.iterations ) )
        tetrahedron       = self.mesh( radius = tetrahedronRadius )
        tetrahedra        = [ tetrahedron ]

        pm.polySoftEdge( angle = 0 )
        
        sideLength        = tetrahedron[ 1 ].getSideLength()
        tetrahedronHeight = util.sqrt(6) / 3 * sideLength
        
        positions = [ ]

        for vertex in tetrahedron[ 0 ].vtx:

            position = vertex.getPosition()
            positions.append( dt.FloatVector( position ) );


        for i in range( iterations ):

            mesh = self.__generateMesh( tetrahedra[ 0 ], tetrahedronHeight, tetrahedronRadius, sideLength, positions, ( i + 1 ) )
            
            for j in range( len( positions ) ):
                
                positions[ j ] *= 2
            
            tetrahedronHeight = tetrahedronHeight * 2
            tetrahedronRadius = tetrahedronRadius * 2
            sideLength        = sideLength * 2
            
            tetrahedra = [ mesh ]
        

        print( "Construction complete" )

        return mesh