Tuesday, September 15, 2020

Procedural Buildings: Improvements to Interiors

I've continued to improve 3DWorld's procedural building interiors over the past few weeks. I added some new room objects and models, some of them based on suggestions from other people. I'll describe the additions to houses and office buildings, and show some pictures in the approximate order in which I added them.


Bedrooms were often too large and sparse. One way to use the available space in larger bedrooms is by adding closets against one wall. There are large closets with 4 panels of folding doors, and smaller closets with a single door that opens. Closets can span the entire length/width of a room or only part of it. Closets must be placed to avoid blocking windows, doorways, or access to furniture such as beds.

Here are two screenshots showing a large closet and a small closet. I haven't yet added door handles to large closets.

Bedroom with a large closet in the back.

Bedroom with a small closet in the far corner.

Next I added trim along the edges where walls meet the ceiling and floors. Then I added trim around doors and windows. This makes it easier to tell where the wall and ceiling meet for buildings like the one below that have the same wall and ceiling textures. The screenshot above also shows trim along the walls and door.

House interior with wall trim around floors, ceilings, windows, and doorways.

Note that this trim accounts for a large number of polygons when you add up all the small quads needed, especially around all of the windows. Sure, they're only individual untextured white cubes, but there are more of these in a building than any other object (except for maybe books). This does finally add real 3D geometry for windows, which are cut into the zero width exterior walls using textures. As an optimization, trim is only generated and drawn when the player is very close to a building. Office buildings don't have quite as much trim.

Kitchens needed a bit more work. The kitchen sink was previously only a basin with no faucet. I added a simple two-cube faucet as a placeholder until I find a better model. I also added a dishwasher under the counter next to the sink if there was enough space. The most difficult part was disabling the cabinet doors around the dishwasher and adjusting their positions so that they start and end on either side of the dishwasher with no clipped or small doors.

Kitchen cabinets, counters, sink, dishwasher, and stove. The dishwasher has a shiny metal handle.

I decided that I liked railings better than straight vertical walls for the smaller sets of stairs that appear in houses and some other building types. It took a bit of work to add support for arbitrarily oriented cylinders, but I now have that working. I also added specular color support to the building materials system so that railings reflect light like proper shiny metal objects. You can see this used on the dishwasher handle above as well. This looks much better (and safer) than stairs with no railing at all. Here is an example screenshot, with the railings in beautiful gold.

Simple cylindrical railings have been added to open stairs.


When I was happy with houses, I moved on to improve office buildings. All those cubicles looked pretty bare. I decided to find a 3D model of a rolling office chair and place one in most cubicles with a random rotation. Right now the chairs are untextured black materials because I couldn't find a free model in a supported format that had proper materials with textures. This doesn't look too bad though, especially considering my chair at work is completely black with little texture.

A large office building room containing cubicles and rotating office chairs.

Adding chairs makes offices look better. But they're not lit very well with a single light in the center of the room. I increased the number of lights for some rooms using an X by Y grid of lights based on room size. Smaller rooms still have a single light, but larger rooms can have a 2x1 or 2x2 array of lights. There may be rooms with more than 2x2, but I haven't come across any yet.

Large offices can now have multiple light sources, usually an array of 2x1 or 2x2.

Desks were too empty, even though some had books on them. I decided to reuse the TV model as a computer monitor to put on some desks. I downloaded several screenshots and used one of my own desktop to create illuminated texture images on some of the monitors. These desktops are a mix of Windows, Linux, and MacOS. Monitors are more common in offices but can also be placed in houses. For now I haven't attempted to make the operating system consistent within a building.

Office desk with a monitor on it, turned on and showing a desktop.

The next step was improving bathrooms. Those individual tall sinks looked fine in residential bathrooms, but larger office bathrooms usually have a single long slab containing multiple sinks. I reused the kitchen sink code with some modifications for these bathrooms. Now the sinks are part of one counter with multiple basins and faucets, as seen below. Also, office bathrooms can have multiple lights as well.

Individual sinks have been replaced with a single long counter with built-in sinks for office bathrooms. They can now also have multiple lights.

I finally found a usable free urinal 3D model to place in the men's restrooms. I even added short walls between the urinals for privacy. Now they look like a proper men's restroom.

The Men's restroom now contains urinals.

I made various other fixes and improvements as well. Some houses have brown wooden front doors instead of white front doors. Straight stairs have walls on the sides or railings to keep people from falling off. The room object placement algorithm has been adjusted again to take into account clearance around objects to prevent the player and AI from getting stuck/blocked. Refrigerators are no longer placed in locations that block windows. Oh, and houses now have a number of bathrooms that scales with the size and number of total rooms in the house.