Skip to content

Commit

Permalink
Revert previous changes that broke a lot of things
Browse files Browse the repository at this point in the history
  • Loading branch information
myuce committed Jun 1, 2022
1 parent 80b9a40 commit a9a406a
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 127 deletions.
19 changes: 6 additions & 13 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,9 @@ def getMounted():
prefabDir = "prefabs" if game == "CoD4" or game == "CoD2" else "_prefabs"
try:
makedirs(f"{outputDir}/map_source")
makedirs(f"{outputDir}/model_export/corvid/{vmfName}")
makedirs(f"{outputDir}/model_export/corvid")
makedirs(f"{outputDir}/source_data")
makedirs(f"{outputDir}/texture_assets/corvid/{vmfName}")
makedirs(f"{outputDir}/texture_assets/corvid")
if game != "BO3":
makedirs(f"{outputDir}/bin")
makedirs(f"{outputDir}/map_source/{prefabDir}/{vmfName}")
Expand All @@ -601,23 +601,16 @@ def getMounted():
settings["convertBrush"], scale=Vector3(settings["scale"][0], settings["scale"][0], settings["scale"][1])
)


if game == "BO3":
writePath = f"{outputDir}/map_source/{prefabDir}/{vmfName}/{vmfName}.map"
else:
writePath = f"{outputDir}/map_source/{vmfName}.map"

print(f"Writing \"{vmfName}.map\" in \"{writePath}\"")

with open(writePath, "w") as file:
print(f"Writing \"{vmfName}.map\" in \"{outputDir}/map_source/prefabs/{vmfName}\"")
with open(f"{outputDir}/map_source/{prefabDir}/{vmfName}/{vmfName}.map", "w") as file:
file.write(res)

convertedDir = gettempdir() + "/corvid/converted"

dirs = [
f"model_export/corvid/{vmfName}",
"model_export/corvid",
"source_data",
f"texture_assets/corvid/{vmfName}"
"texture_assets/corvid"
]

if game != "BO3":
Expand Down
14 changes: 7 additions & 7 deletions modules/AssetConverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,33 +105,33 @@ def getTexSize(src):
image.image_load(src)
return Vector2(image.width(), image.height())

def convertModels(models, modelTints, modelSkins, skinTints, game="WaW", scale=1.0, mapname=""):
def convertModels(models, modelTints, modelSkins, skinTints, game="WaW", scale=1.0):
codModel = Model()
mdlDir = f"{tempDir}/mdl"
convertDir = f"{tempDir}/converted/model_export/corvid/{mapname}"
convertDir = f"{tempDir}/converted/model_export/corvid"
total = len(models)

for i, model in enumerate(models):
print(f"{i}|{total}|done", end="")
model = splitext(newPath(model, prefix=mapname))[0]
model = splitext(newPath(model))[0]
# convert models with tints
if game == "BO3" and model in modelTints:
for tint in modelTints[model]:
hex = Vector3.FromStr(tint).toHex()
convertModel(f"{mdlDir}/{model}", convertDir, tint=hex, scale=scale, mapname=mapname)
convertModel(f"{mdlDir}/{model}", convertDir, tint=hex, scale=scale)
try:
codModel.LoadFile_Raw(f"{convertDir}/{model}_{hex}.xmodel_export")
codModel.WriteFile_Bin(f"{convertDir}/{model}_{hex}.xmodel_bin")
except:
print(f"Could not convert {model}_{hex} to xmodel_bin...")
else:
os.remove(f"{convertDir}/{model}_{hex}.xmodel_export")
convertModel(f"{mdlDir}/{model}", convertDir, scale=scale, mapname=mapname)
convertModel(f"{mdlDir}/{model}", convertDir, scale=scale)

# convert models with skins
if model in modelSkins:
for skin in modelSkins[model]:
convertModel(f"{mdlDir}/{model}", convertDir, skin=skin, scale=scale, mapname=mapname)
convertModel(f"{mdlDir}/{model}", convertDir, skin=skin, scale=scale)
if game == "BO3":
try:
codModel.LoadFile_Raw(f"{convertDir}/{model}_skin{skin}.xmodel_export")
Expand All @@ -145,7 +145,7 @@ def convertModels(models, modelTints, modelSkins, skinTints, game="WaW", scale=1
for skin, tints in skinTints[model].items():
for tint in tints:
hex = Vector3.FromStr(tint).toHex()
convertModel(f"{mdlDir}/{model}", convertDir, hex, skin, scale, mapname=mapname)
convertModel(f"{mdlDir}/{model}", convertDir, hex, skin, scale)
try:
codModel.LoadFile_Raw(f"{convertDir}/{model}_skin{skin}_{hex}.xmodel_export")
codModel.WriteFile_Bin(f"{convertDir}/{model}_skin{skin}_{hex}.xmodel_bin")
Expand Down
Loading

0 comments on commit a9a406a

Please sign in to comment.