--- ray/src/util/rtpict.pl 2018/03/20 01:38:27 2.2 +++ ray/src/util/rtpict.pl 2019/07/05 00:20:57 2.7 @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# RCSid $Id: rtpict.pl,v 2.2 2018/03/20 01:38:27 greg Exp $ +# RCSid $Id: rtpict.pl,v 2.7 2019/07/05 00:20:57 greg Exp $ # # Run rtrace in parallel mode to simulate rpict -n option # @@ -23,11 +23,13 @@ my %vwraysC = ("-vf",1, "-vtv",0, "-vtl",0, "-vth",0, # options we need to silently ignore my %ignoreC = ("-t",1, "-ps",1, "-pt",1, "-pm",1); # Starting options for rtrace (rpict values) -my @rtraceA = split(' ', "rtrace -ffc -u- -dt .05 -dc .5 -ds .25 -dr 1 -aa .2 -ar 64 -ad 512 -as 128 -lr 7 -lw 1e-03"); +my @rtraceA = split(' ', "rtrace -u- -dt .05 -dc .5 -ds .25 -dr 1 " . + "-aa .2 -ar 64 -ad 512 -as 128 -lr 7 -lw 1e-03"); my @vwraysA = ("vwrays", "-ff", "-pj", ".67"); my @vwrightA = ("vwright", "-vtv"); my @rpictA = ("rpict"); my $outpic; +my $outzbf; OPTION: # sort through options while ($#ARGV >= 0 && "$ARGV[0]" =~ /^[-\@]/) { # Check for file inclusion @@ -41,7 +43,7 @@ while ($#ARGV >= 0 && "$ARGV[0]" =~ /^[-\@]/) { } # Check booleans for my $boopt (@boolO) { - if ("$ARGV[0]" =~ ('^' . $boopt . '[-+01tfynTFYN]$')) { + if ("$ARGV[0]" =~ ('^' . $boopt . '[-+01tfynTFYN]?$')) { push @rtraceA, $ARGV[0]; push @rpictA, shift(@ARGV); next OPTION; @@ -82,6 +84,10 @@ while ($#ARGV >= 0 && "$ARGV[0]" =~ /^[-\@]/) { if ("$ARGV[0]" eq "-o") { shift @ARGV; $outpic = shift(@ARGV); + } elsif ("$ARGV[0]" eq "-z") { + push @rpictA, shift(@ARGV); + $outzbf = $ARGV[0]; + push @rpictA, shift(@ARGV); } elsif ("$ARGV[0]" eq "-n") { shift @ARGV; $nprocs = shift(@ARGV); @@ -90,17 +96,25 @@ while ($#ARGV >= 0 && "$ARGV[0]" =~ /^[-\@]/) { } } die "Number of processes must be positive" if ($nprocs <= 0); -if ($outpic) { # redirect output? +if (defined $outpic) { # redirect output? + die "File '$outpic' already exists\n" if (-e $outpic); open STDOUT, '>', "$outpic"; } if ($nprocs == 1) { # may as well run rpict? push(@rpictA, $ARGV[0]) if ($#ARGV == 0); exec @rpictA ; } -die "Need single octree argument\n" if ($#ARGV != 0); -push @rtraceA, (`@vwraysA -d`); -chomp $rtraceA[-1]; push @rtraceA, ("-n", "$nprocs"); -push @rtraceA, $ARGV[0]; -my @view = (`@vwrightA 0`); -exec "@vwraysA | @rtraceA | getinfo -a 'VIEW=@view'"; +die "Need single octree argument\n" if ($#ARGV != 0); +my $oct = $ARGV[0]; +my $view = `@vwrightA 0`; +my @res = split(/\s/, `@vwraysA -d`); +if (defined $outzbf) { # generating depth buffer? + exec "@vwraysA | @rtraceA -fff -olv @res $oct | " . + "rsplit -ih -iH -f " . + "-of $outzbf " . + "-oh -oH -of3 '!pvalue -r -df' | " . + "getinfo -a 'VIEW=$view'"; +} + # no depth buffer, so simpler +exec "@vwraysA | @rtraceA -ffc @res $oct | getinfo -a 'VIEW=$view'";