Hi I am trying to make Hexagon terrain system. As far now I can create hexagon tiles , subdivide it and apply textures to it.
The problem I am facing is how to align texture coordinates to any seamless textures.
So how to apply square seamless texture to hexagon so that it looks like seamless?
If all the hexagons are aligned to each other (flat without any “steps”) and have the same seemless texture, why have multiple hexagon meshes in the first place?
You would save a lot of vertices and solve the texture problem, if you combine all affected hexagons into one single mesh.
Should not be a big problem - just use a factor for the translation between x and y. (or x and z - usually it’s x and z). The rest will be done by the ‘wrapping’ of the texture which will be computed on the graphics card for you. Here is a sketch I made in a couple of seconds:
No. I mean u = (some factor) * x and v = (some factor) * y just as the sketch shows you.
Note that y is typically z in most 3D worlds (jME has default x,z-plane too).
It assumes that you have a different mesh for each hex field or use some very simple shader.
I think it’s called “planar projection of texture coordinates” or something like that.
Very simple thing - might be one of the simplest things in 3D mesh/shader writing.
Yes, each hex is separate tile. At this point I am not using shader right now. Can you guide me how to setup UV mapping by code? is it different than setting TexCoord as I shown in first post?
Sorry I am not good on this concept.
TexCoord is uv-mapping.
x-component of texture coordinate is called “u” instead of x
y-component of texture coordinate is called “v” instead of y
You simply set texture wrapping mode to repeat and assign some numbers to the u and v component of the tex coordinates.
Only problem: It will not wrap at the upper and lower border and left side and right side of the hex tile. It will wrap wherever the u coordinate increases by 1.0 and where the v coordinate increases by 1.0 (so it’s “modulo 1” if you know what modulo means).