Reputation: 27717
In XNA, how do I load in a texture or mesh from a file without using the content pipeline?
Upvotes: 2
Views: 5030
Reputation: 865
If you really want to load an Xna Xna.Framework.Graphics.Model
on PC without the content pipeline (eg for user generated content), there is a way. I used SlimDX to load an X file, and avoid the parsing code, the some reflection tricks to instantiate the Model (it is sealed and has a private constructor so wasn't meant to be extended or customised). See here: http://contenttracker.codeplex.com/SourceControl/changeset/view/20704#346981
Upvotes: 0
Reputation: 31
This is a windows only Way to load a texture without loading it through the pipeline, As Cory stated above, all content must be compiled before loading it on the Xbox, and Zune.
Texture2D texture = Texture2D.FromFile(GraphicsDeviceManager.GraphicsDevice, @Location of your Texture Here.png);
Upvotes: 2
Reputation:
For anyone interested in loading a model from a file check out this tutorial:
http://creators.xna.com/en-us/sample/winforms_series2
Upvotes: 3
Reputation: 47751
The .FromFile method will not work on xbox or zune. You have two choices:
Upvotes: 4
Reputation: 1339
I believe Texture2D.FromFile(); is what you are looking for.
It does not look like you can do this with a Model though.
http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.texture2d.fromfile.aspx
Upvotes: 1