diff --git a/res_pipeline/Pack_images.py b/res_pipeline/Pack_images.py new file mode 100644 index 00000000..b2d3fffc --- /dev/null +++ b/res_pipeline/Pack_images.py @@ -0,0 +1,64 @@ +from __future__ import print_function +import os + +""" + + @author: Thomas Theis + June 2020 + GNU General Public License v3.0 + +""" +os.system("free-tex-packer-cli --project .\shapez_size_100.ftpp") +os.system("free-tex-packer-cli --project .\shapez_size_75.ftpp") +os.system("free-tex-packer-cli --project .\shapez_size_50.ftpp") +os.system("free-tex-packer-cli --project .\shapez_size_25.ftpp") +os.system("free-tex-packer-cli --project .\shapez_size_10.ftpp") + + + +def update_file( filename, match , replacement ): + """ + + Update Line in file, were match. + + """ + + # Read File + with open(filename, 'r') as file: + # Read list of lines into a list object + data = list(file.readlines()) + + # Loop through lines in file backwards, (meta: I know the keyword is at the bottem of the file.) + for i in range(len(data) -1, 0, -1): + + # Check for Match + if match in data[i]: + + # Print data before updated. + print("\n\nUpdated the line:") + print(data[i]) + print("New line:") + + + # Update data + data[i] = replacement + + # Print New data + print(data[i],"\n\n") + + # Break loop + break + + + # ReOpen file to write + with open(filename, 'w') as file: + + # Write modified data. + file.writelines( data ) + + +update_file("../res_built/atlas/atlas0_100.json", "image", ' "image": "atlas0_100.png",\n') +update_file("../res_built/atlas/atlas0_75.json", "image", ' "image": "atlas0_75.png",\n') +update_file("../res_built/atlas/atlas0_50.json", "image", ' "image": "atlas0_50.png",\n') +update_file("../res_built/atlas/atlas0_25.json", "image", ' "image": "atlas0_25.png",\n') +update_file("../res_built/atlas/atlas0_10.json", "image", ' "image": "atlas0_10.png",\n') \ No newline at end of file diff --git a/res_pipeline/Steps.txt b/res_pipeline/Steps.txt new file mode 100644 index 00000000..8e2cb2f3 --- /dev/null +++ b/res_pipeline/Steps.txt @@ -0,0 +1,9 @@ +You need to download free-tex-packer-cli from node. + +1. npm install -g free-tex-packer-cli + +2. run the python script. + + +*** NOTE *** +If you see flashing on the edges of animation textures i.e. belts. Try changing the "alphaThreshold" (between 0 and 1.0) key in the *.ftpp files \ No newline at end of file diff --git a/res_pipeline/shapez_size_10.ftpp b/res_pipeline/shapez_size_10.ftpp index 403a3731..60d43a06 100644 --- a/res_pipeline/shapez_size_10.ftpp +++ b/res_pipeline/shapez_size_10.ftpp @@ -13,6 +13,7 @@ "removeFileExtension": false, "prependFolderName": true, "scale": 0.1, + "scaleMethod": "BICUBIC", "filter": "none", "exporter": "JSON (hash)", "base64Export": false, @@ -25,11 +26,11 @@ "fixedSize": false, "powerOfTwo": false, "padding": 0, - "extrude": 0, - "allowRotation": true, + "extrude": 2, + "allowRotation": false, "allowTrim": true, "trimMode": "trim", - "alphaThreshold": 0, + "alphaThreshold": 0.5, "detectIdentical": true, "packer": "MaxRectsBin", "packerMethod": "BestShortSideFit" diff --git a/res_pipeline/shapez_size_100.ftpp b/res_pipeline/shapez_size_100.ftpp index 293424ec..7f2ae82b 100644 --- a/res_pipeline/shapez_size_100.ftpp +++ b/res_pipeline/shapez_size_100.ftpp @@ -13,6 +13,7 @@ "removeFileExtension": false, "prependFolderName": true, "scale": 1, + "scaleMethod": "BICUBIC", "filter": "none", "exporter": "JSON (hash)", "base64Export": false, @@ -25,11 +26,11 @@ "fixedSize": false, "powerOfTwo": false, "padding": 0, - "extrude": 0, - "allowRotation": true, + "extrude": 2, + "allowRotation": false, "allowTrim": true, "trimMode": "trim", - "alphaThreshold": 0, + "alphaThreshold": 0.5, "detectIdentical": true, "packer": "MaxRectsBin", "packerMethod": "BestShortSideFit" diff --git a/res_pipeline/shapez_size_25.ftpp b/res_pipeline/shapez_size_25.ftpp index a55dfdfe..bf26e3a6 100644 --- a/res_pipeline/shapez_size_25.ftpp +++ b/res_pipeline/shapez_size_25.ftpp @@ -13,6 +13,7 @@ "removeFileExtension": false, "prependFolderName": true, "scale": 0.25, + "scaleMethod": "BICUBIC", "filter": "none", "exporter": "JSON (hash)", "base64Export": false, @@ -25,11 +26,11 @@ "fixedSize": false, "powerOfTwo": false, "padding": 0, - "extrude": 0, - "allowRotation": true, + "extrude": 2, + "allowRotation": false, "allowTrim": true, "trimMode": "trim", - "alphaThreshold": 0, + "alphaThreshold": 0.5, "detectIdentical": true, "packer": "MaxRectsBin", "packerMethod": "BestShortSideFit" diff --git a/res_pipeline/shapez_size_50.ftpp b/res_pipeline/shapez_size_50.ftpp index 0c1b357b..d470c710 100644 --- a/res_pipeline/shapez_size_50.ftpp +++ b/res_pipeline/shapez_size_50.ftpp @@ -13,6 +13,7 @@ "removeFileExtension": false, "prependFolderName": true, "scale": 0.5, + "scaleMethod": "BICUBIC", "filter": "none", "exporter": "JSON (hash)", "base64Export": false, @@ -25,11 +26,11 @@ "fixedSize": false, "powerOfTwo": false, "padding": 0, - "extrude": 0, - "allowRotation": true, + "extrude": 2, + "allowRotation": false, "allowTrim": true, "trimMode": "trim", - "alphaThreshold": 0, + "alphaThreshold": 0.5, "detectIdentical": true, "packer": "MaxRectsBin", "packerMethod": "BestShortSideFit" diff --git a/res_pipeline/shapez_size_75.ftpp b/res_pipeline/shapez_size_75.ftpp index f55f69df..a0252dcd 100644 --- a/res_pipeline/shapez_size_75.ftpp +++ b/res_pipeline/shapez_size_75.ftpp @@ -13,6 +13,7 @@ "removeFileExtension": false, "prependFolderName": true, "scale": 0.75, + "scaleMethod": "BICUBIC", "filter": "none", "exporter": "JSON (hash)", "base64Export": false, @@ -25,11 +26,11 @@ "fixedSize": false, "powerOfTwo": false, "padding": 0, - "extrude": 0, - "allowRotation": true, + "extrude": 2, + "allowRotation": false, "allowTrim": true, "trimMode": "trim", - "alphaThreshold": 0, + "alphaThreshold": 0.5, "detectIdentical": true, "packer": "MaxRectsBin", "packerMethod": "BestShortSideFit"