Migrated rect

This commit is contained in:
neauoire 2020-05-15 19:45:23 +09:00
parent dba5715ca6
commit b77592d180

View File

@ -13,9 +13,9 @@ interface
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}
procedure AddTri3D (var shape: Shape3D; x, y, z, w, h: Fixed);
procedure AddRect3D (var shape: Shape3D; x, y, z, w, h: Fixed);
procedure AddCircle3D (var shape: Shape3D; x, y, z, d: Fixed);
procedure AddTri3D (var shape: Shape3D; x, y, z, w, h: Longint);
procedure AddRect3D (var shape: Shape3D; x, y, z, w, h: Longint);
procedure AddCircle3D (var shape: Shape3D; x, y, z, d: Longint);
implementation
@ -31,25 +31,17 @@ implementation
end;
procedure AddRect3D (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 + w div 2), 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));
SetPt3D(shape.vertices[voff + 4], 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 + 4]);
SetLk3D(shape.edges[eoff + 4], @shape.vertices[voff + 4], @shape.vertices[voff + 1]);
SetFc3D(shape.faces[foff + 1], @shape.vertices[voff + 1], @shape.vertices[voff + 2], @shape.vertices[voff + 3]);
SetFc3D(shape.faces[foff + 2], @shape.vertices[voff + 3], @shape.vertices[voff + 4], @shape.vertices[voff + 1]);
shape.verticesLength := voff + 4;
shape.facesLength := foff + 2;
shape.edgesLength := eoff + 4;
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 - 1, shape.verticesLength - 2);
AddEdge3D(shape, shape.verticesLength - 2, shape.verticesLength - 3);
AddEdge3D(shape, shape.verticesLength - 3, shape.verticesLength);
AddFace3D(shape, shape.verticesLength - 2, shape.verticesLength - 1, shape.verticesLength);
AddFace3D(shape, shape.verticesLength - 3, shape.verticesLength - 2, shape.verticesLength);
end;
procedure AddCircle3D (var shape: Shape3D; x, y, z, d: Fixed);