Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon


2. January 2017

 

Mike Fricker, UE4 Technical Director at Epic Games, just released a new plugin for Unreal Engine that enables you to utilize OpenStreetMap data directly in Unreal Engine.  Keep in mind this is just a hobby project and isn’t directly supported by Epic.  OpenStreetMap.org is a crowd sourced (think Wikipedia) map of the world.  This plugin enables you to take data from OSM and use it directly in your game, quickly creating real world accurate cityscapes like the one shown to the right.OSM  Additionally all of the location information is retained upon import, so if you are creating an Alternate Reality based game like Pokemon Go, the data is available to you.  Keep in mind however that OpenStreetMap data is released under the Open Data Commons Open Database License (ODbL).  I am no lawyer, but I believe the license enables you to create closed source projects using the data so long as you give proper attribute, share any modifications you make to the database and make sure that the data itself (not your game code) remains available and open.

 

Details of the plugin from the Readme:

Street Map Assets

When you import an OSM file, the plugin will create a new Street Map asset to represent the map data in UE4. You can assign these to Street Map Components, or directly interact with the map data in C++ code.

Roads are imported with full connectivity data! This means you can design your own navigation algorithms pretty easily.

OpenStreetMap positional data is stored in geographic coordinates (latitude and longitude), but UE4 doesn't support that coordinate system natively. That is, we can't easily deal with spherical worlds in UE4 currently. So during the import process, we project all map coordinates to a flat 2D plane.

The OSM data is imported at double precision, but we truncate everything to single precision floating point before saving our UE4 street map asset. If you're planning to work with enormous map data sets at runtime, you'll need to modify this.

Street Map Components

An example implementation of a Street Map Component is included that generates a renderable mesh from loaded street and building data. This is a very simple component that you can use as a starting point.

The example implementation creates a custom primitive component mesh instead of a traditional static mesh. The reason for this was to allow for more flexible rendering behavior of city streets and buildings, or even dynamic aspects.

All mesh data is generated at load time from the cartographic data in the map asset, including colorized road strips and simple building meshes with triangulated roof polygons. No spline interpolation is performed on the roads.

The generated street map mesh has vertex colors and normals, and you can assign a custom material to it. If you want to use the built-in colors, make sure your material multiplies Vertex Color with Base Color. The mesh is setup to render very efficiently in a single draw call. Roads are represented as simple quad strips (no tesselation). Texture coordinates are not supported yet.

There are various "tweakable" variables to control how the renderable mesh is generated. You can find these at the top of the UStreetMapComponent::GenerateMesh() function body.

(Street Map Component also serves as a straightforward example of how to write your own primitive components in UE4.)

OSM Files

While importing OpenStreetMap XML files, we store all of the data that's interesting to us in an FOSMFile data structure in memory. This contains data that is very close to raw representation in the XML file. Coordinates are stored as geographic positions in double precision floating point.

After loading everything into FOSMFile, we digest the data and convert it to a format that can be serialized to disk and loaded efficiently at runtime (the UStreetMap class.)

Depending on your use case, you may want to heavily customize the UStreetMap class to store data that is more close to the raw representation of the map. For example, if you wanted to perform large-scale GPS navigation, you'd want higher precision data available at runtime.

 

The plugin and it’s source code is hosted on Github available here.  The plugin is released under the very liberal MIT open source license.

GameDev News

blog comments powered by Disqus

Month List

Popular Comments

Retro Game Programming: Unleashed for the Masses Book Review
Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon


25. August 2015

 

I’m about to date myself brutally with this post (hint… I’m old… much older than this book, which is also old ), however when I stumbled upon this book it stirred a bit of my childhood in a way that no Michael Bay butchered film can even attempt.  You see my first home computer was the Atari 800XL, a machine that still owns a solid place in my heart.

 

SONY DSC

 

Such an amazingly sexy thing, no?  Well in 1983 it certainly was.  Within minutes of bringing it home, my dad managed to erase the disks that came with it, leaving me alone with an Atari 800XL, the manual, the ROM version of BASIC ( thankfully ROM is remarkably Dad proof… ) and 6-8 weeks will waiting for media replacement from Atari.  On this day two journeys began.  My Dad’s continuing and overwhelming hatred of computers and my programming career.

 

I’ll admit however, although I managed to scrape together some simple text adventures, a dice rolling game and a few other simple examples, I was simply too young to get very far.  I was still quite young and information simply wasn’t as available as it is now.  It wasn’t really until I got a PC that I really started to learn to program properly.  Unless of course you count copying hundreds of lines of assembly from the pages of a magazine programming…

 

This is a bit of a shame too as the world of programming on 8bit machines was almost magical.  While those lines of cryptic bytes I typed back then seemed like magic, now that I’ve got a good 20 years of programming under my belt, I have an appreciation for how simple things actually were.  On top of that, expectations were so much lower, it truly was the age where a single developer in his garage could make a successful game.   Yes, you may have been working in BASIC or even Assembly, but the underlying processors were so simple compared to today, that with the right information, it really wasn’t the nightmare you expect it to be.

 

It’s funny, you hear lots of people say they want to work in C++ or C because they want to “get closer to the machine”.  Want to get closer to machine?  Travel back in time!  I actually think there is a lot of value in people messing around in these old systems.  So when I saw this book appear on Safari, I decided to give it a look.

 

Retro Game Programming:Unleashed for the Masses

 

Available on Amazon for less than $10 (starting at $2 actually).  With a 1.5/5 star review… that’s not a good start.  The book is old, the book is cheap, is it worth reading?

 

RetroGameProgrammingCover

I suppose that entirely depends.  The book is in a word, sloppy.  It covers a number of old systems including the Atari 800, C64 and TRS80.  It actually wastes a chapter on plugging these various machines in…  yeah.  This chapter alones suggests to me that the book may not have in fact had an editor.

 

But then it gets a bit more interesting, there’s a touch of history which I almost always enjoy, I’m not sure how it would go for someone without my rose coloured glasses on.  Then the book seems to flip back and forth between being a complete beginners book and… not.  We get a chapter on 6502 assembly programming… very cool.  We get some coverage of setting up the video and drawing to the screen, which are good reads.  Then a chapter on input and player AI, which frankly doesn’t have a single purpose for existing.  Followed by a chapter on audio programming.  It is then all capped off with a completely meaningless BASIC text adventure.  Had the book actually concluded on a complete Assembly project using what we’d learned so far, I think that 1.5 star rating would be a great deal higher.

 

So do I recommend this book?

 

No, not really.  However as I said earlier, I discovered it on Safari and it provided a few hours of amusement.  If you were looking for an interesting, but sloppy, look back at the way things were, it’s certainly worth the couple bucks it’s being sold for these days.  Even more so because it is now easy to get a hold of incredibly solid emulators of all the systems used in this book.  There is value in modern programmers experiencing how things used to be, and it’s amusing for the older folks among us to take a trip down memory lane.

 

You may be asking yourself…  hey did he just review a 10 year old book that he didn’t particularly like?  Why yes, yes I did.  I will say however, one of the advantages of being a book on retro game development is…  you never really become out of date, do you?

Totally Off Topic ,

blog comments powered by Disqus

Month List

Popular Comments