Come faccio a disegnare ricorsivamente una mappa esadecimale in OpenGL?
-
14-11-2019 - |
Domanda
Sono nuovo per GL e volevo creare una mappa piastrellata come auto protornale.Voglio creare una mappa esagonale piccola (forse 7 esagoni larghi / alti).Il mio primo pensiero era quello di creare un metodo per disegnare un esagono e poi solo tradurre l'offset appropriato e posizionare il nuovo esagono.Ma questo non sembra effsciente.Qualche idea?Alos come una domanda laterale, come posso determinare se un motigagevent è con nelle sono di un dato esagono?
Soluzione
Altri suggerimenti
To determine if a MotionEvent is within a certain hex you have to convert the coords passed in via the motion event to your OpenGL World coords. Its just like a unit conversion, you know the screen goes from 0 - WIDTH and your GL world lets say goes from -1 to 1.
(xCoord / (Width - 0)) * (1 - (-1)) = xCoordWorld
will give you the xCoord from 0 to 2, then subtract 1 to get it in -1 to 1.
As far as the hexes go I've always used 'art' hexes. Draw the hex out in paint then render a bunch of squares with that piece of art on them, fast and easy to swap a hex out for another hex.