BlendShapes

Hi,

free code time! The animation, which seems that you have already done:

This is rather complex, but it deals with the key frames & weights, it is probably not 1:1 to you Blender data but I’m sure the principle is the same:

1 Like

hi tonihele!

I’m glad you saw this, because I actually looked at your github code last night and it inspired me to get to the point I’m at. Your project is awesome, and it really looks impressive.

I think my current problem is my mesh is too complex. I need to start out with a simple low poly mesh like a box with a single material and try to get shapekeys working, then expand the solution to a multiple material mesh.

That’s ok nehon, thanks for noticing the post. I’m sure that bumping all our heads together we’ll come up with something, and hopefully we can give something back useful to the engine as well :smile:

1 Like

I was able to get the shapekeys to work for the facial animation for my model. It looks like hearing from you guys was just the amount of encouragement and feedback I needed to get things working. In all the above posts target was set to the first geometry of the spatial.

Mesh target = geom.getMesh();

This works fine for single material mesh, but when you have multiple materials, you need to apply the deformation across all of them. I have several animations, and distinct facial poses that all seem to work.

I still haven’t checked to see if skeletal animation still works, so I may have a bit of work to go, but I feel like I’ve reached a major milestone.

Below is a video of it working. There are still a few glitches I need to work out. It isn’t actually animating properly yet, just setting the initial pose. Subsequent calls to setTime seem to do nothing, and setSpeed doesn’t actually cause the animation to proceed. Also, when I create multiple models it seems to carry the pose over to the other models which is wrong.

shapekey animation in jme3

The head and its poses were generated using a tool called facegen modeller, quite a nice tool for making heads.

If anyone is interested in reproducing this, this is the eclipse project I’m using:
Experimental.tar.gz

I included the original testhead.blend file in the assets folder, which I created using blender 2.63. Apologies for the horrible specular level on the eyes, I wanted just a little bit of shine, I added so much it looks evil. :smile:

I’m using Ubuntu 12.04, but there’s no reason this shouldn’t work on any platform. I also included my specific version of the jme3 libraries I forget how old they are, I think they’re nightlies from January 2014, so they aren’t super recent.

Let me know if any of you are able to reproduce my results.

1 Like

Video is private :frowning:

Oops! Should be fixed now.

Wow! There’s been a lot of activity since I last came online. Thanks a lot for sharing your project dbugman. I first tried to use your code from HelloAssets.java with the code I reconstructed from the thread, but I got a nullPointerException at:

ctrl = findAnimControl(heartModel);

Not sure why that happened exactly. So instead I used your advanced meshLoader, PoseTrack and Pose classes, and the program runs, but all I get is just a stationary head with no animation.

Side question: I’ve found that my own blender exported ogre xml mesh only has a poses tag, but no animations tag. My guess is that this means blender exports only the keyframes, but not the animations. How do I get blender to export the animations as well?

Sorry. Ignore my previous post. I hadn’t seen the video. Yes they are working indeed, but we need to animate them. I’ll try figuring out the cause of the null pointer exception and see if I can get them to work with kidow’s and nehon’s code, maybe that’ll work. I’ll also send you the code, you’ll probably be more likely to figure it out than me!

Yes, its not actually animating the poses correctly. Its only applying the first time frame of the specified pose (specified on the setAnim line). I’m still trying to figure that one out, but it may have to do with nehons later fixes that I didn’t put in.

You can see the other poses by changing the animation from “Angry” to “SmileOpen”, “SmileClosed” Oh", “Ee”, " Ah", as I did in the video. My end goal is a model capable of skeletal animations and shape key animations, so I can make a walking, talking model. But I have a few other cool application ideas for shapekey generated poses.

In order to get the animation tags in your own ogre file you have to add NLA tracks as you would for skeletal animation.

If you are unfamiliar with how this is done, I can make a quick video tonight (I’m at work right now until 5pm US central time) showing how I created the head model.

I’m glad that someone else is interested in this. Hopefully we can help each other arrive at our goals.

Ok, I’ve been at this for hours now, tinkering with the code, and I have to say I haven’t really gotten anywhere. You seem to have applied all the changes nehon made, and in addition provided support for multiple meshes. Other than that there’s no real difference between your classes and the ones I put together. I used diff to compare them all side by side. I’m still stuck at these fixed poses.

Don’t let my failure hold you back though, I have only a very limited experience with jMonkey, you’ll probably have better luck.

I’ll go jump off a cliff now :sweat: .

Ok, I got the animation to work. I had to store the base unmodified mesh and apply each pose frame to the unmodified mesh. It now animates…I’ve noticed some minor glitches with the eyebrows, due to how I keyed my model (basically, some poses will carry over into other poses). But I think its behaving like it is supposed to. I have posted a video of the animated shapekey on youtube:

Animated shapekey poses in jme3

After this I’m going to test to see if skeletal animation still works, and if it works simultaneously with poses. Like I said, my goal for this is a walking, talking single exported model. I’d like to be able to independently control facial poses from skeletal animations. My only worry is that right now the two systems may be mutually exclusive (only shapekey or skeletal at a given time), due to the fact they are both set through setAnim, but I’m hoping it isn’t the case.

I updated the code at Experimental.tar.gz since the original code didn’t work correctly. I’m going to work on cleaning the code a little bit now and maybe improving the speed, as well as the other stuff I mentioned above.

3 Likes

Dude you are the man!! I’m pulling a double shift at work now, but once I get back I’ll add NLA tracks to my mesh animation and try this code.

A question though. Can we now blend animations using separate channels? meaning that, in your example, can we make her frown and go “Oh” at the same time for instance?

Another thought: can we start an animation from the end frame of another animation? As in transitioning from smiling to frowning for example without going back to the base mesh. Would that be possible?

Kudos to you dbugman, you’re a lifesaver. Its people like you who make the internet such a wonderful place.

I would like to be able to do all those things you mentioned, and I think that it should be possible. Whether or not its possible in the current state, I’m not certain. If not I would think we can write additional methods to allow for it.

I was able to verify that you cannot have a mesh that has both skeletal and pose animations. However, you can have a single scene file with multiple meshes, some containing skeletal and others containg poses. This works for my purpose as I can separate the head model and have a talking head while still having body animation. The only issue is keeping the head attached to the correct bone in the body, but that really isn’t that hard, its similar to attaching a weapon model to a hand bone.

And thank you for the kind words, but I’d have to give all the credit to nehon and kidow, and the JME community as a whole.

Yep, works just great with my mesh! Thanks so much to you dbugman, nehon, and kidow for all the work and time you put into this

Well, if you liked that, you’ll really like what I’ve got next :smile:

I was able to get the Skeletal animation and pose animations working in a single scene file. The caveat is that the animations have to exist in separate meshes. Because of this, I have to do a bit of trickery with the head (remove it from the model and actually reattach it to the “headbone” using getAttachmentsNode from the SkeletonControl). But the end result actually looks better than I expected. I gave the model a “Walk” animation and an “Idle” animation. Here is the end result:

jme3 poses and skeletal animation in a single model

As a side note, the body was created in makehuman, and the shirt and shoes are off blendswap.
tshirt
shoes

Hi,

Great work !
I would like to allow this kind of feature into xbuf pipeline (in future), could I copy and adapte it ?

Thank you, I’m glad you like it, and using like that is fine with me. I uploaded the code to:

Experimental Project Full Body

I included the .blend file in the archive as well so you can see how to make your own models.

Let me know if you’re able to recreate my results. Also, feel free to change any of it in any way. I apologize if its messy, my coding style is…rough until I polish my work. If you want some explanation of any part of it, including how I made any of the model, I’ll gladly provide explanations either here or in a personal message. Let me know how you end up using it though, I’d like to see what my work contributes to. :smile:

btw, what is xbuf pipeline?

Thanks, I’ll take a look after I’ll fixe other bugs (I hope in september).
xbuf pipeline, is a data format (xbuf) and a set of tools (blender exporter, jme3 loader, “assimp” to xbuf converter, blender renderer (eg to view xbuf renderer by your jme3 app into blender). And I would like to support several type of animation (as extension) in the format then into exporter/importer.

Wow, quite impressive!

@nehon I think it’s maybe time to start considering building this into jMonkey by default?