Page 1 of 1

[SOLVED] Blender 2.5 Exporter: bones

Posted: Thu Oct 13, 2011 3:00 am
by Latin1
Edit: The solution is in my before-last post.

Hi everyone,

I've been trying out the OGRE Exporter add-on for Blender, and it halfway works: when I export the content, I get all the right files (mesh, skeleton, material, xml files, etc.).

However, when I look at the mesh with OgreMeshy (1.4), I see that all the bones are distorted and misplaced.

Right now I'm using a simple model for testing. Here's what it looks like in Blender:
And here's what I get in OgreMeshy:
That multicoloured dot in the middle is the armature. The distortion varies with the shape of the model's skeleton. On another model with a more human and more complex armature, the bones are just misplaced and somewhat shrunken.

Question: What steps are needed to correctly export the skeleton for use in an Ogre application?

A few notes:

- I'm using Blender 2.59 and the latest version of OGRE Exporter (0.5.4), which was apparently made for Blender 2.58. Realizing this, I tried using the same exporter with Blender 2.58 on another computer, with the same results.

- The mesh file is flawless, and can be used in an Ogre application, with its material, without any problems.

- There are directions for exporting the skeleton in, which is the file for the add-on:
Quick Start:

1. select your armature and set a single keyframe on the object (loc,rot, or scl)
. note, this step is just a hack for creating an action so you can then create an NLA track.
. do not key in pose mode, unless you want to only export animation on the keyed bones.

2. open the NLA, and convert the action into an NLA strip

3. name the NLA strip(s)

4. set the in and out frames for each strip ( the strip name becomes the Ogre track name )
As I understand it, the "in and out frames" are the Strip Extents (Start Frame and End Frame). I've followed all these steps, to no avail.

I've looked around the forum, and have found the same suggestions many times:

- make sure all the vertices are in at least one vertex group related to a bone (but less than four groups, which can cause animation problems);
- apply the model's changes to the object data (Ctrl + A > Location/Rotation/Scale);
- clear all transformations to the armature;
- check the armature's hierarchy and make sure the main bone is a parent to all other bones.

These are all things I've tried. No matter which version of Blender, OGRE Exporter, OgreMeshy or Ogre Command Line Tools I use, the results are always the same. This leads me to believe that I'm simply missing one crucial step, some property of the armature that I've overlooked. Wherever the problem is, I believe it creates a bad xml file which is used to create the .skeleton. I've changed some values in the xml and found that the changes were well applied when using it to create a new .skeleton file with OgreXMLConverter.exe. I also noticed that nowhere in the xml does it seem to take into account the position of the tail end of the bone. All three bones have their heads at position (0,0,0), so that's where they are in the skeleton.

Has anyone had this problem before?

Thank you.

Re: Blender 2.5 Exporter: bones

Posted: Thu Oct 13, 2011 10:59 am
by LiMuBei
How exactly do you figure that the bones are misplaced and distorted? In the Ogre Meshy screenshot I can't make out anything. Two things I can think of: bone size doesn't matter. The bones could be correct in Ogre, they are just tiny and short so one can't see it, but it shouldn't affect the end result. The other thing is that often the swap axis options mess up stuff using the exporter, it's just a guess though.

This could also be moved to the Artists & Content creators forums :)

Re: Blender 2.5 Exporter: bones

Posted: Thu Oct 13, 2011 4:54 pm
by Latin1
Thanks for the reply. I hadn't thought of posting in Artists & Content creators, as I didn't suspect the problem might be in Blender... but I suppose it would have been the best choice.

I guess it's hard to make out the second image; it's the same object as in the first one, but with no shadows or anything. The bones are centred like they should be, but don't protrude in any direction as they do in Blender.

When I say bone size, I guess I mostly mean bone length. Here is that more complex model I was talking about. The armature is bigger so it's easier to see what the problem is.

If you click the second picture, you'll see where the skeleton's arms and legs have gone.

I've noticed the two concrete problems:

1. The bones at the extremities have no length. The neck, forearms and feet aren't visible except for their... heads? Whatever it is, their names are still there.

2. There is an odd 90-degree rotation about the connection point between the central bone and the hips (where the directional arrows are in the first image). It seems very relevant that the horizontal hip bones aren't in fact children of the body bone; they were extruded from its head, unlike the parts in the upper body.

Nothing changed when I tried the other axis swaps. Are there properties I would need to change in Blender to remove the unwanted transformations, and also give the right lengths to the bones?

Re: Blender 2.5 Exporter: bones

Posted: Thu Oct 13, 2011 8:55 pm
by LiMuBei
My experience is, that bones that do not have a child bone show up super tiny in OgreMeshy. They should work fine nonetheless.

The rotation of the leg bones seems to be an issue with the armature. I think the exporter needs a tree like bone hierarchy with only one root that all other bones are children of. I suspect this might be where the problem is. If not, then there's still some rotation somewhere in there that should be applied in Blender (mabye bone roll?).

Re: Blender 2.5 Exporter: bones

