% Author: Andrew Gwozdziewycz
% For: CIS 601 Fall 2004, Latecki
% Date: September 13, 2004
%
% Reads a VRML file (don't try with other files as it's specific to
% ones formatted in this way) for vertices and faces and translates, 
% rotates and then does some scaling on them.
%
clear all;
vrmlfile = 'chess1.wrl';
[vertices, faces] = LoadVRML(vrmlfile);
vertices = vertices{1};
faces = faces{1};

fileavi = 'chess1.avi';
fps = 24; % default
      
global aviobject;
aviobject = avifile(fileavi, 'fps', fps);

oness = ones(1, size(vertices,1));

%for i = 0:1:fps*2
%    figframe(vertices, faces);
%end              

vertices = transform(vertices, pi/2, 0, 0, 0, 0, 0, 1, 1, 1);
for i = 0: pi/10: 2 * pi
    text(-10, 20, 0, 'X rotate');
    new = transform(vertices, i, 0, 0, 0, 0, 0, 1, 1, 1);
    figframe(new, faces);
end    

for i = 0: pi/10: 2 * pi
    text(-10, 20, 0, 'Y rotate');
    new = transform(vertices, 0, i, 0, 0, 0, 0, 1, 1, 1);
    figframe(new, faces);
end   

for i = 0: pi/10: 2*pi
    text(-10, 20, 0, 'Z rotate');
    new = transform(vertices, 0, 0, i, 0, 0, 0, 1, 1, 1);
    figframe(new, faces);
end  



for i = 0: -.5: -10
    text(-10, 30, 0, 'Oh know where is it going (X)?');
    new = transform(vertices, 0, 0, 0, i, 0, 0, 1, 1, 1);
    figframe(new, faces);
end


for i = -10: .5: 0
    text(-10, 30, 0, 'Oh know where is it going?');
    new = transform(vertices, 0, 0, 0, i, 0, 0, 1, 1, 1);
    figframe(new, faces);
end

for i = 0: .5: 10
    text(-10, 30, 0, 'Oh know where is it going (YZ)?');
    new = transform(vertices, 0, 0, 0, 0, i, i/2, 1, 1, 1);
    figframe(new, faces);
end

for i = 10: -.5: 0
    text(-10, 30, 0, 'Oh know where is it going (YZ)?');
    new = transform(vertices, 0, 0, 0, 0, i, i/2, 1, 1, 1);
    figframe(new, faces);
end

for i = 1: .5: 10
    text(-10, 30, 0, 'Its getting ready too...?');
    new = transform(vertices, 0, 0, 0, 0, 0, 0, i, i, i);
    figframe(new, faces);
end

for i = 10: -.5: 1
    text(-10, 30, 0, 'Oh good, It is not going to blow up after all');
    new = transform(vertices, 0, 0, 0, 0, 0, 0, i, i, i);
    figframe(new, faces);
end

i = 0;
aviobject = close(aviobject);
