simple file scan question
-
walaber
- OGRE Expert User

- Posts: 829
- Joined: Sat Oct 02, 2004 2:20 pm
- Location: California, USA
simple file scan question
well I'm finally starting work on my first complete Ogre game... it's a simple vehicle game.
anyway, I have made a simple text-format for my vehicles with the extension .vehicle. at load-time, I want the app to search a specific directory for all files with the .vehicle extension... then I can create a "choose vehicle" screen, which will load the vehicles individually.
I'm pretty sure I can use the ResourceManager to do this, but I'm not sure where to start. my .vehicle file is just a simple Ogre Config file, which I parse with a function I've already written...
so all I need is a way to search for files in a directory with a specific extension, and perhaps put the list into a string <vector>.
any help would be greatly appreciated!!
I could use a MFC function, but if possible I'd like to maintain portability of my app...
anyway, I have made a simple text-format for my vehicles with the extension .vehicle. at load-time, I want the app to search a specific directory for all files with the .vehicle extension... then I can create a "choose vehicle" screen, which will load the vehicles individually.
I'm pretty sure I can use the ResourceManager to do this, but I'm not sure where to start. my .vehicle file is just a simple Ogre Config file, which I parse with a function I've already written...
so all I need is a way to search for files in a directory with a specific extension, and perhaps put the list into a string <vector>.
any help would be greatly appreciated!!
I could use a MFC function, but if possible I'd like to maintain portability of my app...
-
pjcast
- OGRE Retired Team Member

- Posts: 2543
- Joined: Fri Oct 24, 2003 2:53 am
- Location: San Diego, Ca
- x 2
You can query Ogre for files within its resource locations... And you can also add specific directories to the Ogre location with (useing resource.cfg as the example apps do) or within your own code/
However, the exact way you do this depends on which Ogre version you use... If you are using Ogre cvs head (soon to be v1) look at ResourceGroupManager class.
If you are using pre v1... You can download my videoplugin directory from ogreaddons and both the ffmpeg and theora plugin use a custom helper class I made called OgreResourceLocator (note... that is not an Ogre file... but my own class)
However, the exact way you do this depends on which Ogre version you use... If you are using Ogre cvs head (soon to be v1) look at ResourceGroupManager class.
If you are using pre v1... You can download my videoplugin directory from ogreaddons and both the ffmpeg and theora plugin use a custom helper class I made called OgreResourceLocator (note... that is not an Ogre file... but my own class)
Have a question about Input? Video? WGE? Come on over... http://www.wreckedgames.com/forum/
-
pjcast
- OGRE Retired Team Member

- Posts: 2543
- Joined: Fri Oct 24, 2003 2:53 am
- Location: San Diego, Ca
- x 2
Actually... I'll just post the code for what I used for Orre .15 and before.
edited - Actually, I misinterperted what you wanted.. Its not my resource class you want, but the way I scanned files in my video demos to build lists is what you need.
Pre v1 (.15.2 and before)
This works for version 1 (cvs head)
edited - Actually, I misinterperted what you wanted.. Its not my resource class you want, but the way I scanned files in my video demos to build lists is what you need.
Pre v1 (.15.2 and before)
Code: Select all
std::set< String > OGG_MovieList = ResourceManager::_getAllCommonNamesLike( "./", "ogg" );
std::set< String >::iterator i;
This works for version 1 (cvs head)
Code: Select all
StringVectorPtr OGG_MovieList =
ResourceGroupManager::getSingleton().
findResourceNames( "General", "*.ogg" );
Have a question about Input? Video? WGE? Come on over... http://www.wreckedgames.com/forum/
-
walaber
- OGRE Expert User

- Posts: 829
- Joined: Sat Oct 02, 2004 2:20 pm
- Location: California, USA
-
SpannerMan
- Gold Sponsor

