Camera + specular-map lighting + more

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.

Continue reading “Camera + specular-map lighting + more”

Turning a Cube into a Sphere

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.

Vertex points of a cube
Vertex points of a cube

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.

Continue reading “Turning a Cube into a Sphere”

Textured Sphere and The Economy

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.

Earth UV mapped sphere
Earth UV mapped sphere

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.

Ugly UV mapping
Ugly UV mapping

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.

Continue reading “Textured Sphere and The Economy”

The Last Boundary – A Game of Universal Domination?

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 Concept

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

The Tools

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