Archive December 2007
Thursday 20 December 2007
Well that was an annoying half hour that I'm going to blog about not because it's particularly interesting but because Google didn't help, and if I post it then maybe it will help someone else. Since I'm doing it for that reason I won't be sparing the jargon and you probably want to not bother reading this.

The problem is, the Z-buffer in my DirectX code seemed to be not working. A bit of testing with my existing 2D stuff showed that the Z-buffer itself wasn't the problem - but the 3D stuff was rendering as "maximum distance" (z-buffer value 1.0f) for every pixel, even though it was obvious the two objects were not the same distance. My field-of-view matrix seemed to be sensible:
D3DXMatrixPerspectiveFovRH(&m, pi/2.0f, screenwidth/screenheight, 0.0f, 100.0f);
Which is to say, a 45-degree field of view, the aspect ratio of the screen, closest viewpoint is "touching the camera", furthest viewpoint is 100 units away.

After checking all my z-buffer initialising stuff, I tried messing with the 'Clear' function, making it 'clear' the z-buffer to 0.5f rather than 1.0f. The 3D all disappeared (even though half of it was closer than 50f) and the 2D didn't, confirming that the z-buffer wasn't just blocking everything. Then I tried clearing at 0.999f, which still disappeared all the 3D.

Anyway, at that point I asked Google to no avail, then started poking related things at random in the hope of finding one that would make it work. The answer is, it turns out, that you can't have your projection matrix start at distance 0.0f - I guess the representing matrix is messed up with a division by zero or something. So the fix is:
D3DXMatrixPerspectiveFovRH(&m, pi/2.0f, screenwidth/screenheight, 1.0f, 100.0f);
Anyone who came here from Google suffering the same Z-buffer failure - you're welcome.

Special bonus update for anyone who read this far or skipped to the end to see if there was anything more interesting - the 3D code for my current game project is now pretty much working at last, skinning and all. Now I get to work on actual game things again for a bit, hoorah! [10:41] [0 comments]


Thursday 6 December 2007
Gosh, it's been longer since I posted anything than I thought. This is what comes of being relatively productive, and possibly also of my house still being near-uninhabitable. Some months ago, kitchen renovation was started. It is still not done, nor does it look likely to be done in the near future. The granite countertops have turned out to be much more of a pain than anticipated, due to requiring specialist fitters. That part isn't a problem, the problem is when the other people say "it'll be ready for the granite by date X", and the granite guys are booked for X+2, and then they have to be cancelled because it is, in fact, not ready. Floor covered in wet adhesive, builder unexpectedly sodded off with the back door key (the only reasonable entrance for getting the granite in), things of that nature.

On the other hand, having no kitchen at all, and being reduced to preparing food using only a kettle, a microwave and a toaster is an enjoyable flashback to being a student. "I'll get a takeaway curry," I thought, "there is a two for one deal so I'll microwave the second one tomorrow." Tomorrow comes, and I realise I don't have a bowl. The curry is in a foil container, so can't microwave it in that. Studently solution; a mug of curry. Bonus side effect - it actually microwaves better in a mug, done in a single pass rather than having to stir half way as you do with a bowl, so I'll be doing that in future.

Anyway, the life-update part of the post is just padding, designed to bore you into being more easily amused by this: an xkcd comic that I repaired. [07:51] [16 comments]