Friday, May 6, 2022

Procedural Buildings: Office Building Utilities

I spent a lot of time improving my procedural houses last year and in the beginning of this year. Now I'm getting back to putting more work into office buildings. Two posts ago I showed some parking garages with sewer pipes in the ceilings. I've been working on several different areas in the past month rather than a single big feature. I've added cold and hot water pipes, a vertical fire suppression system pipe, electrical panels, utility rooms, water heaters, and vents since the last post. The pipes are all connected to water heaters and other plumbing fixtures to form a complete system. Each of these additions increases draw time, so some of my effort has also gone into making optimizations to the code to get back to my framerate targets of 100 FPS outdoors and 60 FPS indoors.

Here are some more details on these additions to my procedural office buildings.

Cold and Hot Water Pipes

I definitely liked the way sewer pipes turned out in my earlier post. I want to add more pipes to parking garage ceilings, and water pipes seemed like the obvious next step. And why add just cold water when I can have hot water pipes as well?

I reused most of the sewer pipe code to add water pipes. These were placed above the sewer pipes, closer to the ceiling, using a smaller pipe diameter. I used copper material for the pipes and shiny brass for the fittings. I didn't have enough space near the ceiling to route hot water pipes above cold water pipes, so I put them at the same level and added cold water pipes as blockers going into the hot water pipe routing algorithm. This way cold water had a priority, and hot water was added where there was space between everything else. In many situations the hot and cold water mains ran parallel to either side of the risers feeding the main bathrooms.

Here's a screenshot. I don't particularly like how water pipes must pass through ceiling beams, but I guess it's good enough for now. I disabled cars to avoid distracting from and blocking the view of pipes in the ceiling. Note that parking garages now have yellow curbs at the ends of parking spaces and some handicap spots near the elevator(s). I also made the occasional parking garage ceiling light flicker, though you can't see that in screenshots.

Water pipes in the ceiling of a parking garage with no cars. I've also added handicap parking spots and yellow curbs.

Hot water pipes have an additional layer of white thermal insulation. I've seen buildings with this style of pipes and feel it has good contrast against the copper while also matching the ceiling so as not to stand out too much.

Hot water, cold water, and sewer pipes in the ceiling of the parking garage.

Fire Suppression

The fire suppression/sprinklers pipe is currently just a big red tube placed near an exterior wall that extends vertically from the lowest level of the parking garage up into the building. However, I did add support for extruded N-gon shapes, which I used to add hexagon bolts to connect the pipe sections together. Now I can use this system to add bolts and similar details to other building objects.

I haven't added any horizontal pipes or actual sprinklers yet. I might add these to parking garage levels at some time in the future if I can find a way to fit them. Maybe they can hang down lower than the other pipes. Or maybe I can get away with only having them along walls and away from other types of pipes. I'll have to look through some reference images to help me decide what approach would work the best and fit within the constraints of my buildings.

Fire suppression/sprinkler water pipe running vertically through the parking garage, with hex bolts.

Utility Rooms and Water Heaters

Each large office building now has a dedicated utility room on the ground floor. This is assigned to a windowless room that's as close as possible to a bathroom to minimize the average length of water pipes. So far utility rooms contain only a row of water heaters. I used the same style of vertical cylinder water heater that I used for houses, except the pipes bend down and pass into the floor below instead of extending to the ceiling as with houses. This is because the plumbing is in the basement below the water heater, while water heaters are placed in the basement of houses. At some point in the future I plan to add other objects such as HVAC components to utility rooms to use up all that wasted floor space.

Water heaters have their own hot and cold water lines that connect through the floor to the pipes in the parking garage below. The hot water main connects between these and plumbing fixtures that use hot water such as sinks. The number of water heaters is determined by the number of hot water fixtures, which generally scales with building size. Hot water flow is evenly distributed between heaters. If some of them can't be connected, a section of the pipe joining the row of water heaters is moved inside the floor itself, or somewhere else not visible by the player.

I've added signs to the doors of utility rooms as well as storage rooms and libraries using the same style I previously used with men's and women's restrooms. I plan to add more types of building signs in the future. For now they're placed on the wall next to the door rather than the door itself to avoid having to deal with rotating them when doors are opened and closed.

Office building utility room with a row of five water heaters with pipes reaching down to the floor. I even added a sign next to the door.


Electrical Panels

