Categories: General Posted by pieterg on 11/8/2005 11:59 PM | Comments (6)
Today I am going to try and map out what I have in store for my resource and entity manager. When working with large amounts of data such as textures, meshes and other variables also known as resources you need to be pretty sure that you manage them well. Let s go over some of the basic methods that present themselves. Entity self loadingYou could have an entity manager that has a couple of methods for handling it s own resources. This is quite a good concept at first and let s look at the basic outline /// /// Handles specific entities and queries the resource list to instantiate them /// class EntityManager { #region Membersprivate ArrayList entityList;#endregion#region Propertiespublic ArrayList EntityList {get { return entityList; } }#endregion#region Methodspublic EntityManager() { entityList = new ArrayList(); }publicvoid Add(Entity entity) { entityList.Add(entity); }publicvoid Remove(Entity entity) { entityList.Remove(entity); }#endregion } From first glance this seems pretty useless as it s just a skeleton and it could easily be just an ArrayList can t it. The thing to note is that you could enhance the entity manager to control certain parts of each entity like provide a cull method or provide a property that will only return renderable entities. This is really just a simple entity manager. The problem comes in resource management and that you might have 50 entities using the same texture or mesh or both. So when loading your entities and letting them handle their resources themselves present the problem of duplicating alot of resources which is "bad". What else can we do?The Resource Manager We could create a resource manager. This resource manager will keep a list of all available resources that are loaded and ready to use. This will include textures, models and more.. This will enable the entity manager or scenegraph whatever the structure of your engine is to query the resource manager for a set of specific resources and create an entity object and place it in a entity list. PS: The entity list is usefull for doing queries from as it will enable you to pass the list between manager such as your physics engine that will do it s magic on the entities and pass the object to a pre-render batching system that will compute a PVS (Potentially visible set) which will basically cull some objects and pass a modified list to the renderer for rendering. /// /// Manages resources such as Meshes, Animations, Textures. /// class ResourceManager {#region Membersprivate Hashtable resourceList; #endregion#region Propertiespublic Hashtable ResourceList {get { return resourceList; } } #endregion#region Methods /// /// Constructor : Initializes the resource list /// public ResourceManager() { resourceList = new Hashtable(); }public void Add(string key, object resourceItem) { resourceList.Add(key, resourceItem); } #endregion } You could provide methods on getting the resources which should be trivial. As I continue to make adjustments to this work in progress I shall post updated parts of the resource and entiy manager.

Comments

Stefan Liukkonen
Stefan Liukkonen United States on 4/6/2010 1:50 PM Discovering the best way to open up your Xbox 360 will allow you to insert just about any mods you prefer. I have composed instructables on how to open up, disassemble the case, how to fix the Red Ring of Death. Get ready to dig into  Microsoft's successor to the Xbox, and have some fun in your future projects =)
Waylon Viteo
Waylon Viteo United States on 4/30/2010 4:26 PM There are actually quite a few incredibly great points made here. Commonly, I am not very keen on blogs. however, occasionally all of us should take notice. Stimulating, I'm thankful to you.
ssk sorgulama
ssk sorgulama United States on 5/1/2010 6:48 PM I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post
locksmiths
locksmiths Germany on 5/4/2010 11:16 AM MMM...Maby considere to put here more this subject pic
Danilo Stembridge
Danilo Stembridge Poland on 5/6/2010 8:24 PM Do you earn decent capital from this blog or are you doing it only for fun?
bellingham real estate agent
bellingham real estate agent United States on 5/8/2010 9:09 AM I've been serious about beginning a weblog like this, however I just don't know if I'd have the tenacity and the momentum to keep going day after day.  I assume I should go for it if I really need it!

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading