# HG changeset patch # User Axel Jacobs # Date 1385853926 0 # Node ID eaa48934a5bd19e5a7008668830d2a503e4b714d # Parent b32315c3402e7bf714e960b933f99d10df2d6004 objpict: Working and tested under LINUX and Vista. diff -r b32315c3402e -r eaa48934a5bd bin/objpict.pl --- a/bin/objpict.pl Sun Dec 11 23:04:42 2011 +0000 +++ b/bin/objpict.pl Sat Nov 30 23:25:26 2013 +0000 @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/perl # Make a nice multi-view picture of an object # Command line arguments contain materials and object files @@ -16,25 +16,20 @@ my $yres = 1024; my $rpict_cmd = "rpict -av .2 .2 .2 -x $xres -y $yres"; -my $inprad = "$td/op$$.rad"; my $testroom = "$td/testroom.rad"; my $octree = "$td/op.oct"; -# See if files actually exist. -foreach (@ARGV) { - if (! -e) { - die("Can't read file $_\n"); +# We need at least one Radiance file or a scene on STDIN (but not both) +if ($#ARGV < 0) { + open(FH, ">$td/stdin.rad") or + die("objview: Can't write to temporary file $td/stdin.rad\n"); + while (<>) { + print FH; } + # Pretend stdin.rad was passed as argument. + @ARGV = ("$td/stdin.rad"); } -# Dump files passed on command line or from STDIN to a temp file. -open(FH, ">$inprad") or - die("Can\'t write to temporary file $inprad"); -while (<>) { - print FH; -} -close(FH); - # Create some lights and a box as back drop. # The objects and view points will be inside the box. open(FH, ">$testroom") or @@ -56,17 +51,18 @@ EndOfTestroom close(FH); -my $dimstr = `getbbox -h $inprad`; -# Values returned by getbbox are indented and padded with spaces. -$dimstr =~ s/(\s)+/\ /g; # squeeze spaces -$dimstr =~ s/^\ //; # remove leading space -my @dims = split(/\ /, $dimstr); # convert to array +my $dimstr = `getbbox -h @ARGV`; +chomp $dimstr; +# Values returned by getbbox are indented and delimited with multiple spaces. +$dimstr =~ s/^\s+//; # remove leading spaces +my @dims = split(/\s+/, $dimstr); # convert to array # Find largest axes-aligned dimension my @diffs = ($dims[1]-$dims[0], $dims[3]-$dims[2], $dims[5]-$dims[4]); @diffs = reverse sort { $a <=> $b } @diffs; my $size = $diffs[0]; +# Define the four views my $vw1 = "-vtl -vp 2 .5 .5 -vd -1 0 0 -vh 1 -vv 1"; my $vw2 = "-vtl -vp .5 2 .5 -vd 0 -1 0 -vh 1 -vv 1"; my $vw3 = "-vtl -vp .5 .5 2 -vd 0 0 -1 -vu -1 0 0 -vh 1 -vv 1"; @@ -79,7 +75,7 @@ # Scale so that largest object dimension is unity my $scale = 1 / $size; -my $cmd = "xform -t $xtrans $ytrans $ztrans -s $scale -t .5 .5 .5 $inprad"; +my $cmd = "xform -t $xtrans $ytrans $ztrans -s $scale -t .5 .5 .5 @ARGV"; $cmd .= " |oconv $testroom - > $octree"; system "$cmd";