mirror of
https://git.sr.ht/~rabbits/macintosh_cookbook
synced 2025-01-18 01:29:42 +00:00
106 lines
3.3 KiB
ObjectPascal
106 lines
3.3 KiB
ObjectPascal
unit Graf3DStructures;
|
|
interface
|
|
|
|
uses
|
|
FixMath, Graf3D, Graf3DScene, Graf3DPrimitives;
|
|
|
|
procedure SetStairs3D (var shape: Shape3D; x, y, z, w, h, d: Fixed);
|
|
procedure SetDoorway3D (var shape: Shape3D; x, y, z, w, h, d: Fixed);
|
|
procedure SetDoorwayWall3D (var shape: Shape3D; x, y, z, w, h, d: Fixed);
|
|
procedure SetLedge3D (var shape: Shape3D; x, y, z, w, h, d: Fixed);
|
|
procedure SetParticles3D (var shape: Shape3D; x, y, z, w, h, d: Fixed);
|
|
|
|
implementation
|
|
|
|
procedure SetStairs3D (var shape: Shape3D; x, y, z, w, h, d: Fixed);
|
|
var
|
|
hq: Longint;
|
|
begin
|
|
hq := h div 4;
|
|
AddRec3D(shape, x, y - h + hq div 2 * 5, z + d - hq * 2, w, h div 4);
|
|
AddRec3D(shape, x, y - h + hq div 2 * 7, z + d - hq * 3, w, h div 4);
|
|
AddRec3D(shape, x, y - h + hq div 2 * 9, z + d - hq * 4, w, h div 4);
|
|
AddRec3D(shape, x, y - h + hq div 2 * 11, z + d - hq * 5, w, h div 4);
|
|
AddEdge3D(shape, 4, 7);
|
|
AddEdge3D(shape, 1, 6);
|
|
AddEdge3D(shape, 8, 11);
|
|
AddEdge3D(shape, 5, 10);
|
|
AddEdge3D(shape, 12, 15);
|
|
AddEdge3D(shape, 9, 14);
|
|
{last step}
|
|
AddVertice3D(shape, x - w div 2, y + h div 2, z - d div 2);
|
|
AddVertice3D(shape, x + w div 2, y + h div 2, z - d div 2);
|
|
AddEdge3D(shape, 16, 17);
|
|
AddEdge3D(shape, 13, 18);
|
|
{sides}
|
|
AddVertice3D(shape, x - w div 2, y - h div 2, z - d div 2);
|
|
AddVertice3D(shape, x + w div 2, y - h div 2, z - d div 2);
|
|
AddEdge3D(shape, 17, 19);
|
|
AddEdge3D(shape, 18, 20);
|
|
AddEdge3D(shape, 19, 3);
|
|
AddEdge3D(shape, 20, 2);
|
|
end;
|
|
|
|
procedure SetDoorway3D (var shape: Shape3D; x, y, z, w, h, d: Fixed);
|
|
begin
|
|
{ frame }
|
|
AddVertice3D(shape, x - w div 2, y - h div 2, z);
|
|
AddVertice3D(shape, x - w div 2, y + h div 4, z);
|
|
AddVertice3D(shape, x, y + h div 2, z);
|
|
AddVertice3D(shape, x + w div 2, y + h div 4, z);
|
|
AddVertice3D(shape, x + w div 2, y - h div 2, z);
|
|
AddEdge3D(shape, 1, 2);
|
|
AddEdge3D(shape, 2, 3);
|
|
AddEdge3D(shape, 3, 4);
|
|
AddEdge3D(shape, 4, 5);
|
|
AddEdge3D(shape, 1, 5);
|
|
end;
|
|
|
|
procedure SetDoorwayWall3D (var shape: Shape3D; x, y, z, w, h, d: Fixed);
|
|
begin
|
|
{ frame }
|
|
AddVertice3D(shape, x - w div 2, y - h, z);
|
|
AddVertice3D(shape, x - w div 2, y + h div 4, z);
|
|
AddVertice3D(shape, x, y + h div 2, z);
|
|
AddVertice3D(shape, x + w div 2, y + h div 4, z);
|
|
AddVertice3D(shape, x + w div 2, y - h, z);
|
|
AddVertice3D(shape, x + w * 2, y - h div 2, z);{6}
|
|
AddVertice3D(shape, x + w * 2, y + h, z);{7}
|
|
AddVertice3D(shape, x - w * 2, y + h, z);{8}
|
|
AddVertice3D(shape, x - w * 2, y - h div 2, z);{9}
|
|
AddFace3D(shape, 4, 5, 6);
|
|
AddFace3D(shape, 4, 6, 7);
|
|
AddFace3D(shape, 3, 4, 7);
|
|
AddFace3D(shape, 3, 7, 8);
|
|
AddFace3D(shape, 2, 3, 8);
|
|
AddFace3D(shape, 2, 8, 9);
|
|
AddFace3D(shape, 1, 2, 9);
|
|
end;
|
|
|
|
procedure SetLedge3D (var shape: Shape3D; x, y, z, w, h, d: Longint);
|
|
begin
|
|
AddRec3D(shape, x, y, z, w, h div 4 * 4);
|
|
AddRec3D(shape, x, y - 120, z + 20, w, h div 4 * 3);
|
|
AddEdge3D(shape, 2, 5);
|
|
AddEdge3D(shape, 3, 8);
|
|
AddFace3D(shape, 2, 3, 5);
|
|
AddFace3D(shape, 3, 5, 8);
|
|
end;
|
|
|
|
procedure SetParticles3D (var shape: Shape3D; x, y, z, w, h, d: Fixed);
|
|
var
|
|
i: Integer;
|
|
rx, ry, rz: Fixed;
|
|
begin
|
|
for i := 1 to 16 do
|
|
begin
|
|
rx := FracMul(Fix2Frac(Random), w);
|
|
ry := FracMul(Fix2Frac(Random), h);
|
|
rz := FracMul(Fix2Frac(Random), z);
|
|
AddVertice3D(shape, x + rx, y + ry, z + rz);
|
|
AddVertice3D(shape, x + rx, y + ry + 10, z + rz);
|
|
AddEdge3D(shape, i * 2 - 1, i * 2);
|
|
end;
|
|
end;
|
|
|
|
end. |