Cleaned up primitives

This commit is contained in:
neauoire
2020-05-15 19:54:21 +09:00
parent d08f838eec
commit 96a0102d6f

View File

@@ -4,22 +4,22 @@ interface
uses uses
FixMath, Graf3D, Graf3DScene; FixMath, Graf3D, Graf3DScene;
{2d}
procedure SetTri3D (var shape: Shape3D; x, y, z, w, h: Fixed);
procedure SetRec3D (var shape: Shape3D; x, y, z, w, d: Fixed);
procedure SetCir3D (var shape: Shape3D; x, y, z, r: Fixed);
{3d}
procedure SetWed3D (var shape: Shape3D; x, y, z, w, h, d: Fixed);
procedure SetBox3D (var shape: Shape3D; x, y, z, w, h, d: Fixed);
procedure SetCyl3D (var shape: Shape3D; x, y, z, w, h, d, r: Fixed);
{parts} {parts}
procedure AddTri3D (var shape: Shape3D; x, y, z, w, h: Longint); procedure AddTri3D (var shape: Shape3D; x, y, z, w, h: Longint);
procedure AddRec3D (var shape: Shape3D; x, y, z, w, h: Longint); procedure AddRec3D (var shape: Shape3D; x, y, z, w, h: Longint);
procedure AddCir3D (var shape: Shape3D; x, y, z, d: Longint); procedure AddCir3D (var shape: Shape3D; x, y, z, d: Longint);
{2d}
procedure SetTri3D (var shape: Shape3D; x, y, z, w, h: Longint);
procedure SetRec3D (var shape: Shape3D; x, y, z, w, d: Longint);
procedure SetCir3D (var shape: Shape3D; x, y, z, r: Longint);
{3d}
procedure SetWed3D (var shape: Shape3D; x, y, z, w, h, d: Longint);
procedure SetBox3D (var shape: Shape3D; x, y, z, w, h, d: Longint);
procedure SetCyl3D (var shape: Shape3D; x, y, z, w, h, d, r: Longint);
implementation implementation
procedure AddTri3D (var shape: Shape3D; x, y, z, w, h: Fixed); procedure AddTri3D (var shape: Shape3D; x, y, z, w, h: Longint);
begin begin
AddVertice3D(shape, x, y + h div 2, z); AddVertice3D(shape, x, y + h div 2, z);
AddVertice3D(shape, x + w div 2, y - h div 2, z); AddVertice3D(shape, x + w div 2, y - h div 2, z);
@@ -30,7 +30,7 @@ implementation
AddFace3D(shape, shape.verticesLength - 2, shape.verticesLength - 1, shape.verticesLength); AddFace3D(shape, shape.verticesLength - 2, shape.verticesLength - 1, shape.verticesLength);
end; end;
procedure AddRec3D (var shape: Shape3D; x, y, z, w, h: Fixed); procedure AddRec3D (var shape: Shape3D; x, y, z, w, h: Longint);
begin begin
AddVertice3D(shape, x + w div 2, y + h div 2, z); AddVertice3D(shape, x + w div 2, y + h div 2, z);
AddVertice3D(shape, x + w div 2, y - h div 2, z); AddVertice3D(shape, x + w div 2, y - h div 2, z);
@@ -44,7 +44,7 @@ implementation
AddFace3D(shape, shape.verticesLength - 3, shape.verticesLength - 2, shape.verticesLength); AddFace3D(shape, shape.verticesLength - 3, shape.verticesLength - 2, shape.verticesLength);
end; end;
procedure AddCir3D (var shape: Shape3D; x, y, z, d: Fixed); procedure AddCir3D (var shape: Shape3D; x, y, z, d: Longint);
var var
voff, eoff, foff: Integer; { vertices offset} voff, eoff, foff: Integer; { vertices offset}
i, segs: Integer; i, segs: Integer;
@@ -72,33 +72,22 @@ implementation
end; end;
{publics} {publics}
procedure SetTri3D (var shape: Shape3D; x, y, z, w, h: Fixed); procedure SetTri3D (var shape: Shape3D; x, y, z, w, h: Longint);
begin begin
AddTri3D(shape, x, y, z, w, h); AddTri3D(shape, x, y, z, w, h);
end; end;
procedure SetRec3D (var shape: Shape3D; x, y, z, w, d: Fixed); procedure SetRec3D (var shape: Shape3D; x, y, z, w, d: Longint);
begin begin
AddRec3D(shape, x, y, z, w, d); AddRec3D(shape, x, y, z, w, d);
end; end;
procedure SetCir3D (var shape: Shape3D; x, y, z, r: Fixed); procedure SetCir3D (var shape: Shape3D; x, y, z, r: Longint);
begin begin
AddCir3D(shape, x, y, z, r); AddCir3D(shape, x, y, z, r);
end; end;
procedure SetBox3D (var shape: Shape3D; x, y, z, w, h, d: Fixed); procedure SetWed3D (var shape: Shape3D; x, y, z, w, h, d: Longint);
var
i: Integer;
begin
SetPt3D(shape.origin, Long2Fix(x), Long2Fix(y), Long2Fix(z));
AddRec3D(shape, x, y, z + d div 2, w, h);
AddRec3D(shape, x, y, z - d div 2, w, h);
for i := 1 to 4 do
AddEdge3D(shape, i, i + 4);
end;
procedure SetWed3D (var shape: Shape3D; x, y, z, w, h, d: Fixed);
var var
i: Integer; i: Integer;
begin begin
@@ -109,7 +98,18 @@ implementation
AddEdge3D(shape, i, i + 3); AddEdge3D(shape, i, i + 3);
end; end;
procedure SetCyl3D (var shape: Shape3D; x, y, z, w, h, d, r: Fixed); procedure SetBox3D (var shape: Shape3D; x, y, z, w, h, d: Longint);
var
i: Integer;
begin
SetPt3D(shape.origin, Long2Fix(x), Long2Fix(y), Long2Fix(z));
AddRec3D(shape, x, y, z + d div 2, w, h);
AddRec3D(shape, x, y, z - d div 2, w, h);
for i := 1 to 4 do
AddEdge3D(shape, i, i + 4);
end;
procedure SetCyl3D (var shape: Shape3D; x, y, z, w, h, d, r: Longint);
var var
i: Integer; i: Integer;
begin begin