|
|
This might be of more interest to you.
const
Size = 25;
DirBits : array[0..5] of byte = ($01,$02,$04,$08,$10,$20);
Dx : array[0..5] of integer = (0,1,0,-1,0,0);
Dy : array[0..5] of integer = (1,0,-1,0,0,0);
Dz : array[0..5] of integer = (0,0,0,0,1,-1);
Db : array[0..5] of integer = (2,3,0,1,5,4);
var
Maze : array[-Size..Size,-Size..Size,-Size..Size] of byte;
x, y, z, nx, ny, nz, l : integer;
n, d : integer;
f : textfile;
begin
Randomize;
fillchar(Maze,sizeof(Maze),0);
l := Size*2+1;
l := l * l * l; // Number of nodes left to visit
x := random(Size*2+1)-Size;
y := random(Size*2+1)-Size;
z := random(Size*2+1)-Size;
dec(l);
while l > 0 do
begin
d := 0;
while d <> $3F do // $3F = All directions tried, and no unvisited
nodes as neighbors.
begin
n := random(6); // Pick a random direction
d := d or DirBits[n];
nx := x + Dx[n];
ny := y + Dy[n];
nz := z + Dz[n];
if (abs(nx) <= Size) and (abs(ny) <= Size) and (abs(nz) <= Size) then
begin
if Maze[nx,ny,nz] = 0 then // 0 = Unvisited Node
begin
Maze[x,y,z] := Maze[x,y,z] or DirBits[n];
Maze[nx,ny,nz] := Maze[nx,ny,nz] or DirBits[Db[n]];
dec(l); x := nx; y := ny; z := nz; d := 0;
end;
end;
end;
if l > 0 then // If we get here, we ran into a "dead end"
begin
x := random(Size*2+1)-Size;
y := random(Size*2+1)-Size;
z := random(Size*2+1)-Size;
while Maze[x,y,z] = 0 do // We need to branch off of a node we have
already visited
begin
x := random(Size*2+1)-Size;
y := random(Size*2+1)-Size;
z := random(Size*2+1)-Size;
end;
d := 0;
end;
end;
assignfile(f,'c:\cflag\maze.inc'); rewrite(f);
writeln(f,'union {');
for z := -Size to Size do
for y := -Size to Size do
for x := -Size to Size do
begin
writeln(f,' sphere { <',x*2,',',y*2,',',z*2,'>, 0.2 }'); // sphere is
the elbow
for n := 0 to 5 do
begin
if (Maze[x,y,z] and DirBits[n]) > 0 then
writeln(f,' cylinder{ <',x*2,',',y*2,',',z*2,'>,
<',x*2+Dx[n],',',y*2+Dy[n],',',z*2+Dz[n],'>, 0.2 open}');
// cylinder is 1/2 of the "pipe"
end;
end;
writeln(f,' texture { pigment { color rgb <1.0,0.6,0.0> } }');
writeln(f,'}');
closefile(f);
end;
Steve <sjl### [at] ndirectcouk> wrote in message
news:slr### [at] zero-ppslocaldomain...
> On Wed, 1 Mar 2000 00:03:11 -0800, Mike White wrote:
> >This image was created as a god awfully huge 3d maze (50x50x50) but once
it
> >was born, it was a perfect representation of what programmers see looking
at
> >MS code.:)
> >
> Nice work, gonna tell us how ya did it?
>
>
> --
> Cheers
> Steve email mailto:sjl### [at] ndirectcouk
>
> %HAV-A-NICEDAY Error not enough coffee 0 pps.
>
> web http://www.ndirect.co.uk/~sjlen/
>
> or http://start.at/zero-pps
>
> 12:17am up 5:22, 3 users, load average: 1.00, 1.00, 1.00
Post a reply to this message
|
|