Filling a mesh

Hi All,



I was wondering if JME 3.0 would allow me to fill a line mesh? That is, I traced the outline of a map, but would like to fill or texture its interior. I know that I could either use triangulation (i.e. find the map’s centre and use it as a corner for each triangle) or implement some form of point-in-polygon algorithm to find and fill all points within my map. However maybe JME 3.0 already did all the hard work for me?

Why not just setting the mesh mode to triangle or so?

Yes, I’m aware of that option, however it complicates things slightly as I only have chart outlines. Given the nature of the charts, it would be more difficult to find center points to which to tie individual corners. Naturally, it’s my only other feasible option. However I was wondering whether there is an easier (built-in) way…

?



EDIT: I’m aware that I could implement a boundary fill or flood fill, but maybe JME already handled this for me…?

I wonder from what your are trying to build your level? maybee there is a better solution to this ?

What data o you have before any loading/processing?

I developed a map parser that loads maritime charts in the form of lat,long (I have constructed a mercator projection etc). Each lat,long defines a country boundary. So, all that I have are polygons defining country boundaries. I have previously drawn these charts to file and used the new terrain system to render them. However I ran into some precision issues, so decided that it would be best to work from scratch.



In short: I have sets of x,y,z coordinates that define country boundaries.



Thanks for your time. :slight_smile:

Mercator projection on a global scale is not possible with float accuracy and probably also not feasible, to avoid accuracy problems you should “partition” your mercator projection into multiple sectors.

Cheers,

Normen

In essence, that is what I am doing already. i.e. I have a global projection and as the user “zooms” or “moves” into specific regions, the chart projection is re-calculated. Works fine. Except of course that I want to texture or fill my countries :smiley:

Cool. Yeah, I guess some mesh mipmapping or LOD’ing / swapping will be necessary for the zooming… Keep on jme’ing :slight_smile:

Cheers,

Normen

hm to fill the countries you probably have to generate a mesh first, containing the vertexes and then triangulate it, I don’t see any faster way to achieve this.

Will do, cheers!

Its quite easy making the user think he moves in one direction while you move him in another to avoid excessive location values. When I was working on Scalaxy, you could move through “the universe” but in fact you were just moved around in one area and the stars around you moved in a way so that you think you move in one direction all the time, see our wiki entry about this. See the image at the bottom of the site (Text is in german but I think both of you are german, right? :))



Same could be done with scaling and swapping meshes to make the user think he approaches the surface of the planet.

Cheers,

Normen

It is possible to fill a 2D shape made of lines by placing a vertex in the center of it and then making triangles with every line in the shape. This won’t work for non-convex meshes though …

I am sure there are algorithms online that can handle this sort of thing.

Thanks momoko. Yes, that is what I meant with " (i.e. find the map’s centre and use it as a corner for each triangle) ". There are indeed algorithms out there, I was just wondering whether it had already been implemented in JME :slight_smile:



EDIT: If anybody is looking for a solution in the future: Seidel’s Polygon Triangulation algorithm does just that.



If you guys want, I can pass on the implementation once I get it working. Would be nice to have a fill() method or something along those lines.

Indeed normen. Well observed :wink:



Thanks for that link!