
This is the third release of the KiloWatt Animation library. It is intended as a companion to the kW X-port 3ds Max X file exporter, to be used with Microsoft XNA Game Studio. This release is for version 3.0 for Windows and Xbox 360. Sorry, no Zune support :-)
The KiloWatt Animation Library is different from the XNA Skinning sample code in several ways, including:
New in release 20080703 is full support for skinned meshes, more documentation, and more sample art.
New in release 20081128 is an upgrade to XNA Game Studio version 3.0, and pre-made Xbox 360 projects for those who don't want to do it themselves.
Find more documentation in the download, and please let me know what works for you and what doesn't. This is the third release, and there were no known bugs between second and third release. Note, however, that this is a power tool for programmers who understand 3D animation; it is not a step-by-step tutorial on the basics of what skinning, skeletons or animation blending are.
| Attachment | Size |
|---|---|
| KiloWatt.20081128.zip | 4.4 MB |
Comments
How many animated models can you display with good performance?
I haven't used this library yet, but how many animated models should you be able to produce on the screen without dipping below the 60 FPS mark? Right now I am using XNAnimation, but I haven't really found a way to produce, say 100 animated models effectively without a huge hit in performance. This was mostly in drawing the model and updating the animation. Would this still happen with this library or would you say this is more optimized?
I haven't compared the
I haven't compared the library to XNAnimation, so I have no idea as for the answer to your question. I can tell you that, while writing kW Animation, I did have performance in mind, but I have not attempted any major trickery to make it "ultra optimized." Also, kW Animation uses SRT keyframes, not matrix keyframes -- I don't know what XNAnimation uses.
Finally, your question is lacking certain parameters: How many bones per model? How many animations are being blended? Are you cloning animations (the same pose applied to multiple model instances), or running one animation per model? What target hardware: Xbox or PC?
getting any animation to display
Hi there - very interesting site and animation project. Sadly I can't get anything to display. I exported the sample spinning cube that comes with the exporter and then added it to the same project that contains the archer, plant and cube3 models/anims. I asked XNA to import it using the Kilowatt animation import. It doesn't show up anywhere, on any amount of zoom. Perhaps I'm doing something horrible obvious. I can't find the original max file for the archer so I have nothing with which to compare it. I haven't forced shader or skinning shaders in the solution explorer - perhaps I need to set them to something built in to your library - after all a shader must be hidden away in there somewhere or your archer would not display. Its a bit of a head scratcher. I can code a bit in XNA but not shaders - been happy so far using BasicEffect. A hint about what I'm ballsing up would be much appreciated :-)
Cheers,
Robin.
The viewer application
The viewer application assumes that the shader in use follows the conventions of the sample shaders that ship with the library. If you attempt to render geometry imported for BasicEffect with the sample app, it won't work.
I can't re-distribute the Max file for the archer, but you can purchase it at a low cost from 3dbud.com.
cheers for the tip
Bit of a misunderstanding over BasicEffect - I wasn't expecting the built in shader to work - just curious about how I set the x file up for the various shaders in your project. diffuse skinning and metalfx for instance. I exported a model with no animation and forced it to use mtlshader.fx - and it displays, which is a great first step. For anybody having that first step problem I turned off almost every option in the exporter, including tangents and animation - and exported a left handed mesh. This may help anybody using a model imported from Blender. I also used dxt5 model processor for the file in the solution explorer and forced mtlshader.fx. I'll buy that archer and hopefully learn a bit about how to export an animation. I know nothing about Max as I'm used to Blender - it seems wilfully complicated in comparison. Still can't get the cube which is on the kilowatt exporter website to display - perhaps the options are more complicated for animation.
I think it's important that
I think it's important that you understand how bindings between shaders and host applications generally work. There are a set of defined, named parameters that have specified meanings (world transform, diffuse texture, etc). All of those parameters have a given name in the host application, and the shader needs to match. Because each host application renderer generally has different requirements from other games, there's no real standard to these names, so you can't expect to take a shader from one place, and expect it to work in another, except possibly by accident.
If you look in KiloWatt/Base/Graphics/EffectConfig.cs, you will find the names of parameters that the animation viewer is looking for. Hopefully, the names will be self-explanatory as for what the meaning of each of the parameters is. You need to make sure that the shader that you apply to the object, either upon export, or upon processing with the kW model processor, matches those names requested by the application.
Maya Exporter?
I realise the raw stupidity of this request, so I'll apologise now and I resign myself to the answer i know is forthcoming.
Would you ever consider writing that exporter for Maya? I've tried so many and they all miss this, or that, one even openly corrupted our skinning data, another mutilated our uv's, it's a nightmare out there. There is not much love for Maya from the XNA community.
Failing that, possibly another solution.
One of the guys in our team is a Maya MEL programmer and would take a crack at it, but really doesnt know enough about how to export these files. If you have no interest in writing a Maya exporter, do you think we could work together with our MEL scripter to do so? I think it would be super valuable.
BUT, i realise how these things go. I can dream cant i?
However, if we were to just use maya's FBX exporter, which while fickle usually works, can I still use your animation library? How hard would it be, and what would the drawbacks be?
I'd just like to say that reading what your library is capable of is VERY exciting to us for out current project
Dave
That is not a stupid request,
That is not a stupid request, but I'm afraid it is futile. While I do have access to Maya at work through the Autodesk developer program, I really know very little about it, and I have no need for a .X exporter for Maya.
There's no reason I know of why FBX wouldn't work with the kW Animation library. The kW Animation library simply works on the data that you import into XNA, whichever way it gets imported. However, I have not tested the FBX path, so there may be unforeseen bugs. At least you do get the source code and can easily track those down, should they occur.
I guess a million dollars might change my priorities, though :-)
Strange draw...
Sorry for my english....
why now I've added the Kilowatt Animation draw work only for animated model, but no more for the others??
//Draw Sky
foreach (ModelMesh mesh in sky.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
//Transform
effect.View = camera.View;
effect.Projection = projection;
effect.World = world;
}
mesh.Draw();
}
//Draw Plane
foreach (ModelMesh mesh in plane.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
//Transform
effect.View = camera.View;
effect.Projection = projection;
effect.World = world;
}
mesh.Draw();
}
DrawObject(gameTime);
DrawMobiles(gameTime);
player.Draw3D(camera.View, projection, gameTime);
ModelAnimation.Draw(camera.View, projection);
Only ModelAnimation works fine, the previous draw call dont show nothing on screen.
Thanks in advance.
To debug draw state problems
To debug draw state problems with Direct3D in general, I highly recommend downloading and installing the Microsoft Direct3D SDK. It comes with a tool called PIX for Windows, which can start your application, and then capture all draw calls during one frame when you press a key. When you quit your application, you can single-step through all the draw calls, and see what gets sent to the screen, what the different renderstates on the graphics device is (culling, etc), what the contents of the vertex buffers are, etc. It's the absolutely best way to debug the kinds of problem you describe here.
tnx very much for reply The
tnx very much for reply
The problem is as follows:
With code
foreach (ModelDraw man in Human_Man)
{
Mobile mobile = null;
try
{
mobile = (Mobile )WorldObjectsManager.Mobiles[Convert.ToUInt32(man.Name)];
}
catch (Exception)
{
continue;
}
man.Transform = Matrix.CreateScale(.01f) * Matrix.CreateRotationZ((float)(mobile.Rotation * MathHelper.PiOver4 )) * Matrix.CreateTranslation(personaggio.RealPosition.X, personaggio.RealPosition.Y,
personaggio.RealPosition.Z);
uomo.SceneDraw(dd);
//uomo.SceneDrawTransparent(dd);
//Program.game.spriteBatch.Begin();
//Program.game.spriteBatch.End();
}
everything works perfectly, of course without transparency
if uncomment the last three lines are seen only parts animated transparent
thanks in advance
How to use this Library
Hello,
myself and a pal just wondering how it works. We downloadet it and try the AnmitationViewer and its great! But we still dont understand how to use the code with our animations and diddnt find any tutorials or something else that can help us.
What we need is a documentation how the code is used in simple Examples how to load a Model an the animationplayer and so on.
We tryed the XNAnimation Library but its doesnt work with XNA 3.0 so we want to use KiloWatt :)
plz help 2 frustrated students and many regards to your work
All the code for how to use
All the code for how to use the library can be found in the Animation Viewer application. You can just pick that apart to see how it works.
Note that the fact that there are no tutorials is a recognized property of the KiloWatt animation library. It's not intended as a teaching tool; it's production-grade code for real game production.
Where can I find info about the basic concepts?
Hello, I want to say thanks by this great job, I'm a C# programmer but new to 3D animation stuff, I want to get an animated models in very little game, however I've found hard to start, I have problems doing the rigth thing with the files that I've exported from 3D Max, I'd like to have a step by step tutorial on how to bring an animation from 3D Max to an XNA 3.0 games using this library, I don't now if something like that exists now, so, where can I find something similiar??
Again, thanks a lot¡¡¡¡
does it work with FBX too or only X?
hello and thanks for this great library.
i was wondering, does it work with FBX models too, or only X models?
It should work for any model
It should work for any model you can import into the XNA content pipeline. However, I have only tested it with .X models.
wow! thanks for the quick
wow! thanks for the quick reply!
i have tested it with an animated FBX, which i have previously used with the official skinned model library as well as the xnanimation library.
when it is used in kilowatt, everything compiles fine, but it just does not show up in the AnimationViewer. i tried zooming a lot as well as padding to check if it has a high or low scale, but it just doesnt show up.
Try tracing through it in the
Try tracing through it in the debugger, or use PIX for Windows to see what is being issued to the graphics card. It may be that the model is too big, rather than too small. Or it may be that the shader isn't correctly configured for some reason.
I'm assuming you're processing the model with the kW Animation Model Processor, and applying the proper skinning shader?
thanks again for your
thanks again for your reply!
well, the model looks fine in maya and in XNA with the other libraries.
about the shader, i read through the documentation, but what i didnt quite understand was, if i will need to provide my own shader if this model does not have a directX material on it?
There's a "force shader"
There's a "force shader" field in the KW Model processor. There, you can enter the name of the shader you want to use. You can, for example, use the shader that is used for the archer in the sample, or write your own.
FBX models
Hi,
I'm working with FBX models exported from MotionBuilder. In MotioinBuilder, I cannot assign a .fx shader to the model (only .CgFx). If I force your skinned shader in the animation processor, the model shows up, but it is black (my texture doesn't get hooked up properly). I tried to find where the effect parameters get assigned to each model with no luck (I admit, much of this code is over my head). Is there an easy way to assign a texture to a model in this pipeline?
Thanks,
Chad Birosh
If you give the texture
If you give the texture parameters the same name in CgFx as you do in the .fx file, it may work. If that doesn't work, then the problem is that the CgFx file isn't recognized when imported into XNA, which means it's too late to do anything about it in the model processor that does the shader substitution.
thanks a lot! i tried forcing
thanks a lot!
i tried forcing my own shader, which is basically the one from the SkinnedModel sample. still no success.
where do i find the shader from the archer-example?
thanks!
Great library
Thanks for the library. We are using it for some XNA projects.
Great work.
Depth-order problem
Hello,
I'm very impressed with the library overall, and have had a lot of success with it after a very short learning curve. The only problem I've encountered is that when I render a ModelDraw using the kW library, all of the meshes that aren't a ModelDraw are not displaying in proper depth order. (In my case, a sphere being drawn behind a platform when it's actually on top of it.) As soon as I comment out the the calls to
ep.Begin() ... ep.End()inside the DrawChunk() method (With ep being an EffectPass) the depth ordering returns to normal.Obviously, my understanding of XNA devices and rendering calls could use some improvement. But I've never seen this phenomenon before, and I would appreciate any help you could give. Thank you!
Robert
Chances are that the other
Chances are that the other models are drawn with different triangle culling (clockwise vs counterclockwise).
In general, in computer graphics, you want models to use counter-clockwise winding in right-handed coordinate systems (OpenGL does this), and clockwise winding in left-handed coordinate systems (Direct3D does this). However, XNA chose to use a right-handed coordinate system, but use clockwise triangles by default (especially inside SpriteBatch). This is terrible, because the normal you get by following the winding of the triangle using your right hand will be inverted of the actual face direction.
That's just a default, though, and in kW, I generally use counter-clockwise triangles, and put that in my shaders. I just have to remember to reset it after using the SpriteBatch class (which is the worst offender).
Anyway, whatever else you draw, make sure to set the triangle culling direction correctly, and you'll do fine.
Hi, I'm considering this
Hi,
I'm considering this library once again (especially since you wrote the exporter I'm using).
With regards to the point:
"# KiloWatt Animation replaces the Effect used for your Model only when you tell it to."
Does that mean you add an effect file to your animated model and then you modify that effect to have the skinning code contained in diffuseonly-skinned.fx. And finally tell the content processor to use this one? Pretty straight forward :) I remember last time I delved for the better part of a day in a previous version and found it too laborious to modify.
Secondly, is it possible to calculate the world position of a bone? In my hockey game I use a bone to position the puck.
Thanks again,
Bino
The KiloWatt animation
The KiloWatt animation processor will do one of two things:
1) It will use whatever effect is already being used for the mesh. This is the default. This is good if the animation is played on non-skinned geometry, or if the effect already supports skinning.
2) If you add a non-empty effect name in the settings for the processor, it will replace any effect reference with the effect of that name. That's useful if you want to play back skinned animations on a mesh that has skinning information, but was exported without a skinned shader.
Actually, in case 2, if your name starts with a dash ("-skinned" say), then the original name of the effect will be used, but the text will be appended. So if the effect was called "foo.fx," it would then be called "foo-skinned.fx." However, you still need to provide both the original and the replaced shader source -- the processor does not write any shader functionality for you.
To get the world position of a bone, there's no convenient function in the code I released, it seems, but the data is there. Add an accessor for an element in the matrices_ array member of the ModelDraw class, and a function to look up the index given a bone name. matrices_ contains the transform in object space; multiply by the world matrix of the model and you get world space transform.
Awesome seems simple enough
Awesome seems simple enough :)
Thanks,
Bino
Animation problem
When I run certain animations, they play once, lag, then repeat. I have this problem with the archer's run animation and one of my own models run animation. Can someone tell me how to fix this?
The problem is likely with
The problem is likely with the XNA X animation importer. For reasons unknown, the importer pads every imported animation to at least 1 second duration. Shorter animations will have the last keyframe repeated. You may want to vote for Microsoft to fix this issue on Connect.
Same problem here
Hi ! First of all congratulations for your great work.
I'm having the same problem: short animations lag for a while repeating the same frame and then loop.
Debugging I have found that:
MyModel.AnimationInstances[RUN_ANIMATION].Animation.NumFrames == 30
when it should equal 20, the real length of the animation. I've found that turning NumFrames into read/write property and setting the value to 20 (dirty hacking, I know) solves the problem. Is this the problem you were pointing ? Any other workaround in addition to stretching the animation over 1 second ?
Thank you very much and HAPY NEW YEAR !!!! :)
David.
The only other work-around
The only other work-around would be to add code into the processor to recognize when the last N frames are identical, and strip them off the animation.
I think a better solution is to vote on this issue on connect.microsoft.com!
How do you work around this?
Do you make sure each animation is at least a second, and increase the animation playback speed to compensate?
Yes, I think that would
Yes, I think that would work.
Also, you could write code to recognize when the end keyframes are the same, and the duration of the animation is exactly one second, and strip the added keyframes.
Adding the Reference
Hi, this is probably a silly question, but I was following the instructions from the documentation for the library and I followed the first two steps where you put Base.csproj and Pipeline.csproj into the solution but when I right click on Add Reference under content and go to the Projects tab there is only the project file of my project, no others show up. What am I doing wrong?
No idea! Generally, it works.
No idea! Generally, it works. Perhaps try to build the projects first, which should get you a missing-reference error from Pipeline. Then add the Base reference to the Pipeline project (and your project).
Note that Base does not need to have a reference to anything other than the XNA Framework and System.
biped animation
hello!
good library here. i have a problem though..
i'm trying to display a character which i've modeled and animated in 3dsmax using a biped.. but it own't animate in my program.
if i export a regular move/rotate keyframe animation, it works and shows up right, but for a biped animation, it just gets stuck on the first frame with nothing happening.
do i need to set my model up in any specific way to get this to work? or do i need to add some particular code in my program to make this type of animation work?
thanks!
If you open the exported mesh
If you open the exported mesh in the DirectX Viewer, does it animate there?
Also, which shader are you drawing with? If your animation is skinned, then you need to draw it using a skinning shader. The KiloWatt model processor can set up a new shader for you in the "force shader" and "force skinned shader" fields. You can look at the Archer sample model in the content project to see how this is set up.
i guess my first problem was
i guess my first problem was not using a skinned shader, because i had no idea.
trying the model in the included animationviewer now, it tells me it needs an "inverse bone transform". is this also something i set up before the model is exported? i tried googling a bit but couldn't come up with anything. i also tried poking around inside the archer.x file.
sorry to be asking all this, but i've never used this kind of 3d animation in games before..
Did you read the
Did you read the documentation? Did you use the proper model processor for your mesh?
hmm, i see. what i did first
hmm, i see.
what i did first was select the diffuseonly-skinned.fx shader in 3dsmax *before exporting*, which didn't work. when i select diffuseonly.fx in 3ds and then add +-skinned under forceskinned shader, it works. is this because it only recognizes the shader as skinned when it's entered there, and not the 'regular' way?
either way, it appears to be working now. thanks a lot for your time! sorry again for the silly questions..
Cannot find ContentTypeReader ...ArrayReader
Hi,
I'm trying to run the AnimationViewer on my 360. I've created a copy of the AnimationViewer "for XBox 360" and changed the assembly names of the new projects to "Base.360" and "AnimationViewer.360". The problem is everytime I try to load a model I get the message:
Error loading "archer". Cannot find ContentTypeReader Microsoft.Xna.Framework.Content.ArrayReader`1[[KiloWatt.Base.Animation.SkinnedBone, KiloWatt.Base, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].
Am I missing something?
Thanks a lot,
Kique
in response to ContentTypeReader error
The FIX
Add a reference of "Base" in the base references folder.
A 4th note to update your docs...
1) Add KiloWatt\Base\Base.csproj to your solution.
2)Add KiloWatt\Pipeline\Pipeline.csproj to your solution. solution.
3)In main project References folder add a reference to "Base" under Projects tab.
4)Find the "Content" project in your main project. Right-click on that project and choose "Add Reference...". From the "Project" tab, choose "Pipeline."
Tomoprime
KiloWatt.Base ContentTypeReader error in XNA windows env
Hi jwatte
I get an error when trying to load a model in windows.
Cannot find ContentTypeReader KiloWatt.Base.Animation.AnimationSetReader, KiloWatt.Base.
I added the Pipeline reference to the Content references folder. What else is missing? Thanks.
Tomoprime (creators club)
Version 20080624 is replaced
Version 20080624 is replaced with version 20080703, which includes better documentation, and doesn't include the unnecessary files. It also includes more sample art for your viewing enjoyment.
Animation Library Compatibility
Will this animation code work if I'm not using the kW X-port to export my model into XNA?
Some extra files were
Some extra files were accidentally included, in the "Runtime" and "tools" directories. Those are not used by the animation library, and can be safely ignored. They will not work stand-alone as they have other dependencies, too. My apologies for the inconvenience.