Sunday, December 21, 2008

INTRODUCTION TO 3D GRAPHICS

This blog entry is to document everything that I have done so far for intro to 3d. I have been so disorganised this yea it is untrue. I have found this module extremely difficult, which caused me to get behind with the work, as it was taking me two weeks rather than one to get each section done.

Lets begin at week 4

This is where it all started to go wrong. This week I had to implement a virtual camera this used my matrix class extensively as we needed to create a view matrix based on position and rotation passed into the method and second to store the projection matrix. The next task was to get the program to load models from Quake 2 (.md2 file format). We were given the code for this as it would have taken an absolute age to get it working by ourselves. The main problem I had this week was the camera class. I just over complicated the entire thing, I could tell you what the camera had to had and how you calculated each matrix but I could not write it down in code, but with a little help from my lecturer I managed to get it working but a week after I should have.

Week 5

This week was the big one, where we first got something rendering on screen. First of all I had to finish implementing the camera class, by giving it the screen transform to complete the set of matrices the renderer needed to display models on screen.

Next was getting a wireframe on screen this took a while to implement as I was stepping through what we had been told to implement slowly making sure is was getting it right. To begin with I had strange bug, where I was getting the lines on screen but only two and they filled the screen. This was due to my matrix multiplication method was calculating using the transpose of one of the matrices in the calculation. With that fixed I then had the problem that there was nothing on screen. After 4 hours of looking I found that when I dehomogonised the verts of the model, it wasn't just dividing the verts value by w but adding the result to the original value meaning the value was in the thousands when the screen transform was peformed on them placing the model well out of view of the camera. So instead of saying

_transformedVerts[i].Divide(_transformedVerts[i]._w);

I changed it to

_transformedVerts[i] = _transformedVerts[i].Divide(_transformedVerts[i]._w);

After that I had my model cube on screen. Next was to apply rotation to it, which was pretty straight forward I found as I was just applying a rotation matrix to the original verts at the very beginning of the update before anything else was dealt with. Week 6

I was starting to catch up with the work this week as I had my wirframe on screen and rotating. The next job was to cull the backfaces of the model as these would not be seen if the model is solid and so would be a waste of time drawing them on the screen.


After that we were given the task of sorting the verts so they were in some kind of order so that verts at the back were being drawn first and verts at the front being drawn last. After that was getting some solid colour on the model. The result was a model that looked 2D as there was no shading so just looked like a solid object. This is where I fell behind again, lighting took up a lot of time as I got extremely confused and over complicated things again. This took me some time to get sorted and eventually got to a point where I had something on screen but it was all blocky and wasn't actually shading. It was either solid colour or black. After realising I had missed out a few lines and moving the where the calculation for the light was done, I had what looked like an x-ray on screen. And after another week (into week 10 now, really behind, remember this is week 7 work) I finally had the model shading properly on screen. After that I stupidly stopped working on the renderer for a week to my Game Development Techniques project to a point where I was nearly finished.

So in week 11 I started to look at making the renderer work with scanlines and setting pixels to the right colour for the polygons rather than using Gdi+ FillPolygon() method.

Scanlines really confused me and it took me several attempts to understand it properly and get it working. Whan I finally had something on screen I had two problems. The first was that the polygons were a little spikey in places and the second was half the polygons were not being rendered. The first problem was due to the calculation of the scanlines is done using floats and ints. When calculating the differences of x and y of two verts the values had to be cast as ints as so not to make the spikes meaning the float result didn't have too main numbers after the point.
There next problem was that each polygon is drawn separately and so becuase of this applying scanlines to the entire window would be silly! So as to limit the amount of scanline being looked at I had a minimum and maximum y value which would be the top and bottom of the polygon respectively as 0 is the top of the screen. But when calculating the max and min values I was checking the wrong way and that meant I was only getting half of the polygons. So this is where I got up to for the deadline of the project. But I will be carrying on with it over Christmas, so that it is the best it can ever be.

Here is an image of the actual program handed in for the deadline. Each model has 2 directional lights on them and the polygons are being rendered using scanlines.

Thursday, December 18, 2008

GAME DEVELOPMENT TECHNIQUES: Tick Tock Tick Tock

This post will deal the last three weeks of the semester and the run to the deadline for the assignment, where all these blog entries will be included in the documentation.

