Mazes in 3D

After sorting some of my issues with trig (though not all of them), I spun up some simple maze views this morning, based on Ray's maze generator.  Assume we have this maze (straight out of genMaze(10, 10) and into a printing loop like Ray demoed at CFUnited):

##  ######################################
##  ##          ##          ##          ##
##  ##  ##  ######  ######  ##  ######  ##
##  ##  ##      ##      ##  ##  ##  ##  ##
##  ##  ######  ##  ######  ##  ##  ##  ##
##  ##      ##      ##      ##      ##  ##
##  ##################  ##########  ##  ##
##              ##      ##      ##  ##  ##
##############  ##  ######  ##  ##  ##  ##
##              ##  ##      ##      ##  ##
##  ##############  ##  ##############  ##
##              ##      ##          ##  ##
##############  ##  ##########  ######  ##
##      ##      ##          ##      ##  ##
######  ##  ##############  ##  ##  ##  ##
##      ##              ##  ##  ##  ##  ##
##  ##################  ##  ######  ##  ##
##  ##      ##          ##          ##  ##
##  ##  ##  ##  ######################  ##
##      ##                              ##
######################################  ##

From the model (a two-dimensional array), I can make a pretty map of it (demoing the camera rotation in both horizontal and vertical directions).  I discuss the obviously erroneous curvature below.

map1

And then we can also stand in front of the doorway and look down the initial hallway (much like the original version did, though this hallway is far less interesting).

front_door

Both of these captures are generated the "right" way, with the maze plotted in three-space and then rendered into a 2D image.

The curvature of the map view is due to the issues still remaining in my camera/POV rotation logic.  The camera rotates correctly (both vertically and horizontally), but it also "curls" the world based on the degree of vertical rotation.  I'm not sure what I've actually done wrong, other than not understanding anything about how to do 3D rendering.  : )  But everything at least lays out correctly now, even if it's on a weird curve, so that's a large improvement. Real6

That particular map capture was from a very high camera position and a correspondingly large "tip down" of the camera to accentuate the curvature issue.  With a smaller rotation, the curvature is far less grotesque, though still noticeable.

UPDATE: Here's another capture (of the same "world" as the image in my original post) that illustrates the curve issue in better detail.

curved_space

In the maze map at the top, every block is drawn individually, so the curve seems uniform.  But in this capture you can see how that smoothness is localized.  The grid is a collection of lines from end to end, but the lines themselves don't curve, just the endpoints.  So you get horribly wonky drawing when you don't have a uniform distribution of localized segments.  As such, fixing this is rather essential for this to have any sort of utility beyond academic pursuits.

5 responses to “Mazes in 3D”

  1. Brian Rinaldi

    Barney. For the record, these posts are completely useless…and utterly fascinating! Keep up the good work, I am enjoying reading these. P.S. Great finally meeting you at CFUnited.

  2. marc esher

    I dunnoknow dude. When Homer Simpson was walking through space/time in Homer3, he was bending it. Maybe Homer's just a smidge stage right?

    Or have you tried setting graphicsStage.quitFuckingBending()?

  3. Brad Wood

    I think the curvature looks pretty slick. I mean if you fix it now you might never be able to figure out how to do it again. Mark it as a feature and move along. Next!

  4. Brad Wood

    Ouch, I see what you mean. Reminds me of a Dr. Seuss world. Will you be posting the code anywhere for us to play with/help out?