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
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 :)
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.
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
精彩评论