simple file scan question

Problems building or running the engine, queries about how to use features etc.
User avatar
walaber
OGRE Expert User
OGRE Expert User
Posts: 829
Joined: Sat Oct 02, 2004 2:20 pm
Location: California, USA

simple file scan question

Post by walaber »

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...
Go Go Gadget OGRE!!
Image
User avatar
pjcast
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2543
Joined: Fri Oct 24, 2003 2:53 am
Location: San Diego, Ca
x 2

Post by pjcast »

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)
Have a question about Input? Video? WGE? Come on over... http://www.wreckedgames.com/forum/
User avatar
pjcast
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2543
Joined: Fri Oct 24, 2003 2:53 am
Location: San Diego, Ca
x 2

Post by pjcast »

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)

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/
User avatar
walaber
OGRE Expert User
OGRE Expert User
Posts: 829
Joined: Sat Oct 02, 2004 2:20 pm
Location: California, USA

Post by walaber »

exactly what I was looking for! thanks! :lol: :lol:
Go Go Gadget OGRE!!
Image
User avatar
SpannerMan
Gold Sponsor
Gold Sponsor
Posts: 446
Joined: Fri May 02, 2003 10:05 am
Location: UK

Post by SpannerMan »

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 :D
User avatar
SpannerMan
Gold Sponsor
Gold Sponsor
Posts: 446
Joined: Fri May 02, 2003 10:05 am
Location: UK

Post by SpannerMan »

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

Code: Select all

RenderTexture * rt = new D3D7RenderTexture( name, width, height, texType, miscParams );
is missing an argument and should be:

Code: Select all

RenderTexture * rt = new D3D7RenderTexture( name, width, height, texType, internalFormat, miscParams );
but apart from that compiles fine.
nfz
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 1263
Joined: Wed Sep 24, 2003 4:00 pm
Location: Halifax, Nova Scotia, Canada

Post by nfz »

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.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Post by sinbad »

I never thought of that - if it's going to be useful to people I could put in an optional 'origin' string on Resource which can be populated by script loaders.
nfz
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 1263
Joined: Wed Sep 24, 2003 4:00 pm
Location: Halifax, Nova Scotia, Canada

Post by nfz »

That would be cool. If you are busy I could make a stab at this since I really do need it.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Post by sinbad »

It was very small, I already did it. :) I'll commit it as soon as I've run through some basic compat tests, let me know if it does what you need.
nfz
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 1263
Joined: Wed Sep 24, 2003 4:00 pm
Location: Halifax, Nova Scotia, Canada

Post by nfz »

Great, Thanks. I will check it out.
User avatar
SpannerMan
Gold Sponsor
Gold Sponsor
Posts: 446
Joined: Fri May 02, 2003 10:05 am
Location: UK

Post by SpannerMan »

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. :shock:

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
OGRE Retired Team Member
Posts: 1263
Joined: Wed Sep 24, 2003 4:00 pm
Location: Halifax, Nova Scotia, Canada

Post by nfz »

Sinbad: Man you are fast. Tested out the changes for materials and works great! Thankyou very much.