Bit of progress made over the last couple of days. Each tool now has its own transparent panel that it can create and manage controls within for options relating to that tool. The select tool doesn't actually work yet, but when it is active you can now click and drag a rectangular marquee on any of the ortho views.
Haven't quite decided how to make this work in a general way yet that will avoid the tool code needing to be concerned about which sort of projection it is acting on. I'm thinking about returning an AABB that stretches infinitely along the viewing axis of the view (e.g. along the Z axis for the front and back views), then I can test for an intersection between this volume and an vertex or a triangle.
Had a couple of interesting diversions yesterday. I decided that it was too much work to keep making different coloured versions of the buttons, so I invested some time in writing an algorithm to colourise a grey button by converting the RGB values of the source image to HSL, then reconverting back to RGB, having substituted the hue and saturation values. Seems to work really well.
I also decided I wanted the cube logo to be alphablended onto the background. It was previously drawn with a white backdrop. Since I use a diffuse bitmap and a red-black alpha bitmap to construct my images, the quickest hack was to write a program that would take a PNG and convert it into a diffuse and a red-black alpha bitmap.
I spent a bit of time struggling with libPNG but gave up in the end and used GDI+ to write a quick program that does this. Seem to get some strange diffuse artifacts around the very low alpha pixels, but the end result seems to be okay.
Now off to try to get the text rendered with ClearType.
Got the selection working now. You can select and deselect vertices or triangles using the ortho views and triangle selection supports ignoring backward facing triangles. As per szec's comments below, it was easier to just do this in screen space really. I have an existing function that converts an (x,y,z) into an (x,y) based on the current projection.
Man, this project is going to be a biggy though. The further I get into it, the more complex it seems to get. I don't want to implement too much more functionality until I have the undo/redo system working now - selection and deselection should be undo-able/redo-able so I now have something concrete to base the system on and I've learned in previous editor projects that if you don't get undo/redo working right from the start, it is almost impossible to retro-fit.
Quite a lot more enthused now it doesn't look so much like MilkShape but have also been pondering some of the ways I want to add functionality that MilkShape lacks. Some ideas are:
- A hide/unhide stack. In MilkShape, if you have performed a few hide actions on different groups of verts or triangles, your only option is to unhide them all to get them back. I intend to implement a stack where you can Hide, then Unhide Last or Unhide All.
- Automated, real-time mirroring. Again, in MilkShape, a symmetrical model has to be built in one half, then mirrored manually and the vertices stitched together. I've found a model often looks nothing like I expect when I do this so it would be great to have a more Sculptris-style mirroring system.
- Bone mirroring. MilkShape's animation system has many foibles, but one of the most annoying is that you can't easily mirror an animation (for example, in a walk cycle, you want to mirror the arms and legs on alternate key-frames) so I plan some system for this.
- UV unwrapping. This is complex. If only I knew someone who had worked extensively on a paper-modelling program who could give me some advice. Oh, hi szecs. Never saw you there.
- Vertex weight painting. I have no idea how to improve on MilkShape in this respect, but there must be a better system. I'll research how the big players (3DSMax, Maya etc) work in this respect.
- Pre-rendering. I've never written a ray-tracer but would be nice to have some high-quality rendering support a la Blender. Also a system to pre-render animations as sprite sheets would be cool.
And also just some generally game-useful features like maybe an IK system to, for example, lock walk-cycles to the floor.
Lots of ambition, less of the ability but it's a great learning curve and I'm sure I'll pick up a lot of 3D programming skills I lack.
Just bored shit-less with writing games at the moment so this project is a very interesting sideline.