Sign in to follow this  
speciesUnknown

What should this look like?

Recommended Posts

Hi there, Ive successfully written a loader for the AC3D file format, from file into VBO's. This file format is designed to load a large file of 3d geometry from disk, then store it in memory such that the geometry is divided into chunks of an arbitrary size. Then, the sysem can load the data in real time, ensureing that no more world is loaded than the circle of the same radius as the draw distance. My first prototype does both the job of loading the file from the intermediete file format, and storing it in memory as seperate chunks. However, I need to break it into several classes because it would be absolutely massive if given all the functionality. Classes that I will likely need in order to obey single responsibility principle: LOADERS: class AC3DLoader - loads from the intermediate file format .ac class NativeLoader - loads from the native file format of the system. WRITERS: class NativeWriter - writes data to the native file format, .polyforest or .plf STORAGE IN MEMORY: class Streamer - controls all the other classes and transparently loads the file into memory. Can only stream from the native file format. class SceneGraph - uses the streamer and a database to load and store the entire world transparently, including entities, and provides an interface to manage the addition of new entities, and the removal of old ones. The names of the last two classes are uncertain, since Im not planning to have any streaming functionality in the first prototype. Does anybody have any recommendations for what this should look like? IM thinking that the above classes should go into a namespace, and a single header includes all the other class headers.

Share this post


Link to post
Share on other sites
Might I suggest a template-based resource manager to finish? Configure the classes that load files to have the same Load(std::string Filename) function and write a resource manager that could do something like:


CResManager<CModel> ModelsManager;
CResManager<CTexture> TextureManager;

ModelsManager.SetDirectory("Data//Models");
TextureManager.SetDirectory("Data//Images");

CModel *Dino = ModelsManager.Load("dinosaur.3ds");
CModel *Dino2 = ModelsManager.Load("dinosaur.3ds");
CModel *Plane = ModelsManager.Load("plane.3ds");

CTexture *MouseCursor = TextureManager.Load("mouse.png");

ModelsManager.Release(Dino);


This is how I propose mine will behave once its finished.

The responsibility of the resource manager is to make sure no two copies of the same file are in memory, and to ensure resources are not released until every instance has been finished with. In the above example, the data for dinosaur.3ds would NOT be released until ModelsManager.Release(Dino2) had also been called.

I think its tidy, and I'm enjoying making it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this