Compiling From Source

Topics: Developer Forum
Jan 31, 2007 at 9:06 PM
I'd like to try to compile from source, so I downloaded ChangeSet 17349 from the Source Code tab here on CodePlex.

I noticed that no Project or Solution files appear to have been checked in, and I'm looking for a little guidance as to how they should be setup. I know that the binary release comes as two DLLs. Is that nessesary, or can I simply do a single Class Library containing the full content of the changeset download?

Thanks,
--
Mike
Coordinator
Jan 31, 2007 at 10:08 PM
1. Download the source
2. Create a new solution (Windows Game Library) with two projects
3. Put all the files outside the content folder into the first project and compile it into a dll such as Animation.dll
4. Add this dll as a reference to the second project, and compile it into a dll such as Animation.Content.dll

You can combine them into one dll for windows, and add it to the content pipeline folder and as a reference. However, this doesn't work on xbox 360 since the content dll uses windows-only calls. This is why they are split up.
Feb 1, 2007 at 5:27 AM
A few minor details missing.

For the Animation.Content project, you'll need to add a reference for Microsoft.Xna.Framework.Content.Pipeline and another for System.XML

And then the Animation.Content project needs a reference to the Animation project.

Everything seems to compile up nice then, except that I can't seem to follow the wiki instructions for loading a model and using bvh, but I'll post that seperately.
Feb 3, 2007 at 11:33 PM
On the main page it is stated that the components work on the XBox 360, but the DLLs are for Windows. So, I created a new XBox360 Game Library project and added the source code for animation.dll and I got errors when trying to compile. I commented out/changed the Windows specific calls and was able to succcessfully compile. However, when I add this new DLL as a reference to Animation.Component.DLL and try to compile, Animation.DLL can not be loaded. I THINK this is because one is a 360 game component and one is a X86 game component. I tested this by compiling both DLLs as X86 game components and they both compile with no problems. Animation.Component.DLL needs to be an X86 game component, right? I am still reading about the content pipeline so I haven't figured this out. So how can I get Animation.DLL to run on the 360? I assume the reason that Animation.DLL needs to be added as a reference to Animation.Contnent.DLL is because Animation.Content.DLL is making calls to Animation.DLL. If I copy this code from Animation.DLL and put it into Animation.Content.DLL, will this work? Any help would be greatly appreciated!
Coordinator
Feb 4, 2007 at 7:39 AM
Yah, don't cause yourself the stress of trying to compile it for 360. You need to jump through a number of hoops.

However, it is possible by playing with the assembly info/names, and I have released a dll for 360 before (check archives). I just haven't released a dll for the latest source since I'm busy making vast changes to its infrastructure that may or may not go through. I have to test them on a model I have with 10 or so animations and make sure I can blend waving/nodding and walking.

When everything is all said and done, I'll make a wiki on how to do this for the ambitious ones. Also, tomorrow i'll update the misleading news page.
Feb 4, 2007 at 4:09 PM
I am in the process of trying to convert a game that was written in C# using Managed DirectX to C#/XNA and will run on an XBox 360. I was ecstatic when I found this XNA Animation Component Library, because the game has a very simple animation for one object. I do not have a video card that supports pixel shaders, and it is unlikely that I will get one. So, after I compile, I send the code to the 360 to test it.

I tried using the released 360 DLLs by creating a new project (XBox 360 Game) that was the same as the SimpleDemo that uses the Bear_Walking.x file (except the project uses two DLLs instead of one). But when I try to compile, Animation.Content.DLL does not get loaded. I thought maybe I could fix this if I could compile from the source code. Unfortunately, I don't know which version of the source was used to compile this version, or if it's even posted... If you could point me in the right direction, I would GREATLY appreciate it!
Coordinator
Feb 5, 2007 at 1:26 AM
So you couldn't get the 360 DLLs working?

I don't understand what you mean by Animation.Content.DLL not getting loaded. Are you adding it to the content pipeline tab under properties or adding it as a reference? It should not be added as a reference.
Feb 5, 2007 at 6:54 AM
It is in the content pipeline. When I try to build the project, I get and error that says the DLL could not be loaded.

I downloaded the source code to an earlier version (which has less code), and I am going to figure out how to compile that for the 360.
Coordinator
Feb 5, 2007 at 10:07 AM
HMmmm.. could you maybe give the exact error? It's very important that the 360 dlls work on other people's computers without recompiling.
Feb 6, 2007 at 2:13 AM
Edited Feb 6, 2007 at 2:14 AM
Sure.

I created a new Project (XBox 360 Game). I added Animation.DLL as a reference (360 version). I added Animation.Content.DLL to the content pipeline. I copied the following code from Game1.cs file in the SimpleDemo example:

model = content.Load<Model>("bear_walking");
Animation.ModelViewer viewer = new ModelViewer(this, model);

and pasted it into the appropriate location in the new project. I added bear.jpg to the project. I added bear_walking.x to the project. When I select Build Solution from the Build menu, the exact error I get is:

