A volume object contains a three dimensional data array of voxel values and a set of rendering attributes. The voxel array is mapped to colors and opacity values through a set of lookup tables in the volume object. Several rendering methods are provided to draw the volume to a destination.
To create a volume object, create a three dimensional array of voxels and pass them to the IDLgrVolume::Init method. Voxel arrays must be of BYTE type. For example, the following will create a simple volume data set and create a volume object which uses it:
data = BYTARR(64,64,64)
FOR i=0,63 DO data[*,i,0:i] = i*2
data[5:15, 5:15, 5:55] = 128
data[45:55, 45:55, 5:15] = 255
myvolume = OBJ_NEW('IDLgrVolume', data)
The volume contains a shaded prism along with two brighter cubes (one located within the prism).
See IDLgrVolume for details on creating volume objects.
| Note |
obj_vol.pro, located in the examples/visual subdirectory of the IDL distribution. You can run the example procedure by entering OBJ_VOL at the IDL command prompt. The procedure file stops after each operation (roughly corresponding to each section below) and requests that you press return before continuing.
A volume object has spatial dimensions equal to the size of the data in the volume. In the example, the volume object occupies the range 0-63 in the x-, y-, and z-axes. To make the volume easier to manipulate, we use the XCOORD_CONV, YCOORD_CONV, and ZCOORD_CONV properties of the volume object to center the volume at 0,0,0 and scale it to fit in a unit cube:
cc = [-0.5, 1.0/64.0]
myvolume->SetProperty, XCOORD_CONV=cc, YCOORD_CONV=cc, $
ZCOORD_CONV=cc
; Create a window and view tree:
mywindow = OBJ_NEW('IDLgrWindow', DIMENSIONS=[200,200])
myview = OBJ_NEW('IDLgrView',VIEWPLANE_RECT=[-1,-1,2,2], $
ZCLIP=[2.0,-2.0], COLOR=[50,50,50])
mymodel = OBJ_NEW('IDLgrModel')
myview->Add, mymodel
mymodel->Add, myvolume
; Rotate the volume a little and draw it:
mymodel->rotate, [1,1,1], 45
mywindow->Draw, myview