vgvm commited on
Commit
89777fd
1 Parent(s): 3d5f8b6

script to defargle the downloaded obj files

Browse files
Files changed (1) hide show
  1. meshin-around.sh +37 -0
meshin-around.sh ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ _meshin_around_main() {
4
+ local mesh="${1}" ; shift
5
+ local mash="${1-fun.obj}" ; shift
6
+
7
+ if [ "" = "${mesh}" ] ; then
8
+ echo "usage: meshin-around.sh <download.obj>"
9
+ return 1
10
+ fi
11
+
12
+ local name=$( basename ${mash} | sed 's,\.obj$,,' )
13
+ local mtl="${name}.mtl"
14
+ local png="${name}.png"
15
+
16
+ if [ -f ${mash} ] ; then
17
+ echo "${mash} already exists"
18
+ else
19
+ echo "creating ${mash} for ${mesh}"
20
+ sed "s,^f.*,,;s,#f,f,;s,file=.*,${mtl}," ${mesh} > ${mash} || exit ${?}
21
+ fi
22
+
23
+ if [ -f "${mtl}" ] ; then
24
+ echo "${mtl} already exists"
25
+ else
26
+ echo "creating ${mtl} for ${mash}"
27
+ echo -e "newmtl MyMaterial\nillum 2\nmap_Kd ${png}" > ${mtl} || exit ${?}
28
+ fi
29
+
30
+ if [ -f "${png}" ] ; then
31
+ echo "${png} looks good"
32
+ else
33
+ echo "be sure your texture is in pwd and named ${png} or edit ${mtl}"
34
+ fi
35
+ }
36
+
37
+ _meshin_around_main ${*}