It’s been a long time since the last update – exactly 993 days. Luckily, there are new features coming in, what lead to implementing… trees!
I pushed 122 new commits since the last update, current total 282. What has changed?
A completely new feature, you can paint trees over terrain. Brush supports modifiers:
Shift increases brush radius
Ctrl decreases brush radius
Alt will switch to single tree placement mode
Placing building or a road will remove all trees on affected tiles.
New rendering pipeline
I spent majority of time implementing a new rendering pipeline for objects. After engine loads models through Assimp, new renderer packs them up to a single buffer for static geometry. It also holds definitions of materials (basic Phong shading right now). On flush() renderer sorts all draw commands to minimize state changes and sends OpenGL batches to GPU. Instancing is supported with transform matrices per instance.
New collision system
I created a new, simpler collision system where bodies are separate from game object representation. With layers, you can for example place a road which crosses another one, but not a building. This also fixes a few weird quirks when placing roads.
Combinations Ctrl+S and Ctrl+L will save/load buildings, roads and camera position. This is a feature from 2018, I’m yet to port it to new collision system (in February?).
Since the last post, I took some time to better prepare environment. That means there are no new features. I pushed only two commits, total 160. I did set up Google Test and modified makefile to include missing DLLs for Windows releases.
My first low poly model
I also started playing with Blender to make some models. It takes a lot of time and there are lots of new things to learn, but I managed to finish a simple hospital model. I don’t know yet what should be published in the repository for blender models and I didn’t decide on file format yet, so it’s not included in the repo.
To move forward I started working on zoning. There is a new type of object representing a lot. Buildings will grow on these later. Currently, there is no zoning by mouse, even though option appears in the menu. Regarding roads, I started road network graph. I think I will finish intersection rendering next week. Pushed 10 commits, total 131.
This week was pretty tough on me, so the update comes late. I made a bulldozer tool for buildings. All the buildings in selected area will get removed. I added the executable icon, which is also visible in the window title. There’s new menu to choose the tool, I have to create some decent icons since temporary ones are awful 🙂 Pushed 14 commits, total 121.
Honestly, this week was quite unproductive, speaking of new features. I managed to resolve most of the problems with textures (but it’s still WIP, there are some minor artifacts). I wrote needed geometry checks for the roads; standard intersections render correctly. The rest of the time went for some refactoring and code cleanup necessary to paint on ground tiles. Pushed 16 commits, total 107 (over 100, yay!).
Previous week I mentioned road implementation. I started with rendering and got stuck a bit while handling texture atlases (search for GL_TEXTURE_2D_ARRAY if you’re interested, I even may write an article about it). Roads are half-done then. I moved to easier stuff and made menu state and settings (in code so far). UI renders textures now; it took me quite a lot of time since I missed there is a function for loading images and wrote everything by hand at first 🙂 Use G to turn off the grid. This week I pushed 21 commits (total 91).
This week was a bit slower than previous (I pushed 24 commits, total 70) since I needed to introduce some graphical user interface. I went with NanoVG library, which lets me draw basic shapes and text. There’s a new top bar with essential information about the city. You can place buildings now. I worked a bit with geometry to make a foundation for zoning (you assign a zone, e.g. residential, and people build if you provide media, low taxes, etc.).
Every Friday I will post updates of what I did. I started eight days ago (so it was longer than a week) and pushed 46 commits (changes) to the repository. The project went from a triangle to buildings.
The first brick occurred to be a triangle, not cuboid 🙂
Looks like a playable thing
Project and dependencies setup
State manager – currently not used, but will come in handy for main menu, settings, and other screens
Camera and input handling
Basic renderer for chunked terrain (first textures ever) and buildings in flat shading manner (will have to add SSAO)
Selecting fields with mouse, rendering selection on terrain
Normals preview for debugging
Linked UI library
It is an open source project; you can find Github repo here: https://github.com/kantoniak/konstruisto. Feel free to build and try, comment on the commits or participate in any other way. I write a game for the first time, so any tips are welcome.
If you don’t know how/don’t want to build, there are x64 binaries for Windows and Linux. I hope everything works fine, please let me know of any problems.
Q, E - rotate view
Left click - select
Right click and drag - move view
Mouse scroll - zoom
1 - toggle normals
I would like to think of simulation part, starting with time speed. I need a little framework behind this. Another thing is geometry – buildings of different sizes, checking for collisions. Also, I wrote a lot of bad code; I would like to refactor it a bit.