Konstruisto: Update #9 – Trees!

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!

We’re almost there now.

I pushed 122 new commits since the last update, current total 282. What has changed?

Trees

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.

A group of trees placed on the ground.

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.

Terrain chunk full of trees rendering at 62 FPS.

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.

Buildings and roads in the forest.

Game saves

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?).

Code repository

Go and see https://github.com/kantoniak/konstruisto. There are Star and Watch buttons in the sidebar (right). Repository contains setup scripts for both Visual Studio and makefile/clang++. Have fun!

Konstruisto: Weeks #8 & #9 – Added tests, first Blender model

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.

I don’t publish builds this time.

Changelog

  • Set up Google Test framework
  • Fixed missing DLLs for Windows releases
  • First Blender model

Code repository

Go and see https://github.com/kantoniak/konstruisto. You can build from there or download binary release below. There are Star and Watch buttons in the sidebar (right).

Konstruisto: Week #5 – Free lots, transportation graph

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.

Continue reading

Konstruisto: Week #4 – Roads once more, buldozer tool

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.

Continue reading

Konstruisto: Week #3 – Fighting road textures

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!).

Just like Manhattan, where’s Central Park? 🙂

Continue reading

Konstruisto: Week #2 – Main menu and settings framework

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).

Previous week

Roads learn alphabet

Continue reading

Konstruisto: Week #1 – World geometry

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.).

Previous week

We were placed by hand!

Continue reading

Konstruisto: Week #0 – First buildings

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

Video preview

Changelog

  • Project and dependencies setup
  • State manager – currently not used, but will come in handy for main menu, settings, and other screens
  • Logger
  • 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

Code repository

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.

Binaries

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.

Windows x64: Konstruisto v0.0.0-6386289 DEBUG WIN
Linux x64: Konstruisto v0.0.0-6386289 DEBUG LINUX

Controls

Q, E - rotate view
Left click - select
Right click and drag - move view
Mouse scroll - zoom
1 - toggle normals

Next week

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.