function f = takeVRCapture(vrfigh)
% TAKEVRCAPTURE Takes a screen capture of a Simulink(R) 3D Animation(TM) 
% window and places it in a figure. The figure is also adjusted to display
% appropriately. The input is the handle to the virtual reality figure
% (usually obtained by vrgcf).

% Copyright 2007-2009 The MathWorks, Inc.

% Create figure and get the background color of figure
f = figure; color = get(f,'color');

% Get current panel value for vrfigure
navPanelValue = get(vrfigh,'NavPanel');

% Turn off the navigation panel in vrfigure window. Pause statement lets
% the update finish before the vrfigure is captured in an image.
set(vrfigh,'NavPanel','none'); pause(1);

% Take snapshot of vrfigure window
vrwindowcapture = capture(vrfigh);

% Reset value to navigation panel
set(vrfigh,'NavPanel',navPanelValue);

% Put captured image into figure created above.
image(vrwindowcapture);

% Set axes color and size
set(gca,'XColor',color,'YColor',color,'TickDir','out','Position',[0 0 1 1]);
