Thursday 12 December 2013

Scene Graphs

What are scene graphs?

A scene graph is a graphical scene data that forms a hierarchy made up of nodes and edges. Scene graphs specifies the relationships between objects in a game. Its like a tree that contains parent nodes and child nodes. Take a look at this scene graph below.


Lets say for example you have a dining table set with chairs around. The parent node would of course be the dining set and the chairs would be children of the dining set. This is the same idea with scene graphs for games. If we were doing a scene graph about gameplay then we would make gameplay the root node. That root node would then become a parent of all the other components that help make up gameplay. Examples could be like physics, characters, enemies, etc. Scene graphs allows us to organize objects, organize primitives, group transformation, and group effects such as shaders.




Scene graphs provide a great framework for a team to organize their work. In games, scene graphs help programmers be able to organize the overall structure of the game. It really causes one the think about all the necessary components before actually starting the implementation. Sometimes when a group of gamers get together and gather up all of these great ideas and yet still were not able to get it done because of lack of data. You cannot have one thing before the other. That is why scene graphs are important to have. They are like the core of game engines. They feed geometry to the renderer. They should also gather information based on spacial proximity and render-state coherency.

Scene graphs provide 4 key benefits:

  • Performance
  • Productivity
  • Portability
  • Scalability.

It is a great framework to build on for any 3D game. It encourages game developers to be more aware of the components being used in the game engine.

Conclusion

Scene graphs are beneficial and very useful for any 3D game. It sure helped us at the beginning of our studio game development. We had a very lengthy scene graph that I thought was very over whelming but it was great to see how we were constantly referring back to it as we continued developing our game.  



Wednesday 11 December 2013

Threading

What is it?

Sometimes in games, it is very useful and effective to have a variety of sections of code running on one processor. But what if there was a way that programmers can have more than one paths of execution? What if there actually was a way that code could be run on different processors? This is the idea that threading brings. A thread is simply a path of execution. Single path execution run through single-threaded programs whereas multiple paths run through multi-threaded programs.





Single-threads are computed one at a time whereas multi-threads can all run at once. One thing these threads have in common is that both single and multi have a single core. Threads also have to be able to handle their own execution. On another note, they have two callbacks, "suspend" and "resume".

 There are two specific types of threading:
  • Kernel threads
  • User-Level threads

Kernel-Threading & User-level Threading

Kernel-threading is the lowest operating system. It handles the scheduling in the execution process. The thing is with kernel-threading is that they manage the operating system and maps the user-level threads. So in a way kernel can incorporate user-level threads too while being managed by the CPU. User-level threading operates in user-space. These user-level threads are processed using a One-to-One or Many-to-One format.




Why Use threads?

Using threads give more efficiently on single or multiple executions. They allow us to use multiple tasks at once like receiving and computing input.They also take advantage of multiple CPUs. Not to mention they are quite simple to program. Here is an example done in class.

Example
pthread_create(do Physics)

void do Physics()
{

while(1)
{
if (press)
pthread_cancel
}
}

Once the thread exits the loop dies.




Sunday 8 December 2013

AI

So what is AI?

When you think of AI, what kind of terms or aspects would actually go well with AI? Well AI can be used for enemies, decisions, and rules. AI takes those things and brings them into a realistic perspective. According to Ian Millington, AI or Artificial Intelligence is about making computers able to perform thinking tasks that humans and animals are capable of. Its providing an illusion of  NPCs or non-player characters to be doing a human-like behaviour trait. AI gives an illusion of the characters being intelligent. Examples include characters getting out of the way when something is about to run into them or running towards a soccer ball when it gets near them. Of course we all know that nothing really has an artificial intelligent mindset. We can only make the computer mimick or follow human behaviour.

Most modern games address 3 basic needs:

  • Movement
  • Decision Making
  • Strategy

Movement

Algorithms that turn decisions into some kind of motion. This is where NPCs actually moves around in the game world. In order for NPCs to look intelligent we have to use physics. 

Seek Behaviour is when you have a character that is seeking another character. It calculates the direction from the initial position to the target position. It also requires some sort of velocity  as it moves from each location to another.




Flee Behaviour is the opposite of seek behaviour. Instead of trying to find the character you are trying to run away from the character.



Arriving Behaviour is used with seek because when we finally get to the player we want a realistic look to it by making the character slow down.

Wandering Behaviour allows the character to move in a direction of a current orientation with a maximum speed at each time step.

Pathfinding is another way in which a character can get from point A to point B. In order for this to happen we use graphs in the game world. The graphs filled up with nodes in which characters can move from one node to another using A*.

Decision Making

This involves what kind of behaviours should the character does in case this happens. What to do next? Programmers have to include a range of behaviours like standing, sitting, walking, attacking, wandering, and so forth in the computer but there is still a matter of knowing where and when to execute these types of behaviours. 

AI in AEOLUS

For this semester, we used turrets as the enemy of our game Aeolus. When the player flies within a certain distance, the heads of the turrets will turn towards the player and shoot lasers at them. For next semester we will be introducing much more enemies in our game that will somewhat  have a similar behaviour as the turrets or maybe have multiple behaviour if we can think of any because it is a helicopter combat game. Despite that, we definitely will be trying out new things in the near future for Aeolus.

Conclusion

Sims is a good example of a game that uses AI. NPCs wander around the game world until the player's Sim comes into contact with them. Same thing goes for any FIFA soccer game. The characters will run in the direction the ball is heading but will not actually be running towards it. All of these things allow a game to give off the illusion to its players and therefore gives good gameplay.