Roads of Daggerfall

Show off your mod creations or just a work in progress.
User avatar
Uncanny_Valley
Posts: 67
Joined: Mon Mar 23, 2015 5:47 pm

Roads of Daggerfall

Postby Uncanny_Valley » Thu May 21, 2015 10:29 pm

This is my latest project, adding roads to Daggerfall. It's far from finished but I wanted to share my progress with it. The project consists of two parts. The road editor and the roadmap reader.

The Editor
Image

The editor allows you to paint roads onto an image in the editor. The result is saved into a .png file that the roadmap reader then can read. The editor has the following features.

Save and Load
Zoom in and out.
(Optional) A Gridmap for easier editing.
Show Locations (the locations are read using "dfUnity.ContentReader.HasLocation()")

The roadmap Reader
Image

Reads the roadmap image file. Depending on the amount of red in each pixel in the image, it will paint roads in different directions and shapes on each corresponding terrain tile.

A few things I would need help with.
Is there any easy way to check the location type? With the ContentReader I can check if there is a location, but I want to know if it's a dungeon, city or any other type. This will make it easier to paint roads only between cities when using the editor.

How does the DaggerFall Terrain billbords work? I want to find a way so that trees and other details doesn't appear on roads.

I would also like to find a way to smooth/flatten roads on the terrain. Any suggestion on how I could achieve this?
User avatar
Daschluba
Posts: 40
Joined: Sun May 10, 2015 5:25 pm
Location: Austria

Re: Roads of Daggerfall

Postby Daschluba » Thu May 21, 2015 10:34 pm

OMG OMG OMG :o :o :o :o :o :o This is awesome! Great work!
User avatar
Arctus
Posts: 40
Joined: Mon Mar 23, 2015 12:28 am

Re: Roads of Daggerfall

Postby Arctus » Fri May 22, 2015 12:15 am

Damn, that's pretty cool.
User avatar
Interkarma
Posts: 1942
Joined: Sun Mar 22, 2015 1:51 am

Re: Roads of Daggerfall

Postby Interkarma » Fri May 22, 2015 12:19 am

HOLY @#$%! :o That's seriously impressive work.

Is there any easy way to check the location type? With the ContentReader I can check if there is a location, but I want to know if it's a dungeon, city or any other type. This will make it easier to paint roads only between cities when using the editor.


It sounds like you already know how to use ContentReader.HasLocation(). This is a fast dictionary check for any given coordinates and returns a compact struct in the form of ContentReader.MapSummary. We can then use MapSummary.RegionIndex and MapSummary.MapIndex to find more information about that location.

With those indices, you can use ContentReader.MapFileReader.GetLocation(regionIndex, mapIndex) to return a DFLocation struct. There are two overloads of GetLocation(), one for indices and one for strings if you need it.

Now, DFLocation probably contains a lot more information than you need, including the map layouts, but it's only a small amount of data and should be quite quick to read even hundreds of locations at a time. Let me know if you need something a bit leaner and I'll code it up in the API. I can probably stick more info in MapSummary without any problems.

Once you have it, here are the members you'll be most interested in DFLocation.

DFLocation.Loaded (this will be true if location loaded OK, otherwise something went wrong, like bad indices or strings not found).
DFLocation.HasDungeon (true if this location has a dungeon - also true for large cities like Daggerfall, Wayrest, Sentinel, but usually only true for dungeons).
DFLocation.MapTableData (another struct with more details about map).
DFLocation.MapTableData.Type (a DFRegion.LocationType enum which tells you the exact location type from game data).
DFLocation.MapTableData.DungeonType (a DFRegion.DungeonType enum which tells you the exact dungeon type).

Minor tip: The MapPixelX and MapPixelY coordinates correspond to a unique location ID. See MapsFile.GetMapPixelID() and it's close relatives to convert between IDs, coordinates, latitude, longitude, etc. This might come in handy later.

How does the DaggerFall Terrain billbords work? I want to find a way so that trees and other details doesn't appear on roads.


The wilderness nature flats are just a grid of billboards placed at the vertex point of each texture tile. Check TerrainHelper.LayoutNatureBillboards() for examples of where I reject nature billboards inside location rects (which define their own nature layouts) and weight based on tile type. For example, water has a zero percent chance. If we're able to push the road tiles into the tilemap array before it hits LayoutNatureBillboards() it should be pretty easy to reject road tiles just like water.

