[SOLVED] Combining skeletal animation with vertex animation

The place for artists, modellers, level designers et al to discuss their approaches for creating content for OGRE.
Post Reply
Elusive Pete
Kobold
Posts: 39
Joined: Tue Jun 27, 2006 11:09 am

[SOLVED] Combining skeletal animation with vertex animation

Post by Elusive Pete »

Hello all,

I have a question about using skeletal and vertex animation.

We've got a character moving using skeletal animation, and one of our artists wants to use vertex animation for facial expressions and lip-sync movements (on the same model, at the same time). We've successfully tested both forms of animation in Ogre separately (i.e. separate models), but are getting stuck trying to combine them on the same model. Is such a combination possible with Ogre?

The artists are using Maya 7, and the Ogre exporter doesn't seem to allow both skeletal and vertex animations to be exported at the same time. However, I tried editing the XML output files manually to force it to do both, but when loading the resulting binary file, the Ogremain.dll had an error (I think it was an access violation reading memory location 0). Perhaps this is a known bug, or maybe just an anomalous glitch with my build of the libraries?

If the combination is not realistically possible, without wasting much time (as we have a very tight programming schedule), then we can just use one form of animation for both purposes. However, that would either be less flexible, or would involve more work for the animator. Any suggestions?


Many thanks.
Last edited by Elusive Pete on Tue Jul 04, 2006 7:24 pm, edited 1 time in total.

User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

Is Maya the only tool your artists have available? The Maya exporter, while fairly robust and fairly well-supported, is still a community-developed exporter (by Bisco) and not directly supported by the Ogre team, so your only options are to alter the exporter to export both types at once or contact Bisco to see what's up with it.

The only exporter right now that is directly supported is the XSI exporter (although you could say that the Blender exporter is supported by the Ogre team in a way). oFusion for Max may be able to export both at the same time too -- I haven't tried (see the oFusion forum in the Addons Forum -- green buton at the top of the page).

Elusive Pete
Kobold
Posts: 39
Joined: Tue Jun 27, 2006 11:09 am

Post by Elusive Pete »

We have a copy of 3DS Max available, and we can get Blender easily (since its free anyway), but our artists are not familiar with the packages. We are on such a tight schedule that another learning curve is not really feasible (oh, the joys of deadlines!). I gather from what you're saying, though, that it is definitely possible for Ogre to handle the combination of skeletal and vertex animations in a single ".mesh" file (along with the associated ".skeleton" file)?

Does anybody know where I could find a model (in Ogre format) using that combination, so I can test our Ogre setup? (I'd rather not spend ages screaming at the export scripts, just to find that there's another problem buried in our libraries somewhere).


Our other programmer did think of an 'interesting' alternative approach, and that's to programmatically add a vertex animated face mesh onto a skeletally animated body at run-time. I guess that'd be pretty easy in principle, but in practice could be very glitch-prone (making everything line up would be nearly impossible!).

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 65
Contact:

Post by sinbad »

Because I suck at modelling, I made a really crappy test case for the combination of skeletal and vertex animation - basically a simple cylinder which bent like a leg through skeletal animation, and bulged using vertex animation. It worked, but it was not art ;) I exported it with XSI but if you've exported each animation type individually, I'm surprised you can't get them working together.

Elusive Pete
Kobold
Posts: 39
Joined: Tue Jun 27, 2006 11:09 am

Solution! :-)

Post by Elusive Pete »

(EDIT: There's a better solution than this now -- see post further down)

Thanks for the replies guys. Things seem to be working now. I tried 3 or 4 different Ogre model viewers which are on the Internet, but none of them succeeded in playing the animations together (one of them just crashed trying to load the file). However, using the latest Ogre libraries, our game framework can combine the animations. Here's what we are doing:

After speaking to Bisco, we've decided to use blendshape animation with the skeletal animation (on the same model). I have not used animation much before, so I don't know a lot about it, but blendshape is apparently good for facial expressions (I don't actually know how it differs from what we were using before!). The Maya exporter can export both blendshape and skeletal animations easily, although only into separate animation tracks.

It's a little tricky to get this done, but fairly straightforward if you know how. At the moment, here's the order of steps I'm going through to export the animations:
  1. Setup all animations on timeline in Maya
  2. Use Ogre exporter to export mesh and vertex (i.e. blendshape) animation clips, to XML file only, without skeleton, but with vertex bone assignments
  3. Use Ogre exporter to export skeleton and skeletal animation clips, to binary, this time without the mesh
  4. Edit mesh XML file to add line before the vertex bone assignments: <skeletonlink name="file.skeleton"/>
  5. Convert mesh XML file to binary (using Ogre XML converter tool)
I do not think that there is any way to use the exporter to put the "skeletonlink" tag in automatically, as it disables the skeleton exporting when you want to use vertex animation clips. I will let you know if I find out anything different. At any rate, it should be easy to write a separate program to do it.

For anybody else who wants to try this, there are some important pitfalls to watch out for:
  1. Make sure you have your model's neutral pose setup in a keyframe somewhere (it should be your skeleton's bind pose)
  2. Export your mesh in that neutral pose (i.e. that keyframe should be visible when you export)
  3. Export your skeletal animations with that neutral pose specified
  4. Make sure all your blendshape animations are based on the same neutral pose (neglecting this caused a lot of weird animation distortions for us)
  5. When combining multiple animations at run-time, make sure you assign each one an appropriate weight, so that all weights sum to no more than 1 (and beware of floating-point and binary errors too!)
We have encountered one or two strange crashes of the program when combining the animations, and it complains about an invalid vertex buffer. This seems to be related to the last point there, about making sure your animation weights are valid.

If I find out anything more, I'll let you know.
Last edited by Elusive Pete on Wed Jul 05, 2006 9:57 am, edited 1 time in total.

User avatar
hmoraldo
OGRE Expert User
OGRE Expert User
Posts: 517
Joined: Tue Mar 07, 2006 11:22 pm
Location: Buenos Aires, Argentina
x 1
Contact:

Re: Solution! :-)

Post by hmoraldo »

Thank you for that long post! It's very interesting and useful indeed.

Best regards!

Elusive Pete
Kobold
Posts: 39
Joined: Tue Jun 27, 2006 11:09 am

UPDATE!

Post by Elusive Pete »

Actually, I think most of my post is now redundant (although I'll leave it there, as it might still be useful for some things). Basically, I just found out that Bisco released a new version of the Maya 7.0 exporter (version 1.2.1.1... get it here). The new exporter allows direct export of blendshapes with skeletal animations, and there's no need to edit the XML files manually.

I've tried it out, and the results are excellent, so that's another superb piece of work from Bisco. :D

Post Reply