|
The conversion of 3D objects into depthmaps provides
useful ways to create heightfield data and to indirectly
perform volume calculations. A depthmap is simply a bitmap
that, for each pixel, stores the camera distance to the
3D geometry that the pixel "sees". The projection of the
geometry to the eye is usually orthographic. The distance
values are also inverted to be relative to some finite backplane
so that nearer geometry appears taller on the depthmap.
The above picture shows the classic teapot in depthmap form.
Depthmaps of normal viewed scenes are useful in automating
the extraction of foreground elements from background ones when
a bluescreen is unavailable (e.g., live broadcasts of outdoor
environments). A rangefinding system in the camera provides
a depthmap and objects farther than a preset value are simply
colored away or replaced with other imagery in the visual frame.
Depthmaps of 3D geometry are produced in a manner highly
similar to which they are displayed -- by rasterization.
In fact, it is trivially easy for a renderer to build a
depthmap of the scene it is visualizing (and some of them do
as part of an internal processing step. OpenGL framebuffers often
maintain depthmaps to perform hidden surface removal).
Objects are tesselated into polygons (or camera rays are
intersected with objects) and the resulting display pixels
are then filled in with camera distance values. If raytracing
is not being used, the same pixel may be computed more than once,
so only nearer values are allowed to overwrite farther ones.
Depthmap rasterization also occurs in Leveller when using
the Text tool. The text glyphs are scan-converted into a
simple bitmap, and then height values are assigned to wherever
the bitmap contains glyph pixels.
For general 3D depthmap conversion, the DXF Import plug-in
or the Leveller Export plug-in for PolyTrans is used.
Either way, the projection axis has to be chosen, since
there are an infinite number of viewing angles onto a 3D object.
Sampling resolution is also a factor: the more pixels
in the depthmap (heightfield), the better that small details will be
captured.
Volume Determination
Leveller can display the volume of a heightfield, and with some
creative depthmap processing, you can figure out the volume
of relationships to smaller 3D objects.
Let's say you wanted to figure out how much material
is displaced by a trench which is caused by a pipe.
First, rasterize the pipe into a depthmap using a top-down
projection axis, and match the sampling resolution (the scale)
so that the depthmap has the same per-pixel distance as
the terrain heightfield. Including a flat rectangle underneath
the pipe which is the same size as the heightfield is the
easiest way to do this. Below is a picture of a three-segment
stretch of pipeline converted into a depthmap and imported
into Leveller.
![]() Once created, scale the depthmap vertically to the appropriate span if necessary. A depthmap of a pipe will show a half-circle ridge formation when the heightfield is viewed edge-on, and if it is a half-oval, then vertical scaling or re-spanning is needed. You may also need to re-span or elevate the depthmap to its proper altitude relative to the terrain heightfield. If the highest section of pipe is supposed to be one meter below the terrain floor, for example, and the floor is at an elevation of 100 meters, then the depthmap needs its uppermost span to be at 99 meters. Use the Window, Properties... command to obtain a volume readout of the terrain heightfield and write it down. Switch to the depthmap's document window, and use the "Selection, Select Elevations..." command or the Magic Wand tool to select all the pixels in the depthmap that correspond to the rasterized pipe object (the easiest way to do this is to select the flat background area and then invert the selection).
![]() Copy the selection to the clipboard and switch to the terrain's window. Paste the depthmap onto the heightfield and position the floating selection appropriately. Then defloat the depthmap using the "Replace" style. The depthmap will appear "sunken into" the terrain causing cliff edges to appear tightly against the pipe walls.
![]() Use the Window, Properties... command to obtain a new volume readout of the terrain heightfield and compare it to the value you wrote down earlier. The difference will be the volume of material that is in the trench but not inside the pipe. If you want to include the pipe's volume, that figure can be obtained by simply requesting the volume of the depthmap heightfield and multiplying by two (since the depthmap only contains a half-circle of the pipe and hence only half of its volume). Note: Leveller computes heightfield volumes by summing the elevation of pixels relative to the lowest point of the heightfield. For that reason, you must ensure that the lowest terrain point does not change after defloating the depthmap (e.g., "poke" a single pixel down beforehand to some minimum elevation that not even the trench will pass). Leveller's volume determiner uses a fast but simple voxel-based approach; e.g., a single pixel at elevation 10 on a flat zero-elevation heightfield produces a volume report of 10 cubic units. More precise volumes depend on how heightfield pixels are mapped to mesh vertices and how those vertices are connected into a surface (i.e., which interpolation method is used). The voxel method gains precision in proportion to the heightfield's resolution.
|
Copyright 2004 Daylon Graphics Ltd.