Week 2 - Wall Segments

This week I have been focused on figuring out how I plan to define and store wall segments that vary greatly and be able to use them to generate walls nicely.

Wall Segment Research

One of the challanges of making a building generator is how to define wall segments with or without windows and doors and how to connect them together nicely when even their pivot points can vary. To answerr that question I took a look at a couple of procedural building generators that don't use a modeling software like Houdini to adjust the meshes.

The first generator I looked at is BuildR which is Unity tool for proceduraly creating buildings with both exteriors and interiors and has been around for 7 years. BuildR's website has a lot of information and demos to help users but they also have a concepts page that explains how building blocks are made and how they work together. They have a custom wallsection asset that the user can modify to design the building blocks they need, the parameters for the wallsection can be found here. I liked BuildR's idea for letting the user define the wallsection and being able to store information about the it so I ended up implementing a similar idea.

The second building generator I looked at is here. This one didn't have a lot of implementation details but for this demo they used a free asset pack from Unreal (Soul: City) so I decided to download the pack to get an idea of how they used it. The pack has a variety of modular wall pieces (with the same size) that can easily be placed next to each other and blend in, most of the wall sections have a bottom left pivot points but some of the wall sections for top floors or multi-floors and some of the building decorations have different pivot points.

Wall Segment Implementation

I spent a lot of time this week setting up the wall segment class. I didn't know what base class would have enough controls for me to display the segment and the offset so I experimented with a couple. I first tried to use a StaticMeshActor but quickly realized it's too limited and doesen't even allow mesh transforms (with the exception of scaling), it can store the info I need but I wouln't be able to show the user the offset for example.

The other two base classes I spent a lot of time deciding between are a general Actor and a SplineMeshActor. An Actor can have a static mesh component that can be offseted in relation to the pivot of the blueprint, however the information like the relative location of the mesh can only be extracted from an instance of the actor and so I would have to create an temp instance to extract the info and then delete it; it was definetly a possibility but I decided to look more into SplineMeshActors because they work will for objects that are meant to be connected together.

A splineMesh in Unreal turns any mesh into a segment with a start and an end positions and start and end tangents instead of a the normal positon and rotation; they work great with splines because they are able to bend meshes since they manipulate the vertices. The mesh can have an offset on the spline and the rest of the adjustments can be done by manipulating the start and end positions and tangents. Also, since SplineMeshActors inherit from Actors they can also have other components if needed but they have the SplineMesh as the root and provide easy access to it. The video below a demo of my current ModularPiece class which is derived from a SplineMeshActor. I plan on adding more parameters to this class as needed.

Using the Wall Segments

While working on the ModularPiece class I also attempted to extract the data from the generated blueprints and using it to make walls. The main challenge with this was to make sure the walls face the outside. Currently the spline points are not snapping to a multiple of the segment size casuing the gaps at the end of the wall but I will work on that when i work on the floorplan.

Research on grouping wall segments by style

Since wall segments with windows and doors have to match I have been trying to figure out how to provide a group container. I didn't spend a lot of time on this but I looked into using Unreal's ObjectLibrary which is just basically a container for homogeneous assets and would work for my MosularPiece variations.