Sunday, April 26, 2020

THREEDIM.P

[Table of Contents]



THREEDIM.P is a sample program on the Kyan Pascal 2.x Advanced Graphics Toolkit disk. The program generates the outline of a F-14 Tomcat figher jet and rotates around 3D space.

It can be run by booting the Kyan Pascal 2.x Advanced Graphics Toolkit and choosing THREEDIM from the menu.

The FIGHTER file must be on the disk to run it as well.

To compile this example program, the following include files need to be available to the compiler:


Source Code


#A
_ORIGIN EQU $4000
#
program threedimdemo(input,output);
    const
        max = 6;
#i      graph3.con
    var
        x,y,z,t,step:real;
        e,d         :real;
        i,j,color   :integer;
        points,lines:integer;
        rep         :char;
        a,b,c:array[1..44] of real;
        lf,lt:array[1..58] of integer;
        f    :text;
#i      graph3.gbl
#i      hires.i
#i      plotter.i
#i      graph3.i
    begin
    writeln(chr(125));
    writeln('This program rotates an object through');
    writeln('110 degrees in seven views.  While also');
    writeln('zooming and changing elevation of the');
    writeln('object.');
    writeln;
    writeln('Press [RETURN] to start the demo');
    readln;
    writeln;
    writeln('Output to plotter?(Y/N)');
    readln(rep);
#A
    LDA #$40
    STA $6A
#
    graphics(8+16);
    if (rep='y') or (rep='Y') then
        plotter:=true
    else
        plotter:=false;
    if plotter then begin
       set_plotter_port(40,440,0,290);
       set_plotter_window(-5,5,-5,0);
       init_plotter;
       advance;
       frame;
       plotter_color(2);
    end;
    reset(f,'fighter');
    read(f,points);
    for i:= 1 to points do
        read(f,a[i]);
    for i:= 1 to points do
        read(f,b[i]);
    for i:= 1 to points do
        read(f,c[i]);
    read(f,lines);
    for i:= 1 to lines do begin
        read(f,lf[i]);
        read(f,lt[i]);
    end;
    SetWindow(-30,30,-20,20);
    color:=1;
    for i:=3 to 9 do begin
        d:=sin(1.6*i/5);
        e:=cos(1.6*i/5);
        setviewreferencepoint(0,0,0);
        setviewplanenormal(d,e,1-i/10);
        setviewdistance(40-6*i);
        setviewup(0,0,1);
        setprojection(perspective,60*d,60*e,60-6*i);
        makeviewplanexfm;
        clearscreen;
        for j:=1 to lines do begin
            display(move_abs,a[lf[j]],
                             b[lf[j]],
                             c[lf[j]]);
            display(draw_abs,a[lt[j]],
                             b[lt[j]],
                             c[lt[j]]);
        end;
    end;
#A
   LDA #$C0
   STA $6A 
#
graphics(0)
end.

Sample Run



No comments:

Post a Comment