1
\$\begingroup\$

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?

\$\endgroup\$
3
  • 1
    \$\begingroup\$ The stove should only have one parent. Parenting is based on logic not visuals. \$\endgroup\$ Feb 5, 2015 at 14:19
  • \$\begingroup\$ 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! \$\endgroup\$ Feb 5, 2015 at 14:29
  • \$\begingroup\$ 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. \$\endgroup\$ Feb 5, 2015 at 16:36

2 Answers 2

1
\$\begingroup\$

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.

\$\endgroup\$
2
\$\begingroup\$

I would say think about what implication your organization have.

E.g. the stow: If it where a top down game you would put the stow under the floor since if you go into the house you would like to make the ceiling invisible by making that node deactivated. If you would have put the stow under ceiling the stow would be goon to and that is not what you want.

Think what you would need to do with the graph for your game.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .