-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·101 lines (94 loc) · 2.08 KB
/
run.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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash
# -*- ENCODING: UTF-8 -*-
# use .env file
set -a
[ -f .env ] && . .env
set +a
parent_path=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P )
cd "$parent_path"
DEFAULT_TAILMAP="resources/small_museum.txt"
DEFAULT_MODEL="models/bunny.ply"
INPUT_FILE=$DEFAULT_TAILMAP
LOD_FLAG=""
LOD_LEVEL=""
CULLING_FLAG=""
CULLING_LEVEL=""
COMMAND=$1
shift
shopt -s extglob;
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
+(cosa|wall|ground|bunny|bunny|frog|horse|maxplanck|sphere|torus|dragon|happy|lucy|moai|tetrahedron))
DEFAULT_MODEL="models/${key}.ply"
INPUT_FILE="models/${key}.ply"
;;
+(small_museum|big_grid))
DEFAULT_TAILMAP="resources/${key}.txt"
INPUT_FILE="resources/${key}.txt"
;;
--LOD|--calc-LOD)
if [[ $INPUT_FILE == *".txt" ]]; then
INPUT_FILE=$DEFAULT_MODEL
fi
LOD_FLAG="--calc-LOD"
shift
LOD_LEVEL=$1
;;
--CULLING|-c|--cull)
CULLING_FLAG="--CULLING"
shift
CULLING_LEVEL=$1
;;
*.ply|*.txt)
OUTPUT_FILE=$key
;;
esac
shift
done
shopt -u extglob;
# pre-build
case $COMMAND in
""|"run"|"build")
cd ./build
;;
esac
# build
case $COMMAND in
"install")
echo "requirements: git, cmake and Freetype"
echo "project-installing: TinyPly"
git submodule init
git submodule update
mkdir -p ./libs/tinyply/tmp/build
cd ./libs/tinyply/tmp/build
cmake ../../
make
echo "if tinyply gives errors try 'sudo make install'"
echo "example: https://github.com/markcox80/tinyply-cmake"
;;
"models")
ls -l --block-size=M --sort=size ../models/*.ply
;;
"init")
mkdir -p build
cd ./build
cmake ../
cd "$parent_path"
$0 build
;;
"build")
cmake --build . || { exit 1; }
;;
"clean")
rm -rf ./build/*
;;
esac
# run
case $COMMAND in
""|"run"|"build")
echo $INPUT_FILE $LOD_FLAG $LOD_LEVEL $CULLING_FLAG $CULLING_LEVEL $OUTPUT_FILE
./BaseCode $INPUT_FILE $LOD_FLAG $LOD_LEVEL $CULLING_FLAG $CULLING_LEVEL $OUTPUT_FILE
;;
esac