| 1 |
#!/bin/sh |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
textureX=512 |
|---|
| 25 |
textureY=512 |
|---|
| 26 |
|
|---|
| 27 |
leaves=true |
|---|
| 28 |
depthmap=true |
|---|
| 29 |
|
|---|
| 30 |
output_dir="textures/" |
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
megapov="megapov" |
|---|
| 36 |
defaultpov="povray" |
|---|
| 37 |
if which $megapov ; |
|---|
| 38 |
then |
|---|
| 39 |
povray="$megapov" |
|---|
| 40 |
else |
|---|
| 41 |
povray="$defaultpov" |
|---|
| 42 |
depthmap="\'$megapov\' not found, we'll use '$defaultpov' instead. We can't compute depthmap on default povray. Please use MegaPov if you want depthmaps (can be found at http://megapov.inetart.net/megapov-1.1.tar.bz2, or try mirror http://mirror.isurf.ca/download.sourcemage.org/mirror/megapov-1.1.tar.bz2)." |
|---|
| 43 |
fi |
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
povname=$1 |
|---|
| 47 |
filename=`echo $povname | sed 's/\.pov$//'` |
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
objname=`grep "union {" $povname -A 1 | tail -n 1 | sed 's/^.*{ \(.*[0-9]*\)_stems/\1/' ` |
|---|
| 56 |
|
|---|
| 57 |
echo "objname=[$objname]" |
|---|
| 58 |
|
|---|
| 59 |
tmppov="/tmp/$objname.$$.pov" |
|---|
| 60 |
tmptex="/tmp/$objname.$$.tga" |
|---|
| 61 |
tmpdepth="/tmp/$objname.$$.depth.tga" |
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
result="/tmp/result.$$.txt" |
|---|
| 65 |
( |
|---|
| 66 |
echo "ARBARO to POVRAY: automatic texture generation, by Fred Marmond, fmarmond@users.sf.net" |
|---|
| 67 |
echo "Input file : $povname" |
|---|
| 68 |
echo "Object name: $objname" |
|---|
| 69 |
echo |
|---|
| 70 |
echo "Options :" |
|---|
| 71 |
echo "textureX : $textureX" |
|---|
| 72 |
echo "textureY : $textureY" |
|---|
| 73 |
echo "leaves : $leaves" |
|---|
| 74 |
echo "depthmap : $depthmap" |
|---|
| 75 |
echo |
|---|
| 76 |
echo "Output files :" |
|---|
| 77 |
)>$result |
|---|
| 78 |
|
|---|
| 79 |
base_pov=" #include \"${filename}.inc\" |
|---|
| 80 |
//we set 'full blue' background, in order to make the transparent texture easily later |
|---|
| 81 |
background {rgb <0.0,0.0,0.0,0.0>} |
|---|
| 82 |
|
|---|
| 83 |
//comment it if you don't want lighting |
|---|
| 84 |
light_source { <5000,5000,-3000>, rgb 1.2 } |
|---|
| 85 |
light_source { <-5000,2000,3000>, rgb 0.5 shadowless } |
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
//#declare HEIGHT = ${objname}_height * 1.02; |
|---|
| 89 |
#declare HEIGHT = ${objname}_height * 1.3; |
|---|
| 90 |
#declare WIDTH = HEIGHT*${textureX}/${textureY}; |
|---|
| 91 |
" |
|---|
| 92 |
|
|---|
| 93 |
camera_face=" |
|---|
| 94 |
camera { orthographic location <0, HEIGHT*0.5, -40 > |
|---|
| 95 |
right <WIDTH, 0, 0> up <0, HEIGHT, 0.0> |
|---|
| 96 |
look_at <0, HEIGHT*0.5, 0> } |
|---|
| 97 |
" |
|---|
| 98 |
camera_side=" |
|---|
| 99 |
camera { orthographic location <40, HEIGHT*0.5, 0> |
|---|
| 100 |
right <WIDTH, 0, 0> up <0, HEIGHT, 0.0> |
|---|
| 101 |
look_at <0, HEIGHT*0.5, 0> } |
|---|
| 102 |
" |
|---|
| 103 |
camera_top=" |
|---|
| 104 |
camera { orthographic location <0, HEIGHT, 0> |
|---|
| 105 |
right <WIDTH, 0, 0> up <0, 0, WIDTH> |
|---|
| 106 |
look_at <0, HEIGHT*0.5, 0> } |
|---|
| 107 |
" |
|---|
| 108 |
|
|---|
| 109 |
obj_pov=" |
|---|
| 110 |
union { |
|---|
| 111 |
object { ${objname}_stems |
|---|
| 112 |
pigment {color rgb <1.0,1.0,0.0>} } |
|---|
| 113 |
" |
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 |
if [ "$leaves" = "true" ]; |
|---|
| 117 |
then |
|---|
| 118 |
obj_pov="$obj_pov |
|---|
| 119 |
object { ${objname}_leaves |
|---|
| 120 |
texture { pigment {color rgb <0.0,1.0,0.0>} |
|---|
| 121 |
finish { ambient 0.15 diffuse 0.8 }}} |
|---|
| 122 |
" |
|---|
| 123 |
fi |
|---|
| 124 |
obj_pov="$obj_pov }" |
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
if [ "$depthmap" = "true" ]; |
|---|
| 128 |
then |
|---|
| 129 |
depth_map=" |
|---|
| 130 |
#version unofficial MegaPov 1.1; |
|---|
| 131 |
#include \"pprocess.inc\" |
|---|
| 132 |
#declare DepthMin=35; |
|---|
| 133 |
#declare DepthMax=45; |
|---|
| 134 |
global_settings { |
|---|
| 135 |
assumed_gamma 1.0 |
|---|
| 136 |
post_process{ |
|---|
| 137 |
PP_Depth(DepthMin,DepthMax) |
|---|
| 138 |
save_file \"${tmpdepth}\" |
|---|
| 139 |
} |
|---|
| 140 |
} |
|---|
| 141 |
" |
|---|
| 142 |
fi |
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
function render() |
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 |
|
|---|
| 150 |
{ |
|---|
| 151 |
camera_view="$1" |
|---|
| 152 |
view="$2" |
|---|
| 153 |
output_rgba="${output_dir}${objname}.${view}.tga" |
|---|
| 154 |
output_depth="${output_dir}${objname}.${view}.depth.tga" |
|---|
| 155 |
( echo "$depth_map $base_pov $camera_view $obj_pov" ) > $tmppov |
|---|
| 156 |
$povray -I${tmppov} -O${tmptex} +UA +W${textureX} +H${textureY} -D +Ft && ( mv ${tmptex} ${output_rgba} && echo "out RGBA file: $output_rgba" >> $result ;if [ -f ${tmpdepth} ]; then mv ${tmpdepth} ${output_depth}; echo "out DEPTH file: $output_depth">> $result; fi ) || ( echo " FAILED..."; exit ) |
|---|
| 157 |
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 |
} |
|---|
| 161 |
|
|---|
| 162 |
render "$camera_face" "face" |
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
|
|---|
| 167 |
rm $tmppov |
|---|
| 168 |
echo |
|---|
| 169 |
echo "---------------------------------------------------------------------------" |
|---|
| 170 |
echo |
|---|
| 171 |
cat $result |
|---|
| 172 |
echo |
|---|
| 173 |
rm $result |
|---|