Once I had the plumbing done I started working on the electrical system. Houses have an electrical panel with circuit breakers placed on an exterior wall of the basement. Office buildings can have multiple electrical panels placed on the wall of the underground parking garage, if there is one. These boxes have metal conduits exiting from their tops and going into the ceiling above. I found a circuit breaker texture that I can tile to show vertical rows of breakers on the inside of the box when it's open. For some reason I was only able to find marine breaker pictures. Most of the normal circuit breaker images had poor lighting, hands or tools in the way, labels for breakers that I didn't want, etc. So I clipped off the picture of a boat and used the rest of the image as the texture.

Currently the player can only open and close the metal doors of each panel. I might add more functionality to these later. For example, I can make individual breakers clickable so that the player can disable lights on different floors and possibly other electrical items such as the elevators. I'm not sure how to implement this yet, or what gameplay purpose this would serve. I can pretty easily expand electrical panels into a series of breakers that the player can interact with to switch on and off. I would need a new system to handle tracking of which areas are powered, with some sensible default positions for breakers in panels that haven't yet been opened and generated. Maybe each breaker will need to search through the lights and other appliances in the building and disable the correct ones. That means I also have to figure out what "zone" each breaker controls. I feel that having one breaker per room is too many, and one breaker per floor is too few. For example, the building I took these screenshots from has 19 floors and 913 rooms.

This is what the breaker panels currently look like when open and closed.

Two breaker panels in an underground office building parking garage, one open and one closed.

Ah, wait. It's too hard to see the panel with the poor lighting of the parking garage ceiling. Here, the flashlight makes it all better:

An open breaker panel lit with a flashlight.

Vents

I added vents near the ceiling on walls of offices, storage rooms, and utility rooms. These are placed on interior walls to avoid having to deal with windows. If you look closely you can see one in a screenshot above. They don't connect to anything yet, they're simple wall decorations. Building walls and ceilings are too thin to add internal vents anyway. I think I would have to fix that before I can add a proper ventilation system. Sorry, I don't plan on adding gameplay where the player climbs through ceiling vents any time soon.

An air vent in the wall of a bathroom near the ceiling.

There are many possible ways to improve on these systems. Buildings have thousands of different types of objects and many different interacting systems. This is certainly an endless project!

Also, this is post #128. Yay, a power of two!

