Merge pull request #12875 from druiz17/update-baking-tools

Update baking script to include skyboxes.
This commit is contained in:
Seth Alves 2018-04-12 19:46:46 -07:00 committed by GitHub
commit 3830f65df5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 7 deletions

View file

@ -44,26 +44,35 @@ def groupKTXFiles(directory, filePath):
originalFilePath.strip()
shutil.move(originalFilePath, newFilePath)
def bakeFile(filePath, outputDirectory):
def bakeFile(filePath, outputDirectory, fileType):
createDirectory(outputDirectory)
cmd = EXE + ' -i ' + filePath + ' -o ' + outputDirectory + ' -t fbx'
cmd = EXE + ' -i ' + filePath + ' -o ' + outputDirectory + ' -t ' + fileType
args = shlex.split(cmd)
process = subprocess.Popen(cmd, stdout=False, stderr=False)
process.wait()
bakedFile = os.path.splitext(filePath)[0]
groupKTXFiles(outputDirectory, bakedFile)
if fileType == 'fbx':
groupKTXFiles(outputDirectory, bakedFile)
def bakeFilesInDirectory(directory, outputDirectory):
rootDirectory = os.path.basename(os.path.normpath(directory))
for root, subFolders, filenames in os.walk(directory):
for filename in filenames:
appendPath = getRelativePath(directory, root, rootDirectory);
name, ext = os.path.splitext('file.txt')
if filename.endswith('.fbx'):
filePath = os.sep.join([root, filename])
absFilePath = os.path.abspath(filePath)
outputFolder = os.path.join(outputDirectory, appendPath)
print "Baking file: " + filename
bakeFile(absFilePath, outputFolder)
bakeFile(absFilePath, outputFolder, 'fbx')
elif os.path.basename(root) == 'skyboxes':
filePath = os.sep.join([root, filename])
absFilePath = os.path.abspath(filePath)
outputFolder = os.path.join(outputDirectory, appendPath)
print "Baking file: " + filename
bakeType = os.path.splitext(filename)[1][1:]
bakeFile(absFilePath, outputFolder, bakeType)
else:
filePath = os.sep.join([root, filename])
absFilePath = os.path.abspath(filePath)

View file

@ -6,7 +6,7 @@ def createAssetMapping(assetDirectory):
baseDirectory = os.path.basename(os.path.normpath(assetDirectory))
for root, subfolder, filenames in os.walk(assetDirectory):
for filename in filenames:
if not filename.endswith('.ktx'):
if not filename.endswith('.ktx') or os.path.basename(root) == 'skyboxes':
substring = os.path.commonprefix([assetDirectory, root])
newPath = root.replace(substring, '');
filePath = os.sep.join([newPath, filename])
@ -30,7 +30,7 @@ def handleURL(url):
baseFilename = os.path.basename(url)
filename = os.path.splitext(baseFilename)[0]
newUrl = MAP[filename]
print newUrl
print url + ' -> ' + newUrl
return newUrl
def handleOptions():
@ -43,8 +43,12 @@ def main():
argsLength = len(sys.argv)
if argsLength == 3:
jsonFile = sys.argv[1]
gzipFile = jsonFile + '.gz'
assetDirectory = sys.argv[2]
inputFilename = os.path.basename(jsonFile);
absPath = os.path.abspath(assetDirectory)
finalPath = absPath.replace('\\', '/');
gzipFile = finalPath + '/' + inputFilename + '.gz'
print gzipFile
createAssetMapping(assetDirectory)
f = open(jsonFile)
data = json.load(f)
@ -65,6 +69,15 @@ def main():
except:
value = handleURL(value)
if prop == "ambientLight":
for index in value:
value[index] = handleURL(value[index])
if prop == "skybox":
for index in value:
value[index] = handleURL(value[index])
if prop == "serverScripts":
value = handleURL(value)