local dir = string.format("models/%s/%s", v.type, v.file)
if fileExists(dir..".itxd") then
local fileString = self:uncompileFile(dir, "itxd")
local txd = engineLoadTXD(fileString)
if txd then
engineImportTXD(txd, v.model)
else
outputDebugString(string.format("[TR_models] Failed to load TXD for model %s!", v.file), 0, 255, 0, 0)
end
end
if fileExists(dir..".idff") then
local fileString = self:uncompileFile(dir, "idff")
local dff = engineLoadDFF(fileString)
if dff then
engineReplaceModel(dff, v.model, v.alpha)
else
outputDebugString(string.format("[TR_models] Failed to load DFF for model %s!", v.file), 0, 255, 0, 0)
end
end
if fileExists(dir..".icol") then
local fileString = self:uncompileFile(dir, "icol")
local col = engineLoadCOL(fileString)
if col then
engineReplaceCOL(col, v.model)
else
outputDebugString(string.format("[TR_models] Failed to load COL for model %s!", v.file), 0, 255, 0, 0)
end
end
function ModelLoader:uncompileFile(dir, format)
local file = fileOpen(dir.."."..format)
local fileString = fileRead(file, fileGetSize(file))
local uncompiledString = self:teaDecodeBinary(fileString, EncriptionKey)
fileClose(file)
return uncompiledString
end
function ModelLoader:teaDecodeBinary(data, key)
return decodeString("tea", data, {key = key})
end
-- PLIK SETTINGS:
replaceList = {
-- Vehicles
{ -- Santa sleights
file = "shamal",
type = "vehicles",
model = 512,
},...