Jump to content

  • Log In with Google      Sign In   
  • Create Account

How to cleanly load different styles of assets?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 TheAsterite   Members   -  Reputation: 202

Like
0Likes
Like

Posted 01 May 2012 - 05:54 PM

Continuing my topic from here:
http://www.gamedev.n...ased-framework/

I understand that for assets like meshes and levels that are loaded/parsed the same way I can use one function to open up a file handle, then pass it on to the different asset loaders to be parsed and stored. However, when I start loading assets like a .dds texture which is easiest done with a graphics library call, is there a way to set up the asset pipeline such that it can use the same function? Or is there no way around the problem, and I need to set up a different way to load assets like these? I really don't like this approach because then I'd have to manage the different types of loading so that the asset loader now know about different types of assets.

It would really be of help if someone could link to some source code that has an asset loader like this implemented so I could see how it works.

My basic goals for the framework:

I'm only worried about having it work on windows

I'm only worried about using directX

I want to stream in world blocks to have a straight continuous level with branches

I want to have flexibility to experiment with shaders


Edited by TheAsterite, 01 May 2012 - 06:33 PM.


Sponsor:

#2 Rld_   Members   -  Reputation: 1404

Like
0Likes
Like

Posted 02 May 2012 - 04:43 AM

I don't think you can really differentiate the loading/parsing of different assets. To take model formats as an example, .obj files are simply differently constructed compared to .fbx files so it is impossible to parse it all the same way. One thing that is true though, in your case with directX, is that it expects the data you get from parsing is constructed in a certain way which will allow you to abstract it.

To give a basic example. You can write a loader that can handle several formats and it is able to distinct different formats in that loader, or you can make multiple loaders (polymorphism comes to mind), that's up to you really, some just have a bigger advantage. Anyway, you know what you need to load to properly render a mesh, so you can write all the read data to custom buffers of some sort which you can pass to DirectX.

I don't have any source code available for you, but it shouldn't be hard to figure out.

#3 Hodgman   Moderators   -  Reputation: 30351

Like
0Likes
Like

Posted 02 May 2012 - 05:22 AM

You can use something like the abstract factory pattern to associate different factories with different asset types (or file extensions, etc).

#4 TheAsterite   Members   -  Reputation: 202

Like
0Likes
Like

Posted 02 May 2012 - 11:12 AM

Thanks for all your help. Architecture is somewhat hard for me to understand. I really wish my university had some software design classes, I'm just learning this stuff as I go along.

#5 Krohm   Crossbones+   -  Reputation: 3113

Like
0Likes
Like

Posted 02 May 2012 - 11:05 PM

Perhaps have a look at the Asset Import library. What's the key point? Abstraction. Different layers of abstraction wrap different functionality inside the same call. In the factory pattern, the functionalities are sort of "distributed".
So, taking for examble OBJ vs FBX, AssImp lets you load it in the same way and spits out... with some flexibility of mind... the same resulting data structure.
Internally, the two things are very different, but at AssImp level of abstraction we don't care.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS