Surface Objects
Surface objects create a representation of functions of two variables. Surfaces are presented as three-dimensional objects in three-dimensional space, and thus are good candidates for interactive rotation, and scaling. Examples in this section discuss interactive manipulation of surface objects.
Note
Also see Mapping an Image onto Elevation Data (Image Processing in IDL) for additional examples using the surface object.
Creating Surface Objects
To create a surface object, provide a two-dimensional array of surface values (Z values) to the IDLgrSurface::Init method. Optionally, you can supply two vectors or arrays X and Y that specify the locations in the XY plane of the Z values provided. If X and Y are not provided, the surface is generated as a function of the array indices of each element of the Z array.
For example, the following statements create a surface object from the two-dimensional array created by the IDL command DIST, as a function of the Z data array indices:
Similarly, if xdata and ydata are either 40-element vectors or 40x40 element arrays specifying the X and Y values which, when evaluated by some function, result in the zdata array, you would create the surface object with the following statement:
See "IDLgrSurface" (IDL Reference Guide) for details on creating surface objects.
Using Surface Objects
Surface objects have numerous properties controlling how they are rendered. You can set these properties when creating the surface object, or use the SetProperty method to the surface object to change these properties after creation.
Style
Set the STYLE property to an integer value that controls how the surface is rendered. Set the STYLE property equal to one of the following integer values:
0 = Display a single pixel for each data point.
1 = Display the surface as a wire mesh. (This is the default.)
2 = Display the surface as a solid.
3 = Display the surface using only lines drawn parallel to the x-axis.
4 = Display the surface using only lines drawn parallel to the y-axis.
5 = Display a wire mesh lego-type surface (similar to a histogram plot).
6 = Display a solid lego-type surface (similar to a histogram plot).
For example, the following statement changes the surface object to display the surface as a wire mesh, with the lines drawn in blue:
The following statement draws the surface as a solid lego-type surface in green:
Vertex Colors
You can supply a vector of vertex colors via the VERT_COLORS property. The colors in the vector will be applied to each vertex in turn. If there are more vertices than colors supplied for the VERT_COLORS property, IDL will cycle through the colors. For example, the following statements color each vertex and connecting line one of four colors:
vcolors =[[0,100,200],[200,150,200],[150,200,250],[250,0,100]] mysurf->SetProperty, STYLE=1, VERT_COLORS=vcolors
Shading
IDL provides two types of shading for surfaces. In Flat shading, the color of the first vertex in the surface is used to define the color for the entire surface. The color has a constant intensity. In Gouraud shading, the colors along each line are interpolated between vertex colors, and then along scanlines from each of the edge intensities.
Note
By default, only ambient lighting is provided for surfaces. If you do not supply a light source for your object hierarchy, solid surface objects will appear flat with either Flat or Gouraud shading. See Light Objects for details on creating and using light objects.
Set the SHADING property of the surface object equal to 0 (zero) to use flat shading (this is the default), or equal to 1 (one) to use Gouraud shading. In the above example using vertex colors, adding the following statement:
creates a surface in which the color values are interpolated between the vertex colors.
Skirts
You can draw a skirt around the bottom edge of your surface object by setting the SHOW_SKIRT property of the surface object to 1. The skirt extends from the edge of the surface to a Z value specified by the SKIRT property. For example, the following statements draw the surface in wire mesh mode, with a skirt extending from the bottom of the surface to the value z = 0.1:
Hidden Line Removal
Set the HIDDEN_LINES property to the surface object equal to one to remove lines that are behind the visible parts of the surface from the rendering. By default, hidden lines are drawn. The following statement alters the surface to remove the hidden lines:
Warning
Hidden line removal can be time-consuming.
Texture Mapping
You can map an image onto a surface object by specifying an IDLgrImage object to the TEXTURE_MAP property. The TEXTURE_COORD property defines how individual data points within the image data are mapped to the surface's vertices. If the TEXTURE_COORD property is not specified, the surface object will map the texture onto the entire data space (the region between 0.0 and 1.0 in normalized coordinates). See Mapping an Image onto Geometry (Image Processing in IDL) for examples.


