KiloWatt Animation 20081128 / 20100307

jwatte's picture

This is the third-and-a-half 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/3.1 for Windows and Xbox 360. Sorry, no Zune support :-)

Click here to download.

Then click here to download the update and merge it into the previous download (replacing files by name probably will work mostly OK). If you run into problems, feel free to let me and others know on the web site, but you will likely have to solve them yourself first :-)

The most important feature update is the animation processor, which now will remove sequences of identical keyframes from the end of an animation, to work around the "one second minimum length" bug. Yay! There may also be a working octree-based triangle mesh collider processor included, but if so, it's totally not a supported part of kW Animation (it's still released under the same license).

The KiloWatt Animation Library is different from the XNA Skinning sample code in several ways, including:

  • KiloWatt Animation stores animation keyframes as position, rotation and scale (for a total of 10 floats), instead of the full matrix used by the Animation Components.
  • KiloWatt Animation removes unnecessary keyframes (down to a tolerance that you can specify), for a usually quite significant savings in file size.
  • KiloWatt Animation does interpolation between animation keyframes using quaternions, which means that slow-motion and varispeed playback will still look smooth.
  • KiloWatt Animation supports composition (blending) of animations to generate the final output pose for a given Model.
  • KiloWatt Animation replaces the Effect used for your Model only when you tell it to.
  • KiloWatt Animation does not make any specific demands of your geometry; you can (and should) use it to animate rigid objects such as windmills, catapults etc. in addition to skinned meshes.

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.

New in release 20100307 is a few code updates, and a work around for the "one second minimum duration" bug, applied in the content processor.

Find more documentation in the download, and please let me know what works for you and what doesn't. This is the third-and-a-half 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.

AttachmentSize
KiloWatt.20081128.zip4.4 MB
KiloWatt.Dump_.20100307.zip124.39 KB

Comments

It looks as if translations

It looks as if translations are being applied twice, or scale is not appropriately applied to the translations....
.. This can happen if the bones or mesh contain scale, and/or if the bones or mesh are not properly "reset transform" before attaching to the skin pose.

jwatte's picture

That's a good hint, btw.

That's a good hint, btw. Resetting transform of all bones and the skin before attaching the skin is always a very good idea when creating skinned objects.

Can't view model in AnimationViewer

I've encountered a problem and would like some help please. These are the steps I have taken when trying to create a view a model in the AnimationViewer project.

- I create a simple box in 3DS Max 2011 x64. (The dimensions are 1x1x1 meters)
- I then export the model using the kW Export Tool. (The mesh is right handed, y is up and the winding order is correct)
- I load the model in DirectX Viewer and it displays the model.
- I add the model to the AnimationViewer project and process it with the AnimationProcessor.

The model's name is displayed (as are the names of any animations I decide to export) but the model can't be seen from any distance when selected.

Why would the model not be displayed?

jwatte's picture

If you run the animation

If you run the animation viewer using PIX for Windows, and capture all draw calls for a full frame, what does it say about the display of the model?

regarding archer model

Hi, I want to ask if I could have the archer model in .3ds for reference purposes. I just want to compare with what I have on my end. Thx!

jwatte's picture

Sorry, no -- my license for

Sorry, no -- my license for the model does not allow re-distribution of the source art.

animation processor missing?

After I updated the files, I found myself having to recreate a new animation viewer project. But this I checked that the animation processor seems to be missing from the drop down menu.

jwatte's picture

The Content project is

The Content project is probably missing the reference to the Pipeline project that defines the animation processor.

MaxBones

HI
My project has a model with more than 72 bones.

Is this a hard limit or is it possible to increase it by recompiling the source?

Will this work? If not, do you have any recommendations on a good way to do this?

Thanks!
Pragya

jwatte's picture

The 72 bones come from the

The 72 bones come from the limitation on the number of vertex shader constants, which limits how large a pose you can send into a vertex shader.

You can push it up to about 110 by sending quaternion and offset (and no scale), and convert from quaternion to matrix in the shader. That will slow down the shader, though.

An alternative is to build your object as several separate meshes, each of which is less than 72 bones. That's what I would do, if I really, truly needed more than 72 bones for a single object.

Changing Pixel Shaders?

Is there a way to change Pixel shaders using kW... i haven't used it yet?

i just want to give different effects to the skinned models

jwatte's picture