The final few weeks have been extremely busy. Before week 10 I had experimented with AI for my NPCs and managed to get on with it quite easily. A couple of problems with it is that the animations of the models don't seem to play correctly sometimes and that they can still be shot and bleed. No matter what I do to stop them bleeding it didn't seem to work. But then in game settings I discovered a setting that allowed me to turn gore off. So now they don't bleed and there is no chance of them being blown into big meaty chunks if i stick the weapons cheat in for UT2K4. So now I have several NPC's that react to events only and my sidekicks. The sidekicks in the game just follow the player around the map. This is a default setting that the class for these NPCs inherit from. They inherit from class Monster, but are unable to perform any of the fighting states within that class.

I also added conversation to my game. You can talk to one of the NPC characters that is controlled by events and actions and get a task off him, which is the butterfly mini game mentioned in an earlier post. This conversations were created using CSDTalk, which is a set of classes created by Jesse Schoch at Critical Systems Digital, who create mods for the Unreal Engine. This was extremely useful and works well in game. But I did discover a bug within it to do with alternate conversations that I sill don't understand and have been unable to fix. I may be just using it wrong, I don't know =P

Here is the NPC and conversation system in game.

The other major part of the game was getting the cutscenes done, they turned out pretty long =S woops. They were not supposed to be as long as they ended up being.

Everything has gone really well but there was one bug that I have fixed right at the last moment where you could lose the game because of an npc getting to close to the losing trigger I've now set the trigger so that it can only be activated by the player.

Just the documentation to do now.

GAME DEVELOPMENT TECHNIQUES: Audio

Week 9

When discussed texturing we were looking at file size and we also looked at it with audio, but mainly to do with sampling rates and the positives of analogue over digital audio. We also discussed Foley. This is where bespoke sound effects are created in a recording studio using all kinds of different objects. The most famous of this is using coconuts for a horse trotting.

The tasks for this week were to include music and sound effects into our game. I added the theme tune of the 1990s Famous Five TV show. In the first half of the playable game I added Concerning Hobbits from the first Lord of the Rings movie as this went really well with the level being in the countryside. The music for that level starts when the level is loaded, which also has the opening sequence of the game. The music plays while the movie plays and by chance is in time with the text that comes up on screen. For the second playable level I added a piece of music from the game 007 Nightfire. This adds to the mood of the level as you sneak around under the cover of darkness, and is quite nostalgic for me and makes me want to play the game. =P No Dan! Must concentrate on this!

For ambient sound around the level I have birds singing and the rustle of leaves, as well as chickens clucking at one of the farms in the level. In one of the cutscenes I have a plane flying over and so had to search for something appropriate for the plane.

GAME DEVELOPMENT TECHNIQUE: Level Design

Week 8

This week was nice as we were talking about the design of our levels for our total conversions. We were shown a level from Max Payne and a 2D top down layout plan for the level. I already sketched my level layout at this point, way back in at the beginning of the semester and have stuck to the layout but had to alter the sizes as the level was a bit on the small size with the original measurements.

Our task this week was to finalise our level, which was already well on the way!

GAME DEVELOPMENT TECHNIQUES: Geometry

Week 7

This week we looked at using Autodesk's Maya 3D modelling environment.

Now I'm not an artist so this was difficult for to do. Although I have explored it in the past, it is not my forté. Probably with more tuition I might get to grips with it but the moment it is not important. So with a few basic walkthroughs of several tools I managed to create a tent for my total conversion.

Texturing the model was easy this was just an extension of the carpet tile that i created last week. But, I could not scale the texture properly and so it came out a little to large against the model.

GAME DEVELOPMENT TECHNIQUES: Texturing

Week 6

For this week we were look at texturing, what size is best, does it have an alpha, RGB colour.

The task that was set this week was to create a texture that will be integrated into the total conversion in Unreal.

I chose to take a photo of my carpet. I then put it into Photoshop and used the pattern maker tool by selecting an area i wanted to create a pattern with and setting the size to 256 pixels. This creates one tile that can then be used over and over again and no matter which way it is placed with another tile it will always look seamless.

Here is a single tile created in photoshop.

And here is 4 tiles put together. Seamless. In this image you can see the recurring pattern. this is something that is unavoidable with use a tiled texture as the human eye is programmed to recognise patterns. If the pattern is not scaled and placed in the right position this could diminish the reality of our virtual world.

