type _tImg ID as integer filename as string endtype global _textureList as _tImg[] function Load3DObject(fn$) obj = LoadObject(fn$) noext$ = left(fn$, FindString(fn$, ".")-1) if GetFileExists(noext$+" textures.txt") _ImportTextures(obj, noext$+" textures.txt") endif endfunction obj function Load3DObjectWithChildren(fn$) obj = LoadObjectWithChildren(fn$) noext$ = left(fn$, FindString(fn$, ".")) if GetFileExists(noext$+" textures.txt") _ImportTextures(obj, noext$+" textures.txt") endif endfunction obj function _ImportTextures(obj, fn$) OpenToRead(99, fn$) ln$ = ReadLine(99) stage = val(GetStringToken(ln$, ":", 1)) texture$ = GetStringToken(ln$, ":", 2) SetObjectImage(obj, _GetTextureID(texture$), stage) closefile(99) endfunction /*Return th image ID of the loaded texture but first check to see if an image with that filename has already been loaede and if it has, don't load it again but return it's ID */ function _GetTextureID(texture$) if _textureList.length > - 1 for k = 0 to _textureList.length if _textureList[k].filename = texture$ exitfunction _textureList[k].ID endif next k endif img as _tImg img.ID = LoadImage(texture$) img.filename = texture$ _textureList.insert(img) endfunction img.ID