Tyr: Transforming Nodes

Posted in Code on December 11th, 2011 by Pyroka

It’s been a good week, I managed to complete the to-do list from my last post early in the week, node transforming (translate, rotate and scale) went in pretty fast, and it was very nice to be able to drag nodes around the screen. I also buffed up the properties slightly, adding a hash property (created by hashing the name of the property with MurmurHash) and saves that when saving the properties, when loading properties it finds a property that matches that hash, and then checks that the type is what is expected. This should allow me to add, remove and move around properties and it will ‘just work’ (previously it assumed that the order of the properties would be the same loading as it was saving, and that properties were all the correct type, very dangerous assumptions but that was just first-pass temporary code).

Fixing the issue with dragging and dropping items from the scene graph TreeCtrl turned out to be a one-line fix, I forgot that the tree control items own the data you associate with them, and it was being deleted as part of the drag/drop action, and then causing a crash (well, hitting an assert actually) when that item was then selected (as that data was expected to be there).

So with those tasks sorted, I moved on to the next big job: Making it so that you can select multiple nodes and then transform them with the mouse, this was a bit of a pain and is still not entirely complete (currently the properties PropGrid only shows if you have exactly one node selected, in future it will show all common properties shared between all selected nodes, and allow you to change them for all selected nodes at once), but as a task it wasn’t particularly difficult, just a case of going through the code and sorting out each of the places that assumed there was only ever one selected node (not that many, as it turned out).

Then I added a ‘selection marker’, this is a cross that follows the selected node or nodes (assuming the average position in the case of more that one node being selected) and has a (small) hit-area, you click can click and drag that to translate, rotate and scale the selected node(s), thus allowing the click-and-drag transforms to work on nodes that have a size of 0, which previously didn’t work.

Finally I added some extra buttons to the editor to expose some align functions, these allow the user to select a group of nodes and align them to the left, center, right, top, middle or bottom, which uses the nodes personal bounding boxes (as in, the bounding box that encompasses that node only, excluding it’s children) to align the nodes, for example if you select a bunch of nodes and click ‘align-left’ then the nodes will be arranged so that the minimum extent on the x-axis of their personal bounding boxes will all equal that of the left-most node, quite a useful operation.

So then, next week I want to make sure that loading and saving scenes works as intended, and I might move on to attempting to build-up a more complex, realistic scene… I’ve been putting some thought into the game I might make to test features of the engine as I go along, nothing has really solidified yet but I have some interesting (at-least for me) ideas. I also want to make sure it compiles on Linux but progress on that front may be slightly slower (I have to be in a particular mood to comb through GCC compile errors…)

Tags:

Tyr: Now Using Premake

Posted in Articles on December 3rd, 2011 by Pyroka

So, no blog post last week, I had actually managed to get some things done, just not really enough to blog about, my attention was irratic, jumping from task to task so much that I didn’t really get anything in a fit state to talk about. This week however, I managed to finish off some of the things I started last week, or at-least get them to the stage where I can write about them.

So the most major thing I did is that I finally moved the project over to using Premake, I’ve wrote about Premake before, but basically, it allows you to define project file that can then be compiled into Visual Studio, XCode or makefile projects (and more) so that you only have to maintain one file, (in my case, one file per-project and a master-file for the solution) and you can build on the 3 major platforms.

I also added the repository to Cerberus, (and it pretty much built first-time) so whenever I push to the main repository (hosted on BitBucket), Cerberus will download and compile the project on all the platforms I’ve set-up (currently only Windows, as I’m in the middle of setting up a Linux VM on my laptop) and e-mail me the result, it’s kinda cool to see my own CI software compiling my own engine, and then e-mailing me telling me it’s ok.

I’m anticipating some issues when I attempt to get Tyr compiling on Linux for the first time, I got a bit sloppy blocking off my Win32 specific code and I’m sure I will have fallen-foul of some of the warnings GCC has enabled that VS doesn’t, so I want to try and get this working as soon as possible, so I can sort these issues before I get too far with things. But I’m also tempted to leave it till the new year, where I shall be constructing a dedicated build machine or two (ideally one per-platform, but I’m debating just getting some OSX compatible hardware and VMing everything).

I also started the input library, (thinking I’d need it to progress with the editor) which saw me referring to this article by Keith Judge, which gave me a start diving into the weird and wonderful world of the Win32 RawInput API (I’d really love to talk to someone at MS who could attempt to justify some of those decisions…) which seems to be the way to go input-wise, and fits in with my whole taking care of things myself aspect.

Finally I looked into the editor, more precisely making it so you can translate, rotate and scale nodes using the mouse, like one would expect from a civilised program. I’d actually been working on that for a few days but apparently I wasn’t very awake when I was, it got to the stage where it was nearly working but not quite, but then the next day I had a look and it was glaringly obvious that the approach I was taking was making it stupidly hard for-myself and I re-wrote the thing in about half the lines of code of the original solution, and it worked just fine. So now you can drag nodes around the level… As long as those nodes have a size greater than zero, I’m attempting to come up with a solution for selecting/transforming nodes with no size in a way that won’t pollute the game-side code and only be available for the editor.

So that’s it for the past two weeks, this week I hope to clear up how I’m accessing properties (I’m planning some form of compile-time hash so grabbing properties by string is ok) and finish off the editor transforming code and add the buttons to the editor. Then I really need to look at dragging/dropping nodes from one part of the scene-graph tree control to another, as it currently very much doesn’t work but is a rather vital operation.

 

Tags: