Jump to content


Virtual Files


5 replies to this topic

#1 _NOISEcore

    Member

  • Members
  • PipPip
  • 31 posts

Posted 15 September 2011 - 07:17 PM

Yes, the title is quite ironic. Virtual files. Isn't any file virtual? Anyho.

Say that I write a file format used for 3D models, which combines the 3D files with the textures, AO, ...

How would I be able to read that file without have to create temporary files out of that.

Basically:
5 files into 1 file to write
to read: load them all during runtime while not having to create 5 actual files (so some sort of buffer system)

EDIT: Forgot to mention which language, dumb me.. It's C++

#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 5306 posts
  • LocationBellevue, WA

Posted 15 September 2011 - 07:49 PM

Why would you need to create temporary files? Just read the file into one big memory buffer, then set up pointers to the individual resources within that, and access them as you please.
reedbeta.com - developer blog, OpenGL demos, and other projects

#3 _NOISEcore

    Member

  • Members
  • PipPip
  • 31 posts

Posted 15 September 2011 - 08:34 PM

Yes, that was my question.

I have never had that much experience with file streaming,
and I didn't know that that was possible.

But now that I think of it..
Thank you :)

#4 rouncer

    Senior Member

  • Members
  • PipPipPipPip
  • 2722 posts

Posted 16 September 2011 - 10:30 AM

You can actually manage the whole harddisk from your own program just out of one file, set up access pointers, defragment, find writable positions... thats how sparse voxel octrees work, being able to find all the exact information out of one file so it quickly streams.
You can do the same thing with ram, just allocate it all into a single static buffer, then manage the internals yourself with your own code.
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.

#5 _NOISEcore

    Member

  • Members
  • PipPip
  • 31 posts

Posted 16 September 2011 - 02:56 PM

Ok.

So basically write it all into one file
And then when reading, read it into one buffer, and then (possibly)
Set up multiple pointers pointing to positions in the buffer which represent
beginnings & endings of files within the "master" file.

Or am I mistaken?

#6 rouncer

    Senior Member

  • Members
  • PipPipPipPip
  • 2722 posts

Posted 16 September 2011 - 03:39 PM

You could do it like that, but think, how are you going to reduce access times from just iterating through the list of files until you hit the right string comparison? :) Remember, this is how all "file packs" or "file wads" (like from doom) work, but you need to be able to extract the right information as quick as possible.

If you wanted to release a game, its good to do, its tacky (carmageddon was sold with about 10 million separate files in the program hehe) releasing a game with all the media in separate files people can just import into editors so simply, if you pack them all away you can add compression whilst copy protecting your media, visual studio can pack media in with the exe file, also.

[EDIT] actually, if you just wanted to load the whole thing, what reedbeta said would be all you need to do, but if you wanted to say load each level one at a time, you need the extra searching pointers.[EDIT]
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users