18 comments:

  1. Hey frank. I was trying to compile 3dworld recently and i noticed a build error "cannot open input file 'alut.lib' " I was wondering if there is a dependency of sorts that i need to change or if something else is wrong?

    ReplyDelete
    Replies
    1. When was the last time this worked? I don't remember changing anything recently. Also, what version of Visual Studio are you using, the most recent 2022? Do you have the OpenAL SDK installed? If you still haven't figured it out, please open an issue on the 3DWorld GitHub page.

      Delete
    2. I've tracked the issue back to a commit you made on June 17th 2021 when you removed the freealut-1.1.0-bin and replaced it with your own compile. Your custom compile is lacking the alut.lib file witch for some reason the game still wants for the compile?

      Delete
    3. Yes i do have the Openal SDK 1.1 installed on my PC

      Delete
    4. Okay i've done some more compiling and the newest source i'm able to compile is June 14th 2021. A few days after you made changes to the dependencies and starting with those changes i'm unable to compile anything newer without that error.

      Delete
    5. I'll take a look after work when I'm on the other computer. Maybe I have alut.lib somewhere else in my working directory that's not checked into git. However, I believe others have been able to compile more recently, so I'm not sure why it would work for them and not for you. Maybe they copied that library from somewhere else.

      Delete
    6. One more question. Are you using the debug or release build?

      Delete
    7. I tried building both release and debug in VS2019. They give the same error. But yea something is different on your end to allow you to compile. as you removed the alut.lib on june 17th 2021 when you switched to your own freealut compile. But it's still requesting it

      Delete
    8. I've just discovered. I took the alut.lib file from the june 14th 2021 version and put it into the june 17th 2021 version. The compiler error changes to: fatal error C1900: Il mismatch between 'P1' version '20210202' and 'P2' version '20210113'

      Witch i assume means that the alut.lib version is incompatible. So even placing the file in the compile directory wont fix it.

      You may need to add a pre-compiled dependency or something as it freealut is not compiling properly or something important is missing. This really sucks as i would love to be able to compile more recent builds.

      Delete
    9. I apologize if i'm bugging you. I am discovering new things about this issue as i experiment. I've figured out how to manually compile the "freealut" you have in the source dependencies so i can have the lib file. By using the "alut.sln" file i can compile freealut and also receive the needed alut.lib file. However with these files the compiler now only gives the error:

      mismatch between 'P1' version '20210202' and 'P2' version '20210113'
      So there is still something missing? Or is it the wrong version or something?

      Delete
    10. That sounds right. I think that's why I removed the library originally. It kept breaking with newer updated versions of Visual Studio, so I got tired of updating it and just removed it. If I always update to the latest version of VS then it won't work for someone using an older version. I wish Microsoft or alut would fix that, I don't have this problem with the other libraries.

      I'm not sure what the P1 vs. P2 error is. Maybe you need to rebuild the entire solution or some other dependencies to fix that. I don't have that error so I can't easily reproduce it. I'll try adding my library back into the project tonight and we'll see if that fixes it.

      Now that I look in my issues list someone else had that alut error a few months ago. I had no idea how to debug it, so the issue is still open.

      Delete
    11. Okay, I added the libraries I'm using for my build here: https://github.com/fegennari/3DWorld/tree/master/dependencies/freealut/admin/VisualStudioDotNET/alut/Debug
      See if that works for you. I seem to only have the Win32 libraries. I'm not sure where the x64 went, I'll have to rebuild those later.

      Delete
    12. Yes After hours i've finally managed to get passed the issue i think. So far i can now compile up to Dec 2021 as i have not tested the latest builds since VS 2022. I had to manually recompile the solution projects for freealut, freeglut-2.8.1, glew-2.0.0 and jpeg-9a. I opened the .sln solution files for each and rebuilt the projects. This got rid of the P1 P2 error and it finally dumped the 3DWorld.exe

      Delete
    13. I've managed to compile the latest May 23 2022 build :) I rebuilt the Jpeg and freeglut dependencies as needed and used the v142 build tools and i was able to compile a release build exe. Thanks for you help too. I also had to record the whole process for my own purposes incase i forget XD.

      Delete
    14. I realized that I don't actually have an alut.lib for x64, but somehow it works anyway? Is that library needed or not? I don't know. Anyway, I updated the alut project files to the latest version of MSVS 2022 (v143), built both the win32 and x64 libraries, and added them to the git repo.

      Sorry this caused you so much trouble. I'm no expert in build issues on Windows, and I haven't run into those problems you did, so I'm not sure how I would have even known that I broke it. I'm glad you were finally able to get the build working. All of my latest changes have been to buildings, which would be config_heightmap.txt and config_buildings.txt in defaults.txt. But you may need that extra models and textures directory I have on Google Drive.

      Delete
  2. Really cool that you're putting in all these utilities. Maybe there will even be some game-play associated with them at some point?
    For the utility room, there are usually some booster pumps to keep the water pressure up at the higher floors. Also, large buildings usually have boilers instead of residential water heaters, but it looks kinda neat with them all arranged in a manifold like that. You're right though that HVAC machinery takes up a lot of the space. If there is any housekeeping, the laundry usually goes in the utility room as well.
    As far as electrical, you're in the right ballpark with your estimates for number of breakers. Usually they are broken up by tenant space, with one breaker for the lights, and one for the outlets, and then one for each dedicated appliance. Some rooms have multiple outlet breakers, like the kitchenette/break room and medical work rooms. Medical buildings often have each room on their own breaker, and sometimes separate circuits for outlets protected by UPS and generator backup (to plug in critical life support equipment).

    ReplyDelete
    Replies
    1. Thanks. I'm now working on adding gas lines and furnaces. I'm not sure how all of these utilities fit into gameplay.

      I did add individual circuit breakers that the player can switch to control the lights, elevators, and appliances. I assigned breakers to blocks of rooms, which seemed like the easiest thing to do. Some of them are even labeled in the box!

      I did a Google image search for something like "commercial water heater" and saw some images of an array of individual tanks like I have. It was easier since I already have the model. I'll add other items in there later. I already have sinks for janitorial service.

      I don't have medical buildings yet. Maybe sometime in the future.

      I do have a plumbing question though. How do buildings with multiple sub-basements handle sewer lines for bathrooms below ground? I assume the sewer pipes are gravity based and must flow down, but I don't think the connection to the city sewer system would be that far underground. Are there pumps or something?

      Delete
    2. Correct! Sewers are gravity fed, so any drain fixtures that are too low have to be pumped. Usually they are collected into a sump at the lowest level, which has a macerating sump pump with a level control. Occasionally though, the sewer will feed directly into the pump, but this has the disadvantage of backing up quickly if the power fails. It's also possible to have a leech pit if the load is small and sewer services aren't available. Or you could use the Burj Khalifa solution and truck it out.

      Delete