www.gusucode.com > map 案例源码 matlab代码程序 > map/IlluminateColored3DReliefMapsWithLightObjectsExample.m

    %% Illuminate Color 3-D Relief Maps with Light Objects
% This example shows how to add a light source to a surface colored data
% grid.  The toolbox manages light objects with the
% |lightm| function. 
%%
% Load Digital Elevation Model (DEM) data and display it. This example
% loads DEM data centered on the Korean peninsula. The example uses the
% |meshm| function to display the data, without lighting effects, and color
% it with terrain hues.

% Copyright 2015 The MathWorks, Inc.

load korea
figure; axesm('MapProjection','miller',...
     'MapLatLimit',[30 45],'MapLonLimit',[115 135])
meshm(map,refvec,size(map),map);
demcmap(map)
%%
% Create a light object with |lightm| function and place the light at
% the northwest corner of the grid, one degree high. (The |lightm| function
% is similar to the MATLAB |light| function, but it accepts latitude and
% longitude for positioning information, rather than _x_ , _y_ , and _z_ .)
% Note that the figure becomes darker.
h=lightm(45,115,1);
%%
% Exaggerate the vertical dimension to make any relief viewable in
% perspective. Note that the figure becomes darker still.
daspectm('meters',50)
%%
% Set the ambient (direct), diffuse (skylight), and specular (highlight)
% surface reflectivity characteristics, respectively.
material([.7,.9,.8])
%%
% By default, the lighting is flat (plane facets). Change this to Gouraud
% shading (interpolated normal vectors at facet corners).
lighting Gouraud
%%
% Remove the edges of the bounding box and set a viewpoint of
% -30 degrees azimuth and 30 degrees altitude.
ax = gca;
ax.Box = 'off';
view(-30,30)
%%
% To remove a light (when there is only one) from the current figure, use
% the |clmo| function.
clmo(handlem('light'))