As part of the spec for this total conversion there has to be a cameo of ourselves within the game. To this end I exported an existing texture from an Unreal mod texture package that consisted of a frame and placed myself within it by creating a layer for the image of me and cropping it where needed to. This was then applied to an existing static mesh and placed on a wall.

Both these were compressed using DXT1 compression format.

These example can be seen within a cutscene in the second playable half of the demo. Also the I was wearing the nose and ears at the time the photo was taken. =P

Friday, November 21, 2008

GAME DEVELOPMENT TECHNIQUES: Design

Right, so far I havn't really explained what story I will be making in Unreal. I will be making the Famous Five book; Five Go To Billycock Hill.

The actual playable 10 minutes of the game roles out as follows:

After the opening sequence, the player must go to Mr Gringle. He then gives the player the task of catching 10 butterflies for him and in return will show them around his butterfly farm. They must first collect a butterfly net from Billycock Farm. After they have collected the net they can then collect the butterflies. Once the player has collected 10 butterflies the player returns to Mr Gringle, which triggers a short cutscene before returning to the player. The cutscene shows more of the story which is not playable.
The player joins the Five at their camp site on Billycock Hill at night. The player takes control of Julian as default because he is the eldest. The player is given the first objective to meet Toby at the large Oak Tree near the butterfly farm. The player then has to sneak down to the farm house. Getting close to the house involves passing quickly through areas of light. If the player stays within the lights too long, the boys get caught and it’s end game. As the player gets close to each of the two windows on the ground floor with lights on, a cutscene plays showing what is going on in that room. After the second window it is suggested to look through the upstairs window with the light on. To do this the player has to look around the farm, keeping to the shadows again, to find a ladder. Once the player finds a ladder another cutscene show the ladder being placed at the window and the boys seeing Will Janes in the upstairs room. When he leaves the room the cutscene ends and goes to the three boys at the bottom of the ladder with the player taking control of one of the boys. Will Janes walks past nearby and the player must follow him to some trees without being seen. The player must not get too close to him but also not lose him in the dark. Once Will stops within the trees and the player is close enough a cutscene plays where the boys hear Will’s argument with two men and the boys are discovered and Timmy comes along to save them.

Thats it for now more in the way of development of the game to come in the next couple of days.

Monday, November 10, 2008

Extremely Overdue Update for Game Development Techniques

Well, what can I say? I didn't keep to my promise of blogging on a more regular basis so here go.

Game Dev Tech Weeks 2-6
Week 2

Well so far we have mainly been concentrating on increasing our skills with Unreal. First of all to give us some more practise using the Unreal Editor we were given the task of creating a map using a location somewhere in the area. This was a group project for the week and meant that we split down the location into smaller manageable areas.
There were four groups, each with at least 4 members and one of the members was also project manager for that group; I was project manager for my group. The 4 project managers sorted out in their groups who was doing what of the area assigned to them. The project managers met to see what the naming convention of the entire project will be and which of the smaller maps from each group will connect up, we decided on the naming convention of the area the group was dealing with and then the smaller areas being dealt with by each member of the group e.g Market_North. The project managers also set a deadline to have the work done ready for the connection to eachother before the actual deadline. I think in a way we all knew we would not stick to the deadline but it did make us get on with the work and we had it ready for the actual deadline.
This shows the section I created:
Week 3

This is where we started to real get down to the nitty gritty of Unreal Script. This is the week where we first started creating our proper game. Using the Total Conversion files that were provided to us we added our own levels and get a character and menu working on screen. This was pretty easy going but gave an insight into the code we will be dealing with for the rest of the semester. One bug that was slightly weird and only happened on the computers at uni was in a certain area the character would just slide along the floor with the no means of input.
Week 4
This week we were introduced to pickups and started looking at the code. Our tasks this week to implement our own pickup into our Total Conversion and when it is picked up to display text on screen saying that it has. The actual pickup was not too difficult to create but the text on screen was difficult but so simple, if you know what I mean. The fact of the matter is to actually get the text on screen all I had to was change where my HUD class was inheriting from and the change a value. The change was so slight you could have been there for weeks otherwise!
Week 5
The task for this week was to implement a tool into the game. In the Famous Five book I am basing my game on, the Five help a local butterfly expert catch butterflies. I came up with the game where you have to collect a butterfly net and help catch some then report to the expert and he shows them around his butterfly farm. Unfortunately I didn't get this completed but I did get the pickup of the butterfly net working without the net you cannot collect the butterflies. At this point as I do not have the resources the net is represented by a fire ball and the butterflies are represented by the adrenaline pickups from UT2004.
This image shows the butterfly net pickup:
This image shows the butterfly pickup:

