mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-16 00:20:20 +02:00
update bake tool
This commit is contained in:
parent
2e37b4a312
commit
66f78ea2c7
1 changed files with 14 additions and 2 deletions
|
@ -1,6 +1,16 @@
|
||||||
import os, json, sys, shutil, subprocess, shlex, time
|
import os, json, sys, shutil, subprocess, shlex, time
|
||||||
EXE = os.environ['HIFI_OVEN']
|
EXE = os.environ['HIFI_OVEN']
|
||||||
|
|
||||||
|
def getRelativePath(path1, path2, stop):
|
||||||
|
parts1 = path1.split('/');
|
||||||
|
parts2 = path2.split('/');
|
||||||
|
if len(parts1) <= len(parts2):
|
||||||
|
for part in parts1:
|
||||||
|
if part != stop and part != '':
|
||||||
|
index = parts2.index(part)
|
||||||
|
parts2.pop(index)
|
||||||
|
return os.path.join(*parts2)
|
||||||
|
|
||||||
def listFiles(directory, extension):
|
def listFiles(directory, extension):
|
||||||
items = os.listdir(directory)
|
items = os.listdir(directory)
|
||||||
fileList = []
|
fileList = []
|
||||||
|
@ -44,18 +54,20 @@ def bakeFile(filePath, outputDirectory):
|
||||||
groupKTXFiles(outputDirectory, bakedFile)
|
groupKTXFiles(outputDirectory, bakedFile)
|
||||||
|
|
||||||
def bakeFilesInDirectory(directory, outputDirectory):
|
def bakeFilesInDirectory(directory, outputDirectory):
|
||||||
|
rootDirectory = os.path.basename(os.path.normpath(directory))
|
||||||
for root, subFolders, filenames in os.walk(directory):
|
for root, subFolders, filenames in os.walk(directory):
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
|
appendPath = getRelativePath(directory, root, rootDirectory);
|
||||||
if filename.endswith('.fbx'):
|
if filename.endswith('.fbx'):
|
||||||
filePath = os.sep.join([root, filename])
|
filePath = os.sep.join([root, filename])
|
||||||
absFilePath = os.path.abspath(filePath)
|
absFilePath = os.path.abspath(filePath)
|
||||||
outputFolder = os.path.join(outputDirectory, os.path.relpath(root))
|
outputFolder = os.path.join(outputDirectory, appendPath)
|
||||||
print "Baking file: " + filename
|
print "Baking file: " + filename
|
||||||
bakeFile(absFilePath, outputFolder)
|
bakeFile(absFilePath, outputFolder)
|
||||||
else:
|
else:
|
||||||
filePath = os.sep.join([root, filename])
|
filePath = os.sep.join([root, filename])
|
||||||
absFilePath = os.path.abspath(filePath)
|
absFilePath = os.path.abspath(filePath)
|
||||||
outputFolder = os.path.join(outputDirectory, os.path.relpath(root))
|
outputFolder = os.path.join(outputDirectory, appendPath)
|
||||||
newFilePath = os.sep.join([outputFolder, filename])
|
newFilePath = os.sep.join([outputFolder, filename])
|
||||||
createDirectory(outputFolder)
|
createDirectory(outputFolder)
|
||||||
print "moving file: " + filename + " to: " + outputFolder
|
print "moving file: " + filename + " to: " + outputFolder
|
||||||
|
|
Loading…
Reference in a new issue