%COMP 236 Programming Assignment 1
%Adrian Ilie, Feb. 2002

function myMovie=makeMovie()
imWidth=300;%pixels
imHeight=200;
filmWidth=36;%mm
filmHeight=24;
k=imWidth/filmWidth;%pixels per mm
mpi=25.4;%mm per inch
cb=load('ws');%cereal box in inches
cb=cb-([4 6 1.5]'*ones(1,20))';%make center of box the origin
cbp=cb*mpi*k;%cereal box in pixels
f=15*k;%15 mm in pixels
imSize=[imHeight,imWidth];
distance=4000;

%animate!

frame=1;



angle=[0 0 0];

for t=1:3
    for i=0:-100:-1000
        cop=[0 0 distance];
        cop(t)=cop(t)-i;
        img=cerealBox(cbp,imSize,cop,angle,f);
        imshow(img);
        myMovie(frame)=getframe;
        frame=frame+1;
    end

    for i=-1000:100:1000
        cop=[0 0 distance];
        cop(t)=cop(t)-i;
        img=cerealBox(cbp,imSize,cop,angle,f);
        imshow(img);
        myMovie(frame)=getframe;
        frame=frame+1;
    end

    for i=1000:-100:0
        cop=[0 0 distance];
        cop(t)=cop(t)-i;
        img=cerealBox(cbp,imSize,cop,angle,f);
        imshow(img);
        myMovie(frame)=getframe;
        frame=frame+1;
    end
end



cop=[0 0 distance];

for t=1:3
    angle=zeros(1,3);
    for i=0:180
        angle(t)=i;
        img=cerealBox(cbp,imSize,cop,angle,f);
        imshow(img);
        myMovie(frame)=getframe;
        frame=frame+1;
    end
end



for i=0:180
    cop=[0 0 distance];
    angle=[i i i];
    img=cerealBox(cbp,imSize,cop,angle,f);
    imshow(img);
    myMovie(frame)=getframe;
    frame=frame+1;
end




%movie2avi(myMovie, 'CerealBox.avi', 'COMPRESSION', 'None', 'QUALITY', 100);
%mpgwrite(myMovie, gray(256), 'CerealBox.mpg', [1 2 2 1 10 8 10 25]);