mirror of
https://git.sr.ht/~rabbits/macintosh_cookbook
synced 2025-02-25 22:29:41 +00:00
Improved pyramid
This commit is contained in:
parent
f74923d9ff
commit
867f563262
@ -15,7 +15,7 @@ program ExampleScene;
|
||||
isDown: Boolean;
|
||||
{scene}
|
||||
scene: Scene3D;
|
||||
box1, box2, box3, box4: Shape3D;
|
||||
box1, wed1, pyr1: Shape3D;
|
||||
|
||||
{>>}
|
||||
procedure ClearScreen;
|
||||
@ -94,19 +94,13 @@ begin
|
||||
{scene}
|
||||
|
||||
SetScene3D(scene);
|
||||
SetBox3D(box1, 0, 0, 0, 100, 100, 100);
|
||||
SetBox3D(box2, 0, 0, 0, 100, 100, 100);
|
||||
SetBox3D(box3, 0, 0, 0, 100, 100, 100);
|
||||
SetBox3D(box4, 0, 0, 0, 100, 100, 100);
|
||||
SetBox3D(box1, -100, 0, 0, 100, 100, 100);
|
||||
SetWedge3D(wed1, 0, 0, 0, 100, 100, 100, 50);
|
||||
SetPyramid3D(pyr1, 100, 0, 0, 100, 100, 100, 50, 50);
|
||||
|
||||
AddShape3D(scene, @box1);
|
||||
AddShape3D(scene, @box2);
|
||||
AddShape3D(scene, @box3);
|
||||
AddShape3D(scene, @box4);
|
||||
|
||||
MoveShape3D(@box2, 100, 0, 0);
|
||||
MoveShape3D(@box3, 0, 100, 0);
|
||||
MoveShape3D(@box4, 0, 0, 100);
|
||||
AddShape3D(scene, @wed1);
|
||||
AddShape3D(scene, @pyr1);
|
||||
|
||||
Redraw;
|
||||
MainLoop;
|
||||
|
@ -23,21 +23,22 @@ program ExampleRotate;
|
||||
point.y := Long2Fix(y);
|
||||
end;
|
||||
|
||||
function Distance2D (a, b: Point2D): Fixed;
|
||||
function DistancePoint2D (a, b: Point2D): Fixed;
|
||||
var
|
||||
val: Fixed;
|
||||
begin
|
||||
val := FracMul((b.x - a.x), (b.x - a.x)) + FracMul((b.y - a.y), (b.y - a.y));
|
||||
Distance2D := Frac2Fix(FracSqrt(val));
|
||||
DistancePoint2D := Frac2Fix(FracSqrt(val));
|
||||
end;
|
||||
|
||||
procedure RotatePoint2D (var target, origin: Point2D; angle: Fixed);
|
||||
var
|
||||
radians, cos, sin, x, y, r, pi: Fixed;
|
||||
begin
|
||||
pi := FixRatio(22, 7);
|
||||
{ pi := FixRatio(355, 113); }
|
||||
pi := 205887;
|
||||
radians := FixMul(angle, FixDiv(pi, 180));
|
||||
r := Distance2D(target, origin);
|
||||
r := DistancePoint2D(target, origin);
|
||||
target.x := origin.x + FixMul(r, FracCos(radians));
|
||||
target.y := origin.y + FixMul(r, FracSin(radians));
|
||||
end;
|
||||
|
@ -19,7 +19,7 @@ interface
|
||||
end;
|
||||
|
||||
Shape3D = record
|
||||
origin: Point3D;
|
||||
origin: Point3D;
|
||||
length, verticesLength, facesLength: Integer;
|
||||
vertices: array[1..9] of Point3D;
|
||||
edges: array[1..13] of Link3D;
|
||||
@ -43,7 +43,7 @@ interface
|
||||
procedure SetFc3D (var fc3D: Face3D; a, b, c: Point3DPtr);
|
||||
procedure SetBox3D (var shape: Shape3D; x, y, z, w, h, d: Fixed);
|
||||
procedure SetWedge3D (var shape: Shape3D; x, y, z, w, h, d, a: Fixed);
|
||||
procedure SetPyramid3D (var shape: Shape3D; x, y, z, w, h, d: Fixed);
|
||||
procedure SetPyramid3D (var shape: Shape3D; x, y, z, w, h, d, ax, az: Fixed);
|
||||
procedure DrawLink3D (link: Link3D);
|
||||
procedure DrawShape3D (shape: Shape3DPtr);
|
||||
procedure DrawScene3D (scene: Scene3D);
|
||||
@ -69,9 +69,9 @@ implementation
|
||||
i: Integer;
|
||||
begin
|
||||
for i := 1 to shape^.verticesLength do
|
||||
begin
|
||||
begin
|
||||
{ DO IT }
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure SetLk3D (var lk3D: Link3D; a, b: Point3DPtr);
|
||||
@ -94,7 +94,7 @@ implementation
|
||||
|
||||
procedure SetBox3D (var shape: Shape3D; x, y, z, w, h, d: Fixed);
|
||||
begin
|
||||
SetPt3D(shape.origin, x,y,z);
|
||||
SetPt3D(shape.origin, x, y, z);
|
||||
SetPt3D(shape.vertices[1], Long2Fix(x + w div 2), Long2Fix(y + h div 2), Long2Fix(z + d div 2));
|
||||
SetPt3D(shape.vertices[2], Long2Fix(x + w div 2), Long2Fix(y + h div 2), Long2Fix(z - d div 2));
|
||||
SetPt3D(shape.vertices[3], Long2Fix(x - w div 2), Long2Fix(y + h div 2), Long2Fix(z - d div 2));
|
||||
@ -124,7 +124,7 @@ implementation
|
||||
|
||||
procedure SetWedge3D (var shape: Shape3D; x, y, z, w, h, d, a: Fixed);
|
||||
begin
|
||||
SetPt3D(shape.origin, x,y,z);
|
||||
SetPt3D(shape.origin, x, y, z);
|
||||
SetPt3D(shape.vertices[1], Long2Fix(x + a), Long2Fix(y + h div 2), Long2Fix(z - d div 2));
|
||||
SetPt3D(shape.vertices[2], Long2Fix(x + a), Long2Fix(y + h div 2), Long2Fix(z + d div 2));
|
||||
SetPt3D(shape.vertices[3], Long2Fix(x + w div 2), Long2Fix(y - h div 2), Long2Fix(z + d div 2));
|
||||
@ -147,10 +147,10 @@ implementation
|
||||
shape.length := 9;
|
||||
end;
|
||||
|
||||
procedure SetPyramid3D (var shape: Shape3D; x, y, z, w, h, d: Fixed);
|
||||
procedure SetPyramid3D (var shape: Shape3D; x, y, z, w, h, d, ax, az: Fixed);
|
||||
begin
|
||||
SetPt3D(shape.origin, x,y,z);
|
||||
SetPt3D(shape.vertices[1], Long2Fix(x), Long2Fix(y + h div 2), Long2Fix(z));
|
||||
SetPt3D(shape.origin, x, y, z);
|
||||
SetPt3D(shape.vertices[1], Long2Fix(x + ax), Long2Fix(y + h div 2), Long2Fix(z + az));
|
||||
SetPt3D(shape.vertices[2], Long2Fix(x + w div 2), Long2Fix(y - h div 2), Long2Fix(z + d div 2));
|
||||
SetPt3D(shape.vertices[3], Long2Fix(x + w div 2), Long2Fix(y - h div 2), Long2Fix(z - d div 2));
|
||||
SetPt3D(shape.vertices[4], Long2Fix(x - w div 2), Long2Fix(y - h div 2), Long2Fix(z - d div 2));
|
||||
|
Loading…
x
Reference in New Issue
Block a user