Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Batching Objects together

Posted on 2006-06-08
4
Medium Priority
?
216 Views
Last Modified: 2010-04-16
I have a quick little C# app that draws 3D objects (primitives)

I have 3 objects that I want to draw:

Cubes
Cones
Spheres

At the moment I am drawing them as they come in. So I could have 3 cones, 1 Cube, 2 spheres, 1 cone, 5 cubes etc.

As you can imagine this is in-efficient. Basically what I would like to do is batch the objects together so that all like objects are together eg: all cones, all cubes, all spheres are together.

Just before I finish a frame I will refer to the batch and draw the primitives.

What I was planning was to create a simple design pattern that simply added the objects to the relevant structure (either an array list or perhaps a hash table.) Then iterate through the structures when ready.

Anyone have any ideas on how to organise or store basic objects in a structure that would all for the most efficient insertion and retrieval?

0
Comment
Question by:directxBOB
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 16867796
>> As you can imagine this is in-efficient.
Why?

Drawing objects is 3D space is usually done by z-order, and not by their types. However, you can keep all your objects in 3 lists, every list contains objects of one type.
0
 

Author Comment

by:directxBOB
ID: 16867819
In this situation Z-Order isnt important, but rather squezzing that little bit extra out of it. I could pipe all objects into their various lists and pull them out as needed.
0
 
LVL 9

Accepted Solution

by:
pallosp earned 2000 total points
ID: 16868262
I think the fastest data structure that meets your requirements is a generic FIFO queue for each type of objects. The insertion and the retrieval are both done in constant time.

http://msdn2.microsoft.com/en-US/library/7977ey2c.aspx
0
 
LVL 3

Expert Comment

by:solublefish
ID: 16868529
I think it probably doesn't matter. With 3d graphics, almost all the processing time is in the transforms, etc that go into processing the objects. Optimizing the storage is like taking an eyedropper of water out of niagra falls. The fastest order to process them is the one that eliminates the most transforming, lighting, texturing, and rendering. As someone said, that's usually done by descending z-order, but there are more complictated algorithms (BSP-trees come to mind) that are even better.

If really all you care about is the storage for some reason, pallosp is right - use 3 queues. If you need a single data structure to retrieve from, wrap the 3 queues in a simple class that inserts/retrieves from the right one.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question