--Enhanced Model Viewer MHrise global resources
--by alphaZomega

local EMV = require("EMV Engine")

local game_name = reframework.get_game_name()
local create_resource = EMV.create_resource
local orderedPairs = EMV.orderedPairs
local loaded_resources = false
local bgs = {}

--a dictionary of tables with 2-3 tables each, one for body and one for face and sometimes one to exclude
local alt_names = {
	--["ch13_01"]= { Body=table.pack("ch13_00"), Face=table.pack("asdf"), exclude=table.pack("ch07_20") }
}

re.on_application_entry("BeginRendering", function()
	
	if not loaded_resources and game_name == "mhrise" and EMVSettings and RSCache and (figure_mode or forced_mode) then 
		global_motbanks = global_motbanks or {}
		RSCache.motbank_resources = RSCache.motbank_resources or {}
		RSCache.tex_resources = RSCache.tex_resources or {}
		EMVSettings.init_EMVSettings()
		local all_motbanks = {}
		if true then 
			--[[table.insert(all_motbanks, "enemy/em001/00/mot/em001_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em001/07/mot/em001_07_bank.motbank")
			table.insert(all_motbanks, "enemy/em002/00/mot/em002_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em002/07/mot/em002_07_bank.motbank")
			table.insert(all_motbanks, "enemy/em003/00/mot/em003_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em004/00/mot/em004_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em007/00/mot/em007_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em007/07/mot/em007_07_bank.motbank")
			table.insert(all_motbanks, "enemy/em019/00/mot/em019_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em020/00/mot/em020_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em023/00/mot/em023_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em023/05/mot/em023_05_bank.motbank")
			table.insert(all_motbanks, "enemy/em024/00/mot/em024_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em025/00/mot/em025_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em027/00/mot/em027_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em032/00/mot/em032_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em037/00/mot/em037_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em042/00/mot/em042_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em044/00/mot/em044_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em047/00/mot/em047_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em054/00/mot/em054_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em057/00/mot/em057_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em057/07/mot/em057_07_bank.motbank")
			table.insert(all_motbanks, "enemy/em059/00/mot/em059_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em060/00/mot/em060_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em060/07/mot/em060_07_bank.motbank")
			table.insert(all_motbanks, "enemy/em061/00/mot/em061_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em062/00/mot/em062_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em071/00/mot/em071_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em072/00/mot/em072_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em077/00/mot/em077_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em081/00/mot/em081_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em082/00/mot/em082_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em082/07/mot/em082_07_bank.motbank")
			table.insert(all_motbanks, "enemy/em086/05/mot/em086_05_bank.motbank")
			table.insert(all_motbanks, "enemy/em089/00/mot/em089_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em089/05/mot/em089_05_bank.motbank")
			table.insert(all_motbanks, "enemy/em090/00/mot/em090_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em090/01/mot/em090_01_bank.motbank")
			table.insert(all_motbanks, "enemy/em091/00/mot/em091_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em092/00/mot/em092_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em093/00/mot/em093_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em093/01/mot/em093_01_bank.motbank")
			table.insert(all_motbanks, "enemy/em094/00/mot/em094_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em094/01/mot/em094_01_bank.motbank")
			table.insert(all_motbanks, "enemy/em095/00/mot/em095_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em095/01/mot/em095_01_bank.motbank")
			table.insert(all_motbanks, "enemy/em096/00/mot/em096_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em097/00/mot/em097_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em098/00/mot/em098_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em099/00/mot/em099_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em099/05/mot/em099_05_bank.motbank")
			table.insert(all_motbanks, "enemy/em100/00/mot/em100_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em102/00/mot/em102_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em107/00/mot/em107_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em108/00/mot/em108_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em109/00/mot/em109_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em118/00/mot/em118_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em131/00/mot/em131_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em132/00/mot/em132_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em133/00/mot/em133_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em134/00/mot/em134_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em135/00/mot/em135_00_bank.motbank")
			table.insert(all_motbanks, "enemy/em136/00/mot/em136_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems003/00/mot/ems003_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems003/05/mot/ems003_05_bank.motbank")
			table.insert(all_motbanks, "enemy/ems005/00/mot/ems005_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems006/00/mot/ems006_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems007/00/mot/ems007_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems008/00/mot/ems008_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems009/00/mot/ems009_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems013/00/mot/ems013_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems014/00/mot/ems014_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems016/00/mot/ems016_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems019/00/mot/ems019_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems020/00/mot/ems020_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems021/00/mot/ems021_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems025/00/mot/ems025_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems026/00/mot/ems026_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems027/00/mot/ems027_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems029/00/mot/ems029_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems034/00/mot/ems034_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems035/00/mot/ems035_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems036/00/mot/ems036_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems038/00/mot/ems038_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems039/00/mot/ems039_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems040/00/mot/ems040_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems041/00/mot/ems041_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems042/00/mot/ems042_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems043/00/mot/ems043_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems044/00/mot/ems044_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems049/00/mot/ems049_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems051/00/mot/ems051_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems051/05/mot/ems051_05_bank.motbank")
			table.insert(all_motbanks, "enemy/ems090/00/mot/ems090_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems091/00/mot/ems091_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems092/00/mot/ems092_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems092/01/mot/ems092_01_bank.motbank")
			table.insert(all_motbanks, "enemy/ems093/00/mot/ems093_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems094/00/mot/ems094_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems095/00/mot/ems095_00_bank.motbank")
			table.insert(all_motbanks, "enemy/ems096/00/mot/ems096_00_bank.motbank")
			table.insert(all_motbanks, "enemy/mot/detach/Detach_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec001/00/mot/ec001_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec002/00/mot/ec002_00_01_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec002/00/mot/ec002_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec004/00/mot/ec004_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec005/00/mot/ec005_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec006/00/mot/ec006_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec007/00/mot/ec007_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec008/00/mot/ec008_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec009/00/mot/ec009_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec010/00/mot/ec010_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec012/00/mot/ec012_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec014/00/mot/ec014_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec015/00/mot/ec015_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec017/00/mot/ec017_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec018/00/mot/ec018_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec021/00/mot/ec021_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec022/00/mot/ec022_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec024/00/mot/ec024_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec025/00/mot/ec025_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec026/00/mot/ec026_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec027/00/mot/ec027_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec028/00/mot/ec028_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec029/00/mot/ec029_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec030/00/mot/ec030_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec031/00/mot/ec031_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec032/00/mot/ec032_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec034/00/mot/ec034_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec035/00/mot/ec035_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec036/00/mot/ec036_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec037/00/mot/ec037_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec038/00/mot/ec038_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec050/00/mot/ec050_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec051/00/mot/ec051_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec052/00/mot/ec052_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec053/00/mot/ec053_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec054/00/mot/ec054_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec054/01/mot/ec054_01_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec055/00/mot/ec055_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec056/00/mot/ec056_00_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec057/00/mot/ec057_00_01_bank.motbank")
			table.insert(all_motbanks, "environmentCreature/ec057/00/mot/ec057_00_bank.motbank")
			table.insert(all_motbanks, "huntingMachine/hm07/000/hm07_bank.motbank")
			table.insert(all_motbanks, "huntingMachine/hm07/005/mot/hm07_005_bank.motbank")
			table.insert(all_motbanks, "huntingMachine/hm08/000/hm08_bank.motbank")
			table.insert(all_motbanks, "huntingMachine/hm14/000/hm14_bank.motbank")
			table.insert(all_motbanks, "huntingMachine/hm23/002/Motion/hm_npc002_bank.motbank")
			table.insert(all_motbanks, "huntingMachine/hm23/003/Motion/hm_npc003_bank.motbank")
			table.insert(all_motbanks, "item/acc/acc007/mot/acc007_bank.motbank")
			table.insert(all_motbanks, "item/acc/acc008/mot/acc008_bank.motbank")
			table.insert(all_motbanks, "item/acc/acc013/mot/acc013_bank.motbank")
			table.insert(all_motbanks, "item/acc/acc027/mot/acc027_bank.motbank")
			table.insert(all_motbanks, "item/acc/acc032/mot/acc032_bank.motbank")
			table.insert(all_motbanks, "item/acc/acc055/mot/acc055_bank.motbank")
			table.insert(all_motbanks, "item/gm/gm015_001/mot/gm015_001_bank.motbank")
			table.insert(all_motbanks, "item/gm/gm023_000/mot/gm023_000_bank.motbank")
			table.insert(all_motbanks, "item/gm/gm044_000/mot/gm044_000_bank.motbank")]]
			table.insert(all_motbanks, "npc/mot/npc001_00/LS_Swd050_Fugen_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc001_00/npc001_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc001_00/npc001_00_event_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc001_00/npc001_00_hyakuryu_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc002_00/B_Bow050_Hinoe_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc002_00/npc002_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc002_00/npc002_00_event_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc002_00/npc002_00_hyakuryu_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc003_00/npc003_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc004_00/npc004_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc004_00/npc004_00_hyakuryu_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc005_00/npc005_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc005_00/npc005_00_hyakuryu_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc006_00/npc006_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc006_00/npc006_00_hyakuryu_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc006_01/npc006_01_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc006_02/npc006_02_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc007_00/npc007_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc007_00/npc007_00_hyakuryu_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc007_01/npc007_01_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc007_02/npc007_02_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc007_03/npc007_03_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc007_04/npc007_04_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc007_07/npc007_07_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc008_00/npc008_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc009_00/npc009_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc010_00/npc010_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc013_00/npc013_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc014_00/npc014_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc014_02/npc014_02_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc014_03/npc014_03_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc014_04/npc014_04_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc016_00/npc016_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc016_00/npc016_00_hyakuryu_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc016_01/npc016_01_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc016_02/npc016_02_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc017_00/npc017_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc017_01/npc017_01_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc018_00/npc018_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc018_01/npc018_01_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc018_03/npc018_03_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc018_04/npc018_04_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc018_05/npc018_05_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc018_06/npc018_06_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc018_07/npc018_07_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc018_08/npc018_08_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc018_16/npc018_16_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc021_00/npc021_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc021_00/npc021_00_hyakuryu_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc021_01/npc021_01_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc021_02/npc021_02_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc021_02/npc021_02_hyakuryu_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc031_00/npc031_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc037_00/npc037_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc101_00/npc101_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc101_00/npc101_00_event_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc102_00/L_Lan050_Minoto_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc102_00/npc102_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc102_00/npc102_00_hyakuryu_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc103_00/npc103_00_Quest_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc103_00/npc103_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc103_00/npc103_00_hyakuryu_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc107_00/npc107_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc107_00/npc107_00_hyakuryu_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc110_00/npc110_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc301_00/npc301_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc302_00/npc302_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc302_00/npc302_00_hykuryu_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc303_00/npc303_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc305_00/npc305_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc305_00/npc305_00_hykuryu_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc309_00/npc309_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc311_00/npc311_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc501_00/npc501_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc502_00/npc502_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc503_00/npc503_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc504_00/npc504_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc601_00/npc601_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc602_00/npc602_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc603_00/npc603_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc603_01/npc603_01_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc605_00/npc605_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc607_00/npc607_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc612_00/npc612_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc613_00/npc613_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc613_02/npc613_02_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc613_03/npc613_03_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc613_04/npc613_04_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc613_05/npc613_05_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc615_00/npc615_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc617_00/npc617_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc701_00/npc701_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc701_01/npc701_01_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc702_00/npc702_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc702_01/npc702_01_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc709_00/npc709_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc710_00/npc710_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc711_00/npc711_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc713_00/npc713_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc715_00/npc715_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc715_01/npc715_01_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc715_02/npc715_02_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc715_04/npc715_04_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc720_00/npc720_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc720_02/npc720_02_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc723_00/npc723_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc724_00/npc724_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc725_00/npc725_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc729_00/npc729_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc731_00/npc731_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc733_00/npc733_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc735_00/npc735_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc736_00/npc736_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc745_00/npc745_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc746_00/npc746_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc750_00/npc750_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc751_00/npc751_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc752_00/npc752_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc755_00/npc755_00_bank.motbank")
			table.insert(all_motbanks, "npc/mot/npc809_00/npc809_00_bank.motbank")
			table.insert(all_motbanks, "npc/seabird/seabird_bank.motbank")
			table.insert(all_motbanks, "otomo/OtAirou/mod/ota_item/ota_item041/mot/ota_item041_bank.motbank")
			table.insert(all_motbanks, "otomo/OtAirou/mot/OtAirou_Create_bank.motbank")
			table.insert(all_motbanks, "otomo/OtAirou/mot/OtAirou_Lobby_bank.motbank")
			table.insert(all_motbanks, "otomo/OtAirou/mot/OtAirou_Preview_bank.motbank")
			table.insert(all_motbanks, "otomo/OtAirou/mot/OtAirou_Quest_bank.motbank")
			table.insert(all_motbanks, "otomo/OtAirou/shell/OtAirouShell103/OtAirouShell103MotBank.motbank")
			table.insert(all_motbanks, "otomo/OtDog/mot/OtDog_Create_bank.motbank")
			table.insert(all_motbanks, "otomo/OtDog/mot/OtDog_Lobby_bank.motbank")
			table.insert(all_motbanks, "otomo/OtDog/mot/OtDog_Preview_bank.motbank")
			table.insert(all_motbanks, "otomo/OtDog/mot/OtDog_Quest_bank.motbank")
			table.insert(all_motbanks, "otomo/OtDog/mot/OtDog_Servant_bank.motbank")
			table.insert(all_motbanks, "otomo/OtDog/mot/test/OtDog_110_Bank.motbank")
			table.insert(all_motbanks, "otomo/OtomoRecon/mot/OtomoRecon_Bank_Airou.motbank")
			table.insert(all_motbanks, "otomo/OtomoRecon/mot/OtomoRecon_Bank_Dog.motbank")
			table.insert(all_motbanks, "player/face_mot/mF_plc_Edit_bank.motbank")
			table.insert(all_motbanks, "player/face_mot/mF_plw_GreatSword_bank.motbank")
			table.insert(all_motbanks, "player/mot/QuestEvent.motbank")
			table.insert(all_motbanks, "player/mot/QuestEvent_Servant.motbank")
			table.insert(all_motbanks, "player/mot/fbw_Bow_bank.motbank")
			table.insert(all_motbanks, "player/mot/fbw_ChargeAxe_bank.motbank")
			table.insert(all_motbanks, "player/mot/fbw_DualBlades_bank.motbank")
			table.insert(all_motbanks, "player/mot/fbw_GreatSword_bank.motbank")
			table.insert(all_motbanks, "player/mot/fbw_GunLance_bank.motbank")
			table.insert(all_motbanks, "player/mot/fbw_Hammer_bank.motbank")
			table.insert(all_motbanks, "player/mot/fbw_HeavyBowgun_bank.motbank")
			table.insert(all_motbanks, "player/mot/fbw_Horn_bank.motbank")
			table.insert(all_motbanks, "player/mot/fbw_InsectGlaive_bank.motbank")
			table.insert(all_motbanks, "player/mot/fbw_Lance_bank.motbank")
			table.insert(all_motbanks, "player/mot/fbw_LightBowgun_bank.motbank")
			table.insert(all_motbanks, "player/mot/fbw_LongSword_bank.motbank")
			table.insert(all_motbanks, "player/mot/fbw_ShortSword_bank.motbank")
			table.insert(all_motbanks, "player/mot/fbw_SlashAxe_bank.motbank")
			table.insert(all_motbanks, "player/mot/mbw_Bow_bank.motbank")
			table.insert(all_motbanks, "player/mot/mbw_ChargeAxe_bank.motbank")
			table.insert(all_motbanks, "player/mot/mbw_DualBlades_bank.motbank")
			table.insert(all_motbanks, "player/mot/mbw_GreatSword_bank.motbank")
			table.insert(all_motbanks, "player/mot/mbw_GunLance_bank.motbank")
			table.insert(all_motbanks, "player/mot/mbw_Hammer_bank.motbank")
			table.insert(all_motbanks, "player/mot/mbw_HeavyBowgun_bank.motbank")
			table.insert(all_motbanks, "player/mot/mbw_Horn_bank.motbank")
			table.insert(all_motbanks, "player/mot/mbw_InsectGlaive_bank.motbank")
			table.insert(all_motbanks, "player/mot/mbw_Lance_bank.motbank")
			table.insert(all_motbanks, "player/mot/mbw_LightBowgun_bank.motbank")
			table.insert(all_motbanks, "player/mot/mbw_LongSword_bank.motbank")
			table.insert(all_motbanks, "player/mot/mbw_ShortSword_bank.motbank")
			table.insert(all_motbanks, "player/mot/mbw_SlashAxe_bank.motbank")
			table.insert(all_motbanks, "player/mot/plc_Edit_bank.motbank")
			table.insert(all_motbanks, "player/mot/plc_Lobby_bank.motbank")
			table.insert(all_motbanks, "player/mot/plw_Bow_bank.motbank")
			table.insert(all_motbanks, "player/mot/plw_ChargeAxe_bank.motbank")
			table.insert(all_motbanks, "player/mot/plw_DualBlades_bank.motbank")
			table.insert(all_motbanks, "player/mot/plw_GreatSword_bank.motbank")
			table.insert(all_motbanks, "player/mot/plw_GunLance_bank.motbank")
			table.insert(all_motbanks, "player/mot/plw_Hammer_bank.motbank")
			table.insert(all_motbanks, "player/mot/plw_HeavyBowgun_bank.motbank")
			table.insert(all_motbanks, "player/mot/plw_Horn_bank.motbank")
			table.insert(all_motbanks, "player/mot/plw_InsectGlaive_bank.motbank")
			table.insert(all_motbanks, "player/mot/plw_Lance_bank.motbank")
			table.insert(all_motbanks, "player/mot/plw_LightBowgun_bank.motbank")
			table.insert(all_motbanks, "player/mot/plw_LongSword_bank.motbank")
			table.insert(all_motbanks, "player/mot/plw_ShortSword_bank.motbank")
			table.insert(all_motbanks, "player/mot/plw_SlashAxe_bank.motbank")
			table.insert(all_motbanks, "player/mot/wpg_Bow_Main_00_bank.motbank")
			table.insert(all_motbanks, "player/mot/wpg_ChargeAxe_Main_00_bank.motbank")
			table.insert(all_motbanks, "player/mot/wpg_ChargeAxe_Sub_00_bank.motbank")
			table.insert(all_motbanks, "player/mot/wpg_DualBlades_Main_01_bank.motbank")
			table.insert(all_motbanks, "player/mot/wpg_GreatSword_Main_00_bank.motbank")
			table.insert(all_motbanks, "player/mot/wpg_GreatSword_Main_01_bank.motbank")
			table.insert(all_motbanks, "player/mot/wpg_GunLance_Main_00_bank.motbank")
			table.insert(all_motbanks, "player/mot/wpg_HeavyBowgun_Main_00_bank.motbank")
			table.insert(all_motbanks, "player/mot/wpg_Horn_Main_00_bank.motbank")
			table.insert(all_motbanks, "player/mot/wpg_InsectGlaive_Main_00_bank.motbank")
			table.insert(all_motbanks, "player/mot/wpg_InsectGraive_Sub_01_bank.motbank")
			table.insert(all_motbanks, "player/mot/wpg_Lance_Main_00_bank.motbank")
			table.insert(all_motbanks, "player/mot/wpg_LightBowgun_Main_00_bank.motbank")
			table.insert(all_motbanks, "player/mot/wpg_LongSword_Main_00_bank.motbank")
			table.insert(all_motbanks, "player/mot/wpg_SlashAxe_Main_00_bank.motbank")
			table.insert(all_motbanks, "stage/pop/pop013/40/mot/pop013_40_00.motbank")
			--[[table.insert(all_motbanks, "stage/prefab/gimmick/Fg027/Fg027.motbank")
			table.insert(all_motbanks, "stage/v01/setmodel/sm813/sm813_044/sm813_044_00/bank_MochiLv1.motbank")
			table.insert(all_motbanks, "stage/v01/setmodel/sm813/sm813_044/sm813_044_01/bank_MochiLv2.motbank")
			table.insert(all_motbanks, "stage/v01/setmodel/sm813/sm813_044/sm813_044_02/bank_MochiLv3.motbank")
			table.insert(all_motbanks, "stage/v01/setmodel/sm813/sm813_045/sm813_045_00/bank_MochiSeiro.motbank")]]
		end
		
		for i, bank_string in ipairs(all_motbanks) do 
			local bank
			local bank_name = bank_string:lower() --bank_string:match("^.+/(.+)%.motbank") or bank_string
			--pcall(function()
				bank = create_resource(bank_string, "via.motion.MotionBankResource")
			--end)
			if bank then
				global_motbanks[bank_name] = bank
				RSCache.motbank_resources[bank_name] = bank
			end
		end
		
		for bank_name, bank in pairs(RSCache.motbank_resources) do 
			global_motbanks[bank_name] = bank
		end
		
		--[[for bank_name, bank in pairs(RSCache.motbank_resources) do 
			if bank_name ~= " " and not bank_name:find("not_set") then
				global_motbanks[bank_name] = bank
			end
		end]]
		
		if true then			
			table.insert(bgs, "environmentCreature/ec041/00/mod/ec041_00_IBL.tex")
			table.insert(bgs, "MasterMaterial/Textures/IBL.tex")
			table.insert(bgs, "systems/rendering/MaterialEditor/st8000_01/ibl00_skylight_00.tex")
			table.insert(bgs, "MasterMaterial/Textures/IBL_small.tex")
			table.insert(bgs, "stage/v02/textures/IBL_small.tex")
			table.insert(bgs, "stage/m42/other/IBL/m42_IBL_water.tex")
			table.insert(bgs, "stage/v02/textures/v02a06_IBL_small.tex")
		end
		
		for i, bg_string in ipairs(bgs) do 
			local tex_resource = create_resource(bg_string, "via.render.TextureResource")
			if tex_resource then 
				--local bg_name = bg_string:match("^.+/(.+)%.tex") or bg_string
				local bg_name = tex_resource:call("ToString"):match("^.+%[@?(.+)%]")
				RSCache.tex_resources[bg_name] = tex_resource
			end
		end
		
		loaded_resources = true
	end
end)

local function finished()
	return loaded_resources
end

local function reset()
	loaded_resources = false
end

return {
	backgrounds = bgs,
	alt_names = alt_names,
	finished = finished,
	reset = reset,
}