chriscalef Posted May 31, 2015 Share Posted May 31, 2015 Well this might seem a little random, but I just wrote something rather cool, I do believe, and thought I'd throw it out here for grins and giggles.I'm working on my monolithic OpenSimEarth open world sandbox game project, and one thing that occurred to me recently is that I would really like to be able to import OpenStreetMap vector data. The way to do this that I already had available to me was to incorporate OSM's vector data into my FlightGear terrain building process, and then get it into my world via my WorldServer terrain importer. This brings the roads in as textures on the terrain, but it has many flaws. First, it takes forever to process all that complexity using the flightgear (terragear) tools, and second, the end result is far from satisfactory, being very pixelated and unrealistic in appearance.However, recently I had the thought: what if I imported the OSM data directly into Torque as an XML file, and then created decalRoads or meshRoads everywhere I should have a road? This would give me much better looking roads, with much more flexibility and better performance.In order to do this efficiently, I made it into a two step process: First, on the engine side, I wrote a function called readOSM(const char *filename) which reads an XML file exported by OSM, and stores the required data in an sqlite database. Then, on the script side I wrote a function called makeStreets() which accesses this database and creates an appropriate decalRoad out of all the nodes, after converting all of the latitude/longitude coords into XYZ values for my local T3D mission of course.There are still many problems, this being the first pass and all (primary among them large road segments standing straight up vertically, any place the road crosses a seam between two terrain tiles). However, I was pleasantly surprised by the scale I was able to achieve in just a few hours of messing around. At first I had a huge problem with slow sqlite connection speed, but then I realized I had to use "BEGIN:... COMMIT;" to make all the SQL happen at once, and after that things became most acceptable in terms of performance.These pictures demonstrate an import of 10M of OSM data including approximately 4500 Ways, 26000 Nodes, and 49000 WayNodes. Not all of these Ways are turned into DecalRoads because some of them represent buildings or other map decorations, but all roads and paths have been drawn with one of several different available widths and one of the three different possible road textures provided in a stock T3D build.Forward progress will of course include new road and path textures, as well as of course rivers and streams, and perhaps meshRoads in steep terrain. All in all, I'm not too unhappy with my first attempt, however. http://indiemotionsoftware.com/images/terrainPager/osm_all_eugene.pnghttp://indiemotionsoftware.com/images/terrainPager/osm_all_eugene_2.pngLooking west from somewhere around the U of O.http://indiemotionsoftware.com/images/terrainPager/osm_all_eugene_3.pngLooking south from above Skinner Butte. Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.