Wednesday, 18 May 2011

Cylinder Collision

I've just finished tidying up my code following a change I had been planning to do for some time.  I've changed the collision bounds for characters from multiple spheres to a single cylinder.

The red outlines in the following picture best illustrate what I mean.

Although cylinder to cylinder and cylinder to sphere collision is a tiny bit slower to calculate than sphere to sphere collision the end result has made the overall code much more efficient.  There are far fewer iterations and less calls to the final physics bounce calculations.

Another minor distraction from getting the animations done!

Saturday, 14 May 2011

Starting The Main Character Animations

For the last couple of weeks I've been re-writing my collision code.  I had been unhappy with the way characters bounce off static structures.  That is now acceptable and the code is a tiny bit more efficient.  I have also got some plans for some more improvements but I've been distracted enough and need to get back to artwork.

I'm now working on adding the animations to my main character.  I did not create the 3D model but I am animating it and have had to adjust it to make it easier to animate. 

The first and I find most difficult job when starting to animate a character is weight painting.  This is allocating how much each vertex on the mesh is affected by the movement in any bone.  This needs to be right so that the body bends in the right place. 

Remember I am not an expert at any of this.  I muddle through based on various tutorials.  I recently purchased two new training DVD's for Blender which I hope will help me. 

Weight painting takes a bit of fiddling.  When you start animating bits stick out where they shouldn't and the weights for individual vertices need to be corrected.

I finished that yesterday and I've been working on the first of the animations today.  Not so much an animation as a movement.  For the purpose of animating I deal with the skeleton as three sections.  This is so that I can move the arms separately from the rest.  In XNA code I merge the sections in to one movement.  The clip I am working on at the moment moves the arms from pointing a weapon towards the ground through to pointing it at the sky.

I've done the sniper version today.

I need to get ready for dinner now so no more work on the game tonight.

Monday, 2 May 2011

Fixed Some 3D Models

I have confirmed that the odd lighting problem I was having was mainly caused by my modelling skills not my coding skills!

I fixed several models.  It was as easy as applying the Blender 'Edge Split' modifier.  In most cases using the default 30 degree setting but for one model I used 50 degrees to get rounded corners with the minimum of faces.

The 'Edge Split' modifier duplicates vertices where faces join so that they do not share vertices.  This is useful because when rendering, where vertices are shared, the normals are interpolated based on the adjoining vertices.  That makes corners look rounded rather than square.  With separate vertices for each face the corner looks square.

Sunday, 1 May 2011

Lighting Improved

I have been busy over the last month completely re-writing the HLSL effect shaders. The new version has improved lighting with 3 directional lights phong specular lighting to make models look shiny and better shadow resolution.

I tried to improve performance which I think I have done but as I have added features I have used up any gains I made.

I have written a lighting form for my editor so I can change all the lighting values and see the effect on the map immediately.

The biggest improvement to the shaders has been removing some artifacts caused by interior faces of models casting shadows on the wrong surfaces.

I have learnt a lot about lighting and some more about modelling. I also know that I have to re-make some of my models to sort out the effect caused by faces sharing vertices.