2

For my experimental 2D engine, I want to include a scene graph implementation to, with good performance, determine which objects have to be rendered (are visible for the camera).

Unfortunately, I don't know much about the further details on how that would work. A scene graph, as far as I know, is at its core a tree-based structure which can be used to organize child-parent relationships better.

  • How should one implement a 2D scene graph when aiming for the determination of what should be rendered in a single frame?
L K M
  • 29
  • 2
  • 1
    Perhaps read one of the many articles on the subject available on the web through a quick Google search. – Lightness Races in Orbit Apr 05 '11 at 12:33
  • I did not find anything related there, otherwise I wouldn't have asked here – L K M Apr 05 '11 at 12:37
  • When searching as @Tomalak suggests, an important keyword which may be helpful is **culling**. – Ben Voigt Apr 05 '11 at 12:37
  • I dont have a whole answer but finding which objects have to be rendered is easy in 2D : you just need the position and the bounding box of each object. – Jean-Bernard Jansen Apr 05 '11 at 12:39
  • Check out wikipedia : http://en.wikipedia.org/wiki/BSP_tree and http://en.wikipedia.org/wiki/Kd-tree – Jean-Bernard Jansen Apr 05 '11 at 12:39
  • @JB Jansen: I have read those articles, yet I do not fully grasp how I would go for the implementation of the whole system – L K M Apr 05 '11 at 12:41
  • 1
    I think you need to study the articles _in depth_, and analyse your options _over a period of weeks_ or even months. You're not going to be able to look them up on Wikipedia then write your "whole system" within a few hours, and teaching you how to write a graphics engine is beyond the scope of this website. – Lightness Races in Orbit Apr 05 '11 at 12:42
  • So I can't expect an answer to my question of how to implement a scene graph in a 2D engine for culling, thanks bye – L K M Apr 05 '11 at 12:49
  • here's an example: [Qt: The Graphics View Framework](http://doc.trolltech.com/4.2/graphicsview.html) – Nick Dandoulakis Apr 05 '11 at 12:54

1 Answers1

2

I would recommend a quad tree. To determine what to render in a frame you would discard any branches of the tree which are outside the view.

Andrew Marsh
  • 2,032
  • 15
  • 14