Posted: Fri Oct 14, 2011 12:36 am
by Latin1
Your comment about bones in OgreMeshy is reassuring, I can focus on the rotation problem.

I've tried making the hip bones children of the main bone, but doing so links them to the bone's tail (the upper extremity), like the arm and shoulder bones. How could I make the main bone their parent, and still have them be at the right position?

Re: Blender 2.5 Exporter: bones

Posted: Fri Oct 14, 2011 3:29 am
by hartsantler
You may have multiple root bones, but all root bones must have zero rotation and roll (in edit mode). Your root should look like this in the skeleton.xml

Code: Select all

<skeleton >
	<bones >
		<bone name="root" id="0" >
			<position y="0.000000" x="0.000000" z="0.000000" />
			<rotation angle="0.000000" >
				<axis y="0.000000" x="1.000000" z="0.000000" />

Re: Blender 2.5 Exporter: bones

Posted: Fri Oct 14, 2011 9:08 am
by LiMuBei
You can also parent in Blender, but use "keep offset", so the bones stay in place but are children of the root. Also, what hartsantler said, he knows best :)

Re: Blender 2.5 Exporter: bones

Posted: Fri Oct 14, 2011 9:15 pm
by Latin1
Okay! No more problems with rotation, and the skeleton has a nice shape:
I made the hip bones children of the main bone, specifying the Keep Offset option, then made sure the main bone had no roll in either Blender or the xml. Thank you both!

Now there is another problem, which is quite apparent now that the other issues have been solved: the skeleton is scaled and it has moved to the model's head. I have a simple running animation for the legs, and naturally, the model doesn't move right in OgreMeshy.

Also, when I select the animation and click Play, the skeleton doesn't move; it only takes the position of the first frame:
It's strange. The exporter's comments explain that to have an animation, you need to create a track for it in the NLA editor, then "snowflake" it and name the resulting strip. OgreMeshy finds the animation, but doesn't play it; at least not beyond frame 1. I checked the xml; my animation is in it, and the legs are in fact rotated during its twenty keyframes.

I think the size is the first thing that needs to be fixed, it must be simpler anyway. Why would the armature get smaller?

Re: Blender 2.5 Exporter: bones

Posted: Sat Oct 15, 2011 11:04 am
by LiMuBei
For the size issue it's most probably that either your mesh or the rig has unapplied scaling in Blender.

Re: Blender 2.5 Exporter: bones

Posted: Sat Oct 15, 2011 3:35 pm
by Latin1
You were absolutely right!

For some reason, the scale values on the model and skeleton were greatly reduced. I forgot to mention earlier that I had noticed the 0.6 Scale value on the model, and tried changing it; it had made no difference, but now changing the Scale value for both the model and the armature did the trick.

Applying the location of both objects also solved the displacement problem.

It's odd to me that the scales of the object and armature change during modelling, but I guess it's just one of many things I don't yet clearly grasp about working with Blender.

All that's left is the animation. I'll look around and reread the directions, because I remember that the animations were working before.

Thank you again, fixing the skeleton would have taken ages to figure out without your help.

Re: Blender 2.5 Exporter: bones

Posted: Sat Oct 15, 2011 4:40 pm
by LiMuBei
The distinction between object and mesh/rig in Blender is something many people do not know. The concept is quite simple if you now C++: a mesh/rig can be compared to a class, where an object is an instance of that class. If you work in object mode and scale, rotate, whatever the _object_, that doesn't change the mesh/rig. If you work in edit mode though you change the mesh/rig, not the object. One of the applications of this concept is that you can have many different objects sharing the same mesh/rig (use Alt+D to make an instanced copy).

The whole thing is confusing at first, but allows for very efficient modeling if understood well :)

Re: Blender 2.5 Exporter: bones

Posted: Sun Oct 16, 2011 10:38 pm
by Latin1
I see, that does makes the distinction between Object and Edit modes clearer. It makes sense now to have the two modes clearly separated.

As for the animation, it turned out not to be visible because I had disabled it in Blender while I was working on other things, which is why I could see it in Edit mode.

So, to recap for anyone else with armature problems:

1. The skeleton was displaced and scaled down because I hadn't applied its Scale and Location properties (Ctrl + A > Scale / Location).

2. The animation didn't show in OgreMeshy because I had disabled it in Blender, which apparently makes it invisible in all contexts. I clicked on its eye icon in the NLA Editor, then exported it again.

Thank you once more, I truly appreciate the help you've offered me. For the longest time I was sure the issue was with version compatibility, or even just the quality of the exporter. I now realize these problems surfaced because of my own inexperience with 3D modelling and animation. Hopefully, over time I'll learn more practical information about Blender; I've already seen just how useful its wiki is.

Re: Blender 2.5 Exporter: bones

Posted: Sun Oct 16, 2011 11:31 pm
by LiMuBei
Check out BlenderCookie, they have tons of really great tutorials :)

Re: Blender 2.5 Exporter: bones

Posted: Mon Oct 17, 2011 7:35 pm
by Latin1
Wow, just judging from the front page, it looks like an excellent website. I'll definitely check it out, thanks :D