This year we have had a lot of discussion going on about how we would like to go about building our game engine. With about a week and a month left before its due, most of us have decided to build it using a component based engine architecture.
This post was helpful for a good 5 min intro to the topic. Here is pretty much a summary of it:
The base concept is rather than having a giant monolithic class based game structure (above), we want to inherit from a base class that gives everything full functionality. Imagine the base architecture of Unity. Everything starts of as a GameObject. You can add scripts, models, and other functionality to it by dragging items onto it.
The problem with the monolithic class structure is that classes end up having the same functionality and in return things get really messy. Most games get around this by making a really large base class with lots of functionality while having the subclasses turn functionality on and off. This becomes a problem when adding new features because items have to be able to coexist with one another. Since we pretty much add functionality to our game engine the entire year, adding functionality has to be really simple and we don’t want to waste the precious time we have taking one step forward and two steps back.
Say we have three main game items in a component system: a Player, Enemy and Item.
Spatial Component – Allowing it to exist in the world
Renderer Component – Allow objects to be drawn into the screen
Movement Component – We may want to control the player through a keyboard system, enemy through AI and the Item through world physics
Misc Components – We may want some objects behaving different from one another. Like giving some objects health.
Our component class would look something like
We are currently working on some sort of implementation of this system. We have split up into 2-3 engine programmers and 1 person working on getting animation to work using a skeletal animation system. That latter job will most likely be mine, and it shall be quite the interesting job to take on! I have already done some research with the mesh skinning shader and we have a rigged character to test with. All thats left is to make a demo that will work.
Its been a while since I have posted about anything to do with this class. This is because of the shotgun of work being blown my way recently. 3rd year game dev = hardest year yet. Its hard in the sense that there are not enough hours in a day that allow me to accomplish everything required of me. So its gotten to the point where some work gets prioritized over others and the rest falls through the cracks.
Anyways moving onto Ogre. Its an amazing engine from what I have seen of it. The only issue is that it requires a higher level of programming skill to debug. Last year the errors were solvable through simple debugging methods (stepping through, print statements, etc.). This year you really have to have a good handle of how your code gets compiled and what it is asking the engine to do. Which involves using the call stack. I don’t really know how to use the call stack that well, so this is an EXCELLENT learning opportunity.
So the easy question deadline got pushed to Monday. I managed to finish 4 easy questions (1-2. 4-5).
Easy_1 was easy. The key was understanding how Ogre worked. Create a Scene node pointer for your entity to attach to. Create a entity pointer that you attach to a prefab cube and all thats left are the two lights.
Easy_2 was a bit more work. This question was mostly about understanding the hierarchy of the parent-child relationship of scene nodes. We know that we have to create 10 separate cubes for the robot arm. Right away you should think about 10 scene nodes and 1 entities. But it would be stupid to make them all children of the scene manager. So you would just make them all children of whatever entity they would be rotating around. The only problem about only having 10 scene nodes is that the rotations look fairly wonkey. You need to have rotation joints halfway in between each entity.
Easy_4 was probably the most ‘difficult’. Since it involved dealing with .material files. They are still simple however. Once you figure out how to edit the resource.cfg file to load resources into your game, the next step is the .material file. Its pretty much a plaintext structure that is easily readable. You just need like 5 lines of code to create your textured material for your ingame object.
This goes after pass. scene_blend does something with the alpha values, and I had to turn the lighting off because I was having an issue with the object turning black for some odd reason (Thanks Kevin! @Iceninja77).
This goes after texture_unit. This pretty much textures your object.
The rest of the code involves making 4 planes rotated at 90, 180, 270 increments textured to look like an imposter and calling the createBillboardSet command to create your billboard.
Easy_5 was probably the one I finished the fastest. TwoLoc has an interesting dynamic texture class and a base example called BlitTexture something that is a huge help for this. If you use this as your base project and solve a small error you are worthy to use it! There is a function randCol(x,y) that can access the data of a pixel on the plane/billboard that you would like your texture to be put on. You can modify the RGBA values given a row and column point. So be creative and make something cool! I was lazy so i just made a few designs using a for loop. Some people made mini-games, drawing tools and even an etch-sketch!
I don’t do this often, re-blogging that is. This time I have to make an exception because I read a great post from an ‘anon’ user on a forum that offers some pretty great insight into the ‘new’ Microsoft. I am sure many of you have heard about Notch and Gabe Newell’s opposition of Windows 8 and their Metro UI. It has gotten to the point that they will not support the OS with Minecraft and Steam accessibility.
Here is the post:
“Market has changed in the last couple of years. Microsoft has always been reliant on desktop PC’s and their monopoly (once they got it). They focused on software and were pretty happy with the things as they were. Executives weren’t willing to go out of their comfort zone and explore new markets. They only acted once competitors succeeded in different markets (Xbox, Zune), even then, it was always a half-assed attempt that got abandoned in favor of bigger and better things (Xbox is pretty much the only exception, maybe along with .Net).
Apple on the other hand started out as a hardware company. Like Microsoft they stuck with what they knew, this almost made them bankrupt a few times, but they were able to survive long enough to see the hardware rejuvenation era (cheap labor, basically). They (just Jobs at this point) realized they can’t survive with just sticking to what they know, so Apple started to buyout lots of talent to expand their product portfolio. Which led to the Ipod and Itunes. Since Apple produced closed platforms since the dawn of time, these new products had a closed ecosystem as well. Fast forward to Iphone and the age of 3G, WiFi, always on internet (not to mention brilliant ad campaigns), they became hugely successful because they were the first to mass-market the advances of the technology to non-tech-savvy population.
This is incredibly alien to Microsoft. In the last 10 years, they’ve witnessed the creation of the biggest market ever, but they weren’t willing to do anything about it. Now that the Apple have become the biggest corporation in human history, they woke up.
They woke up, because this kind of market shift happened before to many other industries. Cinemas, were the dominant form of visual entertainment, now everyone has a big screen TV and can watch any film they’d like via DVDs/Blu-rays. Cinemas are still big, all around the world. New movies always come first to the movie theaters, but the sheer number of people who have TVs at home just dwarfs it. Effectively, cinemas have become a niche product. Still profitable, but not as profitable as others. I wrote this as an example that this kind of shift happened before and everyone can relate to it someway, it’s not meant to be a perfect representation of current events mind you.
It’s simple, Microsoft doesn’t want to become a niche developer (still big, profitable with stable growth, but a niche compared to other markets). They want to exploit this new market, and they are late to the party already. They need to act, and they need to act fast, otherwise it may be too late (if it isn’t already).
Cue in Windows Phone 7. It should have worked, but didn’t. If you ask any WP7 user, one thing they are sure to complain about, is the lack of selection on the software side (apps, needs apps). Microsoft knew this would happen, so they tried to lure their desktop developers with known tools (C#, XNA, .Net, familiar development environments). It should have worked it theory, but they realized, at this point, it became a chicken in the egg problem. Developers don’t make apps because there aren’t enough users, there aren’t enough users because there aren’t enough apps.
Things are starting to look grim now. They tried and failed (miserably). They didn’t have enough developer support to jump-start the platforms. It’s time to abuse their monopoly. Result is Metro Modern UI. Having a mandatory tablet/phone like environment in the desktop, will force developers to support it. Windows market is huge, they are bringing the monopoly in full force, even if a tiny fraction of developers support the new UI, it’ll create bazjillion of apps, ready for the prime time in mobile market.
To recap, they are trying to leverage their desktop monopoly, by coercing them into developing mobile (Windows RT) compatible software, so that when WP8 finally hits the market, it’ll have bazjillions of apps ready at the Windows Store.
This is bad, because they want to go with Apply way (rather than Windows Android way) with this. They are on their way to create one of the biggest closed platforms in the history of mankind (or so they think), and they are willing to sacrifice everything for it.”
I am sure that sounds like boring business stuff, but there is still some importance here.
When designing game engines we think about the user experience and other things. As an OS developer Microsoft is thinking about expanding their brand to all tech platforms. They still have the user in mind, along with some businessy political warblegarble stuff we don’t really care about (market share, loosing money, blah blah). Microsoft has already implemented this Metro UI with the Xbox 360’s dashboard UI. We know that they want to expand to the mobile market, but their current attempts have been less rewarding as their past projects. So by creating a UI that is similar in look, style and function throughout all their platforms you would think that would be a good idea right? It seems like the developers don’t think so.
It seems like Microsoft is looking at their competition and looking at what markets they are heading into and figuring out where to go. This can only suck for us because Microsoft is following the wrong competition! Apple! NOOOOOooooo! Microsoft is focusing their efforts in the Mobile and Tablet market. I personally sit directly on top of the fence that is between liking and hating touchscreen mobile devices and tablets. I find tablets very useful for turning mundane tasks we used to accomplish via mouse and keyboard into an interactive and ‘fun’ experience.
I wish Microsoft would be following the direction of Valve, Ouya, Oculus Rift, Google Glasses and so on. This idea of a connected system that gives a lot of freedom to the user rather than pigeonholing them into something. User experience, innovative tech that we can use as tools to entertain, build, advance; these are things we should be focusing on. Apple and Microsoft are looking for the most profitable market tested products. The only usefulness of a tablet device is to help bridge the gap between PC’s and Mobile Device.
I think Game Engine developers should focus on developing their game engines to be platform-independent and be able to support any input device (Kinect, PS Move, MIDI keyboard, NES Zapper). Once all game developers have access to a single platform, making games will be super simple. However, that may not be the best idea. If it allows for anyone to make a game, then I might be out of a future job…
This post is going to be me breaking down and trying t understand this blog post (done by Nick) about Spatial indexing with Quadtrees and Hilbert Curves. Hopefully I can learn how this algorithm would be useful for terrain and environment representation. I have a few ideas currently, but I’d like to break down and understand the algorithm first.
Spatial Database’s and Spacial Indices
In order to understand what a spatial index is, we need to know what a spatial database (WIKI) is. A spatial database is essentially a collection of data that stores points, lines and polygons and any other object data. Simple terms: databases that store information related to objects in space. Many databases feature the following functionality:
Spatial Measurements: Distance between points
Spatial Functionality: Modify existing features while creating new ones
Spatial Predicates: Allows for binary/(true/false) queries like, “is there a boss located in that cave 1km from here?”
Constructor Functions: Creates new features in the database with an SQL query specifying the vertices (node points) that create lines. If the first and last vertex are connected (first and last vertex are identical) the feature will be a polygon
Observer Functions: Queries that return specific information like the location of the center of a circle
[ASIDE] SQL – Structured Query Language that is designed for managing data in rational database management systems [ASIDE] SQL Queries – Queries which retrieve data based on specific criteria. Most important element in SQL
Spatial indices are used by the spatial database to make faster queries.
These queries are essentially functions with the following template: functionName(parameter(s)) :returntype
Types of queries:
Distance(geometry, geometry) : number
Equals(geometry, geometry) : boolean
Disjoint(geometry, geometry) : boolean
Intersects(geometry, geometry) : boolean
Touches(geometry, geometry) : boolean
Crosses(geometry, geometry) : boolean
Overlaps(geometry, geometry) : boolean
Contains(geometry, geometry) : boolean
Length(geometry) : number
Area(geometry) : number
Trees. OH NO! I personally hated my class on algorithms and data structure’s, except for the part on trees. Trees were simple to understand and they were related to the more interesting computer animation algorithms (Skeletal Animation, global vs local transformations). Trees are simply data structures of linked nodes.
So quadtrees are used as a form of spatial indexing. They are a special type of tree where each internal node has exactly 4 children. They are heavily used in partitioning 2D space by recursively subdividing it into four quadrants and regions.
Nick describes the quadtree very well on his blog. Each node in the tree is represented by a bounding box covering a part of the space that in indexed, the root node would be covering the entire area. Each node is either a leaf node with one or more indexed points, but with no children. If it is an internal node then it has exactly 4 children, one for each quadrant obtained by diving the area covered in by half on each axes. This next picture should make things a bit more clear:
To query a quadtree is very simple. Since we have a good graphical representation of our quadtree we are essentially dealing with intersecting areas. We know that the root encompasses the entire area of the quadtree, and each child is a subsection of that. So to query, we need to examine each child node and see if the area inside that quadrant intersects with our current query. Once we encounter a leaf node is when we have to search each entry within that area to see if it intersects with the query area. Then you simply return it if it does.
Geohashing and Hilbert Curves
Both of these are ways of not using the quadtree to recursively look up through the tree, but rather use different methods of querying.
Nick goes into a lot more detail in the geohashing and hilbert curve methods, if you are so inclined to learn more about them, click here. However, as a game developer quadtrees and spatial databases make me think of maps in games. Ways of representing them (mini-maps) or ways of maybe organizing our scene managers in ogre? Who knows, but now that I am more familiar with the quadtree data structure I am sure my team an I can think of many ways to implement this useful data structure in our game.