• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Nanook

Scenegraph usage and design

8 posts in this topic

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?
0

Share this post


Link to post
Share on other sites
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.
1

Share this post


Link to post
Share on other sites
[quote name='Nanook' timestamp='1346620075' post='4975827']
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?
[/quote]

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.
0

Share this post


Link to post
Share on other sites
[quote name='Nanook' timestamp='1346620075' post='4975827']I'm designing a scenegraph and got some questions.[/quote]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 [url="http://en.wikipedia.org/wiki/Single_responsibility_principle"]too many responsibilities[/url] at the moment.
For example:[quote]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?[/quote]If the point of the graph is to express connections form one object to another ([i]e.g. a character holding a gun[/i]), 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 ([i]such as the character holding a gun, or the mug glued to the table[/i]).

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.

[url="http://home.comcast.net/~tom_forsyth/blog.wiki.html#%5B%5BScene%20Graphs%20-%20just%20say%20no%5D%5D"]To quote TomF[/url]:
[i]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]
[quote]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?[/quote]When dealing with connected objects, the 'real' data is generally the local transforms, with the world transforms being generated ([i]so there's no need to save them, and they shouldn't be modified directly[/i]).
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.
[quote name='lawnjelly' timestamp='1346671362' post='4976022']
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.
[/quote]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
1

Share this post


Link to post
Share on other sites
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
0

Share this post


Link to post
Share on other sites
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
2

Share this post


Link to post
Share on other sites
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
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0