minigendo

My apologies if this has already been asked, but I seek guidance on a conceptual problem I am having.

I am attempting to write an engine that would exist as a stand alone executable and then read in a script file which would direct it's actions. However the problem as I understand it is that all assets must be included in the XNA project. Is there a way to set things up so that an XNA executable can access files using a relative path

I thank you for your time.




Re: XNA Game Studio Express A question regarding content not explicity included in the project

DreemerNJ

minigendo wrote:

My apologies if this has already been asked, but I seek guidance on a conceptual problem I am having.

I am attempting to write an engine that would exist as a stand alone executable and then read in a script file which would direct it's actions. However the problem as I understand it is that all assets must be included in the XNA project. Is there a way to set things up so that an XNA executable can access files using a relative path

I thank you for your time.

My XNA fighting game engine does that now. It didn't require any setup. Although I've never tried compiling to run on Xbox 360 or anything.

A texture loader in a loop would look like this:
currentCharacter.currentFrame.texture = Texture2D.FromFile(graphics.GraphicsDevice, "content\\graphics\\"+Directory+"\\"+Filename);

It has a main definition file that must be present for it to run, and from that it reads where character definition files are, reads those, and from those reads the character graphics in. Just have to be sure that once it's compiled, when you run it the directories are all there. The code I use is a bit more complicated than what's above because I have it using the path for the application folder and such. I am away from my comp so I can't copy and paste the actual code at the moment :-/






Re: XNA Game Studio Express A question regarding content not explicity included in the project

CodePfo

Here's an idea:

Write a content pipeline objects for your script file. That file could then load each asset described in the file as an external reference. Then you could use the ContentManager to load all of your resources. The only file you would need to have as part of your project would be your assets file.

This is a technique I am using for some things, such as models with metadata, I create a custom importer / processor / typereader and typewriter to process Xml files. All assets (models, effects, textures) are referenced in the Xml file and built as external references. In this way, they can also load their custom metadata as well (like stats etc..).

I don't think this is the best way of doing things, but it works for me and with a lack of other samples I'll continue on this route.




Re: XNA Game Studio Express A question regarding content not explicity included in the project

Shawn Hargreaves - MSFT

On Windows, you can read any files you like from anywhere you like.

On Xbox, you can obviously only read files that were deployed to the Xbox. The deploy copies everything that it finds in your project output directory, so as long as you arrange for your files to end up there, you can read them in your game.





Re: XNA Game Studio Express A question regarding content not explicity included in the project

Shawn Hargreaves - MSFT

DreemerNJ wrote:

A texture loader in a loop would look like this:
currentCharacter.currentFrame.texture = Texture2D.FromFile(graphics.GraphicsDevice, "content\\graphics\\"+Directory+"\\"+Filename);



Be aware that Texture.FromFile is not supported on Xbox.





Re: XNA Game Studio Express A question regarding content not explicity included in the project

minigendo

Excellent, this clears up my problem.

On Windows, the project is variable, but on the 360, itself, the user can't modify the files anyway, so they can all be included in the project.

My thanks to the other users for the suggestions they presented. I imagine they'll come in handy shortly.






Re: XNA Game Studio Express A question regarding content not explicity included in the project

FlatSurfSucks

I've been wondering about something similar. Is it possible to load JPEG or BMP or any other standard format on the fly on the 360 I've got some ideas in my head right now and I've only messed around with it on the PC (won't have a 360 for a few more weeks :) ). How abouts would I go loading non-dx texture files into the scene on the fly