Second year – blink and you’ll miss it

So not a lot has been happening post wise, which is not to say im not busy. Quite the opposite. Second year has been a blur of new and amazing knowledge and with it challenges. I am now on holidays again and busying on my second AI assignment having just completed the first graphics assignments familiarising myself with the modern shader graphics pipeline and all that it entails. I might post some screenies of some of the effects I have made along the way.

I have sidelined my box2D project for the time being until I have at least finished this school assignments first. Hopefully, I can get some free time over the coming weeks to finish that off. Im currently reading Programming Game AI by Example, a book I perused partially in first year and now revisiting in more depth for second year, its a great read and book I would highly recommend if learning AI for the first time, it also has useful accompanying source code and executables allowing me to follow and fully comprehend the subjects outlined by the author.

Thinking outside the Box2D

When one thinks of the capabilities of Box2D one instantly conjures up images of flying birds, angry flying birds. So what really lies underneath the hood of this little engine that could. Well there’s only one way to find out. So I grabbed myself a copy of the latest code, version 2.12 as of this writing. The first thing you need to do after downloading is configure it with cmake to generate the visual studio solution and associated projects. Which is not to difficult just a matter of unzipping the source somewhere, pointing cmake to that directory, set a build output directory, hit the configure and if no errors hitting generate. A solution called Box2D should be created, open it and build both a debug and release build and you’re good to go.

To assist in getting up to speed with Box2D, there is the usual hello world program. This does nothing more than track the movement of a Box2D object or body (as it is defined) and output it to standard output. Better examples are contained within the folder named Testbed. Inside there is a program that when run allows you to choose a set of examples configured to display and render graphically using OpenGL, freeglut and glui. More importantly all the code is available soone can see how it is all done. Its cleverly designed in a such way to be easily extensible. Just create another header file defining your world, body and fixtures while also including the usual Step, Create and Keyboard functionality and add a new entry into the testentries code file and your done.

As with all frameworks there are certain workflows a developer must abide by to create and use the API correctly. In Box2D, you need to define a world in the form of a b2World object. Think of this as your standard factory pattern that allows you to create other things. Within this world, the other things that can be created are bodies, fixtures and shapes. You can create the world object using new, however due to how the memory is contained in pools you can not new bodies, fixtures and shapes. So dont do it. One of the first things I found out about Box2D is it is renderer agnostic, it basically lives as an entity that you tell to work in a world and how you wish to display that world is up to you. What is strange though for an API designed in C++, why are there so many examples found on the web all using mainly Flash. My knowledge of Flash is dismal to non-existent so you can imagine for a beginner you have this API that can create worlds and there are no examples of how to display your beautiful world. In the end I decided to traverse the testbed example and break it up into the minimum functionality that would produce an output.

Here in lies one of the first hiccups I had using Box2D, evidently it was not triggered by Box2D itself rather it was freeglut. I created a new empty console project and added the necessary files from the testbed, namely Test, Render and Main. I linked the freeglut_static.lib file and all was good except when it came time to run, it complained that freeglut.lib was missing. I thought this was strange as I had linked the static lib. Searching through some forums, I sourced a reputable prebuilt lib file and used it, it fixed the issue provided I also placed the associated freeglut.dll in the executable directory. The program fired up with no popups and then instantly terminated, flashing an error message in the command window before shutting down. After tracing through the code I discover the message was trying to say:

freeglut function called without first calling ‘glutinit’

int main(int argc, char** argv)
{
testCount = 0;
while (g_testEntries[testCount].createFcn != NULL)
{
++testCount;
}

testIndex = b2Clamp(testIndex, 0, testCount-1);
testSelection = testIndex;

entry = g_testEntries + testIndex;
test = entry->createFcn();

glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
glutInitWindowSize(width, height);
char title[32];
sprintf(title, "Box2D Version %d.%d.%d", b2_version.major, b2_version.minor, b2_version.revision);
mainWindow = glutCreateWindow(title);

glutDisplayFunc(SimulationLoop);
GLUI_Master.set_glutReshapeFunc(Resize);
GLUI_Master.set_glutKeyboardFunc(Keyboard);
GLUI_Master.set_glutSpecialFunc(KeyboardSpecial);
GLUI_Master.set_glutMouseFunc(Mouse);
...
}

