Horde3D

Next-Generation Graphics Engine
It is currently 26.11.2024, 06:21

All times are UTC + 1 hour




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Resource management
PostPosted: 17.11.2008, 17:43 
Offline

Joined: 27.09.2008, 07:34
Posts: 35
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?


Last edited by kornerr on 17.11.2008, 18:06, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Resource management
PostPosted: 17.11.2008, 18:02 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
Use the findResource function, to find the resource by name.

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
 Post subject: Re: Resource management
PostPosted: 17.11.2008, 18:07 
Offline

Joined: 27.09.2008, 07:34
Posts: 35
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?


Top
 Profile  
Reply with quote  
 Post subject: Re: Resource management
PostPosted: 17.11.2008, 18:13 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
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".


Top
 Profile  
Reply with quote  
 Post subject: Re: Resource management
PostPosted: 17.11.2008, 18:28 
Offline

Joined: 27.09.2008, 07:34
Posts: 35
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')?


Top
 Profile  
Reply with quote  
 Post subject: Re: Resource management
PostPosted: 17.11.2008, 19:08 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Resource management
PostPosted: 17.11.2008, 20:45 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
You can also use queryUnloadedResource to iterate over the resources that were loaded automatically.


Top
 Profile  
Reply with quote  
 Post subject: Re: Resource management
PostPosted: 18.11.2008, 01:19 
Offline

Joined: 27.09.2008, 07:34
Posts: 35
Thanks.
When I unloadResource of a scene graph, does it also unload its geometry, material, shader and other resources?


Top
 Profile  
Reply with quote  
 Post subject: Re: Resource management
PostPosted: 18.11.2008, 02:01 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Resource management
PostPosted: 22.11.2008, 05:59 
Offline

Joined: 27.09.2008, 07:34
Posts: 35
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)?


Top
 Profile  
Reply with quote  
 Post subject: Re: Resource management
PostPosted: 22.11.2008, 15:17 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group