Thursday, 23 June 2011

Quickly approaching the beta stage...

EasyMatrix is getting to the point now where it's almost at beta. I have tons of ideas that I'd like to implement, but I am hesitant because (a) The whole point is to keep it simple to use and (b) originally I only wrote this as a tool to help myself create levels for my AI experiments, and it can already do that!

Since my last blog update, lots of cool stuff has happened...

  • I have now written the texturing routine, which includes a "Texture Paint" function
  • After a suggestion via the DarkBasic Forums, I have changed the node indicators from spheres to cubes
  • I can now Export a matrix design, and Import it again, complete with textures
  • I have implemented "AutoSave" which intelligently saves the design if any changes are made
  • I have moved away from an imported 3D object for the selector rod, replacing it with an internally rendered model.
  • The user can now toggle the "help panel" on or off
  • A few internal routines have been completely rewritten for extra efficiency
  • The code is now fully "Remmed Up", more concisely than I ever have in the past

There are a couple of things that I'm still looking at...
  • A "Flood Fill" function which covers all the tiles with the selected texture
  • A "Node/Tile Drag" function when you drag the selection up/down rather than click to raise/lower
  • "Auto Texture by Height" which automatically textures a tile depending on its height (experimental)
  • "Lamp Posts" which allows the user to place a number of light sources
So it's getting there. I can throw together a perfectly usable level in about 5 minutes which, if coded without using EasyMatrix would take me the best part of a day (including texturing). That's pretty efficient in my book.

Of course I still need to code for the user-selectable bits such as Matrix dimensions, number of tiles, minimum and maximum node heights etc.., but I have pseudo-routines already in place that just need a graphical front end writing.

One thing I will have to look at is the texture pack. The one I'm using is just cobbled up from stock PaintShop Pro textures and colours, and I really am hopeless at graphics. But the idea is that the end user can replace the standard texture pack with one of their own design anyway. Maybe in a later release there will be a couple to choose from. Now if I could only talk someone into throwing some packs together for me..

I just made this level to show the editor in action (it took about 3 minutes), imagine that with a higher resolution (more matrix tiles), better textures, some light sources dotted about etc.. and you get the idea of what I'm trying to ultimately achieve here.

The alpha version used while writing this post can be downloaded FROM HERE.

My biggest "problem" at the moment is that I've fallen in love with Call of Duty 4 all over again...

Saturday, 11 June 2011

A near-usable tool!

I got some really productive coding sessions in over the last few nights. Yes, there were the usual bouts of frustration mixed with raw expletives and sprinkled with a topping of "wtf?", but on the whole, I got loads done.

First up, the viewpoint movement routine. I tried various methods of achieving this, but it turned out that the most effective was one of the simplest. Move the selector rod to a tile, hit "C", and the camera then centres on that tile. Simples. I had to code an assist routine, because when the camera makes the jump, if the tiles aren't yet textured (and they're not because I haven't wrote a texturing routine yet) it's easy to become disorientated and lose track of which tile you centred on. To aid here, I have made a translucent cube appear on the centred tile, and slowly sink down through the matrix. This instantly shows which tile the camera was focused on...

Next up, the Save and Load routines. Admittedly, these do need more work, but the basics are there and I can actually export matrix data, then re-import it. Sort of. What you have to remember is that there is no "Save Matrix" command available. (Or "Load Matrix" for that matter). Both of these routines have had to be built from scratch, and I've probably gone right around the houses to get them where they are, but it's a learning curve.

So on to the issues. Firstly, the Save isn't 100% reliable. That's not a great start. I'm still trying to nail the problem down, but when it does save - which is 9 times out of 10 - it actually saves data. It's just that now and then it completely refuses to export anything at all, and I'm not sure why yet. By the way, these Load/Save tools aren't like your standard Windows dialogue boxes or anything fancy like that, they are pretty much "Press S to save then type in a filename" or "Press L to load then type in a filename" affairs, but I'm a beginner at this so I have to start at the beginning. Or something.

Anyway, on to the Load routine. Yes, it loads the data I saved earlier. Unfortunately, it doesn't pick up on any texture data, and I can't work out why - yet. So I get the Matrix shape loaded, but it's completely wireframe. I know I haven't wrote a texturing routine yet, but all the tiles are textured by default, and it's not picking those values up for some reason. But I'll get there.

So the following pictures show what is currently happening when you export a matrix, then shut down the program, then open it again and import that saved matrix. As you can see, the correct shape is there but that's all. Having said that, getting this far was no walk in the park.


Finally, I've started work on the texturing routine. This is a standalone program at the moment because I want to figure it all out before I embed it into EasyMatrix. Basically, the program takes a bitmap which contains all the textures needed for the level, cuts it up into 48 small pictures, makes 48 sprites from these pictures and lets you manually select which one you want to work with. The "active sprite" as I call it, is shown at the top of the swatch as a full-size (128 x 128) texture tile, ready for application to the Matrix. But I haven't got that far yet.

As you can see, the mini-swatch rotates slightly, to give you a quick indication of where abouts in the texture pallet you are.

So that's about it so far, it's a near-usable tool but not quite there. I would say another couple of weeks if gaming doesn't get in the way. Which reminds me, I re-installed Call of Duty 4 and completed it again this last week. I forgot how much better than Modern Warfare 2 it is. Now I'm getting hooked on the Multiplayer again. So I managed to do that, and get a fair bit done on EasyMatrix. It's been a good week, coding-wise. 

Sunday, 5 June 2011

Off on a tangent...again!

Anyone who has been following this blog will know that I tend to shoot off at random directions when it comes to coding stuff. I'm weak like that, too easily distracted.

Once again, while researching and writing test routines for my AI experiments, I got a bit fed up of working with a flat floor. My newly acquired model objects demanded some more interesting scenery to interact with. So I decided to bang together a quick program which created a randomly generated "matrix" of tiles. But the problem was that they literally were too random. Yes I could apply various restraints etc, but I wanted something that would reflect a realistic game level.

So again I "went off on one" and started a new project. This one is a level editor of sorts, based on a matrix system. This will actually be a useful tool I think, because not only can I use it to make test levels for the forthcoming AI routines, it can (or rather will) be used to make actual game levels once I learn how to code AI.

I was also partly inspired by the "MouseCam" routine mentioned in my previous post. This proved to be very handy in my "EasyMatrix" program, essential in fact. Also, you might remember at the end of my last post, I talked about working out a routine that would convert the mouse input for use in a 3D environment. Well, I nailed that one too! (An achievement I am pretty happy with, if I'm honest.)

So now I can control the camera in 3D space and I can use the mouse to point to any object or area within that space. I just know these routines are going to be useful to me one day, and they are already deeply embedded in my EasyMatrix project.

That picture shows the concept of EasyMatrix - a tile based editor, with 4 editable node points per tile, and a 3D viewing angle. This image was kindly rendered by my friend (and 3D/game design artist) Tom Joyce.

The development of EasyMatrix has flown along so quickly over the last week that I haven't really taken many screenshots. I must throw a shout out to another friend (and mathematical genius) Ragnar Karlsson, who helped me out with a particularly tricky algorithm. I never was any good at trigonometry.

Anyway, this is what EasyMatrix looks like right now...


That bottom picture shows the same viewing angle, but the left one is in "edit" mode while the right one is in "real world" mode. It will look a lot better when I implement the textures. It is still possible to edit the matrix in "real world" mode, but you have to be pretty accurate with the pointer, because the helper objects (red dots) are turned off.

So next I need to implement a way to move the point of view (at the moment you can pan around but the camera always points to the dead centre of the matrix), and I need to look into texturing the tiles, and I also better figure out a way to actually save or export the matrix otherwise this whole thing will be pretty pointless.

If you want to have a play with an early version of this, you can download the file by CLICKING HERE. It's a .rar file so you will need to unrar (unpack it) prior to use.

There are only a couple of requirements...
  • You must have at least DirectX 9.0c installed. But you already will if you're a gamer, right? (Get DX9 here)
  • Your mouse must have a clickable wheel. The camera pan only works when you hold the wheel button down.
That's pretty much it really. It will still work if you don't have a clickable mousewheel, but your view will be very VERY restricted. 

Now, I should make a start on that viewpoint movement routine. I think there is some Magners in the fridge...