Old Project – 3D Level Editor (2010)

Today I stumbled upon some old screenshots in my backup folder and I thought maybe I should post it here to remind myself how passionate I was.

This is a 3D level editor I did for my hobby game project back in 2010. The level editor was made using Qt 4 and Irrlicht engine. Some of the screenshots below are showing the editor which uses Irrlicht’s native GUI. Irrlicht’s GUI system was quite limited in term of types of widgets and functionality, which later on led me to switching all the GUI over to Qt.

Some of the features supported by the “game engine” I did back then include:
– Basic fixed function 3D rendering
– Basic collision (box collider and trigger)
– Spawn points
– Player camera and animated camera (for in-game cinematic)
– 3D sound (using irrKlang)
– Simple path finding

I made a simple game demo using the game engine and level editor I made. Unfortunately, the game wasn’t finished and I moved on doing something else. Below is the video recording I did back in 2010 showing how the game demo look like, for a competition. Spore Motions was the name of our team back then.

Hopefully I will be back into game development very soon.

Building a Game with Unity and Blender

I am proud to announce that I have published my very first book! The book is entitled “Building a Game with Unity and Blender” and it’s published by Packt Publishing, a well-known publisher based in Birmingham, UK.

You can get a copy of the book directly from Packt Publishing or you can also order one from Amazon.

I would like to thank all the people who helped to make this possible. Thanks again!

UPDATE: The source files are now available. Download it here.

Change Unity3D Build Target Using CMD

Most people probably won’t need this, unless you encountered such scenario:

You're handling a huge project, and you somehow need to move the entire project folder from a Windows machine to a Mac for porting the project to iOS.
What will happen is when you open the project for the first time on Mac, Unity will load all the files and convert them into Windows formats because well, your project was set to run on Windows previously.
You waited for half an hour or so for all the files to be converted (it' a huge project!) and now you must change the build settings again, and wait for another half an hour for it to be converted to iOS!

If you want to avoid running the conversion twice, you can change your Unity project’s build target before opening the editor, by using the command prompt, like so:

Windows:

"C:\Program Files(x86)\Unity\Editor\Unity.exe" -buildTarget 

Mac:

/Applications/Unity/Unity.app/Contents/MacOS/Unity -buildTarget

Possible options are: win32, win64, osx, osxintel64, osxuniversal, linux, linux64, linuxuniversal, ios, android, web, webstreamed, webgl, xbox360, xboxone, ps3, ps4, psp2, wsa, wp8, bb10, tizen, samsungtv

For example:

"C:\Program Files (x86)\Unity\Editor\Unity.exe" -buildTarget ios

This way, Unity will straight away convert your project files to iOS formats and no need to convert it twice. Time saved!

OGRE Hello World!

In this tutorial, I will teach you how to create an empty window with OGRE graphics engine and C/C++ language. Unlike any other tutorials that you can find on the internet, this tutorial does not rely on ExampleApplication.h and therefore you will be able to learn OGRE completely from scratch.

At the end of this tutorial, you will be able to create an empty window similar to this:

It’s actually not that complicated to code from scratch, just take a look at the full source code below and you will realize that it’s actually pretty simple to understand even for beginners.

#include <Ogre.h>
using namespace Ogre;

int main()
{
    Root *root = new Root("plugins.cfg", "mygame.cfg", "mygame.log");
    root->showConfigDialog();

    root->initialise(true, "My Game");
    RenderWindow *window = root->getAutoCreatedWindow();

    SceneManager *smgr = root->createSceneManager(ST_GENERIC, "SceneManager");

    Camera *cam = smgr->createCamera("MainCamera");

    Viewport *vp = window->addViewport(cam);
    vp->setBackgroundColour(ColourValue(0.3, 0.6, 0.9));

    root->startRendering();

    return 0;
}

Pretty simple isn’t it? I will now explain what the code does part-by-part. First of all, you have to include OGRE’s main header file “Ogre.h” into your project so that you can access its classes and functions for later use:

#include <Ogre.h>
using namespace Ogre;

You can also predefine its namespaces (but not a must) to make your code shorter. For example, instead of calling Ogre::Root *root = new Ogre::Root(), we can use Root *root = new Root() instead, which is much shorter and clean.

After that, create a Root class at the beginning of your main function, like so:

Root *root = new Root("plugins.cfg", "mygame.cfg", "mygame.log");

As you can see, Root requires 3 parameters during initialization: the first one being the config file that defines what plugins to load before starting the program; the second parameter is your game’s rendering config file that defines the resolution, aspect ratio, color depth, and so on which will also be loaded before your game is launched; and the last parameter is the name of the log file that will be generated whenever an error happens and it will tell you what problem had occurred.

After that we will be calling:

root->showConfigDialog();

which displays a config dialog before launching your game. The dialog window looks like this:

It lets the players change display settings before the game starts, which is quite handy especially for debugging purposes during development stages.

Next, we will initialize the Root class and define the window title by doing so:

root->initialise(true, "My Game");
RenderWindow *window = root->getAutoCreatedWindow();

We will then call root->getAutoCreatedWindow() to return the newly created render window and stores it to the a pointer called window. Please note that Ogre uses UK English, therefore you should use initialise instead of initialize.

Next, we will create a scene manager that manages your game’s scene graph (i.e. all the 3D objects in your scene) and save it to a pointer called smgr:

SceneManager *smgr = root->createSceneManager(ST_GENERIC, "SceneManager");

There are two parameters for creating a scene manager. The first parameter defines the type of scene graph you’re about to create. There are multiple types of scene managers you can choose from, such as:

  1. ST_GENERIC – Generic scene manager
  2. ST_EXTERIOR_CLOSE – Old terrain scene manager
  3. ST_EXTERIOR_FAR – Nature scene manager
  4. ST_EXTERIOR_REAL_FAR – Paging scene manager
  5. ST_INTERIOR – BSP scene manager

which each of them serves a very different and specific purpose. In this example, we use ST_GENERIC which is the generic type that works well in most cases. The second parameter simply lets you set a name for your scene manager, in this case, we called it “SceneManager”.

Next, we have the code below:

Camera *cam = smgr->createCamera("MainCamera");

Viewport *vp = window->addViewport(cam);
vp->setBackgroundColour(ColourValue(0.3, 0.6, 0.9));

which simply does the following, in ascending order:

  1. Create a camera and call it “MainCamera”.
  2. Ask the rendering window to link the newly created camera to its viewport.
  3. Set a background color for the viewport which will be used to flush the back buffer.

After everything has been setup correctly, we will now render the scene by calling startRendering() which is quite self-explanatory:

root->startRendering();

and viola! You have now successfully created an empty rendering window that runs on OGRE. That’s all for this tutorial, have fun!