I would also like to find a way to smooth/flatten roads on the terrain. Any suggestion on how I could achieve this?


This should be possible, but will need to think about best place to inject code. Take a look at TerrainHelper.FlattenLocationTerrain() for how I do this for locations. We basically just need to deform/smooth the height at road tiles before it gets promoted to terrain data. I'm already doing something similar for water tiles.

Sorry for the short answers on the last two. Hopefully that's enough to get you started. Just fire any more questions you have my way and I'd be happy to try and help. :)
User avatar
LypyL
Posts: 474
Joined: Sun Mar 22, 2015 3:48 am

Re: Roads of Daggerfall

Postby LypyL » Fri May 22, 2015 12:37 am

I love you so much right now! Roads are something I've wanted to see added since the streaming world update came out. This looks great, I can't wait to see it in action! :D

edit: Any plans on procedurally placing the roads?
User avatar
Uncanny_Valley
Posts: 67
Joined: Mon Mar 23, 2015 5:47 pm

Re: Roads of Daggerfall

Postby Uncanny_Valley » Fri May 22, 2015 1:17 am

I'm happy that you all like it. :D

Adding roads is something that has been on my mind for quite some time but I been struggling to find a good way to implement it, until a few days ago. And yes, my first ideas was to do it in some procedural way but I just couldn't figure out how to make that work. But who knows, maybe a solution will come to me some day in the future. ;)

So many locations in Daggerfall... and you can now toggle the background map image.
Image
User avatar
Interkarma
Posts: 1942
Joined: Sun Mar 22, 2015 1:51 am

Re: Roads of Daggerfall

Postby Interkarma » Fri May 22, 2015 1:26 am

Uncanny_Valley wrote:And yes, my first ideas was to do it in some procedural way but I just couldn't figure out how to make that work. But who knows, maybe a solution will come to me some day in the future. ;)


Check out Voronoi diagrams and Fortune's Algorithm. These are often used to create weighted connections between points and commonly used for roads, rivers, and so much more. They create really natural-looking roads as well.

Slightly off the subject, slime mold can be used to grow optimal road/rail networks. Creepy.
http://www.wired.com/2010/01/slime-mold ... il-system/
User avatar
Hoon
Posts: 11
Joined: Thu May 14, 2015 5:49 am

Re: Roads of Daggerfall

Postby Hoon » Fri May 22, 2015 1:32 am

This is awesome! I know you're only just starting, but is the end goal to have multiple types of roads (dirt paths, cobblestone, etc) that can also travel diagonally?

Oh snap! I just realized something similar to this could be used for rivers!
User avatar
Nystul
Posts: 863
Joined: Mon Mar 23, 2015 8:31 am

Re: Roads of Daggerfall

Postby Nystul » Fri May 22, 2015 8:27 am

wow! incredible stuff!
although I would suggest a mud texture for most roads (except between large cities - there I would say a stone road is adequate)
you have such a enormous work speed - this is impressive
ifkopifko
Posts: 66
Joined: Thu Apr 02, 2015 9:03 am

Re: Roads of Daggerfall

Postby ifkopifko » Fri May 22, 2015 9:37 am

Nice, but do I understand it correctly, that you are putting the roads in manually? Seems pretty scary to me. :D

Interkarma> Interesting what you write about wilderness billboard. I was wondering how does the game/engine decide where to put a tree/rock/something and what type precisely. You used the word "chance", but the trees seem to be in the same places when I restart the demo, so does it have a random factor in it or not?
Why I'm asking... I have a dream... :D Nah... I thought that the look of the land could be changed/improved by reorganizing the trees/rocks/somethings. You know, like creating dense forests and clearings. Just like in the real world. If one could edit this kind of stuff graphically, in a form of a map, I think it might actually be manageable even on the scale of DaggerFall game world. Most of the roads could actually be composed of treeless terrain, rather than a stone/mud texture... though some texture would be nice between the largest cities.

And if the tree sprites could actually be replaced with something more appropriate, to match the quality of terrain you guys have already achieved, it would be... I don't know, but I feel like "awesome" just does not cut it anymore. :D

Hoon> Yeah, rivers would be nice, but there is the problem, that rivers should naturally pass through large cities, but that would only be possible through manual "reconstruction" of the cities involved. Also, rivers would need to follow the terrain levels, so that they would not flow uphill or something. :D

Return to “Creator's Corner”

Who is online

Users browsing this forum: Bing [Bot] and 2 guests