Horde3D http://horde3d.org/forums/ |
|
Resource management http://horde3d.org/forums/viewtopic.php?f=2&t=558 |
Page 1 of 1 |
Author: | kornerr [ 17.11.2008, 17:43 ] |
Post subject: | Resource management |
When I load a model resource the Horde also loads geometry, texture, shader and other resources, but I get back model handle only. How do I get handles to all loaded resources? |
Author: | swiftcoder [ 17.11.2008, 18:02 ] |
Post subject: | Re: Resource management |
Use the findResource function, to find the resource by name. |
Author: | kornerr [ 17.11.2008, 18:07 ] |
Post subject: | Re: Resource management |
What happens if I have two models 'cube1.scene.xml' and 'cube2.scene.xml' which have the same name inside (both have <Model name = "Cube") and I addResource them? |
Author: | Volker [ 17.11.2008, 18:13 ] |
Post subject: | Re: Resource management |
A model is not a resource, so you have two scene graph resources "cube1.scene.xml" and "cube2.scene.xml" that both contains a scene node structure that has a model node called "Cube". |
Author: | kornerr [ 17.11.2008, 18:28 ] |
Post subject: | Re: Resource management |
So I end up having two scenegraph resources named 'cube1.scene.xml' and 'cube2.scene.xml' which I can later find with findResource(SceneGraph, 'cube1.scene.xml')? |
Author: | Volker [ 17.11.2008, 19:08 ] |
Post subject: | Re: Resource management |
If you want to find the resource again, yes then you can search for it using Code: findResource(ResourceTypes::SceneGraph, "cube1.scene.xml") If you want to search for a scene graph node that you have added to the scenegraph you can use findNodes |
Author: | marciano [ 17.11.2008, 20:45 ] |
Post subject: | Re: Resource management |
You can also use queryUnloadedResource to iterate over the resources that were loaded automatically. |
Author: | kornerr [ 18.11.2008, 01:19 ] |
Post subject: | Re: Resource management |
Thanks. When I unloadResource of a scene graph, does it also unload its geometry, material, shader and other resources? |
Author: | DarkAngel [ 18.11.2008, 02:01 ] |
Post subject: | Re: Resource management |
kornerr wrote: Thanks. When I unloadResource of a scene graph, does it also unload its geometry, material, shader and other resources? You're probably looking for removeResource (instead of unloadResource). When you use addResource to create a scene graph res, the new resource is given a reference count of 1. Any other resources that are required (geo, material, etc..) have their own reference counters incremented as well. Then when you call removeResource on your scene graph res, it will decrement the scene-graph-res's reference count. If the count is now 0, then the resource will be deleted. If the scene-graph-res is deleted then it will decrement the reference-counters of it's "sub-resources" (the geo, material, etc...) - again, if their reference counters are now 0, then they will be deleted as well. |
Author: | kornerr [ 22.11.2008, 05:59 ] |
Post subject: | Re: Resource management |
So when I addResource(sceneGraph) I "manually" set sceneGraph's refcount to 1 while it then sets refcount to 1 for materials, shaders it loads by itself? I mean by loading sceneGraph I only increment sceneGraph's refcount, but not resources' refcounts that I don't load manually (manually meaning getting direct handle to the resource without searching for it)? |
Author: | marciano [ 22.11.2008, 15:17 ] |
Post subject: | Re: Resource management |
The engine keeps track of automatically added resources. When you remove a resource, the refcount of all other resources referenced by that is decreased. We are using smart poiters for that. But there is some difference between manually and automatically loaded resources. You should remove a manually added resource (with addResource) manually again (removeResource) because of course the engine can't know if you still need it. |
Page 1 of 1 | All times are UTC + 1 hour |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |