1#!/bin/sh 2 3# make a vrml97 skybox from a povray file 4 5# input file: povrayfile as first argument of the commandline 6# output files: sky.wrl 7# sky_front.jpg sky_right.jpg sky_back.jpg 8# sky_left.jpg sky_top.jpg sky_bottom.jpg 9# 10# Copyright (C) 2003 J. "MUFTI" Scheurich, based on a idea of Marc Schimmler 11# 12# This program is free software; you can redistribute it and/or modify 13# it under the terms of the GNU General Public License as published by 14# the Free Software Foundation; either version 2 of the License, or 15# (at your option) any later version. 16# 17# This program is distributed in the hope that it will be useful, 18# but WITHOUT ANY WARRANTY; without even the implied warranty of 19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20# GNU General Public License for more details. 21# 22# You should have received a copy of the GNU General Public License 23# along with this program (see the file "COPYING" for details); if 24# not, write to the Free Software Foundation, Inc., 675 Mass Ave, 25# Cambridge, MA 02139, USA. 26 27 28SIZE=512 29POVRAY_INC=/usr/local/src/povray31/include 30 31TMPM4=/tmp/sky$$.m4 32 33cat > $TMPM4 << EOT 34camera{ location <0,0,0> 35 up y 36 right x 37 angle 90 38ifdef(\`sky_top', \`look_at < 0, 32000, 0>') 39ifdef(\`sky_bottom',\`look_at < 0,-32000, 0>') 40ifdef(\`sky_left', \`look_at < 32000, 0, 0>') 41ifdef(\`sky_right', \`look_at <-32000, 0, 0>') 42ifdef(\`sky_front', \`look_at < 0, 0, 32000>') 43ifdef(\`sky_back', \`look_at < 0, 0,-32000>') 44} 45EOT 46 47for i in _left _front _right _back _top _bottom; do 48 TMPFILE=/tmp/sky_$i_$$.pov 49 cp $1 $TMPFILE || exit 1 50 # last camera wins 8-) 51 m4 -Dsky''$i= $TMPM4 >> $TMPFILE || exit 1 52 TMPTGA=/tmp/sky$i_$$.tga 53 x-povray +D -I$TMPFILE -L$POVRAY_INC +FT -W$SIZE -H$SIZE +a0.0001 \ 54 -o $TMPTGA || exit 1 55 rm -f $TMPFILE 56 convert $TMPTGA sky$i.png || exit 1 57 rm -f $TMPTGA 58done 59 60rm -f $TMPM4 61 62cat > sky.wrl << EOT 63#VRML V2.0 utf8 64 65Background 66 { 67 frontUrl 68 [ 69 "sky_front.png" 70 ] 71 rightUrl 72 [ 73 "sky_right.png" 74 ] 75 backUrl 76 [ 77 "sky_back.png" 78 ] 79 leftUrl 80 [ 81 "sky_left.png" 82 ] 83 topUrl 84 [ 85 "sky_top.png" 86 ] 87 bottomUrl 88 [ 89 "sky_bottom.png" 90 ] 91 } 92EOT 93