I promise this time blog posts will be more frequent.

Wednesday, October 22, 2008

CONSOLE DEVELOPMENT WEEK 3

This week we started looking at MIPS (Microprocessor without Interlocked Pipeline Stages) this is the assembly language used within the PS2 and PSP. Using the tutorials available here http://chortle.ccsu.edu/AssemblyTutorial/index.html#part4 looking more specifically at chapter 13 and 15
This is Exercise 4 of chapter 13 which evaluates the equation 3x-5y using an x value of 6 and a y value of 2.

.text
.globl main
main: ori $8, $0, 6 #x value
ori $9, $0, 2 #y value
addu $10, $8, $0 #copy x value to register 10
addu $8, $10, $8 #addition method of 3x
addu $8, $10, $8 ori $10, $0, 0 #clear register 10
addu $10, $9, $0 #copy y value to register 10
addu $9, $10, $9 #addition method of 5y
addu $9, $10, $9
addu $9, $10, $9
addu $9, $10, $9
subu $10, $8, $9 #subtract 5y(stored in $9) from 3x(stored in $8)

Chapter 15 caused afew problems as the tutorial is taught using a program called SPIM where I have been using MARS, which has a better graphical interface and some additional extras. But the memory allocation is slightly different and only in the last few minutes has been explained to me so the exercises for chapter 15 have not been completed this is a job for today..... part 2 coming later today.

Tuesday, October 21, 2008

INTRO TO 3D GRAPHICS PROGRAMMING so far

Time management for me has been a real issue for me so far this year and this is the reason for very few blog entries when we are now into the 4th week of the course. To this end this entry will document everything covered in the first 3 weeks of Intro to 3D Graphics. Also blogs will appear at regular intervals rather than being dotted far and in between. Also a similar entry will document the last 2 weeks of Game Dev Tech. Anyway.... lets get started shall we?

Week One

This week we concentrated on using GDI in C++ on Visual Studio 2008. We had a tutorial to work through off MSDN that was actually written for, I believe, VS 2005. There were a few things different naming conventions and placement of some sections of code but nothing to difficult. This tutorial was to basically draw a line in a window application. The code is very similar to that of C#, which I spent a lot of time working with last year on the course and so things like the update and draw methods were there but not as obvious as they are in C#.

Here is the final piece the final product at the end of the tutorial:









I have not delved much further into this at the moment as there is really no need at this stage and we will only be using GDI to draw each pixel using the data from our objects later on.

Week 2

This week was all about vectors. After doing the Computational Maths module from last year this was all fairly easy stuff, actually implement a class in C++ was another matter. This was our task for this week; implement a vector class and test that it works using a console window to display the values of the vector. We were given the help of a header file that included all the methods and variables needed to get this class running.


There were a few things that confused me with actually setting up a copy constructor. All the books I looked in just said it would come in handy but not exactly what it was doing. After talking to Adam he explained that it is just there to create a copy of the vector being created. Also if you do not add a copy constructor yourself C++ adds one in for you anyway.

The rest of the code was really nice and easy but I think was my downfall as made me a bit too cocky for week three's work.....


Week 3


This week was all about Matrices including the transforms of a matrix. The task this week was to implement a Matrix class alongside the Vector class from last week. I underestimated this work thinking that it was very simple, I soon learnt it was not going to be when I had my brain melted a little by the inclusion of a 4-D matrix for the transforms in a 3-D environment. Writing the code also melted my brain a bit more. Still need to put the finishing touches to this class and so will get back to you on how this went along with Week 4's tasks. The inclusion of the 4-D matrix meant that the Vector class had to be updated to include a fourth value, w, to make the calculations possible for transforming the values. This can be seen in the image above for the constructors of the Vector class and also some of the calculations on vectors below:



Notice on the cross product method the w value is 1.0f rather than doing a calculation. This is because the cross product only makes sense in 3-D and so the default value is entered for the w value.

