This repository has been archived by the owner on Aug 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mkargs
executable file
·81 lines (70 loc) · 2.11 KB
/
mkargs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
RED='\033[0;31m'
NC='\033[0m' # No Color
ROOT=.
BAKED=baked
declare -a groups
declare -a channels=("Ambient_Occlusion.png" "Normal.png" "Surface_Color.png" "Metallic.png" "Roughness.png")
declare -a params=("-ao_map" "-normal_map" "-color_map" "-metallic_map" "-roughness_map")
if test -z "$1"; then
echo -e "🗣 No default file such as ${RED}./abc/file.abc${NC} was passed, searching for the newest .abc file in ${RED}./abc${NC} ..."
abc=$(ls ./abc/*.abc | head -n1)
else
abc=$1
fi
if [ -f $abc ]; then
echo -e "found: ${RED}$abc${NC}"
usdz=$(basename "$abc" .abc)
usdz+=".usdz"
else
echo -e "👻 .abc file not found. Export an .abc file into the ./abc folder first."
exit 1
fi
echo -e "🔎 Searching for baked c4d textures in ${RED}./baked${NC} ... "
for file in $ROOT/$BAKED/*.png; do
for channel in "${channels[@]}"; do
if [[ $file == *"$channel"* ]]
then
group=${file#"$ROOT/$BAKED/"}
group=${group%"$channel"}
if [[ ! " ${groups[@]} " =~ " ${group} " ]]; then
groups+=($group)
fi
break
fi
done
done
> usdzargs.txt
#every group
for group in "${groups[@]}"; do
arg="-g $group"
#check for a file for every channel
for channel in "${channels[@]}"; do
file=$ROOT/$BAKED/$group$channel
if [ -f $file ]; then
#echo "found $file"
#get the corresponding param
for i in "${!channels[@]}"; do
if [[ "${channels[$i]}" = "${channel}" ]]; then
p="${params[i]}"
fi
done
if test -z "$p"
then
echo "no parameter found."
else
arg+=" $p $file"
fi
fi
done
echo "$arg"
echo $arg >> usdzargs.txt
done
echo -e "✅ Done."
echo -e "🤖 Create USDZ with: ${RED}'xcrun usdz_converter $abc ../docs/usdz/$usdz -f ./usdzargs.txt'${NC} ? (y/n)"
read -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
eval mkdir -p "usdz"
eval "xcrun usdz_converter $abc ../docs/usdz/$usdz -f usdzargs.txt"
fi