Facial Animation
Using MorphMesh
MorphMesh is very easy to use.
Create an instance of MorphMesh in your Initialize method of Game, I called mine joan.
Then in the LoadContent you must create your expressions, and then your base mesh.
Create an instance of MorphMesh in your Initialize method of Game, I called mine joan.
Then in the LoadContent you must create your expressions, and then your base mesh.
joan.AddExpression(GraphicsDevice, Services, "anger", "Models\\anger"); joan.AddExpression(GraphicsDevice, Services, "fear", "Models\\fear"); joan.AddExpression(GraphicsDevice, Services, "happy", "Models\\happy"); joan.AddExpression(GraphicsDevice, Services, "sad", "Models\\sad"); joan.Load(GraphicsDevice, Content, "Models\\neutral"); joan.SetAbsoluteExpressionValue("anger", 1);
In your update method you need to set all the expression weights.
I will leave it to you the decide how you control the blending (or you can look at the source code at the end of this page), but you must make sure that the sum of them does not exceed 1.0.
I will leave it to you the decide how you control the blending (or you can look at the source code at the end of this page), but you must make sure that the sum of them does not exceed 1.0.
joan.SetExpressionWeight("anger", anger_value); joan.SetExpressionWeight("fear", fear_value); joan.SetExpressionWeight("happy", happy_value); joan.SetExpressionWeight("sad", sad_value);
Don't forget to setup your matrices as well.
Now to draw it just add this to your Draw method.
Now to draw it just add this to your Draw method.
joan.Draw(GraphicsDevice, morph);
Simples.
Okay so I hope this has helped a few of you, below is a link to an example project you can play with.
Happy coding.
Okay so I hope this has helped a few of you, below is a link to an example project you can play with.
Happy coding.
facialmorphing.zip | |
File Size: | 769 kb |
File Type: | zip |