home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Hack-Phreak Scene Programs
/
cleanhpvac.zip
/
cleanhpvac
/
ML_3DROT.ZIP
/
SOURCES
/
FIG10.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-12-26
|
4KB
|
194 lines
{
Example of using the 3D "engine", by Maple Leaf, 1996
This code is freeware. If you find it useful, feel free to do whatever
you want with it, with only one condiion: give some small greetings to
Maple Leaf in your productions that use parts of it.
Maple Leaf, '96
btw, I'm too lazy to write down kilos of comments... :-)
}
uses xmode,crt,engine3d;
var a,b:word;
pal:array[byte] of record r,g,b:byte end;
capag,cvpag : word;
dd:integer;
coord:array[0..720] of record x,y,z:integer end;
RealMapping : Boolean;
ch:char;
MaxPnt:word;
RotStep,TiltStep:longint;
Procedure GenFig;
var cnt,k:word;
begin
cnt:=0;
for k:=0 to 59 do begin
with coord[cnt] do begin
x:=k; y:=0; z:=0;
end;
inc(cnt);
end;
for k:=0 to 59 do begin
with coord[cnt] do begin
x:=60; y:=0; z:=k;
end;
inc(cnt);
end;
for k:=0 to 59 do begin
with coord[cnt] do begin
x:=60-k; y:=0; z:=60;
end;
inc(cnt);
end;
for k:=0 to 59 do begin
with coord[cnt] do begin
x:=0; y:=0; z:=60-k;
end;
inc(cnt);
end;
for k:=0 to 59 do begin
with coord[cnt] do begin
x:=0; y:=k; z:=0;
end;
inc(cnt);
end;
for k:=0 to 59 do begin
with coord[cnt] do begin
x:=k; y:=60; z:=0;
end;
inc(cnt);
end;
for k:=0 to 59 do begin
with coord[cnt] do begin
x:=60; y:=60; z:=k;
end;
inc(cnt);
end;
for k:=0 to 59 do begin
with coord[cnt] do begin
x:=60-k; y:=60; z:=60;
end;
inc(cnt);
end;
for k:=0 to 59 do begin
with coord[cnt] do begin
x:=0; y:=60; z:=60-k;
end;
inc(cnt);
end;
for k:=0 to 59 do begin
with coord[cnt] do begin
x:=60; y:=60-k; z:=0;
end;
inc(cnt);
end;
for k:=0 to 59 do begin
with coord[cnt] do begin
x:=60; y:=60-k; z:=60;
end;
inc(cnt);
end;
for k:=0 to 59 do begin
with coord[cnt] do begin
x:=0; y:=60-k; z:=60;
end;
inc(cnt);
end;
MaxPnt:=cnt;
end;
Procedure PuneFig;
var i:integer; cnt:word;
begin
cnt:=0;
{xvwait;}
xclrvpage(capag);
for i:=0 to MaxPnt-1 do begin
_3dx:=coord[i].x+100;
_3dy:=coord[i].y+10;
_3dz:=coord[i].z+10;
asm
cmp RealMapping,1
je @1
call IntMapCoordinates
jmp @2
@1:call MapCoordinates
@2:
end;
xvplot(_2dx,_2dy,(i+1) shl 3,capag);
end;
end;
Procedure IntroText;
begin
Writeln('3D Figure, by Maple Leaf, 1996.');
Writeln(#13#10,' Hot keys are:'#13#10);
Writeln(' <M> - Change mapping method (float/integer)');
Writeln(' <Left> - Decrement horizontal speed of rotation');
Writeln(' <Right> - Increment horizontal speed of rotation');
Writeln(' <Up> - Increment vertical speed of rotation');
Writeln(' <Down> - Decrement vertical speed of rotation');
Writeln(#13#10'Press a key to start ...');
Readkey;
end;
begin
ClrScr;
GenFig;
IntroText;
xinitvideo(0);
xclrvram;
for a:=1 to 255 do with pal[a] do begin
r:=Trunc(63-63*a/255);
g:=Trunc(63-63*a/255);
b:=Trunc(63*a/255);
end;
xsetpalette(@pal);
ZoomFactor:=500;
SetObserverPosition(0,0,500);
SetAngles(0,0);
capag:=0;
cvpag:=3;
dd:=10;
RealMapping:=false;
RotStep:=2;
TiltStep:=3;
repeat
repeat
xvwait;
xsetvpage(cvpag);
RotAngle:=RotAngle+RotStep;
TiltAngle:=TiltAngle+TiltStep;
if RotAngle>359 then RotAngle:=360-RotAngle;
if RotAngle<0 then RotAngle:=360+RotAngle;
if TiltAngle>359 then TiltAngle:=360-TiltAngle;
if TiltAngle<0 then TiltAngle:=360+TiltAngle;
{SetAngles(RotAngle,TiltAngle);}
PuneFig;
inc(capag); if capag>3 then capag:=0;
inc(cvpag); if cvpag>3 then cvpag:=0;
until keypressed;
ch:=readkey;
case UpCase(ch) of
'M': { Mapping mode } RealMapping:=not RealMapping;
#0: begin
ch:=readkey;
case ch of
#72: {Up} inc(RotStep);
#80: {Down} dec(RotStep);
#75: {Left} dec(TiltStep);
#77: {Right} inc(TiltStep);
end;
end;
end;
until ch=#27;
textmode(25);
end.