-
Notifications
You must be signed in to change notification settings - Fork 0
/
auto_render.sh
executable file
·45 lines (44 loc) · 1022 Bytes
/
auto_render.sh
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
#!/bin/bash
RED_COLOR='tput setaf 1'
GREEN_COLOR='tput setaf 2'
NORMAL_COLOR='tput sgr0'
if [ "$1" = "" ]
then
echo "Wrong arguments"
else
FILE=()
while read line; do
FILE+=($line)
done < $1
if [ ! -f "raytracer" ];
then
make re
fi
count=${FILE[0]}
folder=${FILE[1]}
filename=${FILE[2]}
if [ -d $folder ]; then
read -p "$(${RED_COLOR})There is already a folder there, do you really want to overwrite it ? y/n $(${NORMAL_COLOR})" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
rm -rf "$folder" && mkdir "$folder"
else
exit
fi
else
mkdir "$folder"
fi
echo "$(${GREEN_COLOR})Correctly created render folder$(${NORMAL_COLOR})"
for (( i=0; i < $count; ++i))
do
echo "$(${NORMAL_COLOR})rendering image n ${i}$(${GREEN_COLOR})"
./raytracer ${filename}${i}.xml -screenshot_headless ${folder}/screenshot
done
if [ "$(uname)" == "Darwin" ]; then
open ${folder}
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
xdg-open ${folder}
fi
echo "$(${NORMAL_COLOR})"
fi