Lighting Simulation with Radiance
Most of the generators put the object at the origin, which isn't likely to be the spot you wanted. The xform utility addresses this issue. Its syntax is:
xform -t transx transy transz -rx angle\ -ry -s scalefactor optional_scenefile
xform can transform everything in a file, or you can pipe the output of a generator utility to it. It can scale the objects (-s factor), rotate around an axis (-ry angle means rotate around y axis) and translate to new positions (-t x y z means translate by x y z). You can use the different options multiple times, in any order. The operations are done in the order that they appear on the command line. Also, be sure to pay attention to the exact default position used by a generator. Most of them put a corner at the origin.
Figure 1 shows the effects of xform on a set of cubes generated by genbox. In this image, the viewer is on the +z axis looking back toward the origin. The red axis is +x, and green is +y.
The blue box is the unmodified output of a call to genbox. The red box is the same genbox with an xform:
!genbox redplastic box1 .5 .5 .5 \ | xform -rz 45 -t 2 0 0
The green box is:
!genbox greenplastic box2 .5 .5 .5 \ | xform -t 2 0 0 -rz 45The materials (like redplastic) were defined right before these calls but are not shown in the listings. You can see the way the order of parameters affects the operations and, thus, the output.
I've written a number of generators in Perl that can be used to put together log cabins and log homes (available electronically). In this article I use genlogwall, genlog and genroof. All of these output in units of inches, even though they sometimes take arguments in feet as input for convenience. The materials I use also are included in the electronic distribution.
The genlog utility generates a capped cylinder, centered along the +x axis (Figure 2). It requires several parameters:
genlog material name length_ft diam_inches
The material should be predefined in your scene, and name should be something you make up. The predefined materials file I supply has three wood materials, oriented for proper-looking logs: xpine, ypine and zpine. You should choose the material that matches your eventual alignment for the log.
If you wanted to make a ten-feet tall, eight-inch diameter pole pointed in +z, with its base at (15ft, 0ft, 0ft), you'd do this:
!genlog zpine mypole 10 8 | xform -ry 90 -t 180 0 0
Remember to use the correct units for xform: 180 inches is 15 feet.
The utility genlogwall takes the following form:
genlogwall material name length_ft height_ft \ logdiam_inches [hole_data_file]
The optional parameter is a data file that indicates what holes should be in the wall and what should be in each hole, such as a window or door. At this point, it will help if we work from the floor plan in Figure 3.
There are four walls, each 15 feet long. I chose the southwest corner of the cabin to be (0,0,0), increasing x to the east, increasing y to the north and increasing z up. This orientation faces the building south, according to the standard-generated sky from gensky. genlogwall always places the generated wall at (0,0,0) along the x axis, as shown in Figure 4.
The hole data file is simple. One hole description per line:
holebottom_ft holetop_ft holestart_ft width_ft[:w|d]
The first two numbers are measured from the floor and the latter two from the beginning edge of the wall (x = 0, x increasing). The optional tag on the end indicates that you want the wall generator to fill the hole with a window or door. Our floor plan calls for two such hole description files (see Listings 2 and 3). You can use the same data file for multiple walls, but only if you want them to have the same set of holes.
The final touch to our cabin is the roof. Generic roof generation is tricky, so the genroof tool makes you do a bit more work than the others.
genroof generates planar pieces of roof; use it multiple times with xform to generate a whole roof.
A data file is required for genroof. In the data file, provide the x-y coordinates (in feet) of the vertexes of the piece of roof, as read from the floor plan in counterclockwise order around the edge. The vertexes all must be in the positive quadrant, and any edge of the peak must run parallel to the x axis.
To figure out the points from the plan, rotate it so the peak of the roof runs left to right. Now ignore the bottom half of the roof, and think of the lower-left corner of the top half as your new origin. Your points are then (0,0), (21,0), (21, 10.5) and back to (0,0). Not too bad.
The points should be entered one per line, separated with a space, ending with the letter b, mp or p to indicate whether the point is at the bottom, somewhere in the middle or the peak of the roof section. This is necessary because it is possible to generate odd-shaped roof sections for unusual roofs.
You also need coordinates for the end cap if you want the genroof utility to fill in the ends of the roof with logs. Looking at the floor plan in our roof orientation, you easily can see that the caps should be along the walls at (3,0)®(3,7.5) and (18,0)®(18,7.5). Add this information to the end of the roof data file prefixed with the marker c:. The completed roof data file for the cabin is shown in Listing 4.
The command-line call for genroof is:
genroof -o overhang_ft typename name \ roofdatafile height_ft thickness_in
The overhang parameter allows the utility to adjust the position of the piece so you can transform it to the height of the wall without worrying about meeting the slope of the roof. The completed cabin scene in Listing 5 shows the z transform for the roof pieces matches the height of the walls, even though the overhangs will droop below the top of the walls.
Our roof is symmetrical, so we use the same genroof with a different xform to make the other half. That's easy.
Free DevOps eBooks, Videos, and more!
Regardless of where you are in your DevOps process, Linux Journal can help!
We offer here the DEFINITIVE DevOps for Dummies, a mobile Application Development Primer, and advice & help from the expert sources like:
- Linux Journal
- New Products
- Flexible Access Control with Squid Proxy
- Users, Permissions and Multitenant Sites
- Security in Three Ds: Detect, Decide and Deny
- High-Availability Storage with HA-LVM
- Tighten Up SSH
- DevOps: Everything You Need to Know
- Non-Linux FOSS: MenuMeters
- Solving ODEs on Linux
- diff -u: What's New in Kernel Development