views:

933

answers:

2

Hi. I'd like to enable my game to load content (such as a model, a jpg file, etc.) during run-time and display them.

I looked at the sample on XNA website (http://creators.xna.com/en-US/sample/winforms%5Fseries2), however this method requires Game Studio (which means Visual Studio too) installed on the client computer.

What are the approaches to loading content during run-time without VS+GS? Do I have to to avoid XNA Content Pipeline completely? If so do I have to write my own graphic import library or are there any suitable ones for this task?

Thanks in advance!

+3  A: 

For loading a texture you can use Texture2D.FromFile method.

As for models I don't think there is a way to load them. If you just want to load vertex and index data then loading that from a file into buffers is fairly simple. If, however, you actually want a model instance then I know of no way (other than using the content pipeline)

Martin
If I understand you right, it is possible to write your own custom model class so that a model from an external file can be dynamically constructed? Thanks for the tip on Texture2D.FromFile, looks like just what I need!
Dan7
What do you need from your model class? Having a vertex buffer and an index buffer loaded in from a file is quite simple, doing things with animations etc will be quite difficult
Martin
In an ideal world the model's animations and other data will be imported as well. But I can see how it can be very difficult. Well I give up for now. 2D asset loading is good enough for me. But just for the sake of clarity, would it be easier to accomplish run-time loading if we know the specifications of the xnb binary format? Whenever we load we convert it to xnb first then load using content pipeline?
Dan7
If the model were in xnb format you could do it with the normal Content.Load, the problem is that the content pipeline for compiling resources from formats other than xnb isn't available on the redist of XNA (except for images, they're an exception that proves the rule). If you wanted to import models you'd have to use a filestream and parse the model file manually. Which is doable but not exactly trivial. Your best bet might be to look for a library for doing so, saving you at least parsing the model file, leaving you with the job of just putting it into an appropriate form to render with XNA
Martin
Thanks so much. That definitely clears a lot things up. xD
Dan7
glad to help :)
Martin
Hey by the way I saw your question about scripting on XNA/C# and provided a link to Managed Scripting (http://www.managedscripting.com/home/default.aspx), didn't even realize it was you until I saw the kitteh picture :D Anyway you should check it out, looks promising.
Dan7
oh heh small world in the SO XNA section ;)I'll go check it out
Martin
+1  A: 

Doing this would require alot of tweeks, and looking into the target files, changing them, and breaking some of the rules in the EULA for XNA Gamestudio 3.1 and below. Your best bet would be to create Vertex and Index buffers, and loading your own custom file type for models.

Acedia