top of page
  • kyle890229

Mini City - Midterm Update



I have been working on fixing bugs and rework the sidewalk since the last post. The main issue I was trying to fix is the mesh of the sidewalk will overlap itself if the the width of the sidewalk is too wide.



The way I generate the sidewalk before was extruding the road edge out along the point normal. However, It happened because I was using the subdivided edge and there are too many points at the corner. They are going to pass through each other as they extrude out.



To fix this issue, I am using the none subdivided version of the edge, so there's only one point at each corner. I also separated the road edges into fill and expand groups. Fill the edges that are closed, and expand out the edge if it's not. Thus, I can have faces I can possibly use for generating buildings, and also avoid small edges extrude and overlap because the width is too high.




For the expanding edges, I transfer normals from the subdivided edge to get a more accurate normal angle. However, there is an issue with this method because the magnitude of the normal is all the same.



Edges will not extrude out evenly because the normal is at an angle instead of perpendicular to the edge. As the image shown below, the point is not actually moving out the same distance in the perpendicular directions as other points that the Normal is at 90 degree angle. In order to make the edge extrudes evenly, I have make the magnitude of the normal bigger.




To solve this, I used measure node to calculate the curvature of each points in oder to make changes to the corner points. After that, I calculate the normal by finding the average direction vector by adding directional vector pointing toward the previous and the next point.




The result is working very well with some exceptions. The new normal is an average direction from the points before and after which means it is pointing toward the middle of those points. It will point in the opposite direction when the edge is turning the opposite way than the normal.



The issue was resolved by using the dot product to compare the new normal with the old transferred normal. The dot product will return a positive value if the two vector directions are less than 180 degrees apart and return a negative value if its more than 180 degrees. Therefore, I can flip the normal if it's going in the opposite direction from the transferred normal since the direction of the old normal is correct.



After solving these issues, the sidewalk is working nicely no matter the width of the sidewalk the user chose, and I can start working on adding randomize buildings next.


Here is a quick breakdown of how the city generator is working right now.



Comments


bottom of page