LittleSettler

Hello,
I just wrote a little puzzle game (Windos Game Project) and now I want to build the 360 version of it, but I have a little problem (probably PEBKAC *g*)

I wrote a content-processor for instanced rendering (overriding ModelProcessor) and implemented a new ContentItem called 'Font'. It reads the *.fnt files from AngelCode Bitmapfont Converter. Because I want to reuse this, I put it into a "Windows Game Library" and everything works fine..

Now, if I try to put my custom content stuff into a XBox 360 Game Lib, the build process told me, that there exists no "TargetPlatform" enum - which is needed for the serialization methods. After thinking about it, I realize, that I wouldn't make sense that the XBox Game lib should know anything about the ContentWriter, it's for the build process on the PC (am I right ).

Any suggestions how I should re-arrange the whole stuff to make it work 2 separate libs (one with the actual Font : ContentItem used, one for the actual Importer ).

Thanks in advance,
Markus



Re: XNA Game Studio Express PC project -> 360 (including Game Library)

Shawn Hargreaves - MSFT

There are two possible patterns that seem to work well for me.

For simple stuff, I have a Windows Game Library containing the content pipeline code, and then put all the runtime parts directly into my game project (which usually has versions for both Windows and Xbox).

For more complicated things where I want to share some classes between the content pipeline and the game, I need more projects:
  • A worker assembly that implements the new type, with versions for both Windows and Xbox
  • A Windows content pipeline assembly, which uses the Windows version of the worker assembly
  • My game project, with versions for both Windows and Xbox, using the appropriate version of the worker assembly
You can set up the Windows and Xbox versions of each project to link to the same files, and add them all to the same solution with the appropriate dependencies saying which need to be built first, so hitting F5 will automatically build everything for the appropriate platforms.





Re: XNA Game Studio Express PC project -> 360 (including Game Library)

Jim Perry

Maybe someone else will be able to give you an answer, but without seeing exactly what you're doing it's hard to make a suggestion.




Re: XNA Game Studio Express PC project -> 360 (including Game Library)

jpolivares

I'm in the same situation here and your instructions there were not very clear at all. Can you explain the steps to going from a working PC library/game with custom importer/processors to an XBOX game. I've been writing a library/PC game and it's all been going well. Now I've got my XNA account and I can't figure out how to get any of what I wrote to work for the XBOX. For one thing, the Microsoft.Xna.Framework.Content.Pipeline isn't even available for a 360 game/library! How is this making my code compatible between 360/PC

Please let me know if I'm missing something or what the steps are to making libraries that have content pipeline code in them compatible between PC and 360. I just bought this XNA Creator's Club and I can't do jack with it!

Thanks.
-Javier




Re: XNA Game Studio Express PC project -> 360 (including Game Library)

jpolivares

Okay, I think I managed to figure out what you were talking about. Here's what I currently have, I'll play around with consolidating things a little more but this is working:

A Windows Game Library that has all my engine code and content/importer/processor code
An XBOX Game Library that has just the engine code, no content code.
An XBOX Game that includes the .dll generated by the Windows Game Library in the content pipeline and references the Xbox Game Library to include the engine code.

This atleast compiles and tries to run. Now I have an error about not being able to find content from a relative path so I'll be playing around a bit more before I call it a success.

-Javier

*Okay, scratch that.  I can't see my custom importers at all.  They don't show up in the list of Content Importer or Content Processor under the content properties.  Clearly not accepting my library dll as a content processor.




Re: XNA Game Studio Express PC project -> 360 (including Game Library)

Stephen Styrchak - MSFT

You almost have it, but you should split your processor into a separate project. Getting it set up the right way is complicated the first time. We didn't really document how to do this (an oversight), but you can expect to see a blog post about it at some point.

To make it less confusing, let me explain what you should do to use a custom processor with any Xbox 360 game project (or Xbox 360 library project).

You want to have 2 projects in your solution:

  1. An Xbox 360 Game project which has your game code and assets.
  2. A Windows Game Library project which has your custom processor.

The custom processor is going to execute as part of the build, which occurs on your Windows machine. You don't implement that in an Xbox 360 project because you'll never build any content on your console.

Now, since your Xbox 360 Game project has content in it which you want to process with the processor in the second project, you need to make sure the Windows project builds first. You do that with project dependencies (not project references).

More specifically,

  1. Right-click on the Xbox 360 Game project node in the Solution Explorer, and select "Project Dependencies..."
  2. Check the box next to the Windows Game Library project.
  3. Click OK.

What this does is ensure that the processor project will build before the Xbox 360 game project. You don't want to add a project-to-project reference from the game to the processor because the processor is not actually used by the game code, it is used by the build.

The next thing to do is to make sure you can use the processor in the game project. You do this by adding the processor project output assembly to the list of Content Pipeline assemblies for the Xbox 360 game project:

  1. Build the processor project at least once.
  2. Double-click the Xbox 360 project's Properties node in the Solution Explorer.
  3. Click on the "Content Pipeline" tab.
  4. Click "Add..."
  5. Browse to the custom processor assembly and click OK.
  6. Close the Project Properties designer.

There, now you're pretty much set up. Whenever you build your Xbox 360 game, the environment will check to see if the content project needs to be built first. If it does, it will build, and then the Xbox 360 game project will build and the custom processor will be available.

As for working with both platforms, well, you set it up the exact same way with a Windows game project instead of the Xbox 360 project. If you want to use the same custom processor in two solutions, just add the existing project to a new solution (or just add the already-built processor assembly to the Content Pipeline Assemblies list).

There are a few more things to set up in order to handle switching configurations (Debug/Release) and platforms (x86/Xbox 360/Mixed Platforms). I won't explain that here. Instead, expect to see a blog post about it eventually.

Thanks to Joe Nalewabau (XNA Shaman) for describing these steps to me. He is going to make us simplify this a great deal in the future. ;-)

--Stephen





Re: XNA Game Studio Express PC project -> 360 (including Game Library)

jpolivares

Hey, thanks, this has gotten me a lot further. I thought I had done all this, but maybe adding that dependency did the trick. Anyway, my content processes and begins to load fine, but then it can't find my content reader.

To make it clear, I essentially have 4 projects right now. A windows library, a windows game, an xbox library, and an xbox game. The games are exactly the same code-wise and content-wise and the libraries are almost the same except the windows library has content.pipeline stuff to do processing and importing. Both libraries have the same content reader.

So there is a content reader in both the libraries and the importer has something like:

return typeof(MyStuff.Content.MyTypeReader).AssemblyQualifiedName;

This works fine for the windows game but the xbox errors with:

An unhandled exception of type 'Microsoft.Xna.Framework.Content.ContentLoadException' occurred in Microsoft.Xna.Framework.dll

Additional information: Error loading "Data\Objects\centurion". Cannot find ContentTypeReader MyStuff.Content.MyTypeReader, MyStuff, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.

I tried using unique namespaces instead, but referencing the xbox library in the windows library in order to do something like:

if (targetPlatform == Microsoft.Xna.Framework.TargetPlatform.Windows)
    
return typeof(MyStuff.Content.MyTypeReader).AssemblyQualifiedName;
else if (targetPlatform == Microsoft.Xna.Framework.TargetPlatform.Xbox360)
    
return typeof(MyStuff360.Content.MyTypeReader).AssemblyQualifiedName;

Gave me an error durring compile:

Error 34 The type 'Microsoft.Xna.Framework.Content.ContentTypeReader`1<T0>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.Xna.Framework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=51c3bfb2db46012c'.

So clearly I can't just reference between the two. Am I just going about this content reader thing completely wrong by using the AssemblyQualifiedName I've tried straight strings of the class name, but no luck.

Thanks for the help. Hopefully we can get all the way with this :).

-Javier





Re: XNA Game Studio Express PC project -> 360 (including Game Library)

LittleSettler

Thanks to all of you for the hints and explanations. I will refactor it in the next few days (busy at work atm :( ) and post some results and experiences.

cu,
Markus






Re: XNA Game Studio Express PC project -> 360 (including Game Library)

LittleSettler

Wow, that was easy (after your explanations). It 'seems' to work, the build finished without errors (Win & XBox projects). Unfortunately I can't try it on my XBox (no credit card yet).

Here's how I did it :

1. Added a new Xbox 360 project to my XNAExtension solution
- the Windows project contains all the stuff (new content-items, processors, content-writer/-reader)
- the XBox 360 project only contains the content-items I need (the Font interface and the InstancedMesh class), sourcefiles were added as links
- added some #if !XBOX360 #endif sections where needed
- rebuild both projects, in the end I have a XNAExtensions.dll and a XNAExtensions360.dll

2. Added a new XBox 360 project to the Game Solution
- recreated the same directory structure as in the windows project
- added _all_ *.cs and content files as links
- added the XNAExtensions360.dll to the XBox 360 game project

Voila, it "works". Thanks again.

bye,
Markus





Re: XNA Game Studio Express PC project -> 360 (including Game Library)

jpolivares

How are you dealing with your content-reader Which project(s) is it located in and how are you returning the name for it in the writer Mine compiles and deploys no problem, but once it runs it can't find the reader.

-Javier




Re: XNA Game Studio Express PC project -> 360 (including Game Library)

Shawn Hargreaves - MSFT

It looks like your TypeReader for Windows and Xbox are in projects with different names

The easiest way to make this work is just to return a string for your type reader name, rather than using AssemblyQualifiedName. Then you can do something like:

if (targetPlatform == TargetPlatform.Windows)
return "MyStuff.Content.MyTypeReader, MyStuff";
else
return "MyStuff.Content.MyTypeReader, MyStuffXbox360";

(that's assuming you have the same namespace in both projects, and it is just the assembly name that differs)

An even easier approach, which I tend to use, is to just give your Xbox and Windows projects the same name. The .csproj files obviously need to be named differently, but you can set the assembly name in the project properties, and you can make this the same for Xbox and Windows, so the same ContentTypeReader name string will work on both platforms.





Re: XNA Game Studio Express PC project -> 360 (including Game Library)

jpolivares

That makes more sense, I will try it and let you know how it goes. Thanks.

-Javier




Re: XNA Game Studio Express PC project -> 360 (including Game Library)

jpolivares

This worked, I wasn't properly filling in the assembly name in the string. Now it's all good and runs on the xbox with custom file importers and processors and all.

Thanks!
-Javier




Re: XNA Game Studio Express PC project -> 360 (including Game Library)

Jamie Fristrom

"You can set up the Windows and Xbox versions of each project to link to the same files."

This must be because I'm a C# rookie, but I don't see how. With C++ it's easy, but C# seems to have this thing where the project diretories have to match the directories on the hard drive






Re: XNA Game Studio Express PC project -> 360 (including Game Library)

waruwaru

Be sure to create/include Xbox libraries inside of Xbox game project, and create/include Windows libraries in Windows game project. Use the add link thing to make the file gets compiled with the proper platform settings. I had trouble earlier just adding project references to my projects, and had to figure out why my projects behave incorrectly. Some methods will be available on xbox, but nother other methods...etc. XGSE will not warn you when that happens. If you link the files into platform specific projects, they will get recompiled, and the non-crossplatform-compatible methods/classes will generate errors. Much easier to track down the issues.