graphic object list!

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • graphic object list!

      Disclaimer: I am long winded and have been known to ramble. However, if you can make sense of any of my questions, I am in great need of advice!

      How should I implement the graphic object list in my engine? I will say "list" for lack of a more appropriate term, even though technically the objects may not be arranged in a list. I have a base GraphicObject interface class from which all of my game's graphical objects are inherited from. I have implemented the graphic object list as a simple linked list with the capability of heirarchical relationships between objects, but now I am ready to make the thing not just usable, but practical.

      First of all, what data structure should I use to implement the graphic object list? The list will need to support large numbers of objects with multiple additions/removals from the list. The list will also have to be sorted and/or minimized.

      Secondly, how should I seek to optimize the graphic object list? From what I know, I should try to minimize state changes, minimize overdraw, and batch vertices as much as possible.

      Should I sort my graphic object list according to the z-coordinate of the objects, sorting from front to back, and rendering in that order? And as for batching vertices, should I build a single large vertex buffer from all objects in the graphic object list, and then blast them to the display adapter? It seems like the cost of building the vertex buffer every frame would outweight the gains of cutting down the render state changes just a little.

      I have considered batching vertices on a case-by-case basis, depending on the number and type of objects. For example, if I have a game with a landscape where 50-100 trees are visible at any one time, and all of these tree objects use the same geometry and textures. I could remove these objects from the front-to-back sorting of the graphic object list, and batch them all together into a single large vertex buffer, rendering them all at one time, but increasing the overdraw percentage.

      I don't have much experience in 3D graphics and I would love to here some comments about this subject.

      Thank you!
      -tc

      The post was edited 1 time, last by tchamblee ().

    • RE: graphic object list!

      There's a bit of discussion on sorting in the book - here's a synopsis:

      1. For your draw list, insert your objects in a Z-sorted list, sorted from front to back. As objects move around or the camera moves around, you should resort the list. Draw the static environment first, in the hopes that it will cover other objects - effectively keeping their pixels from drawing and saving some rendering time.
      2. As the list is traversed during the draw filter out transparent objects into a special list and draw them from back to front after everything else. This keeps them looking right since you can see things through them.
      3. Draw your sky last.

      You should probably also have some additional data structures that you can use to do object searches quickly - if you set off an explosion you don't want to search through your entire object list to find out which objects are affected.

      Batching your verts and polys is a good idea - but I've seen this done at a lower lever than your object list. When you send objects into the rendering pipeline, it should do the batching there - maybe taking the time to perform some optimizations like minimzing texture switches.

      I hope that helps!
      Mr.Mike
      Author, Programmer, Brewer, Patriot