mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 22:56:54 +02: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()
|
originalFilePath.strip()
|
||||||
shutil.move(originalFilePath, newFilePath)
|
shutil.move(originalFilePath, newFilePath)
|
||||||
|
|
||||||
def bakeFile(filePath, outputDirectory):
|
def bakeFile(filePath, outputDirectory, fileType):
|
||||||
createDirectory(outputDirectory)
|
createDirectory(outputDirectory)
|
||||||
cmd = EXE + ' -i ' + filePath + ' -o ' + outputDirectory + ' -t fbx'
|
cmd = EXE + ' -i ' + filePath + ' -o ' + outputDirectory + ' -t ' + fileType
|
||||||
args = shlex.split(cmd)
|
args = shlex.split(cmd)
|
||||||
process = subprocess.Popen(cmd, stdout=False, stderr=False)
|
process = subprocess.Popen(cmd, stdout=False, stderr=False)
|
||||||
process.wait()
|
process.wait()
|
||||||
bakedFile = os.path.splitext(filePath)[0]
|
bakedFile = os.path.splitext(filePath)[0]
|
||||||
groupKTXFiles(outputDirectory, bakedFile)
|
if fileType == 'fbx':
|
||||||
|
groupKTXFiles(outputDirectory, bakedFile)
|
||||||
|
|
||||||
def bakeFilesInDirectory(directory, outputDirectory):
|
def bakeFilesInDirectory(directory, outputDirectory):
|
||||||
rootDirectory = os.path.basename(os.path.normpath(directory))
|
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);
|
appendPath = getRelativePath(directory, root, rootDirectory);
|
||||||
|
name, ext = os.path.splitext('file.txt')
|
||||||
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, appendPath)
|
outputFolder = os.path.join(outputDirectory, appendPath)
|
||||||
print "Baking file: " + filename
|
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:
|
else:
|
||||||
filePath = os.sep.join([root, filename])
|
filePath = os.sep.join([root, filename])
|
||||||
absFilePath = os.path.abspath(filePath)
|
absFilePath = os.path.abspath(filePath)
|
||||||
|
|
|
@ -6,7 +6,7 @@ def createAssetMapping(assetDirectory):
|
||||||
baseDirectory = os.path.basename(os.path.normpath(assetDirectory))
|
baseDirectory = os.path.basename(os.path.normpath(assetDirectory))
|
||||||
for root, subfolder, filenames in os.walk(assetDirectory):
|
for root, subfolder, filenames in os.walk(assetDirectory):
|
||||||
for filename in filenames:
|
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])
|
substring = os.path.commonprefix([assetDirectory, root])
|
||||||
newPath = root.replace(substring, '');
|
newPath = root.replace(substring, '');
|
||||||
filePath = os.sep.join([newPath, filename])
|
filePath = os.sep.join([newPath, filename])
|
||||||
|
@ -30,7 +30,7 @@ def handleURL(url):
|
||||||
baseFilename = os.path.basename(url)
|
baseFilename = os.path.basename(url)
|
||||||
filename = os.path.splitext(baseFilename)[0]
|
filename = os.path.splitext(baseFilename)[0]
|
||||||
newUrl = MAP[filename]
|
newUrl = MAP[filename]
|
||||||
print newUrl
|
print url + ' -> ' + newUrl
|
||||||
return newUrl
|
return newUrl
|
||||||
|
|
||||||
def handleOptions():
|
def handleOptions():
|
||||||
|
@ -43,8 +43,12 @@ def main():
|
||||||
argsLength = len(sys.argv)
|
argsLength = len(sys.argv)
|
||||||
if argsLength == 3:
|
if argsLength == 3:
|
||||||
jsonFile = sys.argv[1]
|
jsonFile = sys.argv[1]
|
||||||
gzipFile = jsonFile + '.gz'
|
|
||||||
assetDirectory = sys.argv[2]
|
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)
|
createAssetMapping(assetDirectory)
|
||||||
f = open(jsonFile)
|
f = open(jsonFile)
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
|
@ -65,6 +69,15 @@ def main():
|
||||||
except:
|
except:
|
||||||
value = handleURL(value)
|
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":
|
if prop == "serverScripts":
|
||||||
value = handleURL(value)
|
value = handleURL(value)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue