This assignment was pretty cool, it was the first time I've ever dealt with reading and writing binary files and it's a lot simpler than I thought. I still encountered a infuriating bug that was really hard to fix since everything was in binary, but finding it was pretty easy. Fixing it ended up being easier than what I was trying to do in the first place anyway. I'm still baffled by the stuff you can do with C++. This ain't your grandmothers programming language... then again it might be old enough to be.
Anyway, onto the graphics, this assignment was more about sorting and optimization than anything. We had to sort our entities by their shader and texture in an effort to minimize the slow swapping operations in the update loop. As you can see by my lovely screenshot here, I set the materials together, the effects together and then all the entity stuff. I basically just sorted the entity array after I parsed it in.
The actual fun part of the assignment was writing the Maya plugin. Well, more like writing a method of the Maya plugin. It was still awesome to be able to model something in Maya and export it into my customized format and be able to parse that into my own graphics system. I have a feeling when it comes time to add fbx support to our game engines renderer next semester we'll have a lot easier time. Nothing really bad happened with this section of the assignment, except the Maya install on my laptop apparently broke between now and December when I used it last. I couldn't hit the browse button on the plug in manager or the export all button or most menu buttons without the program immediately becoming perpetually unresponsive. It wasn't the plugin either, I couldn't even get that far. I ended up just using my lab computer.
The only big problem I ran into was the one I mentioned above. Since I'd never written or read in a binary file before I was a little confused as to how to read it back in. I ended up trying a way Sherly showed me, which confusingly only worked some of the time. It worked flawless for my cubes, and for some of the simpler shapes I exported from Maya, but one of my shapes only drew a single triangle and the torus read in a negative vertex count. It's hard to instantiate arrays with a negative size. Anyway, her method worked for her, and involved some bitwise ors to convert a char back to an int, but Cody showed me a much easier method that works 100% of the time. I'm thinking Sherly's method didn't work from machine to machine due to big endian and little endian differences, but I'm pretty sure she tested hers on the same lab machines we were using so I'm not sure.
Anyway, it was a pretty neat assignment, here's the code. Oh, and one thing to note, the changes I made to MeshBuilder in order to write the files to binary no longer overwrite existing files, so if you try to change a mesh in the Assets folder, you'll currently have to delete the mesh files out of the temp/data folder. Sorry about that, I'll find a fix for that next week, it's probably as simple as using another method out of that library that has CopyFile instead of using fstream.
No comments:
Post a Comment