Thursday, July 12, 2007

Deleting Things

I've added the ability to delete objects in the editor. This was actually fairly trivial since everything is nicely wrapped up as an EditorObject. Each type simple defines its constructor to remove the various Ogre items from the scene and a small amount of work is done by the EditorObjectManager (these really should be renamed to SceneObject and SceneObjectManager) to fire off an event and remove it from its internal list. That's about all there is to it.

With this, I have the ability to create and destroy the following Ogre items:

Scene Nodes
Entities
Lights

I haven't gotten to particle systems yet and they should prove to be interesting. I'm not sure how I'm going to layout the properties for those just yet. I'm assuming I'll have some plugin to expose even more properties of it so that it can be edited in its own window.

It should be fairly easy to add undo/redo functionality to this as well since I already have export/import working. I already have the ability to query for all of the properties I need to save so that shouldn't be a problem. The thing I am thinking will be the hard part is recreating the hierarchy. For example, if I delete a scene node, I will need to save that node and everything attached to it. Now when I store that, I'll have to store the scene node as well as all of the children objects (and then traverse downwards). When I go to undo the delete action, I will have to start at the top and create the object and assign its properties and then traverse downwards again. Now that I'm thinking about it, it won't be that hard actually. I'll store the properties of the object as well as an array of all the children objects. Then just create the main objects, set its properties, and then recurse down to its children. Presto bango I have an undo for delete. (And this is why I blog). I may in the future have to add the ability to parse some parameters *after* children objects have been created but I don't think there are any properties in Ogre that you can set on an object that rely on having a children. So yay for that.

I'd post a screen shot but it wouldn't mean much. It'd be the same scenes as I've shown before but with objects remove. Who knows. I could even fake it just be recreating the scenes without putting in a certain light. You wouldn't know :)

I'm still going to leave undo/redo for a bit until I get more done. So far, the system is become fairly stable. I haven't made any significant changes to it in a while which is good. I've been able to accomplish a lot, and in an easy manner, with this EditorObject system. I want it fully solid before I put in undo/redo since it will rely on it heavily to work.

The next feature I am going to work on is the ability to reparent things in the scene so that they can be moved around. It's a pain if you realize you want an additional node in between 2 existing ones. There is no way to do that without having to restart the entire tree at the given node.


That's it for today. I am going to try and go back to bed now.

No comments: