Tuesday, 25 December 2012

Sci-Fi Alien Weapons

As usual with modelling it has taken me a about three weekends to create one model.

I drew the concept on the 10th of December and put the final touches to the finished weapon and added it to the game on Christmas Eve.

It's inspired by, in fact deliberately similar to, the alien style weapons pack I purchased from Garage Games

That set only includes 3 models and I needed an additional larger support weapon for the aliens.

I am getting the hang of 3D modelling and the basic untextured model only took a day.  What takes all the time is the UV unwrapping and then the texturing.

I always start by creating the Ambient Occlusion layer for my texture.

It does not help that I have to do some bits twice because I forget to set some parts of the model as smooth before creating the Ambient Occlusion (AO).

Without using the smooth option on parts of the model that are curved, the AO shading is banded instead of continuous.

I always like the model with the AO texture.  Shame I can't leave it that way.  I have seen a game where that was the style of the game.  It looked very good but not what I want for Diabolical: The Shooter.

If my artistic skills were better I would be able to create the texture quicker.  I have to put most of it togther from parts.  More like contruction than drawing.  I go through each part, as split by the UV unwrapping, and add details as separate components and blended in to the base colour.  Layer after layer after layer.

I am starting to learn some of the techniques but it takes me time.

For some reason it ended up grey but for this model I wanted it a more silver colour to match the others.  I used a bit of brightness but mainly I adjusted the gamma correction curve to get something more silver.

The in game lighting adds a bit more shine to the surfaces.

Merry Christmas to all.  25 Dec. 2012.

Thursday, 20 December 2012

Winform Map Editor

Last night I finished my side project of migrating the map editor from being a game screen to being a normal windows application (Winform.)  I've been doing this when I needed a break from 3D modelling. 

At the moment all I have attempted to do is move all the features I had before in to a separate project.  I did find a few minor bug fixes but it is basically the same.

The only major change was to the controls for moving about the map.  It now works more like a 3D modelling programme, in fact the rotate, zoom and move are very similar to Blender.  I have however retained first person keyboard controls for fine adjustments.

I am doing most of the modelling in Blender so the new controls are much more familiar when I bring the models in to the editor.

I have left space to the side and bottom of the main view window to put properties.  I have not coded anything to go there yet but in time I will add something useful.

The editor is still linked to the main game.  It shares some of the rendering code and all of the map loading code.  I compile the editor project in the same solution as the main game.  This means that the map files will always remain compatible.

I find it works well.  The only peculiarity I had was that the game view control from the Microsoft sample is external.  Exceptions thrown in the game view crash the control but the rest of the Winform app continues without error.  The view window goes white with a red cross in it!

I fixed that with a simple try and catch wrapped round my update and draw code:

/// Redraws the control in response 
/// to a WinForms paint message.
protected override void OnPaint(PaintEventArgs e)
        string beginDrawError = BeginDraw();

        if (string.IsNullOrEmpty(beginDrawError))
            // Slow the game down to no more 
            // than 60 fps (16.667ms per frame)
            if (gameTime.ElapsedUpdateTime > 
                // My own version of GameTime
                // based on a stopwatch.
                // Simulate the update loop in 
                // an XNA game.
                // Draw the control using the 
                // GraphicsDevice.
            // If BeginDraw failed, show an error 
            // message using System.Drawing.
    catch (Exception ex)
        // Exceptions within external applications do 
        // not automatically break the parent form.
        // These lines trap the exception, display the 
        // error and break the parent code for debugging.
            "Exception in Update or Draw: " + 
            ex.Message + " in " + ex.Source);
            "Stack trace: " + ex.StackTrace);
        throw new Exception(ex.Message);

The whole app now crashes and the exception is displayed to help debugging.

In addition to being able to position, models, triggers, waypoints and generate the navigation mesh used by Bots, I have loads of helper overlays within the editor.  Too many to list:

I nearly forgot.  There was a point to moving the editor out of the main game. 

Every time I tried to change the game I had to keep it compatible with the editor.  There was often lots of extra code just so the game remained fast and the editor had features.

When I started looking at adding in the networking code it just got too complicated to do what I wanted and retain compatibility.  That's what kicked off this little side project.

It's how I should have done it in the first place.

Sunday, 9 December 2012

One Line Of Code

I am sure that everyone has these days when coding.  This is just a quick note to remind people to keep on going no matter how bleak things appear!

I had been working away on the new weapons and effects and got round to testing everything on the Xbox.  I do this from time to time because the Xbox does not perform in the same way as the PC does.  Much to my surprise the performance was a disaster on the Xbox!

That was late yesterday and I was going out in the evening so I left it wondering how long it would take to find whatever it was I had done to cause a frame rate of just 9 frames per second!  It was perfect on the PC but the Xbox was unplayable!

I had thoughts of the level being too complicated and having to come up with some clever code to cull more efficiently, or that the texture files were too large, so I would have to reduce the quality.  I had quickly ruled out the particle effects because although they were pretty the code, quantity and textures sizes were unchanged to effects I had been using for years and the performance graphs did not change when they were on the screen.

I've been working in I.T. long enough to know that whatever you last changed is the most likely cause for whatever problem you are now investigating.  This morning I therefore thought through all the changes since the last time I had successfully tested on the Xbox...

I thought it was a fairly easy non-performance affecting change but I have completely re-written the Audio Manager to change from using XACT to using the SoundEffect classes.

Some quick commenting out and I very rapidly confirmed that somewhere in my conversion I had made a mistake.  To cut an hours searching down I found it.

Just one very short line of code:
nextSong = "";

I had an endless loop that would start playing the next waiting piece of background music every frame because I had not cleared the variable once it started playing!

I am a lot happier now and I can go back to creating assets and effects for the game.

Sunday, 2 December 2012

New Weapons New Effects

After having completed modelling the new alien sci-fi weapons and getting them in to the game I wanted to complete them with their own sounds and visual projectile effects.

I am pleased with the results.  The picture above is just one of them.  I have three weapons ready and two particle effects.  Two of the weapons share the same ammunition so the same effect.

The effects are created with particles and I use a tool I wrote for myself to help adjust the effect until I am happy with it.  I created the tool as open source so anyone can use it: https://gpuparticles.codeplex.com/

I find it takes a while to edit the 2D images used for the particles.  It's not that the particle textures need to be complicated it's just that it is difficult to visualise what they will look like in the effect until you try them.  There's a lot of back and forth getting things as I want them.

That's the texture from the other effect I have created.

Now for the sound effects.  I was able to find some public domain and creative common licenced sounds that are just right for the sci-fi sounding shots.  At the moment I have used them 'as is' but they need some minor adjustments.  The main change and my next task is to normalise all the volume levels so they are all the same volume relative to each other.

That's a job for next weekend I think.