home *** CD-ROM | disk | FTP | other *** search
- PROCEDURE SetThreeDeePoint (var tempPt : ThreeDeePoint; x, y, z : real);
- BEGIN
- tempPt.x := X2Fix(x);
- tempPt.y := X2Fix(y);
- tempPt.z := X2Fix(z);
- END;
-
- PROCEDURE ThreeDeeToTwoDee(theWorld : ThreeDeeWorld; aThreeDeePoint : ThreeDeePoint; var a2DPoint : point);
- VAR
- x1, y1, z1 : fixed;
- x2, y2, z2 : fixed;
- tempFixed : fixed;
- BEGIN
- with theWorld
- do begin
- x1 := (screenCenter.x - aThreeDeePoint.x);
- y1 := (screenCenter.y - aThreeDeePoint.y);
- z1 := (eyeLocation.z - aThreeDeePoint.z);
- z2 := (screenCenter.z - aThreeDeePoint.z);
-
- x2 := FixDiv(FixMul(x1, z2), z1);
- y2 := FixDiv(FixMul(y1, z2), z1);
-
- x2 := FixMul(x1, FixDiv(z2, z1));
- y2 := FixMul(y1, FixDiv(z2, z1));
-
- tempFixed := x2 + screenCenter.x - x1;
- a2DPoint.h := Fix2Long(tempFixed);
- tempFixed := y2 + screenCenter.y - y1;
- a2DPoint.v := Fix2Long(tempFixed);
- end;
- END;
-
- PROCEDURE ScaleRect (var tempRect : rect; scaleFactor : real);
- VAR
- itsCenter : point;
- itsWidth : integer;
- itsHeight : integer;
- BEGIN
- itsWidth := (tempRect.right - tempRect.left);
- itsHeight := (tempRect.bottom - tempRect.top);
- itsCenter.h := tempRect.left + (itsWidth div 2);
- itsCenter.v := tempRect.top + (itsHeight div 2);
-
- tempRect.left := round(itsCenter.h - (itsWidth * scaleFactor) / 2);
- tempRect.top := round(itsCenter.v - (itsHeight * scaleFactor) / 2);
-
- tempRect.right := tempRect.left + round(itsWidth * scaleFactor);
- tempRect.bottom := tempRect.top + round(itsHeight * scaleFactor);
- END;
-
- PROCEDURE SetupThreeDeeWorld (var tempWorld : ThreeDeeWorld; monitorRect : rect);
- VAR
- monitorWidth : real;
- monitorHeight : real;
- monitorDepth : real;
- BEGIN
- with tempWorld
- do begin
- monitorHeight := monitorRect.bottom - monitorRect.top;
- monitorWidth := monitorRect.right - monitorRect.left;
- monitorDepth := monitorWidth;
- SetThreeDeePoint(eyeLocation, (monitorWidth / 2), 0, -200);
- SetThreeDeePoint(screenCenter, (monitorWidth / 2), (monitorHeight / 4), -50);
- SetThreeDeePoint(eyeLocation, (monitorWidth / 2), -200, -500);
- SetThreeDeePoint(screenCenter, (monitorWidth / 2), (monitorHeight / 4), -100);
-
- {SetThreeDeePoint(eyeLocation, 0, 100, 0);
- SetThreeDeePoint(screenCenter, 0, 100, 50);}
- screenRect := monitorRect;
-
- SetThreeDeePoint(frontTopLeft, monitorRect.left, monitorRect.top, 0);
- SetThreeDeePoint(frontTopRight, monitorRect.right, monitorRect.top, 0);
- SetThreeDeePoint(frontBotLeft, monitorRect.left, monitorRect.bottom, 0);
- SetThreeDeePoint(frontBotRight, monitorRect.right, monitorRect.bottom, 0);
- SetThreeDeePoint(backTopLeft, monitorRect.left, monitorRect.top, monitorDepth);
- SetThreeDeePoint(backTopRight, monitorRect.right, monitorRect.top, monitorDepth);
- SetThreeDeePoint(backBotLeft, monitorRect.left, monitorRect.bottom, monitorDepth);
- SetThreeDeePoint(backBotRight, monitorRect.right, monitorRect.bottom, monitorDepth);
-
- { SetThreeDeePoint(frontTopLeft, -monitorWidth, monitorWidth, -monitorWidth);
- SetThreeDeePoint(frontTopRight, monitorWidth, monitorWidth, -monitorWidth);
- SetThreeDeePoint(frontBotLeft, -monitorWidth, 0, -monitorWidth);
- SetThreeDeePoint(frontBotRight, monitorWidth, 0, -monitorWidth);
- SetThreeDeePoint(backTopLeft, -monitorWidth, monitorWidth, monitorWidth);
- SetThreeDeePoint(backTopRight, monitorWidth, monitorWidth, monitorWidth);
- SetThreeDeePoint(backBotLeft, -monitorWidth, 0, monitorWidth);
- SetThreeDeePoint(backBotRight, monitorWidth, 0, monitorWidth); }
- end;
- END;