Advice on using a custom mesh for a gamingboard

Hi, I’m new to 3D (but have done my fair share of 2d stuff) and this is my first post to this board :slight_smile:

I am in the planning and evaluation phase on how to create my board environment and would like to get some feedback about my choices. I picked this subform as my thoughts mainly care about graphics.

What do I want to achieve?

  • Something like this in real time 3d for a turn based game:
  • Such a game board would be randomly generated and have dimensions of up to 50x50 tiles with ~15 different terrains (this should simply be not a technical limit)
  • Elevation shall be represented in elevated hex prisms. (I’ve seen Maker’s Tale and am deeply impressed with it!) and will be watched from a standard “top down at an angle” perspective (probably rotatable and titable for the heck of it)
  • I need good/pleasing highlighting of selected tiles, a group of tiles and whole regions.
  • solid fps on my Intel HD Graphics 4000

What did I learn already?

  • I learned about custom meshes and created my own Hexagon and Hexagon-Prism meshes
  • Of course I went the dumbest route first and learned that creating 50x50 distinct geometries having 15 different textures puts my reference spec clearly under 60fps because of the object bottleneck I now know of :slight_smile:
  • I then learned about GeometryBatchFactory.optimize, which greatly improves performance but undid my simple picking detection (I just took the first geometry from the collision results). Frame rate is mostly stable at 60 with pssm shadows, 2 directional lights and everything at CastAndReceive.

What am I about to do?

  1. I should create the whole board as a single mesh and assign texture coordinates in a way that will use a plain color for the vertical faces and a corresponding part of the texture map for the hexagonal faces (as my hex map is still a 2d grid this allows for easy coordinate translations)
  2. On world creation I should pregenerate the texture from 1), probably blending additional terrain features like roads on top of the basic terrain tile from a set of basic, singular tile images.
  3. For picking I should read the coordinates from my collision result and transform the xy coordinates to my hex grid (I have done similar things in 2d already) to get the clicked hex by simply dropping the 3rd coordinate?
  4. Highlighting:
    4a) For active tile highlighting I guess it would be ok to use a simple hex in the mesh line mode. How to make them fancy (aka glow) can be figured out at a later time
    4b) For borders I would need to highlight only certain edges of a group of hexes -> I would create a custom mesh and make it look like 4a)?
    4c) For allowable tiles I would like to alpha-blend a color on top, should I spawn hexes slightly on top that are semi transparent?
    4d) I may want to show the whole board with simple color fills (again only for the hexagonal faces) to indicate world stats (think the info overlays from sim city), for this I would create further textures like in 2), probably regenerated for every turn if it takes too much time to do it on the fly.

X) I may want fog of war, but have yet not done research on that topic

Thank you for taking the time to read all this and for your possible input on my thoughts and issues :slight_smile:

For the X part, this has been discussed on the forum. Just make a quick search for it.
I’ve got pretty good results with a simple light-map so that unxeplored parts are rendered black…

Hello, i’m toying with a similar hex board for a battletech-like game. What i’m doing is the following (which may or may not be the best option. Game programming is not my job, this is just for playing with JME) :

  • I generate an hex mesh for each terrain type (i’m using the same texture with different mapping, ie a texture atlas), as a reference
  • for each hex on the board i create a geometry node with the correct mesh (depending on the terrain type). The Id of the geometry is a string “NODE:x:y” where x and y are the position of my hex on the board, meaning that i can get additionnal data in my model.
  • those geometry are grouped by node in block of 55 (or 1010 depending on the size of the map). each “group Node” has a specific Id
  • those group node are NOT added to the root, but in a hashmap.
  • they are then used to create a set of optimized geometry via GeometryBatchFactory. THOSE are added to the scene. (which mean that you have a set of non displayed scene-tree)

Now when there is a click, i get the optimized group Node. i can then perform the ray-intersection along the corresponding non optimized group node, which in turn gives me the hex node. on my crappy portable, i get more than 130 fps.

Note that BatchNode may even be a better approach to the problem (they where not available when i started playing with the map), since, if i understand well, it would display the optimized node, but perform the intersection on the basic meshes.

PS : i simplified a little bit. I do not define one hex mesh by terrain, but 12 : 6 (1 for each direction) with one texture, and 6 with another texture. For a given hex node, for each idrection i choose one or the other, depending if the neighbour in this direction possess the same terrain type and height. this allow me to display different border on different directions, depending on the generated map.