Part 8 Back in the game.




Memories Of Graftgold.

Twenty nine years ago Andrew and I worked in a little office at the back of my garage. I had to move the car so we could get to the door through the garage. Andrew helped me virtually rebuild the room after I moved to Wickham Bishops.   It was more of a  shed  when we began. I replaced the inner hardboard walls with insulated plasterboard and put in a proper ceiling.  I double glazed the windows and it already had a radiator so it was very cosy. There was just room for our two desks side to side. It was a big step up from using my dining room. 

One sunny day I remember well. My wife Julie took my 5 year old son Mark to his first day of school. Andrew and I were busy working by the time she returned. Soon after she called to me to phone the hospital to page the midwife. Julie  was heavily pregnant and felt something was happening. A little later she called me again as no one had arrived. I ran downstairs to phone the hospital again and they said they had paged the midwife.  My wife called for me again so I ran back upstairs. The baby was clearly on its way so once again I charged downstairs to ring the hospital. Before I could talk to anybody she once again shouted so feeling like a yoyo I once again ran upstairs.  This is it I thought,  grabbed a handful of towels took a deep breath and hoped I could cope.  A baby girl was born very quickly, there was no time to panic.  I wrapped her in a towel and ran to get a first aid book given to by wife as a leaving present. They had jokingly put a marker in a page showing how to deliver a baby , numbered pictures! I followed the instructions and lay the baby on the bed while I tied a piece of wool around the cord.  I then raced downstairs to ring the doctor having got no joy from the hospital. I explained my wife had just had a baby. "How nice, a boy or a girl" the receptionist answered. "You don't seem to understand , there' s no one here, we need help" I pleaded.  By this time it was midday and my son needed to be collected from school. At last there was a knock on the door and a nurse and a midwife arrived simultaneously. I told them they were too late as I exited hurriedly explaining I must pick up my son.  It was not until I got to the school gates it hit me what had happened. "I just delivered a baby" I said to the mums waiting at the gate. I suddenly felt in shock and a great sense of relief and pride that it had gone ok.

Carina Turner 29 years later.




Deepest Blue September Progress.

"At times like this I am glad I have no boss to explain to"
Now my blog is up to date with my progress in the game I have to get around to do a bit of programming each month so I have something to talk about!  So just as well there were many rainy days to keep me inside and a week at the mother in laws while my wife looked after her. That's the nice thing about a laptop. I can take it along and just lose myself for days. I will have to watch the amount of time I spend on Twitter. My new laptop has an app that informs me of each notification and Tweeting is so much easier than programming. I was getting bogged down with the ship parts editor and badly needed to get back to the game. At times like this I am glad I have no boss to explain to why things are taking so long. Some things are complicated and just take time.

I still had to add the facility to remove faces to a model part. This was so I could have multiple pat hulls that had no hidden faces when the parts were joined together. It wasn't a huge change but sometimes programming is like doing a Rubix cube. To get those last pieces in place you have to go through a major shuffle and hope that you don't disturb anything. I decided to add an edge structure to store the data about joins and missing faces. This was in addition to the existing Section structure that managed a set of Spokes that defined the prime vertices of a cross section. Spokes only existed for the prime vertices that were then duplicated according to the symmetry defined in the Section. This allowed complex shapes to be defined quickly. The edge structure would belong to the model part rather than the cross section and contain data about joins and missing faces.

"This should have been easy"
Its great when things start working. I soon had all this tested and the data saving out. The next step was to load the data in the in game spaceship editor. This should have been easy, I have a generic data loading system that knows how to load data from HTML like script into C structures and fix up all the pointers. Well it should have been easy, unfortunately I hit a bug in my loading routines: they could not handle loading nested pointer list constructs. It turned out that the save was not quite right and it took about a day to fix the problem and get the data loaded. Then I found my manufactured model parts were causing a crash. They each had a texture number that was incorrect being the editor texture. That was easily fixed. It was a good moment seeing my new model in the main program.
I could place the first piece but it needed a lot of work to place the next joining piece.

The subsequent pieces had to be placed so that the joins align. That meant taking into account the position and orientation of the part it is joining to as well as the angle and position of the join on the part being added.  That took me hours of drawing diagrams to convince myself I understood the 3d transforms needed but thankfully most of the routines were already coded as part of my 3d engine.