'Error 1 Error loading pipeline assembly "C:\Development\CSharp\XNA Games\AnimationComponent\360 DLLs\Animation.Content.dll". XBearTest'

Maybe I'm doing something incorrectly, or maybe there's a problem with my computer...
Coordinator
Feb 6, 2007 at 2:55 AM
Yuck... I'll surely have to examine that in detail to see what's going on.

Unfortunately, work on the animation library must be delayed for a couple of days because I have a lot of work in my animation class!

Oh, the irony :(
Coordinator
Feb 6, 2007 at 1:18 PM
Edited Feb 6, 2007 at 1:23 PM
Well, I found the problem, but you may not be able to fix it right now without recompiling or without me recompiling.

The Animation.Content dll uses the WINDOWS Animation dll to build the content, but the XBOX Animation dll is used during runtime.

For now, just put the windows animation.dll in the same directory as the xbox Animation.Content.dll, and put the xbox Animation.dll in a different directory and use that in the project.

In future releases I'll be sure to call something different when used by the xbox Animation.Content.dll

This might not work and as of writing I dont have time to test it out, since that particular windows Animation.dll was not changed to be compatible with the xbox animation.content. But it is definitely possible to compile it yourself, and I can tell you how later.


I never realized this problem when testing because I was including the content dll from a directory with a valid Animation.dll
Feb 7, 2007 at 3:53 AM
Edited Feb 7, 2007 at 3:59 AM
I thought this might be a problem, so I tried your suggestion even before I posted the previous message. I don't remember the exact error I got but I didn't get it to work. Now that you've brought the problem to light however, I think I may have given up too soon. I have so many different revisions of the Windows and 360 DLLS, that I may have been using an incompatible version of the Windows Animation.DLL.

What I did do was copy the required code from Animation.DLL to the content.DLL and was able to compile so that the content.DLL no longer needs to reference the Animation.DLL This is really ugly and I was thinking that a 3rd DLL could be made that contains common code for the two other DLLs. And the 3rd DLL could be compiled for Windows or the 360 as needed.

Unfortunately, I ran out of time. I won't be able to work on this any more until the weekend.

Thank you for your help!
Feb 14, 2007 at 5:54 AM
Edited Feb 14, 2007 at 5:56 AM
First of all, great job with this whole Animation Component project!

I've been trying figure out how to recompile the DLL to make it work on XBOX360, and to a certain extent, I have been able to load and run some animated models in XBOX 360, but some models do not seem to work.
Here's what I've done so far:
1. I used source set 17738 (before the recent major changes), and create 2 Windows Game Library, I call the first one "Animationx86" and the second one "Animationx86.Content".

2. Copy all source for Animation to the Animationx86 project and compile. It will create Animationx86.dll

3. Copy all source for Content to Animationx86.Content, add the reference to Animationx86 as well as XNA.Framework.Content.Pipeline and System.xml, and compile. It will create Animationx86.Content.dll

4. This time create an Xbox 360 library and copy all source for Animation, and name the project "Animation360". When I try to compile, it will give me error with the ModelViewer class making references to MouseState. So I just exclude the ModelViewer.cs from the project since its not essential for now.

5. There will be errors compiling due to declarations of SortedDictionary. So I just changed all declarations of SortedDictionary to SortedList. (It seems to work somehow).

6. There will also be errors due to references made to SkinTransformReader, and it is actually a class available from earlier source code packages. So just download, for my case, i used release 17349 and include SkinTransformReader.cs in both Animationx86 and Animation360 projects.

7. Recompile all to create Animationx86.dll, Animationx86.Content.dll and Animation360.dll

8. Create an XBOX360 game, I used the Walking bear example with my own .fbx models, and copy the above three DLLs to the project folder. In the project properties, add the Animationx86.Content.dll to the Content Pipeline. In the project itself, add reference to Animation360.dll.

9. When adding your own 3d models with animation (I used fbx formatted ones), change the Content Processor to Model - Animation Library.

10. When you compile the game, it will give you this Error:

Building content threw NullReferenceException: Object reference not set to an instance of an object. At Microsoft.Xna.Framework.Content.Pipeline.Processors.EffectProcessor.CreateContentIdentityFromErrorString(String& errorString, ContentIdentity oldContentId)

11. I found out the issue is with the AnimatedModelProcessor.cs from the Animationx86.Content project. Particularly line 71 :

CompiledEffect compiledEffect4 = processor.Process(effect, context);

It seems like the line fails when it is used in a XBOX 360 game project. It works fine for a Windows Game though.

12. So i Cheated a bit, I wrote a small writeEffectToFile function in AnimatedModelProcessor.cs and do this after line 69:

effect.EffectCode = BasicPaletteEffect.SourceCode4BonesPerVertex;
writeEffectToFile("SourceCode4BonesPerVertex.fx",effect.EffectCode.ToString());

I will then take the generated effect file SourceCode4BonesPerVertex.fx, put the file and include it into the Animationx86.Content project.

13. Change line 71 of AnimatedModelProcessor.cs to

CompiledEffect compiledEffect4 = Effect.CompileEffectFromFile("../Animationx86.Content/SourceCode4BonesPerVertex.fx", null, null, CompilerOptions.None, TargetPlatform.Xbox360);

14. Compile your game, and deploy to Xbox360. For my case, some of my own fbx models seem to compile successfully and run on XBOX360. Strangely enough, the included Bear.x model doesn't even compile for the XBOX360, and it gives the Warning Message : "Compilation of BasicPaletteEffect failed." with a "Null pointer reference error"

I am kind of stuck now not knowing how to proceed and I was hoping to get some feedbacks on whether what I've done so far makes sense and to get some answers on how to go on from here.

Cheers!

Coordinator
Feb 14, 2007 at 6:06 AM
Edited Feb 14, 2007 at 6:14 AM
To make BasicPaletteEffect compile on the xbox:
1. add "output.color.w = input.color.w;" at the end of TransformPixel, and remove the identical statement right above it, inside the else block.

For some reason this makes the unified shader model on the xbox crash.

2. reduce the PALETTE_SIZE to 40 (from 56). The xbox apparently has fewer registers because of its unified shader model.

(BIG thanks to ghaussman for finding these out for me)

You've gone through most of the steps that I went through to get it to work (I did get it to work with a changeset close to that one), but I remember having to do some tweaking to the assembly strings.

In other words, in PaletteEffectContent.cs and AnimationWriter.cs, which are the two content writers I use, I had to find the assembly qualified name for the respective runtime types and runtime reader types in the xbox compiled Animation.dll and manually enter the string.

Then, after doing all the steps you mentioned, it worked for complex skinned models.
Feb 14, 2007 at 8:22 AM
Oh i see. I get what you mean...Its something like this for my case I think:

if (targetPlatform == TargetPlatform.Windows)
return "Animation.Content.AnimationReader, Animationx86, Version=1.0.0.0, Culture=neutral";

else
return "Animation.Content.AnimationReader, Animation360, Version=1.0.0.0, Culture=neutral";

I will try to recompile again later (at work now) and see whether it works. Sounds promising! If this works, maybe from next release onwards, you could also include the libraries for XBOX360?

Thanks!

Coordinator
Feb 14, 2007 at 6:04 PM
Yes. The icing on the cake is that when you create your xbox project, the Animation.Content has to be in the same directory as the WINDOWS dll with which you built it, but you still add the XBOX animation dll to your game as a reference.
Feb 15, 2007 at 2:21 PM
Thanks dastle for all the tips! I finally managed to recompile it and get it to run on the XBOX360. I tweaked the Dwarf animation demo posted by jnogueira and it runs perfectly on the 360!

Thanks!
Coordinator
Feb 15, 2007 at 4:35 PM

dastle wrote:
Thanks dastle for all the tips! I finally managed to recompile it and get it to run on the XBOX360. I tweaked the Dwarf animation demo posted by jnogueira and it runs perfectly on the 360!

Thanks!

Great! The old router is still dead here so I can't test on XBox, but I'll get a new one soon.
So since you say you got it to work with the dwarf animation, it works for the recent changesets?
Feb 16, 2007 at 2:35 PM
Donny (or Dastle) - could you help diagnose what's going on when the Content Pipeline throws the NullReferenceException that Donny points out in step 10? I'm stuck there right now. I'm trying to get the Tutorial up and running on the 360...

Maybe could you post the complete code for what you're doing around the writeEffectToFile part?
Coordinator
Feb 16, 2007 at 10:32 PM

dastle wrote:
Donny (or Dastle) - could you help diagnose what's going on when the Content Pipeline throws the NullReferenceException that Donny points out in step 10? I'm stuck there right now. I'm trying to get the Tutorial up and running on the 360...

Maybe could you post the complete code for what you're doing around the writeEffectToFile part?


Ok, I'll try to make a version compatible with XBox and check it in, but no guarantees because my router is dead and I can't test it out. I'm going to order a router today though, since linksys won't replace my brand new dead one (actually, the first one was defective too, and I got that replaced. Two defective ones in a row... what are the chances?). The new one won't be from the same company :)
Feb 17, 2007 at 12:12 AM
An XBox-compatible version would be really helpful. I would send you a router if I could :)
Coordinator
Feb 17, 2007 at 1:39 AM
Edited Feb 17, 2007 at 1:40 AM
I actually went out and bought one today.

I checked in a new source changeset that makes it easy to compile for XBox 360, and updated the Compilation Info wiki that is linked to on the front page. I tested it out on Tiny and it worked, but I'll have to do more extensive testing before I release it as a dll.

It's easier to compile now since Animation.Content.dll does not depend on Animation.dll
Coordinator
Feb 17, 2007 at 8:09 PM
Has anyone tried compiling for xbox yet? I have found that just because something works for me doesn't mean it will work for others.
Feb 18, 2007 at 2:00 AM
Once again, great work!
I just tried the latest source code and followed your much simplified tutorial, and it works without a problem :) Glad to see a familiar naming convention too :P