As seen in the highlighted code snippet above, I had actually called glutInit so what could possibly be causing the issue. After debugging I could see that line that was causing the issue was the call to GLUI_Master.set_glutReshapeFunc(Resize);. Now GLUI_Master is a global instance that should be available with the initialisation of glut, so if I was calling glutInit… why then wasn’t this being intialised as well. Several hours past I finally found it to be due to the mixing of the freeglut_static.lib and freglut.lib. The fix was as simple as adding the preprocessor definition FREEGLUT_STATIC. Once in place all the code I transferred from the testbed program into my solution worked. So with a working testbed and seeing exactly how everything hooked up, what else could I do. I decided that perhaps putting together an angry birds clone would fuel my persistence to learn Box2D in more depth. At this stage I only feel like mimicking the first level with the aim to make it as close as possible to the original in functionality.

League of Lull

Literally weeks away from beginning second year at AIE and I for one am very eager. Mainly because I have taken my school holidays a little bit too relaxed, so I am in need of some structure. What has happened since my last post? Well a few things:

I got engaged to my long, long time girlfriend. A parting gift so to speak as she was leaving to go on holiday with a friend to America (San Francisco, LA, Las Vegas, Atlanta and NYC), Hawaii and Fiji. I decided to surprise her just days before both Christmas and her departure date.

The ring was a Verragio and up until about 6 months ago I never even knew such a designer even existed. It was only by chance perusing parts of pinterest that I discovered this hand made exclusive designer. So exclusive that here in Australia there are no retailers, distributors and manufacturers anywhere, nothing. Fortunately the internet age has made things a little easier and I was able to source an online retailer. It even had a useful website allowing me to select an appropriate style, diamond all online. The actual jeweller was situated in NYC, which was somewhat convenient considering the time I purchased the ring was very close to her departure date. So plan B was to have her pick up the ring from them while she was in NYC, fortunately the ring arrived several days before so plan B never eventuated. After the order, I waited 4 weeks only to receive a phone call that customs would not release a delivery of mine until I paided some taxes, some unforseen additional taxes mind you, to the sum of ~$1100. My immediate thought was, is this a hoax? Then a small inkling made me realise that it could possibly be due to the ring I had ordered, it was. I called the toll free number and this took me to FedEx where I later discovered the total tax could be broken down into 3 constituents which included GST (10% on total price), Duty (5% of total price) and admin (around $50). Now that doesn’t seem like a lot until you consider the ring itself set me back ~$9200AUD and I am no longer working which meant I had no income other than savings, so as you can imagine it hurt the pocket a little more than I had expected. In the end I had to pay for it, no point going this far and not getting what I ordered. Besides, most people only perform this act once and considering I had waited just over 10 years to ask, I felt the means out weighed the costs.

Christmas week towards new years saw my cousin and her friend fly in from interstate to visit me. Having moved from Adelaide we did leave behind a lot of family and friends so it was refreshing to see some family especially during Christmas time. Additionally the added benefit for someone visiting me in Sydney after living here for 2 years I was able to show them all the good spots and a taste of what I found interesting about Sydney. Which is not to say the touristy adventures were out, they still happened, only I listed the goods ones or the ones I never had tried before.

However, after they left I feel into a rut and was not over productive, my sleep was a mess and I was not doing much programming or blogging. The only positive was I increased my gym attendance for 3-4 times a week to everyday and I continued this for about 3 weeks straight. The idea was to tire myself out so I could sleep better, however, it instead created more energy and I was finding it had the opposite effect. My mind started thinking about all sorts of game ideas.

Today I can say my sleep is still a mess though it is gaining some normality. Over the next few days I will aim to get back to programming and what better than to contribute on a topic I have always been interested in, physics in games. So with that I have chosen to experiment with Box2D. Hopefully I can post some simple code samples on here with the aim that I will build it up to a game demo prototype of some sort.

Arma 2 DayZ mod steam install issues and fixes

So with the conclusion of this years Steam Autumn sale I was able to add a number of games to my collection. Some of which I had on my list for a while and some which I never heard of and purchased them based on their videos and reviews. The exhaustive list and the reasons for purchase are listed below:

  • Terraria – I wanted to see for myself how similiar it was to minecraft, I can conclude the similarities I found were uncanny to say the least. It has renewed my insterest in procedurally generated worlds.
  • Arma II: Combined Operations – Recommendation by a friend for the DayZ mod.
  • Portal 2 – Already have 1 and enjoyed it so I figured why not get 2.
  • The Walking Dead – Highly recommended by my cousin who is never been wrong about good TV series and games.
  • Mark of the ninja – Seemed interesting and it was indie so why not.
  • F1 2012 – Last formula 1 game I purchased was Ayrton Senna on the sega megadrive, yes a long time ago. I remember I thoroughly enjoyed it and once played it nonstop for 18 hours straight, no working save feature, just to so I could see the ending. Having such a fond memory, it was time to renew my interest and see how much the F1 game technology had changed. Sound is amazing.
  • Borderlands 2 – Previously played 1 and still have the Dr expansion unwrapped and in its box.
  • Borderlands 2 Brady Guide – Yolo and because I found 1 a little slow moving and tedious at times.
  • Dishonored – Wow, this was surprisingly good. Only reached into the sewers on the first level before it suddenly crashed on level load and transition. However, up until that point a really deep and immersive experience. Excellent AI and story. I will be returning to this one.
  • The Witcher 2 – I wanted to compare it to skyrim. I do know it doesnt contain a fast travel feature which I am not looking forward to so I will be leaving this one until the school holidays new week where I will have more time.
  • Alan Wake Bundle (Summer 2012) – Our teacher once said that if he could work for any game company it would be Remedy games. Not knowing who they were I discovered they were the original developers and owners of Max Payne 1&2 series. This cemented my purchase as Max Payne 2 was one of the very few FPS games that I ever finished without being bored first.
  • Super Street Fighter IV Arcade Edition Complete Pack – I simply enjoy collecting street fighter editions.

As the title suggests there were a few complications in installing Arma 2 and getting the DayZ mod working, even from a steam installation, which I found annoying.

Here is how I got it working.

So you need both Arma 2 and Arma 2 operation arrowhead installed. I went ahead and installed Arma 2 first and played the game. Its not your usual FPS and it takes a little getting use it, namely certain action buttons are not configured the same. Next I installed operation arrowhead and played the game also, this time only just to see the game open before shutting it down.

This was when the first incident occurred in the form of the following error:

no entry bin config.bin/cfgingameui/mptable.shadow

Now to fix this issue, I needed to shutdown steam completely and run again as an Administrator. Re-running the game installation process and the issue went away. Note: You I only had to run steam as admin on the first successful install, after that the game did not complain of this issue.

Next I proceeded to grab the latest DayZ mod from here. After downloading I unzip the rar file using 7-zip into my default steam location, it created the folders Key and @DayZ and inside that was the Addon folder with all the necessary mod files. Running the game now I recieved my next error:

dayz_anim requires addon ca_dubbing_counterattack

To fix this I need install the beta patch found here, I just got the latest link at the very top. Next I needed to link the contents of Arma 2 expansion folder to where DayZ was installed, in this case within operation arrowhead folder. To do this I needed to alter the properties of shortcut that ran operation arrowhead to as follows.

“C:\Program Files (x86)\Valve\Steam\steamapps\common\Arma 2 Operation Arrowhead\Expansion\beta\arma2oa.exe” -noSplash “-mod=c:\program files (x86)\Valve\Steam\steamapps\common\Arma 2;expansion;expansion\beta;expansion\beta\expansion;@DayZ;@namalsk;@DayZ_Namalsk;@NC

Retesting, the errors went away and DayZ was finally installed with no errors. Hopefully that helped someone also.

Strangly I didn’t play the game, I think I lost interest with the issues that occurred. I may revisit it during school holidays, mainly because it is nearly impossible to pry my hands away from the more addictive and fun Counter Strike Go.

Game engine month

Not only is it Movember, it also seems to be the month when the major vendors for game development are publishing revisions and updates to their game engine.

  • Epic, makers of Unreal engine released their November SDK
  • Crytek, makers of the Crytek engine have released their version 3.4.3 SDK
  • and finally Unity, makers of the Unity 3D game engine have released Unity 4.0

#AltDevConf Student Summit 2012 – Day 2 Videos

Feeling a lot better today, I decided to finish what I started so with that I am back for day 2 of the AltDevConf Student Summit.

All kudos goes out to all the organisers and speakers, so thank you all. Here are todays videos:

AltDev Student Summit – Being the Voice of an Indie Company – Andrea Schmoll

AltDev Student Summit – What Software Developers Should Expect From the Games Industry – Ted Spence

AltDev Student Summit – What is Game Animation? – Mike Jungbluth

AltDev Student Summit – Essentials the Team Leads Need to See in Your Work – Benjamin Cavallari

AltDev Student Summit – A Day in the Life of a Creative Director – Jurie Horneman

AltDev Student Summit – DIY Development Jay Margalus and Phil Tibitoski

AltDev Student Summit — AAA Game Programming, A Day in the Life — Bobby Anguelov

AltDev Student Summit – The Intern’s Secret Survival Guide – Brandii Grace

AltDev Student Summit – Cultural Issues – Kate Edwards

AltDev Student Summit – I Can’t Believe I Do This For A Living: The Generalist Game Designer

AltDev Student Summit – A Day in the Life of a Games Writer – Anne Toole

AltDev Student Summit – Starting and Running a Company, From a Programmer’s Perspective – Rebecca Fernandez

AltDev Student Summit – From Playtester to CEO – Closing Keynote with Jen MacLean

Edit 16/11/2012: All links have been updated to point to final edited videos.

#AltDevConf Student Summit 2012 – Day 1 Videos

Having caught a one day cold/flu yesterday and being bed ridden for most of the day. Then somehow gaining enough energy to attend a 21st birthday party that same night. I was actually surprised to find myself waking up this morning with only 5 hours sleep for the live stream cast of the AltDevConf Student Summit Conference for 2012. In hindsight it was probably not necessary as the sessions were all recorded. It was still interesting to hear what industry veterans had to say as well as seeing some of the student projects coming out from other schools.

Here is a list of the first day sessions, in predominantly, the order that they were presented.

AltDev Student Summit – Thinking Three Moves Ahead – Opening Keynote with Ian Schreiber

AltDev Student Summit – The Cutting Room Floor – George Kokoris

AltDev Student Summit – A Day in the Life of a Tools Programmer/Buildmaster – Alex Crouzen

AltDev Student Summit – Blue Screen Of Death – Travis Sanchez

AltDev Student Summit – A Day in the Life of a Solo Developer – Mitu Khandaker

AltDev Student Summit – OOP Is the Root of All Evil – Jeff Ward

The AltDev Student Showcase – Session 1

AltDev Student Summit – A Day in the Life of an Indie PR Guy – Erik Johnson

AltDev Student Summit – A Day in the Life of Scrabble! – Sharon Price

AltDev Student Summit – Managing Up – Dustin Clingman

AltDev Student Summit – Breaking In Panel

Edit 16/11/2012: All links have been updated to point to final edited videos.

String Encrypt and Decrypt for C#

A neat little encrypt/decryption code written for c# that also serves as an initial test to see how code postings appear inside WordPress. To find out more on how to post source code in wordpress, go here.

using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;

