--- ray/src/util/bsdfview.pl 2017/08/11 21:39:52 2.1 +++ ray/src/util/bsdfview.pl 2018/07/20 00:50:40 2.7 @@ -1,5 +1,5 @@ #!/usr/bin/perl -# RCSid $Id: bsdfview.pl,v 2.1 2017/08/11 21:39:52 greg Exp $ +# RCSid $Id: bsdfview.pl,v 2.7 2018/07/20 00:50:40 greg Exp $ # # Call bsdf2rad to render BSDF and start viewing it. # Arguments are BSDF XML or SIR file(s) @@ -12,10 +12,11 @@ my $td = tempdir( CLEANUP => 0 ); my $octree = "$td/bv$$.oct"; my $ambf = "$td/af$$.amb"; my $raddev = "x11"; # default output device. Overwrite with -o -my $qual = "Low"; -my $vw = "def"; +my $qual = "Med"; +my $usetrad = 0; -my $opts = ""; # Options common to rad +my @range; # BSDF min and max range +my $opts = ""; # Options common to rad my $rendopts = "-w-"; # For render= line in rif file while (@ARGV) { @@ -24,7 +25,7 @@ while (@ARGV) { $opts .= " $_"; } elsif (m/^-v\b/) { # standard view # Let rad do any error handling... - $vw = $ARGV[1]; + $opts .= qq( -v "$ARGV[1]"); shift @ARGV; } elsif (m/^-[nN]\b/) { # No. of parallel processes $opts .= ' -N ' . $ARGV[1]; @@ -38,6 +39,11 @@ while (@ARGV) { } elsif ((m/^-V\b/) or (m/^-e\b/)) { # print view, explicate variables # Think of those two as '-verbose'. $opts .= " $_"; + } elsif (m/^-t\b/) { # start trad instead of rad + $usetrad = 1; + } elsif (m/^-r/) { # specified range for BSDF + @range = ("-r", $ARGV[1], $ARGV[2]); + shift @ARGV; shift @ARGV; } elsif (m/^-\w/) { die("bsdfview: Bad option: $_\n"); } else { @@ -48,9 +54,13 @@ while (@ARGV) { # We need at least one XML or SIR file if ($#ARGV < 0) { - die("Missing input XML or SIR file(s)\n"); + die("bsdfview: missing input XML or SIR file(s)\n"); } +if (length($opts) and $usetrad) { + die("bsdfview: rad options not supported when calling trad (-t)\n"); +} + my @objects = @ARGV; # Make this work under Windoze @@ -70,11 +80,20 @@ $name =~ s{\.[^.]+$}{}; # remove file extension my $rif = "$name.rif"; -die("bsdfview: will not overwrite existing file '$rif'\n") if (-e $rif); +if (-e $rif) { # RIF already exists? + print "Attempting to run with existing rad input file '$rif'\n"; + if ($usetrad) { + system "trad $rif"; + } else { + system "rad -o $raddev -w $opts $rif QUA=$qual"; + } + die("\nTry removing '$rif' and starting again\n\n") if $?; + exit; +} print "bsdfview: creating rad input file '$rif'\n"; -my $scene = qq("!bsdf2rad @objects"); # let bsdf2rad do complaining +my $scene = qq("!bsdf2rad @range @objects"); # let bsdf2rad do complaining my $objects = join(' ', @objects); open(FH, ">$rif") or @@ -90,7 +109,7 @@ UP= +Z OCTREE= $octree oconv= -w -f AMBF= $ambf -QUAL = $qual +QUAL= $qual render= $rendopts view= def -vp 0 -50 50 -vd 0 50 -50 -vh 45 -vv 30 view= fr -vp 15 -30 30 -vd 0 30 -30 @@ -102,6 +121,9 @@ view= pt -vtl -vp 0 0 -10 -vd 0 0 1 -vu 0 1 0 -vv 35 - EndOfRif close(FH); -system "rad -o $raddev -v $vw $opts $rif"; - +if ($usetrad) { + system "rad -v 0 $rif ; trad $rif"; +} else { + system "rad -o $raddev $opts $rif"; +} #EOF