def getHeightGrid(fileName):
 if ('models/' not in fileName):
  print 'Warning, models/ was not in the absolute file path, so for security nothing will be done for:'
  print fileName
  print 'The heightmap tool can only read a file which has models/ in the file path.'
  print 'To import the file, move the file into a folder called model/ or a subfolder which is inside the model folder tree.'
  return
 pgmText = archive.getFileText(fileName)
 textLines = archive.getTextLines(pgmText)
 format = textLines[0].lower()
 sizeWords = textLines[2].split()
 numberOfColumns = int(sizeWords[0])
 numberOfRows = int(sizeWords[1])
 heights = []
 if (format == 'p1'):
  addHeightsByBitmap(heights, textLines)
 elif (format == 'p2'):
  addHeightsByGraymap(heights, textLines)
 else:
  print 'Warning, the file format was not recognized for:'
  print fileName
  print 'Heightmap can only read the Netpbm Portable bitmap format and the Netpbm Portable graymap format.'
  print 'The Netpbm formats are described at:'
  print 'http://en.wikipedia.org/wiki/Netpbm_format'
  return []
 heightGrid = []
 heightIndex = 0
 for rowIndex in xrange(numberOfRows):
  row = []
  heightGrid.append(row)
  for columnIndex in xrange(numberOfColumns):
   row.append(heights[heightIndex])
   heightIndex += 1
 return heightGrid

def getHeightGrid ( fileName ) : if ( 'models/' not in fileName ) : print 'Warning, models/ was not in the absolute file path, so for security nothing will be done for:' print fileName print 'The heightmap tool can only read a file which has models/ in the file path.' print 'To import the file, move the file into a folder called model/ or a subfolder which is inside the model folder tree.' return pgmText = archive . getFileText ( fileName ) textLines = archive . getTextLines ( pgmText ) format = textLines [ 0 ] . lower ( ) sizeWords = textLines [ 2 ] . split ( ) numberOfColumns = int ( sizeWords [ 0 ] ) numberOfRows = int ( sizeWords [ 1 ] ) heights = [ ] if ( format == 'p1' ) : addHeightsByBitmap ( heights , textLines ) elif ( format == 'p2' ) : addHeightsByGraymap ( heights , textLines ) else : print 'Warning, the file format was not recognized for:' print fileName print 'Heightmap can only read the Netpbm Portable bitmap format and the Netpbm Portable graymap format.' print 'The Netpbm formats are described at:' print 'http://en.wikipedia.org/wiki/Netpbm_format' return [ ] heightGrid = [ ] heightIndex = 0 for rowIndex in xrange ( numberOfRows ) : row = [ ] heightGrid . append ( row ) for columnIndex in xrange ( numberOfColumns ) : row . append ( heights [ heightIndex ] ) heightIndex += 1 return heightGrid
get heightgrid by filename .