- Posts: 446
- Joined: Fri May 02, 2003 10:05 am
- Location: UK
Hi guys,
So far I have been sticking with Hastur, and I havent looked in depth at the new features in version 1 (cvs head) yet.
Do you know whether the new resource manager lets you know exactly where a resource originates?
And I dont mean just the file path, I mean the file, so if I loaded material X then I can tell that this came from the X1.material script. Same thing for particle scripts.
If it does, then thats gonna make things soooo much easier
So far I have been sticking with Hastur, and I havent looked in depth at the new features in version 1 (cvs head) yet.
Do you know whether the new resource manager lets you know exactly where a resource originates?
And I dont mean just the file path, I mean the file, so if I loaded material X then I can tell that this came from the X1.material script. Same thing for particle scripts.
If it does, then thats gonna make things soooo much easier
-
SpannerMan
- Gold Sponsor

- Posts: 446
- Joined: Fri May 02, 2003 10:05 am
- Location: UK
Having read the AzathothNotes on the Wiki page, Im still not sure about reourceManager holding a referance somewhere to the script of origin (see post above), so I decided to update my CVS code with Azathoth CVS HEAD to have a look in there myself. So far I *think* what Im looking for might be held in FileInfoList.
Anyway, I had a bug compiling Azathoth - in OgreD3D7RenderSystem.cpp on line 621, this
is missing an argument and should be:
but apart from that compiles fine.
Anyway, I had a bug compiling Azathoth - in OgreD3D7RenderSystem.cpp on line 621, this
Code: Select all
RenderTexture * rt = new D3D7RenderTexture( name, width, height, texType, miscParams );
Code: Select all
RenderTexture * rt = new D3D7RenderTexture( name, width, height, texType, internalFormat, miscParams );
-
nfz
- OGRE Retired Team Member

- Posts: 1263
- Joined: Wed Sep 24, 2003 4:00 pm
- Location: Halifax, Nova Scotia, Canada
Spannerman, I was looking for the same thing but its not there. Once a material, overlay, etc is loaded from a resource script, you can not tell which resource it originated from. I will have to implement this for the material editor I am working on since its a real pain for the user having to select which materials have to be saved to specific scripts after the script has loaded. I was thinking of using a resource loading listener to keep track of scripts loading and new materials created.
-
sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67
-
nfz
- OGRE Retired Team Member

- Posts: 1263
- Joined: Wed Sep 24, 2003 4:00 pm
- Location: Halifax, Nova Scotia, Canada
-
sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67
-
nfz
- OGRE Retired Team Member

- Posts: 1263
- Joined: Wed Sep 24, 2003 4:00 pm
- Location: Halifax, Nova Scotia, Canada
-
SpannerMan
- Gold Sponsor

- Posts: 446
- Joined: Fri May 02, 2003 10:05 am
- Location: UK
Woohoo!!
Damn you guys are fast! I have been looking through OgreResource etc and couldnt find it. I just came back to the forums before going to bed to post it in Feature Requests, not only to find nfz confirming what I thought, but Sinbad's gone and added it and stuck it in CVS.
Now where else in the world can you get support like that eh?
Currently the Particle Editor has some pretty pretty funky and perhaps-not-so-cross-platform code to get a particle templates filename, and we were probably going to have to do similar with materials. So yes, this is definately a useful feature.
Cheers!
Damn you guys are fast! I have been looking through OgreResource etc and couldnt find it. I just came back to the forums before going to bed to post it in Feature Requests, not only to find nfz confirming what I thought, but Sinbad's gone and added it and stuck it in CVS.
Now where else in the world can you get support like that eh?
Currently the Particle Editor has some pretty pretty funky and perhaps-not-so-cross-platform code to get a particle templates filename, and we were probably going to have to do similar with materials. So yes, this is definately a useful feature.
Cheers!
-
nfz
- OGRE Retired Team Member

- Posts: 1263
- Joined: Wed Sep 24, 2003 4:00 pm
- Location: Halifax, Nova Scotia, Canada
