mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge pull request #12875 from druiz17/update-baking-tools
Update baking script to include skyboxes.
This commit is contained in:
commit
3830f65df5
2 changed files with 29 additions and 7 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue