# Organizing scene graph nodes that have multiple parents

I am trying to understand how, from an abstract sense, scene graphs should be organized.

Say that in a game, there is a scene where the user is inside a house. The house has four walls, and on one wall there is a painting. There is also a wood stove resting on the ground but with an exhaust pipe that extends up and "through" the ceiling. Also on the floor, there is a table with a pen and a piece of paper on it. How might this particular scene graph be organized?

house/
wall_1/
wall_2/
painting
wall_3/
wall_4/
floor/
table/
pen
paper
woodstove
ceiling/


Here's the root of my question: the wood stove connects to both the floor and the ceiling, so which parent node should it be a child of?

• The stove should only have one parent. Parenting is based on logic not visuals. – János Turánszki Feb 5 '15 at 14:19
• Thanks @JánosTuránszki (I'd upvote you if I had the rep to do so) - so maybe that's really the root of my question: what drives the logic for making that determination? Can you give me some examples? Thanks again! – DirtyMikeAndTheBoys Feb 5 '15 at 14:29
• I mean, it would be better to set the stove the child of the floor, and also the ceiling the child of the floor for example. Your graph should not be constructed regards to which mesh intersects with which. – János Turánszki Feb 5 '15 at 16:36

Not everything can be represented as a tree... You're conflating "adjacency" with "hierarchy". Both may be useful concepts, depending what you're doing with your world.

(Also, just to mention, there's no "right way" to do it, it just depends on your needs.)

Hierarchy in your tree is probably useful for moving things around. For example, parenting the pen and paper to the table makes it easy to move the table, and a "reasonable" thing happens, that things on it move also.

For this purpose, perhaps parenting house->floor->walls->roof would give "expected" behavior. If you move the house, the floor (and table) and walls and roof move. If you move the walls, the roof moves but the floor wouldn't.

But that's just for-instance.

Adjacency might be a graph that isn't a tree. For example, if you shake one wall, you might want just the nearest other walls, floor, and roof to shake.

How you arrange your data really depends on how you need to use it.