% Interpret all of the customized parameters, and then call Build to
% create the landscape accordingly
% Calls:  Build
function [method,sz,iters,randm,peak,decay,dim,jag,water] = BuildCustomized(win1H,win2H,dim);

% win2H(3) indicates whether the user wanted a smooth landscape
% win2H(8) indicates whether the user wanted trees
if get(win2H(3),'Value')
	if get(win2H(8),'Value')
		method = 'randsp';
	else
		method = 'spline';
	end
else
	if get(win2H(8),'Value')
		method = 'rndpls';
	else
		method = 'subdiv';
	end
end

% Extract the parameters from array win2H and scale them appropriately
detail = get(win2H(11),'Value');
sz = round(detail/2) + 6;
iters = 15;
randm = 0;
peak = 0;
decay = 0;
jag = get(win2H(6),'Value') / 2;
water = (get(win2H(14),'Value') - 30) / 150;

% Reset the size and iterations sliders in the main window
set(win1H(4),'Value',sz);
set(win1H(3),'String',num2str(sz));
set(win1H(7),'Value',iters);
set(win1H(6),'String',num2str(iters));
set(win1H(12),'Value',randm);
set(win1H(11),'String',num2str(randm));
set(win1H(15),'Value',peak);
set(win1H(14),'String',num2str(peak));

[sz,iters,dim] = Build(method,sz,iters,randm,peak,decay,dim,jag,water,1);
