Horde3D

Next-Generation Graphics Engine
It is currently 19.05.2024, 21:20

All times are UTC + 1 hour




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: 03.04.2009, 09:32 
Offline

Joined: 21.08.2008, 11:44
Posts: 354
Is it possible to show the progress of resource loading? I mean something like bytes loaded or number of loaded resources.


Last edited by Siavash on 07.04.2009, 06:00, edited 2 times in total.

Top
 Profile  
Reply with quote  
PostPosted: 03.04.2009, 14:14 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
You may add a callback or something like that into the Horde3DUtils::loadResourcesFromDisk or write your own custom loading code.


Top
 Profile  
Reply with quote  
PostPosted: 03.04.2009, 15:58 
Offline

Joined: 21.08.2008, 11:44
Posts: 354
Do you mean something like this :
Code:
   float loadedResPercent;
   
   DLLEXP float getLoadedResPercent()
   {
      return loadedResPercent;
   }

   DLLEXP bool loadResourcesFromDisk( const char *contentDir )
   {
      bool result = true;
      string dir;
      vector< string > dirs;

      // Split path string
      ...
      
      // Get the first resource that needs to be loaded
      int res = Horde3D::queryUnloadedResource( 0 );

      /////////////////////////////////////////////////////////
      // Get the total resource count /////////////////////////
      /////////////////////////////////////////////////////////

      int resCount = 0;
      int loadedResCount =0;
      loadedResPercent = 0;

      while ( Horde3D::queryUnloadedResource( resCount ) )
      {
         resCount++;
      }
      
      resCount = 100 / resCount;

      /////////////////////////////////////////////////////////
      // Get the total resource count /////////////////////////
      /////////////////////////////////////////////////////////
      
      ...
         
         loadedResPercent = loadedResCount * resCount;
         
         // Get next unloaded resource
         res = Horde3D::queryUnloadedResource( 0 );
         loadedResCount++;
      }

      return result;
   }
then how to assign a callback to getLoadedResPercent()?


Top
 Profile  
Reply with quote  
PostPosted: 03.04.2009, 16:11 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
You have to define a function pointer and pass a pointer to the callback function to loadResourcesFromDisk.

Something like this:
Code:
typedef void (*cbPercent)( int percent );

void callback( int percent )
{
    printf(" %d percent done \n", percent );
}

Horde3DUtils::loadResourcesFromDisk( ".", &callback );


In this case you have to change the signature of loadResourcesFromDisk to
Code:
Horde3DUtils::loadResourcesFromDisk(const char *contentDir, cbPercent funcPtr )


Top
 Profile  
Reply with quote  
PostPosted: 03.04.2009, 16:14 
Offline

Joined: 21.08.2008, 11:44
Posts: 354
thanks a lot :D


Top
 Profile  
Reply with quote  
PostPosted: 03.04.2009, 16:23 
Offline

Joined: 05.03.2007, 19:38
Posts: 167
Location: Romania
This is interesting. Would it make its way into horde3d?

_________________
Paul


Top
 Profile  
Reply with quote  
PostPosted: 05.04.2009, 12:21 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
Having a good loading screen is a bit tricky. Just counting the number of unloaded resources will make the progress bar jump back since a loaded resource can have new dependencies. I think the only reliable way is to store a list of all required resources (e.g. for a level) somewhere in a custom text file.


Top
 Profile  
Reply with quote  
PostPosted: 05.04.2009, 16:09 
Offline

Joined: 21.08.2008, 11:44
Posts: 354
marciano wrote:
Having a good loading screen is a bit tricky. Just counting the number of unloaded resources will make the progress bar jump back since a loaded resource can have new dependencies. I think the only reliable way is to store a list of all required resources (e.g. for a level) somewhere in a custom text file.
Unforunately it's a little tedious to store a list of all required resources [manually] in a text file. Perhaps you have a top secret tricky way 8)


Top
 Profile  
Reply with quote  
PostPosted: 05.04.2009, 17:06 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
The project is open source, so all secrets are open :-)
As marciano already pointed out, a problem may be the dependencies of resources being loaded. So if you load a scene graph resource, the materials, models, etc. referenced by the scene graph are not known before. And if you trace down all resource dependencies you have at least the scene graph resources loaded already.


Top
 Profile  
Reply with quote  
PostPosted: 05.04.2009, 20:09 
Offline

Joined: 21.08.2008, 11:44
Posts: 354
So we can't count the total resources in code :
Code:
      int resCount = 0;

      while ( Horde3D::queryUnloadedResource( resCount ) )
      {
         resCount++;
      }
     
      resCount = 100 / resCount;
and unfortunately this piece of code would give us the wrong value !?


Top
 Profile  
Reply with quote  
PostPosted: 06.04.2009, 01:07 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
Volker wrote:
The project is open source, so all secrets are open :-)
As marciano already pointed out, a problem may be the dependencies of resources being loaded. So if you load a scene graph resource, the materials, models, etc. referenced by the scene graph are not known before. And if you trace down all resource dependencies you have at least the scene graph resources loaded already.
Realistically, the xml files take almost no time to parse, so one only needs to track the number of models, textures and animations. Perhaps it would make sense to separate resource loading into two passes: the first loads all xml files, and thus computes the complete dependency tree, while the second pass loads all the models/animations/textures.

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
PostPosted: 06.04.2009, 15:24 
Offline

Joined: 21.08.2008, 11:44
Posts: 354
swiftcoder wrote:
Realistically, the xml files take almost no time to parse, so one only needs to track the number of models, textures and animations. Perhaps it would make sense to separate resource loading into two passes: the first loads all xml files, and thus computes the complete dependency tree, while the second pass loads all the models/animations/textures.
Yes, I'm agree with you. This is the best approach to solve this problem.


Top
 Profile  
Reply with quote  
PostPosted: 09.04.2009, 05:18 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
An alternative that I've seen is to simply load the level in the game, and log all of the resources that get loaded.
A full dependency list is then generated from this log.

If the level is modified, then this step needs to be repeated (e.g. by the level designer).

In the project that I saw this technique used on, this log was also used to optimise packed resources (the order that the resource files are stored in the "pack file" was re-arranged to minimise DVD seeking).


Top
 Profile  
Reply with quote  
PostPosted: 09.04.2009, 06:09 
Offline

Joined: 21.08.2008, 11:44
Posts: 354
Wow, good idea ! I'll have a try.


Top
 Profile  
Reply with quote  
PostPosted: 09.04.2009, 07:38 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
TBH, swiftcoder's idea is more robust, but this method could probably be implemented without any changes to Horde.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 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