Beispiel #1
0
def load_objects( filename ):
    global VERSION_NUMBER
    polygons = []
    with open( filename, 'r' ) as f:
        lines = f.readlines()
        version = float( lines.pop( 0 ) )
        if version >= VERSION_NUMBER:
            lines.pop( 0 ) # ignore num_objects
            while len( lines ) > 0:
                c = lines.pop( 0 ).split()
                polygon = Polygon( ( int( c[ 0 ] ), int( c[ 1 ] ), int( c[ 2 ] ) ) )
                num_ps = int( lines.pop( 0 ) )
                for i in range( 0, num_ps ):
                    magnitudes = map( int, lines.pop( 0 ).split() )
                    polygon.add( Point( *magnitudes ) )
                polygons.append( polygon.close() )
        else:
            print "Modeller3D version " + VERSION_NUMBER + " cannot read file from Modeller3D version " + version
    return polygons
Beispiel #2
0
         )
     else:
         actions.do( \
             ( lambda a: objects.append( a ), [ Polygon( ( 100, 100, ( 200 + model.position.z * 2 ) % 255 ) ).add( point ) ] ), \
             ( objects.pop, [] ) \
         )
 elif Command.POLYGON == command[ 0 ]:
     if len( objects ) > 0 and objects[ -1 ].is_open():
         actions.do( \
             ( objects[ -1 ].close, [] ), \
             ( objects[ -1 ].open, [] ) \
         )
     polygon = Polygon( ( 100, 100, ( 200 + model.position.z * 2 ) % 255 ) )
     for p in command[ 1 ]:
         polygon.add( Point( int( p[ 0 ] ), int( p[ 1 ] ), int( p[ 2 ] ) ) )
     polygon.close()
     actions.do( \
         ( objects.append, [ polygon ] ), \
         ( objects.pop, [] ) \
     )
 elif Command.SET == command[ 0 ]:
     option = command[ 1 ][ 0 ]
     if 'g' == option:
         model = model.set_grid( True )
     elif 'nog' == option:
         model = model.set_grid( False )
     elif 'sg' == option:
         snapgrid = True
         model = model.set_grid( True )
     elif 'nosg' == option:
         snapgrid = False