kW Animation uses whatever

kW Animation uses whatever effect file you tell it to use (or already use in your imported model).
The example code uses a specific set of binding parameter names, but you can use your own if you want -- or just take the example shader and change it.

Max bones

HI
My project has characters with more than 72 bones

Is this a hard limit or is it possible to increase it by recompiling the source?
If not, do you have any recommendations on a good way to do this?

Thanks!
Pragya

Can't Draw My Model ?

First of all, Thanks for Great library!

i'm tryin to draw archer (same archer used in viewer) i copied all of the needed materials and models to my content folder, then try to draw it,

My Code: http://pastebin.org/321873

Where i'm doing wrong ?

jwatte's picture

I can't really debug your

I can't really debug your code for you :-)
I suggest you apply the normal debugging techniques:
- breakpoint and step through each line of drawing, verifying that it does what you think it should do
- capture a frame in PIX for Windows, and step through the drawing calls, verifying the device state for each call
- starting with something you know works (the animation viewer, say), and then mutate it one small step at a time towards what your current code does until it stops working -- then you know what broke

dirtysteve's picture

Animation control

How do I tie an animation to a specific key-press, ie. press Space, play punch animation.
I'd like to know how to load animations by name, is it anything like this code I used in an Ox Engine project ?

 else if (keyboardState.IsKeyDown(Keys.Space))           
 {
   Component.AnimationController.PlayClip(Component.SkinnedModel.AnimationClips["Punch"]);                                             
 }

Animation control

How do I tie an animation to a specific key-press, ie. press Space, play punch animation.
I'd like to know how to load animations by name, is it anything like this code I used in an Ox Engine project ?

 else if (keyboardState.IsKeyDown(Keys.Space))           
 {
   Component.AnimationController.PlayClip(Component.SkinnedModel.AnimationClips["Punch"]);                                             
 }

Quickstart

I've been picking apart the Model Viewer, trying to understand kilowatt. I was wondering, what's the bare minimum of code needed to display my model and it's animations?

Can I just do something like ,

DrawDetails dd = drawDetails_;
Model myModel = modelDraw("myModel","myModel");
myModel.SceneDraw(dd);
myModel.SceneDrawTransparent(dd); 

If anyone has simple code they can share, I would appreciate it.
I prefer to do this than use the paths like the viewer, I'm finding it tough to comprehend the code used in the viewer.

Also when I plugged my model into the viewer, I got some weird extra animations, possibly leftovers from Blender, can I use the Exclude Animations drop down to keep them from appearing?

I posted a similar comment earlier, but it didn't appear, sorry for the double post if it does.

jwatte's picture

One of the problems is that

One of the problems is that animation is something that is fairly complex. While it might be possible to create a "just do it" wrapper that drew one model with one animation, that would be totally useless as soon as you wanted to do anything real, which includes blending animations, easing in/out, etc. Thus, the sample and library do it "for real" rather than "for simple."

dirtysteve's picture

Fair Enough

What about my other question(posted above), how would I play the animations by name, rather than stepping through a list? Do I use an AnimationSet, an AnimationInstance, or do I need both?
I assume AnimationSet can be used to load all the animations contained in my .fbx, and AnimationInstance can be used refer to a specific animation by name.

Quickstart

I've been picking at the Animation Viewer, trying to get my head around kilowatt. Does anyone have any simpler code? I just want to start with the minimum required to load my model and play its animations.
I like to declare my models individually, rather than use the folder path like the viewer.

Also when I tested my model in the viewer, I got some strange animations, probably left over from Blender. How do I use the exclude animations field? (I assume that's what it's for)

Changing a model's position?

Hey there, Im Peter.

This might be a weird question, but how can i change the position of an animated model? I'm looking through the base class for days now and still cant find it. Ive tried to manipulate the matrices in the drawdetails class, but it was a failure... :)

Maybe i misunderstood the whole thing from the basics, but so far i created a new class for myself, with the blender, animationset and other things, including drawdetails for each instance. I thought Ill have my settings for each character in the game, but i couldnt figure out wheres the data for the drawing coordinates.

Am I doing it wrong from the start? How should I fix it?

Hope my post isnt a mess... :)

Thank you!
Peter

dirtysteve's picture

Any Luck?

Have you had any luck resolving your problem? What about dd.World in the Draw method? i think that's the position of the model. You could try various multiplications on that to test it.

changing bind pose position or sth

hi

i have animated model of my main hero in game, and it has hit animation
but doing this hit in place (without moving forward) looks bad

so now i have new hit animation in which along with hit (using hand) player is moving forward a little and then a method added to EndReached event sets current animation back to idle animation, but to blend it with model in idle animation this model should have new position (cause witch hit animation my character steps forward)

i hope you understood

TIA
with Regards
Przemek

jwatte's picture

Although there was no

Although there was no question, I'm going to assume you want to know "how do I do this" :-)

You have to extract the motion of the root bone from the animation, and apply it to your character's simulated position instead. This can't be done in the animation library, because the way that position of objects is simulated/updated varies wildly between different engines.

Easiest is to get the Translation of the bone at index 0 each frame, subtract from the value at the previous frame, and simply add that to the position of your object. Then set the Translation to Vector3.Zero before you actually hand the pose to the effect for drawing.

Trouble rendering a simple model

Hello, first of all thank you for making this library and also for being supportive with the people using it.
I'm new using kilowatt library and I have a problem loading a very simple model, its a cylinder with 3 bones a simple bend animation [24 frames], I followed the instructions in the readme file with the source, but I'm getting a not-so-explicit error with :
model = new ModelDraw(Content.Load<Model>("cylinder"), "cylinder");
I get the error
ContentLoadException was unhandled . Error loading "cylinder".
in this line:
AnimationTrack track = input.ReadObject<AnimationTrack>();
I tried to change the export settings in my model to match the ones in the archer example but nothing seems to work (I unchecked the export shaders option, don't know if that is causing the error), that model works fine with the skinned model example from creators club, so I'm out of ideas of whats happening.
It might be a dumb question but I can't figure out the answer :(
Any help is appreciated, if you need some more info or the sample model just let me know!
Thanks in advance!

jwatte's picture

Does that

Does that ContentLoadException have an InnerException? The information you give isn't quite enough to figure out what might be going wrong.
Does the bendy cylinder work in the DirectX viewer?
Are you using the Animation Processor for the model in the content project?

Hardware instancing...

Hello again :)

Is there way how can I use hardware instancing in kw? Something like this:
http://creators.xna.com/en-US/sample/meshinstancing

Thank you!

jwatte's picture

kW Animation is all about

kW Animation is all about providing data for the shader that draws the model. If you can write a shader and vertex buffer set-up that does animated hardware instancing, then you can push the data from kW Animation into that set-up.

The built-in example ModelDraw class is not set up to do hardware instancing, but there's no rule that you have to use that (in fact, my expectation is that most "real" users will write their own versions instead).

Thank you!

I've got this all working with the animation trimming, works a treat thank you! :)

One question though. With XNAnimation it was quite easy to grab the world position and orientation of a bone (for attaching a directional cone light to a gun), but due to crappy knowledge retention on such things I can't figure out how to get from your system. Is there any easy way to do this?

Thanks again! <3

Chris

jwatte's picture

Easiest is probably to rip it

Easiest is probably to rip it out of the Pose array once that's been generated.
If that's not good enough, then I believe there's a pose source interface somewhere in there...
I think CurrentPose or CopyPoseTo() in the AnimationInstance might be the easiest place to start. You'll need an index -- that is the BoneIndex of the ModelBone you're interested in.

awesome thanks a lot :)

awesome thanks a lot :)

composite anims

Hello me again with the questions, apologies! ;)

I notice 'composed' anims which seem seperate to blended anims, and I assume these are like 'additive' anims of sorts? Or have I got this mistaken? i.e. for doing things like talking anims where just the head moves. If so how do you use these? If we were to do an anim with just the bind pose and the head moving should this then make a talking anim we can apply over any other anim without it affecting the rest of the anim? as this seems to go mental and stretch the character all over the place. :( having a blended anim though would affect all the rest of the bones in the model, I guess I need something which only represents the differences from the bind pose or previous frame, and from the Compose method it seems to be doing something similar...

if not how would we go about doing this? I tried forcing just single bones to animate but this ended up with some problems.

thanks! <3

chris

Stop loop animation

Hi

I have stupid question :) I'm beginner to using KiloWatt animation library.
Everything works fine, but all animations are looping - I want play firsttime and then stop.

Can you help me?:)

jwatte's picture

Loop at the

Loop at the AnimationInstance.Looping property.
Additionally, inside AnimationInstance.Advance(), there is a check, which calls OnEndReached when it gets to the end.

Thank you! Looping is now

Thank you!
Looping is now working, but I have got another question.

If animation is running I wanna stop it. I used own function:
public void Reset()
{
for (int x=0; x

Oooops, code is not completed

Oooops, code is not completed :) I try it again...

If animation is running I wanna stop it. I used own funtion Reset() on picture:
http://www.karelhladky.cz/code1.png

Everything is fine - animation stop but then I start animation again, nothing happens. Why?
Thank you for your help!

jwatte's picture

I think you'll have to trace

I think you'll have to trace into the code of the second Start() call using a breakpoint in the debugger, and figure out what's going on.
Also, if you haven't downloaded and merged in the code drop I made a few weeks ago, I think you should do that. I vaguely recall updating things having to do with looping vs non-looping animations.

But when I use your new

But when I use your new release, I have got 3 errors:

first:
loadedModel = new ModelDraw(model, name);
blender = new AnimationBlender(loadedModel.Model, loadedModel.Name);
loadedModel.AnimationInstance = blender;

loadedModel has no property AnimationInstance....

next:
loadedModel.SceneDraw(dd);
loadedModel.SceneDrawTransparent(dd);

there must be another int parameter. I try some numbers and models dont render ....
maybe help me (and maybe for others) some updated example, is there some chance?

jwatte's picture

Can you copy and paste the

Can you copy and paste the error you're getting? It's kind of hard to tell what the problem is from just reading your description.

there is my

jwatte's picture

Yes, it looks like the API

Yes, it looks like the API for those functions changed. You will have to adapt your own code (in GameObject3D.cs) to match.

Namespace Usage Issue

Heya,

First up, keep up the good work. :)

I'm trying to implement your stuff within my project and I'm using the steps covered in the ReadMe.html that comes with the download under the "Using KiloWatt Animation in your project"

Now I'm simply trying to add a 'using Kilowatt.Base.Graphics;' statement up the top (after having followed the instructions).

This is straight up failing, giving the normal namespace could not be found error.

I did upgrade the provided project to a 3.1 version beforehand, not sure if that would have any effect.

I have also tried specifically adding a reference to base in the main app as well as excluding (both to match the instructions as well as the animation viewer example).

Cheers

Primal

jwatte's picture

I suggest looking at what the

I suggest looking at what the Animation Viewer application is doing, and do the same thing yourself. Also, look carefully at the error message -- it may be coming from a different project than you expect, perhaps?

Next Release

Is there another release planned or is KiloWatt Animation 20081128 the final version? Thanks!

~IonDave

I don't "plan" releases. When

I don't "plan" releases. When a few bug fixes accumulate, I build new installers and release them. Also, there may be new releases for new versions of 3ds Max.
Currently, the only annoying outstanding bug is the "one second animation" problem, which I don't have a lot of motivation to fix because I have a work-around in my XNA processor.
Is there anything in particular you're interested in?

Hello

Thanks for doing this animation system, it seems really powerful. :)

You say you have a workaround for the one second padding bug? Reason I ask is I've just converted our project over form XNAnimation to this based mainly on this comment and it's taken about a week, but now I've got animations playing and they're still padded to 1 second. :( if you could let me know how to sort this it would be much much appreciated we're currently well late on getting video footage / screenshots for our publisher and need to get the animations working properly for tomorrow if at all possible :S

Thanks again! :)

Chris

jwatte's picture

The work-around is to detect

The work-around is to detect keyframes that are "the same" in the animation processor, and chop them off the end of the animation tracks.
I'm bundling together some code I have in my current project, which represents some advances in kW Animation, and attaching to this post.
HOWEVER: That code is not built as a usable release. You'll have to figure out how to merge it into the version you have yourself. Substituting by file name might work reasonably well.
I've been hoping to have time to fix this once and for all, but it never seems to quite happen.

Oh you are awesome! Thank

Oh you are awesome! Thank you! :)

No, nothing in particular.

No, nothing in particular. The only reason that I asked was that the latest release is from 2008. I now assume that the functionality is "right where you want it" and that the current version is complete...until changes XNA and/or 3dsmax or .X warrant an update.

Thanks for the response. I look forward to integrating your libraries into our framework.

~Dave