I’m trying to create borders for provinces within my strategy game. The game has towns which are placed randomly at runtime and I have an algorithm which generates the border points for each town. I’d like to draw textured borders which have a material which can change color to indicate which player faction controls the town.
Here is what I have so far:
What I’m currently doing:
Each town has a series of vertex points in world space which define the end points of each border. If I just draw a straight line between these two points, the line will clip through the terrain. So, I currently have a small script which steps along the line segment and samples the terrain position and creates a sub vertex point and adds it to an array. Once I have this list of vertex points, I use “DrawDebugLine” to draw a colored line which follows the contours of the terrain.
Why it’s wrong:
-It’s a debug line! It looks ugly, it’s not meant for production release, etc.
-I can’t texture it with materials.
-If a border is shared, it needs to show both faction colors. This approach doesn’t support that.
What I’ve tried:
-I tried to create splines at run time. I can do this, but I’m new to splines and ran into some clipping and shape issues. My borders have hard corners and splines don’t.
-I tried to manually create textured lines using quad meshes. It’s a pain in the ***, especially when you try to get the mesh to follow the contours of the terrain. A quad has four corners which need to match the terrain shape, and the vertices of one quad need to match the vertices with the next quad (or else you get gaps!). This could work, but it seems like its the “hard way” to do it.
What I’d like to do:
Have some sort of blueprint or object which takes a series of vertex points, draws a contoured line between each line segment, and accepts two colors to apply to each side of the border texture.
What I don’t know how to do:
Create a spline or contour line which follows the contours of the terrain (and only the terrain) without gaps in the mesh and has hard corners (up to 179 degrees).
So, what do you guys think is the best approach to doing something like this?