¿Cómo dibuja un mapa hexagonal en OpenGL?
-
14-11-2019 - |
Pregunta
Soy nuevo en GL y quería crear un mapa azuleado como un autopartita.Quiero crear un mapa hexagonal hexagonal pequeño (tal vez 7 hexes anchos / altos).Mi primer pensamiento fue simplemente crear un método para dibujar un hexágono y luego simplemente traducir el compensado apropiado y colocar el nuevo hexágono.Pero esto no parece eficaz.¿Algunas ideas?Alos como una pregunta lateral, ¿cómo puedo determinar si un SummyEvent está en el HEX dado?
Solución
Otros consejos
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.