Hi,
I am trying to wright hex tile by code. see below code and output. It looks correct as I wanted but I had to wright intbuffer manually.
How to calculate it programmatically?
See the last screen. Its generated in blender. I want to generate the same Hex grid by programmatically. I’ll appreciate is some one give me any suggestions for this too…!!!
Actually i think we should define what you mean for automatically.
Because if you mean like a generateIndexes(mesh) method, that works for every mesh, this is not possible.
If you want to fill a 2d shape of which you have only the external edges, this is possible, search for triangulation algorithms.
If you know the order of your vertices, ie. you generated them from a known function, then you can calculate the index as well… you just need to join the points… for instance in your specific case (first screenshot), you can find the central vertex, and then join any group of two adjacent vertices with the central one.
BTW why do you want to do this?
Is it just to have more vertices (for eg. Lighting or a terrain) or do you have some special plan for it like a triangle based strategy map, because then you should use different meshes instead of one
I am not going to make exactly “flat terrain system” but as of now in its initial stage it will be flat terrain only.
My Idea for Hex terrain system is like below.
Hex terrain will have many hex tiles.
The tiles can be added and removed or hide as per users preference. Idea is at a time 7 tiles will be on screen.
Each tile will have reference of its neighbors.
Each tile will have logical hex grid. The logical grid is basically virtually divided area of surface.
The logical grid will keep track of any assets on surface. e.g. trees grass, water, surface type, weather, characters and part of story line.
Event listeners and notification system will be implemented on tile and its logical grid.
Tile will be relatively small so that more better graphics can be presented.
So one tile is this huge hexagon from above?
So you can only see the “active” tile and its neighbours at a time?
Strange game idea I think XD
I do something like my picture above and for everey field I have a node which holds the ground, the objects etc for this position, you could not do that with one big mesh
Yes, its strange. I want to make plugable design. New story line and tile set can be added later as extension and will be co-relate with main story line.