Get it on Github

Alexandria is a lightweight book generator that can be used to quickly add detailed book stacks and rows for set dressing. Utilizing Unreal’s PCG (Procedural Content Generation) framework it gives you control on how you want your books displayed. If you guessed it’s named after the famous library, you’d be correct. I know, I’m suuuper original, but I’m a sucker for theming.

Why?

I found many similar book generators, however none of them were based on PCG, I like to future-proof my projects and it’s clear Epic is pushing PCG very heavily, which is a good thing, in my opinion, because it’s an incredibly powerful and versatile tool.

The documentation and in-depth tutorials are a bit lacking, but Adrien Logut’s Youtube channel is an amazing resource. If I’m correct, he’s also one of the people working on PCG at Epic, so the knowledge is coming straight from the source.

Another reason was performance, PCG is more and more performant with each new engine release and has been built with performance in mind. For example, when you spawn a static mesh with it, they are instanced by default. Things like that save a lot of time when you are developing a game solo.

How?

The gist of it is, that I made a custom point generator blueprint, that can be found in the plugin’s content folder under PCG/BP_PCG_GeneratePointsForBooks, so you can see for yourself how it’s working. It has some parameters you can control, gap between books, scale, random rotation with min-max values among other things and an array of books you can set. I made the generation deterministic by using seeds, meaning it will always generate the same results based on the seed. You can change the randomness by changing the seed.

Seed based generation

Points are also generated with the bounds of the book meshes in mind. The generation algorithm is aware of the selected book’s size and will make sure the next mesh doesn’t overlap with the previous one. This took the most time to figure out so that it’s more or less mesh agnostic. Meaning you can plug in almost any sort of book mesh, granted they they share the same orientation.

A group of 5 books, 2 with grey covers and 3 with yellowish/orange covers. Each book has a transform gizmo showing their pivot point. They are set on a wooden shelf. There is a checkered floor in the background and clouds in the distance.
Inconsistent pivots are taken into account when calculating positions

Manual control

I also wanted some manual control to add a bit of personal touch to each generated stack. You have the option to add and arrange individual books. I think small touches like these can make game worlds more believable.

For free? In this economy?

It’s one of my core beliefs that knowledge should be free and accessible. We have everything to gain from sharing stuff others might find useful and nothing to lose. Okay that’s not entirely true, I could put this up for sale and make a few euros, but I would rather have this knowledge out there for others to pick up without any kind of paywalls.
Maybe someone makes something even cooler with this.

If you really enjoy this plugin, found it useful and would like to compensate me in some way. I’d ask you to donate to a charity instead. Below you can find a few links where your money could do some good, but if you are donating already to some of your preferred ones, I’d ask you to throw in a little extra the next time you do.