#!/usr/bin/env python import os import re import struct # Reads all texture names from the specified directory. # Textures must end in jpg, png, or bmp. # Returns a directory with the texture name as key. def readAllTextures(dir, result): if type(dir)==type([]): for i in dir: readAllTextures(i,result) return re_is_texture = re.compile("^.*\.(jpg|png|bmp)$") for i in os.listdir(dir): if re_is_texture.match(i): result[i]=1 # ----------------------------------------------------------------------------- # Reads all texture names specified in a materials.xml file. def readMaterialsXML(filename): textures = {} f = open(filename, "r") # Crude RE instead of XML parsing re_texture_name = re.compile("^ *