mirror of
https://git.sr.ht/~rabbits/macintosh_cookbook
synced 2025-01-06 14:31:09 +00:00
Migrated cir
This commit is contained in:
parent
96a0102d6f
commit
75d3045f31
@ -4,6 +4,9 @@ interface
|
|||||||
uses
|
uses
|
||||||
FixMath, Graf3D, Graf3DScene;
|
FixMath, Graf3D, Graf3DScene;
|
||||||
|
|
||||||
|
const
|
||||||
|
CIR_VERTICES = 12;
|
||||||
|
|
||||||
{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);
|
||||||
@ -36,7 +39,7 @@ implementation
|
|||||||
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);
|
||||||
AddVertice3D(shape, x - w div 2, y + h div 2, z);
|
AddVertice3D(shape, x - w div 2, y + h div 2, z);
|
||||||
AddEdge3D(shape, shape.verticesLength , shape.verticesLength - 1);
|
AddEdge3D(shape, shape.verticesLength, shape.verticesLength - 1);
|
||||||
AddEdge3D(shape, shape.verticesLength - 1, shape.verticesLength - 2);
|
AddEdge3D(shape, shape.verticesLength - 1, shape.verticesLength - 2);
|
||||||
AddEdge3D(shape, shape.verticesLength - 2, shape.verticesLength - 3);
|
AddEdge3D(shape, shape.verticesLength - 2, shape.verticesLength - 3);
|
||||||
AddEdge3D(shape, shape.verticesLength - 3, shape.verticesLength);
|
AddEdge3D(shape, shape.verticesLength - 3, shape.verticesLength);
|
||||||
@ -46,29 +49,20 @@ implementation
|
|||||||
|
|
||||||
procedure AddCir3D (var shape: Shape3D; x, y, z, d: Longint);
|
procedure AddCir3D (var shape: Shape3D; x, y, z, d: Longint);
|
||||||
var
|
var
|
||||||
voff, eoff, foff: Integer; { vertices offset}
|
i: Integer;
|
||||||
i, segs: Integer;
|
|
||||||
offx, offy: Fixed;
|
|
||||||
radians, arc: Fixed;
|
radians, arc: Fixed;
|
||||||
begin
|
begin
|
||||||
voff := shape.verticesLength;
|
arc := FracDiv(360, Long2Fix(CIR_VERTICES));
|
||||||
foff := shape.facesLength;
|
for i := 1 to CIR_VERTICES do
|
||||||
eoff := shape.edgesLength;
|
|
||||||
segs := 12;
|
|
||||||
arc := FracDiv(360, Long2Fix(segs));
|
|
||||||
for i := 1 to segs do
|
|
||||||
begin
|
begin
|
||||||
radians := FracMul(FixMul(arc, Long2Fix(i)), FixDiv(205887, 180));
|
radians := FracMul(FixMul(arc, Long2Fix(i)), FixDiv(205887, 180));
|
||||||
offx := FracMul(Long2Fix(d div 2), FracCos(radians));
|
AddVertice3D(shape, Fix2Long(Long2Fix(x) + FracMul(Long2Fix(d div 2), FracCos(radians))), Fix2Long(Long2Fix(y) + FracMul(Long2Fix(d div 2), FracSin(radians))), z);
|
||||||
offy := FracMul(Long2Fix(d div 2), FracSin(radians));
|
|
||||||
SetPt3D(shape.vertices[voff + i], round(Long2Fix(x) + offx), round(Long2Fix(y) + offy), round(Long2Fix(z)));
|
|
||||||
if i <> segs then
|
|
||||||
SetLk3D(shape.edges[eoff + i], @shape.vertices[voff + i], @shape.vertices[voff + i + 1]);
|
|
||||||
end;
|
end;
|
||||||
SetLk3D(shape.edges[eoff + segs], @shape.vertices[voff + segs], @shape.vertices[voff + 1]);
|
for i := 1 to CIR_VERTICES - 1 do
|
||||||
shape.verticesLength := voff + segs;
|
begin
|
||||||
shape.facesLength := foff + 0;
|
AddEdge3D(shape, shape.verticesLength - CIR_VERTICES + i, shape.verticesLength - CIR_VERTICES + i + 1);
|
||||||
shape.edgesLength := eoff + segs;
|
end;
|
||||||
|
AddEdge3D(shape, shape.verticesLength - CIR_VERTICES + 1, shape.verticesLength);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{publics}
|
{publics}
|
||||||
@ -116,8 +110,8 @@ implementation
|
|||||||
SetPt3D(shape.origin, Long2Fix(x), Long2Fix(y), Long2Fix(z));
|
SetPt3D(shape.origin, Long2Fix(x), Long2Fix(y), Long2Fix(z));
|
||||||
AddCir3D(shape, x, y, z + d div 2, r);
|
AddCir3D(shape, x, y, z + d div 2, r);
|
||||||
AddCir3D(shape, x, y, z - d div 2, r);
|
AddCir3D(shape, x, y, z - d div 2, r);
|
||||||
for i := 1 to 12 do
|
for i := 1 to CIR_VERTICES do
|
||||||
AddEdge3D(shape, i, i + 12);
|
AddEdge3D(shape, i, i + CIR_VERTICES);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
Loading…
Reference in New Issue
Block a user