Hi guys,
I'm still working on my engine/framework currently sporting GUI and Scenegraphs and I've never had
to use multiple inheritance for any of this (Or I have been able to justify its use). Just yesterday, I bumped into a problem.
I have the following classes:
- SceneElement (A node in my scenegraph. Contains transformation vectors as well as dimensions and BBs for placeholder rendering. Based on Renderable, as SceneElements can be rendered)
- OffscreenRenderer (Basically an FBO wrapper. It's unrelated to SceneElement purpose-wise but is itself a Renderable, and contains a list of 0..* Renderables that will be drawn offscreen. It owns a Projection, and vectors for Position, Orientation and "Up". It also has a getter for the texture name, and a couple of private vars related to FBOs.
The "Renderable" difference between the two is that SceneElement is often a visual thing that can be shown, and OffscreenRenderer is something that will have stuff drawn onto it, while not self being visible. I was thinking earlier, to have both Renderable and a Renderer base classes,
but I discarded the idea as it would seem too redundant, and they'd both end up with a render() function anyways.
Now, I actually discovered the issue because, as I was creating a Camera class, inheriting from both of the above,
i now had two variables called orientation (the position alias in SceneElement is called offset, but that still smells either way.)
I also notice that Renderable goes for both of the base classes, and Camera as such has two of each Renderable variable!
It's two grandmothers is the same single person. Yuck!
When I based Camera upon SceneElement, I did it for the sole purpose of being able to parse the camera into a scene. But the camera itself is never shown, so it's different from other renderables. It's an invisible point entity,
and I'm really not sure I should keep it where it is.
I like the idea of my display queue to have a Camera as one of its renderables, and then afterwards, when the GUI is rendered, my View element now tied to the (OffscreenRenderer)Camera will show whatever was rendered for the Camera.
Should I aggregate OffscreenRenderer onto Camera instead?
Sorry about the wall of text. I'd like to illustrate it, but I don't want to lock the concepts down too much, as I am, obviously, reconsidering it.
Keep an open mind. :)