Chris
Chris

Reputation: 171

XNA Content Loading

Anybody know how i can stream load Model data in XNA 4 Content Loader ?

And not have to specify a farken filename ... Was hoping somehow get a stream running as the model data resides on a db. And no, im not interested in temp files :p

Regards

Upvotes: 0

Views: 1060

Answers (3)

Aranda
Aranda

Reputation: 865

If you really want to use the Content Pipeline for this, you can subclass ContentManager and override OpenStream. This would assume that the built XNB files reside in the database and you can provide the stream to them when requested :)

Upvotes: 2

ClassicThunder
ClassicThunder

Reputation: 1936

I believe that this should help. If I remember correctly, I can't check because I'm at work, it lets you run the content importer on a stream dynamically. So you should be able to dump your file in a MemeoryStream and load it so long as its any of the file types XNA supports.

Be warned though this is pretty slow because you have to compile every file when you load it.

Curious of why you need to load from a database. I assume its from a remote server? In which case the download time + compile time might be a bit much. since it sounds like you would have to do it every time the game is loaded.

http://create.msdn.com/en-US/education/catalog/sample/winforms_series_2

Upvotes: 0

Neil Knight
Neil Knight

Reputation: 48537

Content.Load<Model>() requires a string parameter, so I don't think that you'll be able to stream a Model in. I should mention that the string parameter that is required is a filePath, so you wouldn't be able to convert a stream to a string and pass that in.

Upvotes: 0

Related Questions