The other techy problem was to update my own graphic object structure to have two parts. My graphic object format is my own design. I have an object container which contains a hierarchy of parts each with its own orientation matrix. The actual parts are elsewhere, the hierarchy just contains pointers. This allows for reuse of the actual parts each of which is a 3d model consisting of triangle strips and a list of vertices and normals which can be preloaded to the graphics card.  So I had to update the hierarchy, slotting in place the new part with its accompanying transform. While doing this I decided to add an Id number to each part so I could identify them. As they shuffled when I added parts I needed a way to find an existing part.  This turned out to be very useful. One of the first things I decided when joining parts was that I needed to be able to highlight the current part. I enhanced my main draw 3d object routine  use  a simple highlight shader to render a specific part of an object.   I added buttons to cycle through the joined parts and another pair of buttons to cycle through existing joins on the highlighted part.




Parts were joining but not in the correct position. Back to the drawing board. The 3d transforms must be wrong. I decided to add a 3d Sprite to show each joins position so I could see what was going on. I I added a routine to export a matrix of the parent parts transformation so I could draw the join in the correct place. These came out as triangles rather than the expected rectangles (joins each had four vertices). This showed the vertice order of my joins was wrong. In the editor the easiest way to process them was in the order the occurred in the editor  top left, bottom left , top right bottom right and this was not the order a triangle strip expects. This was corrected then I realised they were back to front. I had forgotten due to Microsoft's positive Z going into the screen the Z in my model decreased from the front to the back.  Time to revisit the editor and get this right. 

"a really annoying oversight"
I spent a day correcting the editor and decided to output a cockpit as well as a hull piece so I could try out joining two different parts in the game.  I noticed a nasty design issue. When adding the edge structure I had moved some of the spoke data to the edge structure.  When I reused a Section for a different part it was meant to generate an identical cross section shape so the two parts fitted. That was the whole point of having a Section structure. The Edge structure belonged to the model part and altered the shape. This was a really annoying oversight.  I had disturbed part of the working editor and had not retested all the previously working functions.  It took a whole day of coding to move the offending data back to the Spoke structure.

As the Space Ship editor is part of the game it has to be easy and quick to operate suitable for those with no experience in building 3d objects. I decided that it would be easiest to choose a part, select a join and then display all parts that would fit onto the join. Once selected the part would fly to the join and wait to be orientated as it may have several ways it could be joined.  I already had a control I called a carousel that displayed in 3d a selection of parts. This was all soon wired up.

"After much tearing at hair I found the problem"
Now the positioning was in real time I could test the behaviour of the transforms aligning the new part for the new cockpit joining to the hull.  To my surprise it was out of alignment. After much tearing at hair I found the problem.  I had forgot one of the transforms. The cockpit had a join whose direction was not in line with the centre of the part. With a bit of modification adding a matrix multiply to combine the parent orientation and the parts join orientation the parts ended up in the correct places. Again I am glad I have  no boss or Andrew to explain to.

Having got this working I allowed myself a few minutes "smug mode" before talking the next issues.
I need to work out the data for each type of part so I can  add up the attributes of the parts such as cost weight, energy and display the results. That should be a lot easier than the 3d stuff. Then with the totals  and saved data I can load the designs into the game proper and drive them about. This is the moment I have been waiting for  months.

Hmm forgot, somewhere along the line I need some decent textures.  I spent some time looking at spaceship textures on the web. I reckon I can get the computer to invent spaceship textures but I have had enough of writing editors for a while. I will save that for later. 

" have a sneaky fly about on the way to the space dock "
I decided on the next session of work. Top priority was to finish the spaceship editor so I could save the customised ships and reload them. I also need a screen to fit out and arm the ships and a game screen allowing you to choose from available designs that you can afford.  Then I need to get the customised ship attributes into the game ship object and get the ship behaving according to its design. That is a lot of work but its  the crux of the game and it will be fun getting it working. Now I am back in the game code I have a sneaky fly about on the way to the space dock screen and shoot down some meanies. I like the point when the code becomes a game rather than a bunch of complicated routines. If you find yourself playing your own game when you were meant to be programming it is a good sign that it is going in the right direction. 


                                        

Comments

Popular Posts