Game Engine: Level Editor
Posted: March 5, 2011 Filed under: programming Leave a comment »Since I my last rewrote, I’ve been focusing mainly on background engine stuff that wasn’t quite where I wanted it to be. At some point I started working on game-specific stuff as well, although most of it is simply in place to test engine functions. Well, I wanted to get more focused on game-specific stuff but I realized I was missing some way to efficiently make test levels. So I started working on a level editor… a few days ago I believe. I don’t need anything fancy. Just a basic editor that will let me edit the 2D collision geometry alongside the 3D visual aspects of levels. I started working on collision geometry part. All that it requires was being able to draw line segments. Long story short, I ended up requiring to find a point along the ray created by the conversion from Screen to World coordinates. The collision geometry is always at a z-value of 0 but this required me to find a point along the ray which had a z-value of 0 so the segments would properly line up with the mouse when you’re drawing them.
This gave me a headache. I tried several solutions, going from seeing if I could form triangles to find the points I need (which, actually might have worked if I stayed with it) to arbitrarily adding stuff to the slope formula. I looked around the internet but couldn’t find something that screamed “This is what you need!” Perhaps I wasn’t wording it quite right, but then again I wasn’t sure how I should be wording it anyways.
As I am partly hopeful for the future of the Internet (and the people who use it), I half jokingly asked on a Counter-strike server I frequent if anyone knew how to solve this problem. Inititally, I was met with ridicule, so I let it be. A short time later, another player started asking questions. A little bit later, he was showing me parametric functions that I need. So, I am very grateful for him showing me how to go about doing it. In doing so I have gained two things:
- Calculus I != Calculus III and it is something I should read up on as I will be doing crazy stuff like this in the future.
- A new, very useful function to add to the utilities library.
I figured I needed to UnProject so currently I’m using glut’s implementation of Unproject but I will hopefully be creating my own implementation in soon.
Bottom line – the new editor will definitely be more feature complete and in less time than the previous iteration. Now, I need to find a good GUI Library where I can simply add a toolbar or new windows without having to use a special framing class.