Jump to content

  • Log In with Google      Sign In   
  • Create Account


Scenegraph usage and design


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 Nanook   Members   -  Reputation: 504

Like
0Likes
Like

Posted 02 September 2012 - 03:07 PM

I'm designing a scenegraph and got some questions.

I have a local and world transform for each of the nodes in the graph. Is it normal to always work with the local transforms and then calculate the world transforms? When I save the scenegraph to file, would I only save the local transforms? Or would I store the world transform and then calculate the local transforms when I build the scene using the bounding volumes to find wich nodes it belongs to?

If I have some items on a table the items would be childs of the table and the table would be a child of a room, but what happens if the item falls off the table for some reason. Do you automaticaly check the bounding volumes to remove the item from the table and then add it as a child to the room? If so.. atm I'm only using a sphere as bounding volume in the scene graph, would that be accurate enough?

If I have a box with a ball inside the ball would be a child of the box. What if I rotate the box? I wouldn't want the ball to rotate.. how do you solve that issue?

Sponsor:

#2 Jason Z   Crossbones+   -  Reputation: 4905

Like
1Likes
Like

Posted 02 September 2012 - 04:12 PM

These questions all depend on what you are doing with the scene graph. In general, you can think of the relationship from parent to child as a hierarchical one - so things that make sense to have in a direct hierarchy where one depends on the other would make sense. In your example, items on a table make sense in some cases to be linked to the table. If you expect the table to move, then that would be logical to keep the items dependent on the table. However, if you expect the items to move without the table, then I would make the objects relative to the world. It is a matter of choice, and doing it however makes sense.

Regarding the storage of the local and world transforms, you should only have to store the local transforms, and then the links between objects. With that, the world transforms can be reconstructed just like the normal case when updating your scene graph.

#3 lawnjelly   Members   -  Reputation: 429

Like
0Likes
Like

Posted 03 September 2012 - 05:22 AM

I'm designing a scenegraph and got some questions.

I have a local and world transform for each of the nodes in the graph. Is it normal to always work with the local transforms and then calculate the world transforms? When I save the scenegraph to file, would I only save the local transforms? Or would I store the world transform and then calculate the local transforms when I build the scene using the bounding volumes to find wich nodes it belongs to?

If I have some items on a table the items would be childs of the table and the table would be a child of a room, but what happens if the item falls off the table for some reason. Do you automaticaly check the bounding volumes to remove the item from the table and then add it as a child to the room? If so.. atm I'm only using a sphere as bounding volume in the scene graph, would that be accurate enough?

If I have a box with a ball inside the ball would be a child of the box. What if I rotate the box? I wouldn't want the ball to rotate.. how do you solve that issue?


It's normal to have the local (relative) transforms as the most important .. the world transforms can be derived from these when traversing the scene graph, e.g. during rendering. You shouldn't need to save the world transforms to disk.

Having bounding spheres can be ok - depends what they are being used for. Culling, for example, yep they can be used.

Trying to use bounding spheres to decide what belongs to what parent is the wrong approach. The parent of an object is determined by how it should behave - i.e. turn a desk and you might expect the lamp on it to move to. But the chair next to it shouldn't necessarily move, even though it is within the bounding sphere of the desk. When the scene graph is saved, it should be saved with the tree structure information, not reconstructed from positions.

You'd do this typically by numbering the nodes (which might be pointers at runtime), because pointers make no sense when saved (unless you use offsets into a file e.g.), then you can 'fixup' the indices back to be pointers after loading.

The hierarchy might typically be created by an artist in their program, or a level editor, or programmatically. It depends, as said, on what you are doing and what results you want.

Adding the physics to the scene graph at the same time might be jumping the gun a little, I would suggest getting your head around it in terms of rendering, then deciding how or whether you can use the structure to help with physics.

#4 Hodgman   Moderators   -  Reputation: 29469

Like
1Likes
Like

Posted 03 September 2012 - 05:40 AM

I'm designing a scenegraph and got some questions.

The answers will depend on the purpose of the scene-graph. If it exists "to represent a scene", then it's probably too generic / got too many responsibilities at the moment.
For example:

If I have some items on a table the items would be childs of the table and the table would be a child of a room, but what happens if the item falls off the table for some reason. Do you automaticaly check the bounding volumes to remove the item from the table and then add it as a child to the room?

If the point of the graph is to express connections form one object to another (e.g. a character holding a gun), then it makes no sense for the items on the table to ever be a child of the table, unless someone has glued them on there.
If the point of the graph is to accelerate frustum culling queries by grouping objects together, then you might have a reason to dynamically change the parent-child relationships like this -- but now the graph should no longer be used for expressing connections (such as the character holding a gun, or the mug glued to the table).

Trying to make one uber-graph that solves multiple problems at once (e.g. movement constraints/connections and efficient culling) will only result in a bloated data structure that does a bad job of all of these problems. Figure out what the point of your data structure is, and then make it do a good job of solving that problem as simply as possible.

To quote TomF:
It's a great theory, but sadly it's completely wrong. The world is not a big tree - a coffee mug on a desk is not a child of the desk, or a sibling of any other mug, or a child of the house it's in or the parent of the coffee it contains or anything - it's just a mug. It sits there, bolted to nothing. Putting the entire world into a big tree is not an obvious thing to do as far as the real world is concerned.

I have a local and world transform for each of the nodes in the graph. Is it normal to always work with the local transforms and then calculate the world transforms?

When dealing with connected objects, the 'real' data is generally the local transforms, with the world transforms being generated (so there's no need to save them, and they shouldn't be modified directly).
If you're grouping objects for the purposes of accelerating culling, then you don't need each object to have a relative transform from it's parent group -- that's unnecessary information for the problem at hand.

Adding the physics to the scene graph at the same time might be jumping the gun a little, I would suggest getting your head around it in terms of rendering, then deciding how or whether you can use the structure to help with physics.

Also keep in mind that any physics engine is going to implement it's own "scene graph" internally, separate from your own, which is a good thing.

Edited by Hodgman, 03 September 2012 - 05:48 AM.


#5 Nanook   Members   -  Reputation: 504

Like
0Likes
Like

Posted 04 September 2012 - 05:18 AM

The scenegraph I'm working on now is for rendering only. should have specified that.

I realise I can make a more general scenegraph and then use that for each of the systems. rendering and physics..

I'm at work atm so dont have time to reply to much, but lots of good answeres here that gave me some good ideas.. thanks

#6 L. Spiro   Crossbones+   -  Reputation: 13270

Like
2Likes
Like

Posted 04 September 2012 - 07:02 AM

Why do you feel a scene graph would help you with rendering?
Why do you think a scene graph should have any relationship to physics?

A scene graph is a hierarchy of objects, as mentioned.
Once you go beyond a child/parent relationship, it is no longer just a scene graph. A child/parent relationship is appropriate for a character holding a gun as mentioned, or individual parts of a model, but how is that related to rendering or physics in any way?

If you have read about existing scene graphs such as OpenSceneGraph and read about what “features” they support, and somehow gotten the idea that scene graphs are appropriate for accelerating rendering and/or physics, you have been sadly mislead.

Correct implementations and usages of scene graphs have nothing to do with rendering or physics. They have only to do with the logical parenting and child…enting of objects.


If you want to accelerate rendering, use a render queue.
If you want to accelerate physics, use prune-and-sweep or an octree.


You are basically making the folly that so many before you have made where one thinks a scene graph can be used for more than just to say that a gun is a child of a hand.
If an object’s transform depends on that of another object, it should be a child of that object. That is as far as it goes. This has nothing to do with rendering or physics, and OpenSceneGraph and company are grossly overstepping their boundaries by pretending a scene graph can also be used to solve rendering orders and physics efficiency.
Just get out of that mindset.

What you want right now is a render queue. Not a scene graph.


L. Spiro
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#7 Nanook   Members   -  Reputation: 504

Like
0Likes
Like

Posted 04 September 2012 - 07:16 AM

hum.. right.. so will the render que handle the culling then?

#8 L. Spiro   Crossbones+   -  Reputation: 13270

Like
0Likes
Like

Posted 04 September 2012 - 06:03 PM

No, they will be culled before they reach the render queue, and this has nothing to do with a scene graph.
Research octrees for this.


L. Spiro
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#9 Nanook   Members   -  Reputation: 504

Like
0Likes
Like

Posted 05 September 2012 - 04:26 AM

Okay I see.. will do. Thanks :)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS