Migrated tri

This commit is contained in:
neauoire 2020-05-15 19:40:04 +09:00
parent 0ada3dbf9f
commit dba5715ca6
3 changed files with 30 additions and 38 deletions

View File

@ -20,22 +20,14 @@ interface
implementation
procedure AddTri3D (var shape: Shape3D; x, y, z, w, h: Fixed);
var
voff, eoff, foff: Integer; { vertices offset}
begin
voff := shape.verticesLength;
foff := shape.facesLength;
eoff := shape.edgesLength;
SetPt3D(shape.vertices[voff + 1], Long2Fix(x), Long2Fix(y + h div 2), Long2Fix(z));
SetPt3D(shape.vertices[voff + 2], Long2Fix(x + w div 2), Long2Fix(y - h div 2), Long2Fix(z));
SetPt3D(shape.vertices[voff + 3], Long2Fix(x - w div 2), Long2Fix(y - h div 2), Long2Fix(z));
SetLk3D(shape.edges[eoff + 1], @shape.vertices[voff + 1], @shape.vertices[voff + 2]);
SetLk3D(shape.edges[eoff + 2], @shape.vertices[voff + 2], @shape.vertices[voff + 3]);
SetLk3D(shape.edges[eoff + 3], @shape.vertices[voff + 3], @shape.vertices[voff + 1]);
SetFc3D(shape.faces[foff + 1], @shape.vertices[voff + 1], @shape.vertices[voff + 2], @shape.vertices[voff + 3]);
shape.verticesLength := voff + 3;
shape.facesLength := foff + 1;
shape.edgesLength := eoff + 3;
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);
AddEdge3D(shape, shape.verticesLength, shape.verticesLength - 1);
AddEdge3D(shape, shape.verticesLength - 1, shape.verticesLength - 2);
AddEdge3D(shape, shape.verticesLength - 2, shape.verticesLength);
AddFace3D(shape, shape.verticesLength - 2, shape.verticesLength - 1, shape.verticesLength);
end;
procedure AddRect3D (var shape: Shape3D; x, y, z, w, h: Fixed);
@ -111,7 +103,7 @@ implementation
AddRect3D(shape, x, y, z + d div 2, w, h);
AddRect3D(shape, x, y, z - d div 2, w, h);
for i := 1 to 4 do
AddLink3D(shape, i, i + 4);
AddEdge3D(shape, i, i + 4);
end;
procedure SetWedge3D (var shape: Shape3D; x, y, z, w, h, d: Fixed);
@ -122,7 +114,7 @@ implementation
AddTri3D(shape, x, y, z + d div 2, w, h);
AddTri3D(shape, x, y, z - d div 2, w, h);
for i := 1 to 3 do
AddLink3D(shape, i, i + 3);
AddEdge3D(shape, i, i + 3);
end;
procedure SetCyl3D (var shape: Shape3D; x, y, z, w, h, d, r: Fixed);
@ -133,7 +125,7 @@ implementation
AddCircle3D(shape, x, y, z + d div 2, r);
AddCircle3D(shape, x, y, z - d div 2, r);
for i := 1 to 12 do
AddLink3D(shape, i, i + 12);
AddEdge3D(shape, i, i + 12);
end;
end.

View File

@ -70,7 +70,7 @@ interface
procedure DrawScene3D (scene: Scene3D);
{ basics }
procedure AddVertice3D (var shape: Shape3D; x, y, z: Fixed);
procedure AddLink3D (var shape: Shape3D; a, b: Integer);
procedure AddEdge3D (var shape: Shape3D; a, b: Integer);
procedure AddFace3D (var shape: Shape3D; a, b, c: Integer);
implementation
@ -158,7 +158,7 @@ implementation
SetPt3D(shape.vertices[shape.verticesLength], Long2Fix(x), Long2Fix(y), Long2Fix(z));
end;
procedure AddLink3D (var shape: Shape3D; a, b: Integer);
procedure AddEdge3D (var shape: Shape3D; a, b: Integer);
begin
if shape.EdgesLength > LIMIT_EDGES - 1 then
SceneError('Edges limit reached');

View File

@ -20,24 +20,24 @@ implementation
AddRect3D(shape, x, y - h + FixMul(hq div 2, 7), z + d - FixMul(hq, 3), w, h div 4);
AddRect3D(shape, x, y - h + FixMul(hq div 2, 9), z + d - FixMul(hq, 4), w, h div 4);
AddRect3D(shape, x, y - h + FixMul(hq div 2, 11), z + d - FixMul(hq, 5), w, h div 4);
AddLink3D(shape, 4, 7);
AddLink3D(shape, 1, 6);
AddLink3D(shape, 8, 11);
AddLink3D(shape, 5, 10);
AddLink3D(shape, 12, 15);
AddLink3D(shape, 9, 14);
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);
AddLink3D(shape, 16, 17);
AddLink3D(shape, 13, 18);
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);
AddLink3D(shape, 17, 19);
AddLink3D(shape, 18, 20);
AddLink3D(shape, 19, 3);
AddLink3D(shape, 20, 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);
@ -48,11 +48,11 @@ implementation
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);
AddLink3D(shape, 1, 2);
AddLink3D(shape, 2, 3);
AddLink3D(shape, 3, 4);
AddLink3D(shape, 4, 5);
AddLink3D(shape, 1, 5);
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);
@ -90,7 +90,7 @@ implementation
rz := FracMul(Fix2Frac(Random), z);
AddVertice3D(shape, x + rx, y + ry, z + rz);
AddVertice3D(shape, x + rx, y + ry + 2, z + rz);
AddLink3D(shape, i * 2 - 1, i * 2);
AddEdge3D(shape, i * 2 - 1, i * 2);
end;
end;