File size: 870 Bytes
bd34ae9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a8c9a4d
bd34ae9
 
 
 
 
 
a8c9a4d
bd34ae9
 
 
 
 
 
 
 
 
 
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
#!/bin/bash	

_meshin_around_main() {
	local mesh="${1}" ; shift
	local mash="${1-fun.obj}" ; shift

	if [ "" = "${mesh}" ] ; then
		echo "usage: meshin-around.sh <download.obj>"
		return 1
	fi

	local name=$( basename ${mash} | sed 's,\.obj$,,' )
	local mtl="${name}.mtl"
	local png="${name}.png"

	if [ -f ${mash} ] ; then
		echo "${mash} already exists"
	else
		echo "creating ${mash} for ${mesh}"
		sed "s,^f.*,,;s,#f,f,;s,.*mtllib.*,mtllib ${mtl},;s,^usemtl .*,usemtl ${name}Material," ${mesh} > ${mash} || exit ${?}
	fi

	if [ -f "${mtl}" ] ; then 
		echo "${mtl} already exists"
	else
		echo "creating ${mtl} for ${mash}"
		echo -e "newmtl ${name}Material\nmap_Kd ${png}" > ${mtl} || exit ${?}
	fi

	if [ -f "${png}" ] ; then
		echo "${png} looks good"
	else
		echo "be sure your texture is in pwd and named ${png} or edit ${mtl}"
	fi
}

_meshin_around_main ${*}