mirror of
https://git.sr.ht/~rabbits/macintosh_cookbook
synced 2025-01-21 20:33:19 +00:00
Added warnings
This commit is contained in:
parent
31ee0eddd4
commit
a8ac67d685
@ -14,35 +14,12 @@ interface
|
|||||||
procedure SetCyl3D (var shape: Shape3D; x, y, z, w, h, d, r: Fixed);
|
procedure SetCyl3D (var shape: Shape3D; x, y, z, w, h, d, r: Fixed);
|
||||||
procedure SetPyramid3D (var shape: Shape3D; x, y, z, w, h, d, ax, az: Fixed);
|
procedure SetPyramid3D (var shape: Shape3D; x, y, z, w, h, d, ax, az: Fixed);
|
||||||
{parts}
|
{parts}
|
||||||
procedure AddVertice3D (var shape: Shape3D; x, y, z: Fixed);
|
|
||||||
procedure AddLink3D (var shape: Shape3D; a, b: Integer);
|
|
||||||
procedure AddFace3D (var shape: Shape3D; a, b, c: Integer);
|
|
||||||
procedure AddTri3D (var shape: Shape3D; x, y, z, w, h: Fixed);
|
procedure AddTri3D (var shape: Shape3D; x, y, z, w, h: Fixed);
|
||||||
procedure AddRect3D (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, r: Fixed);
|
procedure AddCircle3D (var shape: Shape3D; x, y, z, r: Fixed);
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
procedure AddVertice3D (var shape: Shape3D; x, y, z: Fixed);
|
|
||||||
var
|
|
||||||
voff: Integer; { vertices offset}
|
|
||||||
begin
|
|
||||||
shape.verticesLength := shape.verticesLength + 1;
|
|
||||||
SetPt3D(shape.vertices[shape.verticesLength], Long2Fix(x), Long2Fix(y), Long2Fix(z));
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure AddLink3D (var shape: Shape3D; a, b: Integer);
|
|
||||||
begin
|
|
||||||
shape.length := shape.length + 1;
|
|
||||||
SetLk3D(shape.edges[shape.length], @shape.vertices[a], @shape.vertices[b]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure AddFace3D (var shape: Shape3D; a, b, c: Integer);
|
|
||||||
begin
|
|
||||||
shape.facesLength := shape.facesLength + 1;
|
|
||||||
SetFc3D(shape.faces[shape.facesLength], @shape.vertices[a], @shape.vertices[b], @shape.vertices[c]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure AddTri3D (var shape: Shape3D; x, y, z, w, h: Fixed);
|
procedure AddTri3D (var shape: Shape3D; x, y, z, w, h: Fixed);
|
||||||
var
|
var
|
||||||
voff, eoff, foff: Integer; { vertices offset}
|
voff, eoff, foff: Integer; { vertices offset}
|
||||||
|
@ -4,6 +4,11 @@ interface
|
|||||||
uses
|
uses
|
||||||
FixMath, Graf3D;
|
FixMath, Graf3D;
|
||||||
|
|
||||||
|
const
|
||||||
|
LIMIT_VERTICES = 32;
|
||||||
|
LIMIT_EDGES = 32;
|
||||||
|
LIMIT_FACES = 8;
|
||||||
|
|
||||||
type
|
type
|
||||||
Point3DPtr = ^Point3D;
|
Point3DPtr = ^Point3D;
|
||||||
|
|
||||||
@ -21,16 +26,16 @@ interface
|
|||||||
Shape3D = record
|
Shape3D = record
|
||||||
origin: Point3D;
|
origin: Point3D;
|
||||||
length, verticesLength, facesLength: Integer;
|
length, verticesLength, facesLength: Integer;
|
||||||
vertices: array[1..64] of Point3D;
|
vertices: array[1..LIMIT_VERTICES] of Point3D;
|
||||||
edges: array[1..64] of Link3D;
|
edges: array[1..LIMIT_EDGES] of Link3D;
|
||||||
faces: array[1..16] of Face3D;
|
faces: array[1..LIMIT_FACES] of Face3D;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Shape3DPtr = ^Shape3D;
|
Shape3DPtr = ^Shape3D;
|
||||||
|
|
||||||
Scene3D = record
|
Scene3D = record
|
||||||
length: Integer;
|
length: Integer;
|
||||||
shapes: array[1..10] of Shape3DPtr;
|
shapes: array[1..20] of Shape3DPtr;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Scene3DPtr = ^Scene3D;
|
Scene3DPtr = ^Scene3D;
|
||||||
@ -63,9 +68,20 @@ interface
|
|||||||
procedure DrawLink3D (link: Link3D);
|
procedure DrawLink3D (link: Link3D);
|
||||||
procedure DrawShape3D (shape: Shape3DPtr);
|
procedure DrawShape3D (shape: Shape3DPtr);
|
||||||
procedure DrawScene3D (scene: Scene3D);
|
procedure DrawScene3D (scene: Scene3D);
|
||||||
|
{ basics }
|
||||||
|
procedure AddVertice3D (var shape: Shape3D; x, y, z: Fixed);
|
||||||
|
procedure AddLink3D (var shape: Shape3D; a, b: Integer);
|
||||||
|
procedure AddFace3D (var shape: Shape3D; a, b, c: Integer);
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
procedure SceneError (text: string);
|
||||||
|
begin
|
||||||
|
ShowText;
|
||||||
|
Writeln(text);
|
||||||
|
Halt;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure AddShape3D (var scene: scene3D; shape: Shape3DPtr);
|
procedure AddShape3D (var scene: scene3D; shape: Shape3DPtr);
|
||||||
begin
|
begin
|
||||||
scene.length := scene.length + 1;
|
scene.length := scene.length + 1;
|
||||||
@ -134,6 +150,32 @@ implementation
|
|||||||
scene.length := 0;
|
scene.length := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure AddVertice3D (var shape: Shape3D; x, y, z: Fixed);
|
||||||
|
var
|
||||||
|
voff: Integer; { vertices offset}
|
||||||
|
begin
|
||||||
|
if shape.verticesLength > LIMIT_VERTICES - 1 then
|
||||||
|
SceneError('Verticles limit reached');
|
||||||
|
shape.verticesLength := shape.verticesLength + 1;
|
||||||
|
SetPt3D(shape.vertices[shape.verticesLength], Long2Fix(x), Long2Fix(y), Long2Fix(z));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure AddLink3D (var shape: Shape3D; a, b: Integer);
|
||||||
|
begin
|
||||||
|
if shape.length > LIMIT_EDGES - 1 then
|
||||||
|
SceneError('Edges limit reached');
|
||||||
|
shape.length := shape.length + 1;
|
||||||
|
SetLk3D(shape.edges[shape.length], @shape.vertices[a], @shape.vertices[b]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure AddFace3D (var shape: Shape3D; a, b, c: Integer);
|
||||||
|
begin
|
||||||
|
if shape.facesLength > LIMIT_FACES - 1 then
|
||||||
|
SceneError('Edges limit reached');
|
||||||
|
shape.facesLength := shape.facesLength + 1;
|
||||||
|
SetFc3D(shape.faces[shape.facesLength], @shape.vertices[a], @shape.vertices[b], @shape.vertices[c]);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure DrawLink3D (link: Link3D);
|
procedure DrawLink3D (link: Link3D);
|
||||||
begin
|
begin
|
||||||
MoveTo3D(link.a^.x, link.a^.y, link.a^.z);
|
MoveTo3D(link.a^.x, link.a^.y, link.a^.z);
|
||||||
|
@ -4,13 +4,9 @@ program ExampleScene;
|
|||||||
FixMath, Graf3D, Graf3DScene, Graf3DPrimitives, Graf3DStructures;
|
FixMath, Graf3D, Graf3DScene, Graf3DPrimitives, Graf3DStructures;
|
||||||
|
|
||||||
var
|
var
|
||||||
wed3, box3, cyl3: Shape3D;
|
|
||||||
wed2, box2, cyl2: Shape3D;
|
|
||||||
|
|
||||||
wed1, box1, cyl1: Shape3D;
|
sta1, dwy1, dwy11, dwy12, dww1, cir1, rec1: Shape3D;
|
||||||
rec2, rec1, cir1: Shape3D;
|
sta2, dwy2, dwy21, dwy22, dww2, cir2, rec2: Shape3D;
|
||||||
|
|
||||||
sta1, dwy1, dwy2, dwy3, dww1, prt1: Shape3D;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|
||||||
@ -18,36 +14,33 @@ begin
|
|||||||
|
|
||||||
SetScene3D(scene);
|
SetScene3D(scene);
|
||||||
|
|
||||||
SetWedge3D(wed1, -100, 0, -100, 100, 100, 100);
|
SetStairs3D(sta1, 0, -125, -25, 100, 50, 50);
|
||||||
SetBox3D(box1, 0, 0, 0, 100, 100, 100);
|
SetDoorwayWall3D(dww1, 0, 50, -50, 100, 300, 100);
|
||||||
SetCyl3D(cyl1, 100, 0, -100, 100, 100, 100, 50);
|
|
||||||
|
|
||||||
SetStairs3D(sta1, 0, -100, 0, 100, 100, 100);
|
SetRect3D(rec1, 0, -150, -100, 100, 200);
|
||||||
SetDoorway3D(dwy1, 0, 50, -50, 100, 200, 100);
|
|
||||||
SetDoorway3D(dwy2, 0, 50, -150, 100, 200, 100);
|
|
||||||
SetDoorway3D(dwy3, 0, 50, -200, 100, 200, 100);
|
|
||||||
SetDoorwayWall3D(dww1, 0, 50, -50, 100, 200, 100);
|
|
||||||
SetParticles3D(prt1, 0, 0, 100, 600, 300, 300);
|
|
||||||
|
|
||||||
SetRect3D(rec1, 0, -150, -50, 100, 200);
|
|
||||||
SetRect3D(rec2, 0, 200, -150, 100, 300);
|
SetRect3D(rec2, 0, 200, -150, 100, 300);
|
||||||
SetCircle3D(cir1, 0, 75, -50, 30);
|
SetCircle3D(cir1, 0, 150, -50, 100);
|
||||||
|
|
||||||
|
SetDoorway3D(dwy1, 0, 50, -50, 100, 300, 100);
|
||||||
|
SetDoorway3D(dwy11, 0, 50, -150, 100, 300, 100);
|
||||||
|
SetDoorway3D(dwy12, 0, 50, -200, 100, 300, 100);
|
||||||
|
|
||||||
AddShape3D(scene, @rec1);
|
AddShape3D(scene, @rec1);
|
||||||
AddShape3D(scene, @dwy3);
|
|
||||||
AddShape3D(scene, @dwy2);
|
|
||||||
|
|
||||||
TurnXShape3D(@rec1);
|
TurnXShape3D(@rec1);
|
||||||
TurnXShape3D(@rec2);
|
AddShape3D(scene, @dwy11);
|
||||||
|
AddShape3D(scene, @dwy12);
|
||||||
AddShape3D(scene, @dww1);
|
AddShape3D(scene, @dww1);
|
||||||
AddShape3D(scene, @dwy1);
|
AddShape3D(scene, @dwy1);
|
||||||
AddShape3D(scene, @cir1);
|
AddShape3D(scene, @cir1);
|
||||||
AddShape3D(scene, @sta1);
|
AddShape3D(scene, @sta1);
|
||||||
|
|
||||||
AddShape3D(scene, @rec2);
|
SetCircle3D(cir2, -300, 150, -50, 100);
|
||||||
|
SetDoorway3D(dwy2, -300, 50, -50, 100, 300, 100);
|
||||||
|
SetStairs3D(sta2, -300, -125, -25, 100, 50, 50);
|
||||||
|
|
||||||
AddShape3D(scene, @prt1);
|
AddShape3D(scene, @dwy2);
|
||||||
|
AddShape3D(scene, @cir2);
|
||||||
|
AddShape3D(scene, @sta2);
|
||||||
|
|
||||||
InitWindow;
|
InitWindow;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user