bin/ltpict.pl
changeset 68 67aa83bdbddd
parent 65 f10a54c3213d
child 79 0f5dabeed505
equal deleted inserted replaced
67:cb1224fcd2c2 68:67aa83bdbddd
    45 		last;    # No more options.  What's left is the actual file name.
    45 		last;    # No more options.  What's left is the actual file name.
    46 	}
    46 	}
    47     shift @ARGV;
    47     shift @ARGV;
    48 }
    48 }
    49 
    49 
    50 if ($is_ies == 0) {
    50 # We need exactly one Radiance luminaires or IES file
       
    51 if (! $#ARGV == 0) {
       
    52 	die("ltpict: Need one Radiance luminaire or IES file.\n");
       
    53 } elsif ($is_ies == 0) {
    51 	# Input file is a Radiance luminaire
    54 	# Input file is a Radiance luminaire
    52 	$lumi = $ARGV[0];
    55 	$lumi = $ARGV[0];
    53 } else {
    56 } else {
    54 	# Input file is IES photometry
    57 	# Input file is IES photometry
    55 	system "ies2rad -p $td -o lumi $ARGV[0]";
    58 	system qq[ ies2rad -p $td -o lumi "$ARGV[0]" ];
    56 }
    59 }
    57 
    60 
    58 my $res2 = $res / 2;    # Each rendering is half the size of final composite
    61 my $res2 = $res / 2;    # Each rendering is half the size of final composite
    59 
    62 
    60 # Scale luminaire and center at origin
    63 # Scale luminaire and center at origin
    61 my $dimstr = `getbbox -h $lumi`;
    64 my $dimstr = `getbbox -h "$lumi"`;
    62 chomp $dimstr;
    65 chomp $dimstr;
    63 # Values returned by getbbox are indented and delimited with multiple spaces.
    66 # Values returned by getbbox are indented and delimited with multiple spaces.
    64 $dimstr =~ s/^\s+//;                # remove leading spaces
    67 $dimstr =~ s/^\s+//;                # remove leading spaces
    65 my @dims = split(/\s+/, $dimstr);   # convert to array
    68 my @dims = split(/\s+/, $dimstr);   # convert to array
    66 
    69 
    72 # Move luminaire so centre is at origin, and scale
    75 # Move luminaire so centre is at origin, and scale
    73 my $xtrans = -1.0 * ($dims[0] + $dims[1]) / 2;
    76 my $xtrans = -1.0 * ($dims[0] + $dims[1]) / 2;
    74 my $ytrans = -1.0 * ($dims[2] + $dims[3]) / 2;
    77 my $ytrans = -1.0 * ($dims[2] + $dims[3]) / 2;
    75 my $ztrans = -1.0 * ($dims[4] + $dims[5]) / 2;
    78 my $ztrans = -1.0 * ($dims[4] + $dims[5]) / 2;
    76 my $scale = $maxsize / $size;
    79 my $scale = $maxsize / $size;
    77 
    80 system qq[ xform -t $xtrans $ytrans $ztrans "$lumi" > $lumi2 ];
    78 open(FH, ">$lumi2") or
       
    79 		die("ltpict: Cannot write to temporary file $lumi");
       
    80 print FH "!xform -t $xtrans $ytrans $ztrans -s $scale $lumi";
       
    81 close FH;
       
    82 
    81 
    83 
    82 
    84 # Material for the room
    83 # Material for the room
    85 open(FH, ">$mat") or
    84 open(FH, ">$mat") or
    86 		die("ltpict: Cannot write to temporary file $mat");
    85 		die("ltpict: Cannot write to temporary file $mat");
   121 chomp $dimstr;
   120 chomp $dimstr;
   122 # Values returned by getbbox are indented and delimited with multiple spaces.
   121 # Values returned by getbbox are indented and delimited with multiple spaces.
   123 $dimstr =~ s/^\s+//;             # remove leading spaces
   122 $dimstr =~ s/^\s+//;             # remove leading spaces
   124 @dims = split(/\s+/, $dimstr);   # convert to array
   123 @dims = split(/\s+/, $dimstr);   # convert to array
   125 
   124 
       
   125 
   126 # Define the four views
   126 # Define the four views
   127 my $vw1 = "-vtl -vp 4.5 0 0 -vd -1 0 0 -vh 10 -vv 10";
   127 my $vw1 = "-vtl -vp 4.5 0 0 -vd -1 0 0 -vh 10 -vv 10";
   128 my $vw2 = "-vtl -vp 0 -4.5 0 -vd 0 1 0 -vh 10 -vv 10";
   128 my $vw2 = "-vtl -vp 0 -4.5 0 -vd 0 1 0 -vh 10 -vv 10";
   129 my $zcent3 = $dims[4] - $tiny;
   129 my $zcent3 = $dims[4] - $tiny;
   130 my $vw3 = "-vta -vp 0 0 $zcent3 -vd 0 0 -1 -vu 0 1 0 -vh 180 -vv 180";
   130 my $vw3 = "-vta -vp 0 0 $zcent3 -vd 0 0 -1 -vu 0 1 0 -vh 180 -vv 180";
   131 my $zcent4 = $dims[5] + $tiny;
   131 my $zcent4 = $dims[5] + $tiny;
   132 my $vw4 = "-vta -vp 0 0 $zcent4 -vd 0 0 1 -vu 0 1 0 -vh 180 -vv 180";
   132 my $vw4 = "-vta -vp 0 0 $zcent4 -vd 0 0 1 -vu 0 1 0 -vh 180 -vv 180";
   133 
   133 
       
   134 
       
   135 # Compile octrees
   134 system "oconv $mat $room1 $lumi2 > $oct1";
   136 system "oconv $mat $room1 $lumi2 > $oct1";
   135 system "oconv $mat $room2 $lumi2 > $oct2";
   137 system "oconv $mat $room2 $lumi2 > $oct2";
   136 system "oconv $mat $room3 $lumi2 > $oct3";
   138 system "oconv $mat $room3 $lumi2 > $oct3";
   137 system "oconv $mat $room4 $lumi2 > $oct4";
   139 system "oconv $mat $room4 $lumi2 > $oct4";
   138 
   140