   Model Loader tips?
  I've been writing a few model loaders, well, I guess you could say I've been writing an engine (not in the "OMG I'm gonna write the next great MMORPG and I'm writing my own leet engine for it"), more in the sense that I've just been writing some modules such as timers, camera, frustum, terrain generator, etc... trying to practice some fundamentals like cutting down on coupling, and providing clean interfaces, cutting down on leaking abstractions, basically just trying to improve my coding practices while learning some stuff at the same time, and a week or so ago I realized It's looking closer to beginnings of an engine, or at least a framework type deal, anyways I digress.In the midst of writing a few model loaders (MD2, MD3, working on MD5 and OBJ), I started wondering if it's best to write a Model class (such as MD2Model) with the loading code in a load() method, which is what I've been doing, or writing a model loading class (MD2Loader) that simply fills a a model object.It has always seemed cleaner to have the loading code contained within the model itself, but now dealing with Scanner and Parser objects for dealing with the  ascii files like MD5 and OBJ, it seems like a lot of overhead within the model classes.Any opinions?   
  Well, considering that an MD5 model is vastly different than an OBJ model I don't see why you would want to store them in the same type of data structure.  Separating the loaders from the actual model would make sense if all the model formats you're using worked with the same type of data.   ;Quote:Original post by X Abstract XWell, considering that an MD5 model is vastly different than an OBJ model I don't see why you would want to store them in the same type of data structure.  Separating the loaders from the actual model would make sense if all the model formats you're using worked with the same type of data.Well I wasn't suggesting I would use the same data structure for different types, I just meant the style of loading, built-in vs. Separate loader classes.So is that a vote for built-in?As a footnote.  If I were to use the same class for different model formats, I'd probably separate them into static (OBJ), Vertex Animated (MD2, MD3), and skinned (MD5) types, or write an offline loader to import models into a more suitable internal format, but that's further down the road.   ;  Then I would just use a different class for each model type and use a built in loading function.  Simplicity wins, don't over-complicate the design in my opinion.edit:  Actually, sorry to make your decision harder but I'm on the fence.  In reality, the model should not care how it's data was loaded therefore writing loader classes might make more sense.   ;  I would use seperate models and seperate loaders.A base model which can then be extended to add animations etc.Seperate model loaders which take a "Model" object and fill it outThen finally you have a factory that determines the most appropriate model/loader to use based on a file name (or any other method you choose) and creates a model, fills it out and returns it.I don't really like the idea of returning a "Model" which might actually be an "AnimatedModel" but using a single "Model" object that can deal with everything might get very bloated.I definatly would split model loading and models into seperate classes. I did this myself and its far neater and easier to expand.   ;Quote:Original post by godsenddeathIn the midst of writing a few model loaders (MD2, MD3, working on MD5 and OBJ), I started wondering if it's best to write a Model class (such as MD2Model) with the loading code in a load() method, which is what I've been doing, or writing a model loading class (MD2Loader) that simply fills a a model object.It has always seemed cleaner to have the loading code contained within the model itself, but now dealing with Scanner and Parser objects for dealing with the  ascii files like MD5 and OBJ, it seems like a lot of overhead within the model classes.Any opinions?Write one model class and different model loader classes. Model formats have nothing to do with internal model data structures. Even if your model structure is capable of holding animation data, it is legal to load an .obj file containing a static mesh.It is like image formats, do you want to write different texture classes to hold png,jpg,gif,tga files ?   