custom animation file importer.

0 anims? It should list 1 anim to match the 1 part, and then walk down the tree from there, matching anims to parts. If it lists 0 anims at the root of the hierarchy, it means you fed it an empty anim bundle, and it did nothing at all.

There’s nothing inherently wrong with negative rotations. And numbers like 2.50448e-006 look scary and weird, but that’s really just another way computers sometimes like to write the number 0.

David

I didn’t load the annimation file because I didn’t really know what chan was for…

EDIT:removed, too long

Well, and there you see it failing to bind most of your animation channels (the channels in the anim file are not matched to a corresponding joint in the model; and the joints in the model are then matched to NULL instead of to an animation).

This is no doubt due to the order difference that you have already discovered. Your possible solutions are:

(1) Correct Blender and Chicken so that they do not modify the order of the joint hierarchy

(2) Modify the egg file that Chicken writes so that it matches the expected order of the joint hierarchy

(3) Modify your own anim bundle to match the order of the joint hierarchy as output by Chicken.

David

Our importer imports the bones in order, of course.
I can test now to see if they are stored in Blender Armature object’s “BonesDict” in different order.
If it’s the case, then theres possibly nothing I can do without modifying Blender’s source, which is not an option.

I could modify the Chicken exporter to save the bones in correct order by hard coding ALL the skeleton hierarchies, but it would turn into an exporter suitable only for models imported with our importer.

The simplest (comparably) solution could be to have a “2nd-pass” script to rearrange the joints in the egg file by hard-coded skeleton hierarchies.
However, I dont know if just moving around joint matrix entries would be enough.

Modifying all the animbundles in our loader seems like the worst case scenario, because then the anims would work with the egg models, but not the original ones.

The egg-optchar program performs the cleanup check of rearranging joint children as needed to ensure a match between model and animation files, based on the names of the joints. It only operates on egg files, of course. But it means that if you wrote your exporter to generate egg files, instead of directly generating AnimBundleNodes (which would probably be a simple modification, as the structure is very similar), then you could post-process everything easily using egg-optchar and ensure a match.

David

That doesnt sound like a solution in the long run, youd want to allow users to use new models they made in the game’s format or egg to be campatible with the existing animations. Of course this (maybe) could work with new animations, but it would be an overkill to ask users to import/export all the existing animations to egg to make them work with their new egg characters and even then they wouldn’t work with the original characters files anymore.

I could just write an exporter to the game’s format, but to support new advanced stuff like normalmaps, I’d also want to allow egg files to be used (it would be even greater when collada support is added).

I think the simplest solution would be to have a '2nd pass" script to rearrange the joints in the file, like optchar does it.
I could store each joint data in a python dictionary, remove the existing strings, and write the joint data according to a hard-coded order.
However, i could use some info on what the joint entries are.

there’s , but theres also after only some of them, I don’t understand what they store except references to vertices.

That’s exactly what they are, references to vertices. That’s the skinning information, it describes which vertices are animated by this particular joint. If your model is hard-skinned, each vertex will be 100% assigned to exactly one joint. If your model is soft-skinned, a vertex may be assigned to multiple joints, with a different weighting on each one, such that the total equals 100% (or 1.0).

The full description of egg syntax is available in the manual.

David

So “membership”, is it the weight value.

OK I’ll try to make a “rearranging script” after I have the game’s 3d format exporter for Blender done.

Just a thought, it would be nice if Panda would search farther in the character/animBundle after failing to match a pair, maybe by explicitly asking it to.

Yes, this is a reasonable feature request. Feel free to add it to the launchpad. :slight_smile:

David

bugs.launchpad.net/panda3d/+bug/768798

Terrible news: it’s Blender who changes the bone order. I just printed the bone dictionary and everything is rearranged.

I’m afraid I simply can’t modify Blender’s source and right now it seems both eggs and the native format exported from Blender will be unusable with the existing animations :frowning:

So this is pretty much a dead end for me.
Really looking forward for that Panda feature…

Can’t you rearrange the AnimBundle that you’re creating as you create it, or after you create it? And can’t you rearrange the

and/or entries in the egg file after they’ve been created? I understand the inconvenience, but I’m not sure I understand why this is a show-stopper for you.

David

Yeah, I didn’t use the right words, what I meant was my objective was to make an easier and more convenient tools from old ones and running an extra script doesn’t make it more convenient and user is left to wonder: “why do i need to go through this extra step? I didn’t need to before”.

Hm, well you can’t tell for which model the animBundle is for before assigning an AnimBundle to an Actor.

The use of separate steps internally does not necessarily require the user to invoke these separate steps by hand.

For instance, you could wrap all these scripts within one convenient tool. For instance, you could write your tool to export everything to egg files, and when the user indicates he wishes to load a model, you could generate an egg file, run egg-optchar on it to rearrange the joints, and load that egg file, all in one easy operation.

David

Can I “rearrange” the joints based on animBundles inside Panda? Do they joints have some kind of order? And if so, can it be changed?

I don’t know which “joints” you’re referring to in this case, whether you mean the PartGroup tree that makes up the loaded character, the AnimGroup tree that makes up the loaded animation, the EggJoint tree that makes up the charcter egg file, or the EggAnimTable tree that makes up the animation egg file, but all of these are ordinary n-ary trees with the usual interfaces to add and remove children, and thus the list of children can be set to any order by brute force if necessary.

David

“CharacterJoint” I guess.
I was thinking of a functions “rearrangeJoints”, which would accept a Actor and AnimBundleNode and rearrange one of them to fit the other. I think rearranging character joints would be better.

A CharacterJoint is a subclass of PartGroup and makes up the PartGroup tree that starts at the PartBundle.

David

I couldn’t find any way to change the order of partGroups.
BTW, there is no child-parent bones, they are all relative to the center, if this is important here.

Ah, my mistake. It looks like there is a C++ method called PartGroup::sort_descendants(), which is also available on the PartBundle, of course. A similar method exists on AnimGroup. This method is called on the PartBundle and the AnimBundle by the egg loader after it creates the hierarchy. Its purpose is to sort the entire hierarchy such that siblings are in ascending alphabetical order by name.

So, this means that the order that appears in the egg file is not important–the joint hierarchy must be constructed in alphabetical order.

If your code to create an AnimBundle hierarchy is written in C++, you can simply call bundle->sort_descendants() yourself on the animation bundle after you have populated it. If your code is in Python, this method is unfortunately not exposed to Python (though it could be made so), so it means that you will have to be careful to pre-sort the hierarchy into alphabetical order before you create it.

David