XNA Animation Component now works on Xbox360!
After figuring out what Erik did to get the Flight Simulator to work on 360, using the same knowledge, I've been debugging the Animation component again and managed to fix it and at last get it to run on the XBOX360!
Here are the steps to compile your own Animation library from this component.
Note since this component is also a Work In Progress, what I've done here might be obsolete soon. But it's just great to finally be able to see something moving on the 360, so here it goes:
I used Release #17738 from the source control and do some minor tweaks to be able to get it to run.
1. Create a new solution, add a Windows Game Library project, I call it Animationx86. Include the source code for the Animation component and compile it. It should produce Animationx86.dll
2. Add another Windows game library project, call it Animation.Contentx86. Include references to the above project Animationx86 and .net frameworks:
Now when you try to compile it, it will fail because it is looking for a .cs file which is not available in the source package.
I found out that it is actually a file from the earlier release, so for my case i used Release #17349 and include the file SkinTransformReader.cs into the Animationx86 project.
Recompile everything and it should now work, producing a Animation.Contentx86.dll content processor.
3. Now we need to modify something in the AnimatedModelProcessor.cs.
What we need to do now is to create a DirectX Effect configuration file. I don't understand why, but I just figured that the content processor fails to run when used in an xbox game on line 72:
CompiledEffect compiledEffect4 = processor.Process(effect, context);
So we need to create the effect by capturing the code and writing it to a file. Just write a file writer function (mine is called writeEffectToFile)
private void writeEffectToFile(String filePath, String content){
FileStream file = new FileStream("C:\\"+filePath, FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter sw = new StreamWriter(file);
sw.Write(content);
sw.Close();
file.Close();
}
and do this after line 69:
effect.EffectCode = BasicPaletteEffect.SourceCode4BonesPerVertex;
writeEffectToFile("SourceCode4BonesPerVertex.fx",effect.EffectCode.ToString());
You should now see a file SourceCode4BonesPerVertex.fx created under your root directory, and include it in your project. Now change line 72 into
CompiledEffect compiledEffect4 = Effect.CompileEffectFromFile("../Animation.Content/SourceCode4BonesPerVertex.fx", null, null, CompilerOptions.None, TargetPlatform.Xbox360);
Now your Animation.Contentx86 should work both on Windows and XBoX! And there goes the complicated part!
4. This time create a Xbox library project, call it Animation360, and add all the Source files from the Animationx86 project. If you try to compile it, it will fail because it is looking for SortedDictionary, so just change all declarations of SortedDictionary into SortedList.
Also, remove the file ModelViewer.cs from the project, since it is using a MouseState class not available for xbox360 and not essential at the moment (Need to tweak it into Gamepadstate later on so we can use the ModelViewer, quite useful)
Compile, and it should produce Animation360.dll
5. Create the Xbox Game, include reference to Animation360, include the Content Pipeline processor Animation.Contentx86, include a model (.fbx) and change the Content Processor into Model - Animation Library. Write your game code and deploy. It should now work perfectly!
Problems
- Not all animations can work! Sometimes it failed to build the BasicPaletteEffect on some animated models. I am still trying to figure out why.
- Some animations are not animated correctly. I am not sure whether this is the problem of the component or is it something to do with the settings during exporting to FBX. Hopefully its just the latter.
At least we're moving on, so I think we can start to combine the flight sim engine and animation component to start build up the game engine :D
So I guess its now time to get some Real work done? Hmmm ...
Here are the steps to compile your own Animation library from this component.
Note since this component is also a Work In Progress, what I've done here might be obsolete soon. But it's just great to finally be able to see something moving on the 360, so here it goes:
I used Release #17738 from the source control and do some minor tweaks to be able to get it to run.
1. Create a new solution, add a Windows Game Library project, I call it Animationx86. Include the source code for the Animation component and compile it. It should produce Animationx86.dll
2. Add another Windows game library project, call it Animation.Contentx86. Include references to the above project Animationx86 and .net frameworks:
- CustomMarshalers
- Microsoft.Xna.Framework.Content.Pipeline
- System.Xml
Now when you try to compile it, it will fail because it is looking for a .cs file which is not available in the source package.
I found out that it is actually a file from the earlier release, so for my case i used Release #17349 and include the file SkinTransformReader.cs into the Animationx86 project.
Recompile everything and it should now work, producing a Animation.Contentx86.dll content processor.
3. Now we need to modify something in the AnimatedModelProcessor.cs.
What we need to do now is to create a DirectX Effect configuration file. I don't understand why, but I just figured that the content processor fails to run when used in an xbox game on line 72:
CompiledEffect compiledEffect4 = processor.Process(effect, context);
So we need to create the effect by capturing the code and writing it to a file. Just write a file writer function (mine is called writeEffectToFile)
private void writeEffectToFile(String filePath, String content){
FileStream file = new FileStream("C:\\"+filePath, FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter sw = new StreamWriter(file);
sw.Write(content);
sw.Close();
file.Close();
}
and do this after line 69:
effect.EffectCode = BasicPaletteEffect.SourceCode4BonesPerVertex;
writeEffectToFile("SourceCode4BonesPerVertex.fx",effect.EffectCode.ToString());
You should now see a file SourceCode4BonesPerVertex.fx created under your root directory, and include it in your project. Now change line 72 into
CompiledEffect compiledEffect4 = Effect.CompileEffectFromFile("../Animation.Content/SourceCode4BonesPerVertex.fx", null, null, CompilerOptions.None, TargetPlatform.Xbox360);
Now your Animation.Contentx86 should work both on Windows and XBoX! And there goes the complicated part!
4. This time create a Xbox library project, call it Animation360, and add all the Source files from the Animationx86 project. If you try to compile it, it will fail because it is looking for SortedDictionary, so just change all declarations of SortedDictionary into SortedList.
Also, remove the file ModelViewer.cs from the project, since it is using a MouseState class not available for xbox360 and not essential at the moment (Need to tweak it into Gamepadstate later on so we can use the ModelViewer, quite useful)
Compile, and it should produce Animation360.dll
5. Create the Xbox Game, include reference to Animation360, include the Content Pipeline processor Animation.Contentx86, include a model (.fbx) and change the Content Processor into Model - Animation Library. Write your game code and deploy. It should now work perfectly!
Problems
- Not all animations can work! Sometimes it failed to build the BasicPaletteEffect on some animated models. I am still trying to figure out why.
- Some animations are not animated correctly. I am not sure whether this is the problem of the component or is it something to do with the settings during exporting to FBX. Hopefully its just the latter.
At least we're moving on, so I think we can start to combine the flight sim engine and animation component to start build up the game engine :D
So I guess its now time to get some Real work done? Hmmm ...



0 Comments:
Post a Comment
<< Home