Dev Blog: Week 5
Hello guys,
These past couple of weeks I decided to dedicate entirely to the road system. And that is what I have being doing during my spare time. I quickly discovered that the road system is the single most complicated and time consuming system in the game. A procedural road will need code to create the mesh on the fly, rotate the road towards the mouse, modify the terrain below the road so it stays flat and nice, create nodes to divide the roads so other roads can attach to it, and create a list containing the relationship between all these nodes.
Last week I completed the basic mesh creation and rotation, this week I focused on the node relationship list alone because it is a critical part of the system. Despite of the hard work put into it, I'm not done. Let me explain better what is going on.
The image above shows the basic structure of the doubly-linked list that I'm implementing in order for the nodes to know which node precedes and follows themselves.
Each square on the image is a node that contain exactly another set of the same structure. For instance, if I have the node "Node.Previous" I can get the "Node.Next" by saying "Node.Previous.Next.Next". The first next referencing the center node, and the second next referencing the node after the center node. That is how a linked list works, it is very confusing in the begging but after some practice it gets a bit more manageable.
Right now, I have almost everything working, including when adding T intersections and 4 way intersections. The only problem is that when I have two separate roads that don't share any nodes, the list still points one end of one road to the beginning of the second road, which is wrong since both roads are not connected.
After I figure this out, I should be all set to start messing with dividing roads when a T / 4 way intersection happens where there are no nodes. Ex: A have a straight road and then I build another road crossing the first one in the middle, a node should be created at the intersection and all the relationships should set correctly.
I almost forgot, in the process of creating the node list, I solved a few bugs such as some null refs. and roads inclining when they shouldn't.
This is it for this week, if you like my work let me know in the comments section.
If you want to contribute to the project, go ahead and check the project's Github page.
Take care!