Wednesday, October 15, 2008

CONSOLE DEVELOPMENT WEEK 2

This week we were given the task of researching into the assembly code used in old game consoles. I was in the group that was researching the code for the Sega Mega Drive. I could not find a decent disassembler to actually look at the code for a game of the Mega Drive, but I did find quite a lot of example code.

I have done some assembly code, using a program called Asm Tutor, as part of the computing course I did as one of my A levels, but not to the extent of what is used to actually create a video game.

Here is some sample code I found for reading the controller:



jsinit: moveq #$40,d0

move.b d0,$a10009

move.b d0,$a1000b

move.b d0,$a1000d

rts

porta: move.b #$40,$a10003

nop

nop

move.b $a10003,d1

andi.b #$3f,d1

move.b #$00,$a10003

nop

nop

move.b $a10003,d0

andi.b #$30,d0

lsl.b #2,d0

or.b d1,d0

not.b d0

rts



According to the notes that accompany this piece of code jsinit must be called to set up the joystick. It is only called once but if this code was not present the would be errors when reading back from the controller.

The code porta deals with the controller in the first port on the console the same can also be done with portb. This piece of code returns a boolean value at the end. It uses logic gates to check whether a button has been pressed(returns 1 bit) or not (returns 0 bits).

Also at the same site that I found the link to the above code, I found an assembler and disassembler with a small sample program. There is no documentation to help understand exactly what this program is doing but, I think, will still come in handy in understanding assembly code in the coming months.

This piece of is from the beginning of the sample program. I am not entirely sure what it is doing but I think it is declaring values in registers and adding some values. It also prints out "SEGA GENESIS (C)SEGA 1996 MAY" and "Sample Program".


dc.l $00FFFE00,$200,$200,$200,$200
dc.l $200,$200,$200,$200,$200,$200,$200,$200
dc.l $200,$200,$200,$200,$200,$200,$200,$200
dc.l $200,$200,$200,$200,$200,$200,$200
dc.l $200,$200,$200,$200,$200
dc.l $200,$200,$200,$200,$200,$200,$200,$200
dc.l $200,$200,$200,$200,$200,$200,$200
dc.l $200,$200,$200,$200,$200,$200,$200,$200
dc.l $200,$200,$200,$200,$200,$200,$200
dc.l $200
dc.b 'SEGA GENESIS (C)SEGA 1996 MAY'
dc.b 'SAMPLE PROGRAM '
dc.b 'SAMPLE PROGRAM '
dc.b 'GM 00000000-00',$a5,$fb
dc.b 'JD ',$00,$00,$00,$00,$00,$02,$00,$00
dc.b $00,$ff,$00,$00,$ff,$ff,$ff,$ff,' '
dc.b ' '
dc.b ' '
dc.b 'JUE '
nop
nop
rte

Friday, October 10, 2008

GAME DEVELOPMENT TECHNIQUES

Week 1

For this module we have been given the task of creating a game based on the Famous Five books using the Unreal Engine.



So far I have read a couple of the FF books and chosen to take on Five Go To Billycock Hill. I also watched the Comic Strip presents spoof videos and several episodes of the TV show from the 90s. In respect to using the Unreal Engine I have had no experience using it, so the one of the first things I did was to buy the Mastering Unreal book to get me started on the level design. I have already learned to hate the Unreal editor as I have tried several times to make a map and every single time it has ended up in disaster and me starting again from scratch.



In this weeks levture for GDT we took on the role of the project manager and were given the task of creating a breakdown structure for the project; break down the task until it is made into small manageable tasks.


Also using Program Evaluation and Review Technique create a table of how these tasks will be split down into hours of work.









Tuesday, October 7, 2008

Back at Uni

Well I have started back at Uni but unfortunately caught freshers flu, or something along those lines, and have missed out on a couple of lectures this week. I have been unable to get on with much work as my illness has paralyzed me from doing much work.

This won't stop me from talking though, oh no. =P

This year is all about getting ready for the games industry to this end I am currently working on creating a game using the Unreal 2 engine for one module and the other is starting me off slowly at the moment but will eventually get me programming a fully working 3D rendering programme with no help from DirectX. The other module i missed the first lecture so I will get back to you on what that will entail.

For now I will be you farewell and will start documenting my various projects asap.

Dan