mirror of
https://git.sr.ht/~rabbits/macintosh_cookbook
synced 2024-06-14 05:29:34 +00:00
Added faces
This commit is contained in:
parent
9b725cd77b
commit
e60833f1ad
|
@ -46,9 +46,7 @@ program ExampleScene;
|
|||
Identity;
|
||||
Yaw(Long2Fix(hangle));
|
||||
Pitch(Long2Fix(vangle)); { roll and pitch the plane }
|
||||
|
||||
DrawScene3D(scene);
|
||||
|
||||
end;
|
||||
|
||||
{>>}
|
||||
|
@ -105,8 +103,8 @@ begin
|
|||
SetScene3D(scene);
|
||||
SetBox3D(box1, -300, 0, 0, 100, 100, 100);
|
||||
SetPyramid3D(pyr1, -150, 0, 0, 100, 100, 100);
|
||||
SetWedge3D(wed1, 150, 0, 0, 100, 100, 100, 0);
|
||||
SetWedge3D(wed2, 0, 0, 0, 100, 100, 100, 50);
|
||||
SetWedge3D(wed1, 0, 0, 0, 100, 100, 100, 0);
|
||||
SetWedge3D(wed2, 150, 0, 0, 100, 100, 100, 50);
|
||||
|
||||
AddShape3D(scene, @box1);
|
||||
AddShape3D(scene, @pyr1);
|
||||
|
|
|
@ -10,10 +10,17 @@ interface
|
|||
b: Point3D;
|
||||
end;
|
||||
|
||||
Face3D = record
|
||||
a: Point3D;
|
||||
b: Point3D;
|
||||
c: Point3D;
|
||||
end;
|
||||
|
||||
Shape3D = record
|
||||
length: Integer;
|
||||
length, facesLength: Integer;
|
||||
vertices: array[1..9] of Point3D;
|
||||
edges: array[1..13] of Link3D;
|
||||
faces: array[1..6] of Face3D;
|
||||
end;
|
||||
|
||||
Shape3DPtr = ^Shape3D;
|
||||
|
@ -28,6 +35,7 @@ interface
|
|||
procedure AddShape3D (var scene: scene3D; shape: Shape3DPtr);
|
||||
procedure SetScene3D (var scene: Scene3D);
|
||||
procedure SetLk3D (var lk3D: Link3D; a, b: Point3D);
|
||||
procedure SetFc3D (var fc3D: Face3D; a, b, c: Point3D);
|
||||
procedure SetBox3D (var shape: Shape3D; x, y, z, w, h, d: Fixed);
|
||||
procedure SetPyramid3D (var shape: Shape3D; x, y, z, w, h, d: Fixed);
|
||||
procedure SetWedge3D (var shape: Shape3D; x, y, z, w, h, d, a: Fixed);
|
||||
|
@ -49,6 +57,13 @@ implementation
|
|||
lk3D.b := b;
|
||||
end;
|
||||
|
||||
procedure SetFc3D (var fc3D: Face3D; a, b, c: Point3D);
|
||||
begin
|
||||
fc3D.a := a;
|
||||
fc3D.b := b;
|
||||
fc3D.c := c;
|
||||
end;
|
||||
|
||||
procedure SetScene3D (var scene: Scene3D);
|
||||
begin
|
||||
scene.length := 0;
|
||||
|
@ -76,6 +91,9 @@ implementation
|
|||
SetLk3D(shape.edges[10], shape.vertices[2], shape.vertices[6]);
|
||||
SetLk3D(shape.edges[11], shape.vertices[3], shape.vertices[7]);
|
||||
SetLk3D(shape.edges[12], shape.vertices[4], shape.vertices[8]);
|
||||
SetFc3D(shape.faces[1], shape.vertices[1], shape.vertices[2], shape.vertices[5]);
|
||||
SetFc3D(shape.faces[2], shape.vertices[2], shape.vertices[5], shape.vertices[6]);
|
||||
shape.facesLength := 2;
|
||||
shape.length := 12;
|
||||
end;
|
||||
|
||||
|
@ -96,6 +114,9 @@ implementation
|
|||
SetLk3D(shape.edges[7], shape.vertices[4], shape.vertices[5]);
|
||||
SetLk3D(shape.edges[8], shape.vertices[5], shape.vertices[6]);
|
||||
SetLk3D(shape.edges[9], shape.vertices[6], shape.vertices[3]);
|
||||
SetFc3D(shape.faces[1], shape.vertices[1], shape.vertices[2], shape.vertices[3]);
|
||||
SetFc3D(shape.faces[2], shape.vertices[1], shape.vertices[3], shape.vertices[4]);
|
||||
shape.facesLength := 2;
|
||||
shape.length := 9;
|
||||
end;
|
||||
|
||||
|
@ -114,6 +135,8 @@ implementation
|
|||
SetLk3D(shape.edges[6], shape.vertices[3], shape.vertices[4]);
|
||||
SetLk3D(shape.edges[7], shape.vertices[4], shape.vertices[5]);
|
||||
SetLk3D(shape.edges[8], shape.vertices[5], shape.vertices[2]);
|
||||
SetFc3D(shape.faces[1], shape.vertices[1], shape.vertices[2], shape.vertices[3]);
|
||||
shape.facesLength := 1;
|
||||
shape.length := 8;
|
||||
end;
|
||||
|
||||
|
@ -136,10 +159,27 @@ implementation
|
|||
LineTo3D(link.b.x, link.b.y, link.b.z);
|
||||
end;
|
||||
|
||||
procedure DrawFace3D (face: Face3D);
|
||||
var
|
||||
tempRgn: RgnHandle;
|
||||
begin
|
||||
tempRgn := NewRgn;
|
||||
OpenRgn;
|
||||
MoveTo3D(face.a.X, face.a.Y, face.a.Z);
|
||||
LineTo3D(face.b.X, face.b.Y, face.b.Z);
|
||||
LineTo3D(face.c.X, face.c.Y, face.c.Z);
|
||||
LineTo3D(face.a.X, face.a.Y, face.a.Z);
|
||||
CloseRgn(tempRgn);
|
||||
FillRgn(tempRgn, ltgray);
|
||||
DisposeRgn(tempRgn);
|
||||
end;
|
||||
|
||||
procedure DrawShape3D (shape: Shape3DPtr);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i := 1 to shape^.facesLength do
|
||||
DrawFace3D(shape^.faces[i]);
|
||||
for i := 1 to shape^.length do
|
||||
DrawLink3D(shape^.edges[i]);
|
||||
end;
|
||||
|
@ -150,7 +190,7 @@ implementation
|
|||
begin
|
||||
for i := 1 to scene.length do
|
||||
DrawShape3D(scene.shapes[i]);
|
||||
DrawWidget(50);
|
||||
{ DrawWidget(50); }
|
||||
end;
|
||||
|
||||
end.
|
Loading…
Reference in New Issue
Block a user