You are standing in a quiet forest. Several trees, softly touched by the wind, are blocking your view to the horizon. You see some hills, bushes and flavorsome flowers. With a single snap of your fingers you start an out-of-body experience: From a bird's eye view you can see your own body in the forest. You start to draw lines very easily on the ground that suddenly transform into walls. More of your lines result in even more walls. You combine them to wallpapered rooms and cover their floors with carpets, laminate or marble. Even windows, doors and furniture can be placed in seconds. Finally, a garden with several vegetables surrounded by a cozy fence is your last work before a second snap of your fingers returns your consciousness back to your body. You are now inside the building you've created minutes before and are free to move around and to interact with everything you've placed.

That's what the first milestone of GWAIN - a game without any interesting name - is supposed to be.

  • View media
  • View media
  • View media
  • View media
  • View media
  • View media
Post article RSS Articles

It's time for another update to show you that the project is still alive. Here are the topics I dealt with this time:

  • Organic Tiles
  • Boolean Operations on Polygons
  • BEPU Physics Integration
  • Some Optimizations
    • Support for meshes with more than 64k vertices
    • Random Number Generator
    • Region Files

Organic Tiles


When I first started this project I aimed at making the whole world look more organic than Minecraft does. Therefore I was in need of a counterpart to the sharp tiles for carpets, laminate or other urban ground texture. I always thought about supporting organic tiles as in Warcraft 3. To cut a long story short: I did just that!

Screenshot of the terrain with organic and inorganic tiles at the same time


Technically, I am just blending four uv sets in a shader but it required me to write code that separates all parts of the terrain using four uv sets from parts that only use one uv set for performance reasons. Additionally, organic tiles will use more space in the texture atlas but it's absolutely worth it.

A pixel art grass tileset


Boolean Operations on Polygons


Placing windows and doors requires the game to cut holes into the walls. My first implementation for this hole cutting mechanism was trivial in that it only allowed simple holes, i.e. only one hole for each wall segment, the holes needed to be rectangular and their edges had to be paraxial. However, I want to be able to place more interesting structures, e.g. garage doors that might overlap two wall segments or circular shaped windows. To do that I started implementing an algorithm described by Martinez et al. It turned out to be not very robust due to floating point issues. Further investigations lead me to a programmer called Sean Connelly who had similar issues and invented a better polygon clipping algorithm. His algorithm isn't robust in a mathmatical sense but robust enough for practical use cases like mine. However, all these clipping algorithms only deal with polygons, so I still have to triangulate them. For that I had to partition the resulting polygon into y-monotone polygons because monotone polygons can be triangulated in linear time. I did just that as you can see in the following video:


The partitioning algorithm has similar floating point issues as the original clipping algorithm by Martinez but I hope that I will be able solve the problem.

BEPU Physics Integration


In one of my old articles I said that I've implemented a dynamic character controller. In turns out that I was wrong: creating a dynamic controller in Unity isn't possible or at least way too difficult to be practical. By looking for a way to deal with this problem I found a physics engine called BEPU. This library already contains an implementation for a dynamic character controller and it works like a charm. The developer Ross Nordby said that he was trying to reach the quality of the character controller of Valve's Source engine and I think he nailed it but it gets even better. Version 2.0 of his engine will support reconstructions of collision meshes over time, i.e. the hickups I am getting now due to reconstructions being expensive will hopefully go away since the work will be spread over several frames. I am really looking forward to it.

Some Optimizations


Some of the additional things I've done worth mentioning are my custom XorShift pseudo random number generator based on the work of George Marsaglia. The random number generator of C# is based on a modified version of Donald E. Knuth's subtractive random number generator algorithm and it has two drawbacks: it's quite slow and you can't change its seed unless you create a new instance.

I've also implemented a mechanism to support meshes in Unity with more than 65535 vertices. Unity uses index buffers based on unsigned shorts therfore the strange limit. It is unlikely to happen often but if a player places too many detailed props, walls, windows etc. in an area this limit might be exceeded and in earlier versions the game might have crashed so that's why I had to support it.

Last but not least, I've implemented a region file format for saving terrain chunks inspired by Minecraft's region system. Previously I've opened one file for each chunk in my world. Now, I'm just opening one file every 1024 chunks which should speed things up a bit at least during loading and saving.

Distractions


Wait? Another paragraph? Well, there are some more things to tell you: I've got sidetracked! Every now and then I need a break from the work on this project. Some of the problems I have to solve for this game can become really frustrating or cumbersome, so I try to get new motivion by doing something else like programming a game. Wait? What? Yes, that's right. I just wanted to test my skills or I wanted to see if an idea works without the intention of finishing it. So here are some other things I've done since my last update:



By the way, you can find some of the code I've created in my GitHub account. For example, there's a conversation editor I've programmed for Unity that is inspired by the conversation editor of Neverwinter Nights. The source code for my random number generator called XORShiftRNG or the Martinez Polygon Clipping Algorithm can be found there, too.

My GitHub Account: BrightBitGAMES

Thanks for reading and let me know about any questions in the comments!

BrightBit

Character Model Progression

Character Model Progression

News 6 comments

Another eight months have passed so I thought it's time for a sign of life. For this update I want to show you some character related things that I spent...

Improved build mode, inventory system, cockpit view and more

Improved build mode, inventory system, cockpit view and more

News 13 comments

After four months it's time for some explanations. I've done a lot: a new inventory system, better player physics, more and improved build mode features...

Unity 5, minor improvements and some obstacles

Unity 5, minor improvements and some obstacles

News 3 comments

An upgrade to Unity 5, which enables ambient occlusion, deferred lighting and much more. The A* Pathfinding Project didn't meet my requirements, i.e...

Improved graphics, better GUI and even more

Improved graphics, better GUI and even more

News 7 comments

I've implemented some rudimentary pathfinding algorithms, I did an overhaul of the GUI, created a new vehicle and did some other interesting stuff. ;)

Add file RSS Files
PRE-ALPHA Prototype 0

PRE-ALPHA Prototype 0

Demo 6 comments

This is an early and incomplete prototype for the build mode in GWAIN. It's out of date but it might still give you some insights about its potential...

Post comment Comments  (0 - 10 of 19)
Vladiskov
Vladiskov

Also to question, it have (or will have) a city generator? because creating every building get boring too fast XD

Reply Good karma Bad karma+1 vote
BrightBit Creator
BrightBit

Yes, it will have a city generator. I totally agree that it would get boring otherwise, too fast.

Reply Good karma+1 vote
Vladiskov
Vladiskov

i hope you place a editor to the generator, you know like to place one's building in the seed :D

Reply Good karma Bad karma+1 vote
BrightBit Creator
BrightBit

I have something like this in my mind but it's still a long way to go.

Reply Good karma+1 vote
Vladiskov
Vladiskov

my error wasnt the seed but the building's pool

Reply Good karma Bad karma+1 vote
paraminerstudios
paraminerstudios

Unity free or pro?

Reply Good karma Bad karma+1 vote
BrightBit Creator
BrightBit

Unity Free with some commercial packages however: NGUI, Master Audio, Better Trails, etc.

Reply Good karma+1 vote
Vladiskov
Vladiskov

i love it gta in pixelate glory!

Also while the resolution its great and cool, the bigger one had a retro air in it XD

Reply Good karma Bad karma+1 vote
BrightBit Creator
BrightBit

I agree with you but keeping the low resolution would have forced me to use a lower resolution for the props/furniture as well. And that just didn't feel right.

Reply Good karma+1 vote
Guest
Guest

This comment is currently awaiting admin approval, join now to view.

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account:

X

Latest posts from @brightbitgames

Alright, my article was authorised: Indiedb.com Have a nice read! :)

Apr 11 2016

I've written an update article on IndieDB. It still needs some time to be authorised, though. I will keep you posted. :)

Apr 11 2016

I'm still working on GWAIN but because of a new job I'm currently running low on (spare) time. :/

Nov 18 2015

Awesome! Unity 5.2 is out and that means that the crashes caused by a WheelCollider bug are gone.

Sep 10 2015