namespace ConfigurationLibrary
{
    public sealed class CryptoString
    {
        private CryptoString() { }
        private static byte[] savedKey = ASCIIEncoding.UTF8.GetBytes("YOURVALHERE");
        private static byte[] savedIV = ASCIIEncoding.UTF8.GetBytes("YOURVALHEREASWELL");
        public static byte[] Key
        {
            get { return savedKey; }
            set { savedKey = value; }
        }
        public static byte[] IV
        {
            get { return savedIV; }
            set { savedIV = value; }
        }
        private static void RdGenerateSecretKey(RijndaelManaged rdProvider)
        {
            if(savedKey == null)
            {
                rdProvider.KeySize = 256;
                rdProvider.GenerateKey();
                savedKey = rdProvider.Key;
            }
        }
        private static void RdGenerateSecretInitVector(RijndaelManaged rdProvider)
        {
            if(savedIV == null)
            {
                rdProvider.GenerateIV();
                savedIV = rdProvider.IV;
            }
        }
        public static string Encrypt(string originalStr)
        {
            // Encode data string to be stored in memory.
            byte[] originalStrAsBytes = Encoding.ASCII.GetBytes(originalStr);
            byte[] originalBytes = { };
            // Create MemoryStream to contain output.
            using(MemoryStream memStream = new
                     MemoryStream(originalStrAsBytes.Length))
            {
                using(RijndaelManaged rijndael = new RijndaelManaged())
                {
                    // Generate and save secret key and init vector.
                    RdGenerateSecretKey(rijndael);
                    RdGenerateSecretInitVector(rijndael);
                    if(savedKey == null || savedIV == null)
                    {
                        throw (new NullReferenceException(
                                "savedKey and savedIV must be non-null."));
                    }
                    // Create encryptor and stream objects.
                    using(ICryptoTransform rdTransform =
                           rijndael.CreateEncryptor((byte[])savedKey.
                           Clone(), (byte[])savedIV.Clone()))
                    {
                        using(CryptoStream cryptoStream = new CryptoStream(memStream,
                              rdTransform, CryptoStreamMode.Write))
                        {
                            // Write encrypted data to the MemoryStream.
                            cryptoStream.Write(originalStrAsBytes, 0,
                                       originalStrAsBytes.Length);
                            cryptoStream.FlushFinalBlock();
                            originalBytes = memStream.ToArray();
                        }
                    }
                }
            }
            // Convert encrypted string.
            string encryptedStr = Convert.ToBase64String(originalBytes);
            return (encryptedStr);
        }
        public static string Decrypt(string encryptedStr)
        {
            // Unconvert encrypted string.
            byte[] encryptedStrAsBytes = Convert.FromBase64String(encryptedStr);
            byte[] initialText = new Byte[encryptedStrAsBytes.Length];
            using(RijndaelManaged rijndael = new RijndaelManaged())
            {
                using(MemoryStream memStream = new MemoryStream(encryptedStrAsBytes))
                {
                    if(savedKey == null || savedIV == null)
                    {
                        throw (new NullReferenceException(
                                "savedKey and savedIV must be non-null."));
                    }
                    // Create decryptor and stream objects.
                    using(ICryptoTransform rdTransform =
                         rijndael.CreateDecryptor((byte[])savedKey.
                         Clone(), (byte[])savedIV.Clone()))
                    {
                        using(CryptoStream cryptoStream = new CryptoStream(memStream,
                         rdTransform, CryptoStreamMode.Read))
                        {
                            // Read in decrypted string as a byte[].
                            cryptoStream.Read(initialText, 0, initialText.Length);
                        }
                    }
                }
            }
            // Convert byte[] to string.
            string decryptedStr = Encoding.ASCII.GetString(initialText);
            return (decryptedStr);
        }
    }
}

Enabling dropbox public folder

So today I finally signed up for a Dropbox account, up until now I had no reason to use it. That was until I noticed a pattern where most students were using it to publish their unity games online. So with that I signed up, only to discover straight away that I could not share my links. Well not easily or straight forward as the instructions led me to believe. Just place the unity file and webplayer file into your public folders they said, then copy and display the public link to a webpage and your done.

Only problem, there was no more public folders. What had happened is recently, and by recent I mean last month, dropbox in their infinite wisdom decided to disable public folders for all new accounts. All current accounts will still work the same only new account have it disabled.

Which ultimately means they must still exist, so how to get to it and more importantly how to enable it.

Well if you’ve been reading this far, it is just as easy as following this link, you might need an account for it to work correctly. Hit the enable button and you get your public folder back.

VS2012 Model Editor

Tonight while trying to familiarise myself with some animation files in Unity3D, I stumbled across an unusual feature within Visual Studio. It all happened when I tried to run some animations on a model included within a package I had downloaded, I doubled clicked what seemed to be the animation file in a hopes that it would play the animation I had chosen. Instead, Visual Studio executed and I found myself looking at what seemed to be a modelling editor, all contained within Visual Studio. I remember thinking immediately that this was both unsual and cool and the same time. After the initial shock had settled I went to check out how powerful this editor was.

Having played around a bit inside 3DSMax, Maya and Blender, I recognised that it had implemented the basics of a typical 3D modeling tool, such as the ability to translate, rotate, scale and create primitive shapes. On closer inspection I found you could also select and choose to display either overdraw, wireframe or flat shading. Further investigation unravelled the ability to show poly and vertex count, display backface culling, choose graphics engine, scene manager and looking at the official documentation from Microsoft, I later discovered you can even create shaders using a inbuilt node-based visual shader tool.

VS2012 Model editor

VS2012 Model editor