function [plane,pointer,surf,minx,maxx,miny,maxy,minz,maxz,location]...
    = setupAnimation(res)
% Draw the first frame of the picture before animation

plane=CSGcube(-.25,0,0,.25,res);   % default cube object
surf=CSGtoSurface(plane,res);
surf.facecolor='blue';

sphere1=CSGsphere(0,0,.95,.025,res);

location=[0,0,.9];

pointer=CSGtoSurface(sphere1,res);
pointer.facecolor='red';

renderpatch(surf);
renderpatch(pointer);

grid on
   
l=light('position',[4,-4,0]);
  
%Do a persptective transform
set(gca,'projection','perspective')
set(gca,'CameraViewAngle',8)
   
%The frame background color
set(gcf,'color', [.6,.8,.8])
xlabel('x');ylabel('y');zlabel('z'); 
axis([-1.2 1.2 -1.2 1.2 -1.2 1.2]);
view(7,20)

drawnow  

rotate3d on

surf.EdgeLighting = 'phong';
surf.DiffuseStrength = 0;

%Collect boundaries for determining if you cross an object
minx=min(surf.vertices(:,1));
maxx=max(surf.vertices(:,1));
miny=min(surf.vertices(:,2));
maxy=max(surf.vertices(:,2));
minz=min(surf.vertices(:,3));
maxz=max(surf.vertices(:,3));

% %Iterate through surf (object)
% dimensions = size(surf.vertices)
% surfMap = containers.Map('KeyType','char','ValueType','double');
% 
% for i = 1:dimensions(1)
%     key = '';
%     for j = 1:dimensions(2)
%         val = num2str(round(surf.vertices(i,j)*100)/100);
%         key = strcat(key,val);
%     end
%     surfMap(key)=1.00;
%         
% end

