1
\$\begingroup\$

First of all a little premise: I'm following this tutorial on YouTube for procedural 2d cave generation in unity using cellular automata and I'm extending it in order to make caves in all three dimensions. With this approach, caves are based on a 3d matrix where if a cell value is 1 it is a wall and if 0 it is an empty space. The "rooms" created, after being logically connected, need to be "physically" connected by making a path of zeros in the 3d matrix and the tutorial explains how to do this in 2d.

Can you, please, suggest me the approach on how to draw a discrete line (of zeros in this case), in a 3d matrix, that goes from point A to point B?

I'll attach a screen of a map example where rooms are drawn with cubes and red lines are the logical connections.

Screenshot of a generated cave

\$\endgroup\$
  • 3
    \$\begingroup\$ Bresenham's line drawing algorithm, originally in 2D, has been revised in many places with a 3D version. \$\endgroup\$ – Patrick Hughes Feb 5 at 0:02
  • \$\begingroup\$ I would bet that a DDA line algorithm could also work in 3D. \$\endgroup\$ – user1118321 Feb 5 at 6:57
  • 1
    \$\begingroup\$ Bresenham is more efficient that DDA. \$\endgroup\$ – Patrick Hughes Feb 5 at 18:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.