Scene builder design

Started by
7 comments, last by ThEpRoPhEcY373 14 years, 1 month ago
So, I'm currently working on our companies engine and scene builder at the moment. Our engine of course has a scene graph, which I implemented using industry best practices. To sum it up, I have a base scene node class, that all scene nodes need to inherit from in order to draw, and a scene graph class, that uses recursive iteration to traverse the tree. In the scene node base class I have a bounding sphere property, so that all scene nodes have a bounding sphere. This bounding sphere is later calculated to fit the model/object appropriately. The issue I'm having is in the scene builder. I'm trying to figure out what the best approach would be to rendering a bounding sphere when the model/object is clicked. I have the bounding sphere rendering correctly when a model/object is clicked, It's just the way I currently have it designed in our engine sort of bugs me. To picture it, every scene node has a children collection. When a new model/object is rendered in the scene, a child is added to that scene nodes children collection. That child node represents a bounding sphere scene node. The job of this child node is to visually render the bounding sphere of the model/object. For some reason this just bugs me. Does anyone know what the best approach would be to this? Does anyone have any experience with building scene/world builders? Thanks!
Advertisement
In my case (i do not claim it to be a best practice or even a "right" one, just to give you another possibility) every node has transforms, a child collection and two separate objects, needed for rendering: a material and a bounding shape, that are not nodes (i assume all my nodes to be "part of the scene", no render state nodes or stuff like that).

Each bounding shape has a boolean flag "_debug" that tells it to render itself or not (immediately after the node it bounds is drawed). So it is actually separated from all the child nodes, and there can be only one per node.

But i don´t see anything wrong with your approach. Maybe someone more versed in scenegraph design can give you a better solution.
Hey ArKano22,

Thanks for the reply. When I said that I am using best practices, I meant for the way I designed my scene graph and scene nodes. The bounding sphere thing is separate from the design : ). You know, what you're suggesting is not a bad idea. That makes since to not have it as a node. Instead, have it as an object/property for each node. I'm curious though, when a level designer is designing a level in our scene builder, would it make since to have the app in debug mode? I'm thinking not. It's a good start though! Thanks again!!!
Sort of continuing on this discussion, if anyone has any experience with designing scene/world editors, could you please reply to this post. I would greatly appreciate the knowledge. I have multiple questions regarding implementing a translate manipulator, axis rotation manipulator, and many other common things you see in scene/world editors. Thanks!!!
There are some tutorials that i found quite useful when developing my own editor, such as this one:

On object selection:
http://gpwiki.org/index.php/OpenGL_Selection_Using_Unique_Color_IDs

About translate, rotate and scale manipulators (or gizmos as i like to call them), a quick explanation:

For translate gizmos what i do is trace a ray from the mouse into the scene and intersect it with a plane defined by which axis i´m moving the object along (plane XY if you move along x or y, for example).
Then i take the intersection point between ray and plane and move the object there. This way, as you move the mouse across the screen, the object is moved in the surface of a 3D plane defined by the gizmo.

For scale gizmos, take the difference between the ray/plane intersection and the origin of the gizmo and use that as the object´s scale on that axis.

For rotation, my implementation was so messy that i better not comment on it :P, but it should be a matter of finding the angle of the vector between gizmo origin and the the intersection point. This is an easy 2D operation you can perform using atan2() or equivalent in your language.


I learnt all of this from a very good tutorial that unfortunately i can´t find now. If i happen to stumble upon it again i will give you a link.
Quote:Original post by ThEpRoPhEcY373
I'm curious though, when a level designer is designing a level in our scene builder, would it make since to have the app in debug mode? I'm thinking not. It's a good start though! Thanks again!!!


I don´t quite understand what you mean here. Do you mean if you have to be in a debug mode to see the bounds or something like that? There is just a boolean
that tells each bound to draw itself or not, you can switch it on/off on a per object basis from the editor, so for example if you want all "crates" to show its bbox, you can just select them all and put their bounds´ boolean to true. Its up to you if you use this to debug collisions or stuff during the game itself, or if your editor allows to play the game inside it then you should temporarily disable bounds rendering for all objects...
Thanks for the quick reply ArKano22! I appreciate the link you provided, but it seems that the article doesn't cover creating a translate manipulator and an axis rotation manipulator. Does your editor support those? It seems that both of those or even all manipulators are implemented the same in all editors and 3d modeling software, but I'm not sure on how to implement them. Are they coded in the engine or are they actual models that are created with 3ds Max/Blender ect...?

Continuing with the bounding sphere conversation from the previous posts, I thought you meant to show the bounding sphere only when in debug mode. I see what you're saying now. Yes, I have a simple boolean, "IsVisible", that I set if the bounding sphere needs to be shown or if an object is selected. Thanks again for your quick reply. Hopefully you have implemented an actual visual translate manipulator and axis rotator, so you could hopefully shed some light on the subject with me : ).
Quote:Original post by ThEpRoPhEcY373
Thanks for the quick reply ArKano22! I appreciate the link you provided, but it seems that the article doesn't cover creating a translate manipulator and an axis rotation manipulator. Does your editor support those? It seems that both of those or even all manipulators are implemented the same in all editors and 3d modeling software, but I'm not sure on how to implement them. Are they coded in the engine or are they actual models that are created with 3ds Max/Blender ect...?


About the bouding spheres, yes, i just meant to use a boolean, which in my case i named "debug", but that seemed to confuse you.

I implemented the 3 manipulators in my editor, yes. In my case they were a simple arrow made of lines, so they were coded. But you can use any model you import from Max or Blender, that´s not the important stuff.
You should worry first abou how to make them work, you can decide their appearance later.

The method to make a manipulator is roughly what i described in the previous post. If you have troubles with casting a ray to the scene or finding ray/plane intersections, you can study more on the subject or you can try to use someone else´s code or library. There is a library called gleem
http://www.gnu.org/software/gleem/
that implements all these manipulators. You could try using it.
Thanks again for the quick responses! I'm glad we're on the same page about the bounding sphere ;). Yes, I understand the math involved when it comes to 3d picking, translating, rotating, and scaling. It all came down to actually implementing each manipulator and thought, "crap...I'm not sure how to go about this". I thought about the simple arrow approach like you described, but i want it to look like all the other 3d modeling software packages. They seem to all implement it visually the same. I'm all about standards ;). I found an awesome video
This guy implemented his 3d manipulators exactly how I want to do mine. They're almost identical to Blender's.

This topic is closed to new replies.

Advertisement