The UI is coming along nicely (I need to work out how to do animated gifs to show stuff off). It’s widget based with a good input handling system, I just need to work on using several textured quads so that the windows can be styled nicely.
I’ve also done a bit of work with post-processing effect shaders to produce a glow on the more luminous areas. Here’s a couple of screenshots showing the sun from the perspective of an Earth and the result of the reflection of sunlight over the desert (it’s not quite right over the ocean yet, so still need to work on that).
I’ve spent quite some time investigating the various Text/Font libraries for both SDL and OpenGL. I first looked at SDL_ttf which seemed like the most obvious choice. Unfortunately I could either not get it to compile, or when I did it just threw errors when I tried to use it. I also took a look at a whole slew of OpenGL based ones, however out of the 4 or so I found, only one appeared to be compatible with OpenGL 3.3+; but it lacked some features I wanted to use. In the end I decided to roll my own using FreeType2. I didn’t want two additional dependencies, so this way I only need one. And everyone uses FreeType2, you’d be insane not to. Here’s some pretty straight-forward results.
One of the things that I definitely wanted to include in the game was the effects of time-dilation. However I only really had a vague understanding of what it is and what it means, so after reading that Wikipedia article I’m suddenly confused.
The Last Boundary is, I’d like to think, going to be a Grand Strategy Game. One of my favourite Grand Strategy Games, one of my favourite games ever, is Hearts of Iron III. One of the things that makes HOI3 so good is it’s attention to detail, at least it’s attention to detail regarding waging war during WW2. Things like supply lines play a crucial role; researching advances in radio equipment is beneficial.
In this same vein I want The Last Boundary to pay close attention to similar sorts of likely problems that would affect a space-faring empire and waging space-war. For example, distances, communication and the affects of time-dilation.
I’ve spent the last couple days trying to work out view-space vs world-space and how to incorporate lights into my shaders. It’s been difficult. The concept of a View space vs World space and when to use which is not a simple one.
Anyway, I now have materials with specular maps and diffuse maps (and a fallback to color when diffuse isn’t provided). My shaders are all working correctly and producing the lighting effects. I’ve also added a arcball type of camera only because I needed to see the lighting move around in real time.
Forgive how horribly stretched it looks, it’s due to the only cubemap of the earth I can find on google being created poorly, not due to my implementation.
And here’s that same south pole, you can see how it’s not wedged in, it’s its own full texture. This is a much better result.
So, I read a couple of interesting articles about how to do cube mapping. The most straight-forward way I found was about using a cube to generate a sphere. This makes sense because you don’t need to do any insane math to work out the S,R and T coordinates of your cube texture.
Well, that’s what I’ve gone ahead and done. However, these vertices aren’t in any particular order; so tomorrow night I’ll need to work out a way to index them so that triangles are drawn. This was pretty easy, I haven’t looked at the code below to optimize it in any way; it just seemed like the logical way to produce the vertices.
UV Mapping a Sphere
After another couple of hours I’ve figured out what UV coordinates are and have managed to texture my rotating sphere with earth.
I’ve been reading that the best way to texture a sphere is with a Cube Map, so that’s the next thing to learn now. For example, if I move the camera to get a good look at the south pole (of my sphere) and then move my texture a bit, you can see how the UV mapping leaves a lot to be desired.
Understandably it pinches in the 2D texture. The best way I read this described was that it’s like trying to wrap a piece of paper around a basketball.
Thinking about a simulated economy
One of the things that I’ve definitely wanted to have in The Last Boundary is a simulated economy. As your mighty space empire grows the various sectors of the economy would produce supply and demand which would naturally result in the cost of your fleet and other projects rising and falling. Different government models would probably affect this in different ways.
Well, after learning a few things about OpenGL I’ve solved my problem via the GameDev.net forums and have produced a rotating, colourful sphere.
This is important because it’s essentially… 1/3rd of the entire graphics needed for space stuff.
This is the beginning of a Dev Blog for a very ambitious project. It’s particularly ambitious considering that very few of my game projects (i.e. I nearly completed one) ever make it to a playable state.
However I have learned over time that I’m good at getting a single aspect of it down and done. So; this is how I will approach my new project, a series of small incremental steps, each completed before moving onto the next. If this means my workspace ends up with 100 projects for 100 .dlls then so be it.
The game concept that I’m trying for is, at this stage, simple on the surface but very complex underneath. This isn’t by accident, in fact I think it’s the only way to keep my interest in the project for the coming years to be able to keep it going. By comparison, my last half-finished project was something I had worked on for around 2 years before I scraped it for this one.
What I’m aiming for is a game like Galactic Civilisations + Hearts Of Iron + Civilization. That looks to me like I’m making a 4X game.
Some of the key things I want to include are (in no particular order):
- Very pretty graphics
- Real-time game
- Complex AI for diplomacy and tactics
- Manufacturing and Trading playing into a simulated economy
- Deep gameplay, but not micromanagement
- A randomly generated universe for each play-through
- Using newtonian physics for the n-body problem
- Randomly generated “heroes”, i.e. named characters for both the player and AI players.
- Give these heroes traits (positive and negative traits)
- Give these heroes experience and bonuses
- Both large and small fleets consisting of realistic ship types
- In-game time is consistent with real-world timeframes (1000s of years to get to the next star?)
- Automatic battle resolution in real-time based on numbers and dice
I have no love of other libraries and tools. I took a look at a few 3D graphics engines but they had either too much game stuff in them, or they were confusing. Orge 3D looked great but wouldn’t build for me, Irrlicht didn’t have everything I’d thought I’d need; and after going into the code found that some of the implementation was silly. Horde3D wasn’t much better than Ogre and looked like it was dead for the last year.
One of the reasons I hate open-source libraries is their tendency to have 5000+ dependencies on other libraries. Trying to build something under my platform (I’ll get into it later), is really hard. The other problem with this is that all these different libraries licenses scare me. On the 1 in a trillion chance that my game would be viable commercially, I don’t want the lefties coming for my code.
So I’m building my own.
I use SDL2 to handle my windows, input and sound. I’ll be using OpenGL for graphics. The reason is simple really, I hate relying on Microsoft and I might one day want to port to OSX or something, so this will help. I’m developing on Windows using a 64bit build of Mingw-tools that has thread support. My code is 100% C++11.
Today my only dependencies are SDL2, GLEW and GLM.
Where it stands
Today I have some solutions to AI pathfinding and to some aspects of randomly generating the universe, like an n-body problem simulator. These past 2 weekends I’ve been working on the graphics, which are proving to be very very difficult for me to master. At present I have a rotating sphere that is crashing, if anyone can help, it would be appreciated http://stackoverflow.com/questions/25948992/opengl-segfault-in-gldrawelements.