Help!!!

Jun 18, 2008 at 10:40 PM
Hello

Can anyone tell me how to attach a head to a headless model (with animation) using code.

*I am going to use the head for facial animation.

Thanks for the help.
Jun 20, 2008 at 10:23 AM
Edited Jun 20, 2008 at 10:25 AM
Make sure that the zero-point of your head model is at the right position (the zero point will be connected to the Head Bone of the body).
before you draw the model, you must set the Matrix of the Head.
Use this Method inside your Body Model to get the right Position:
GetAbsoluteTransform( HeadBoneIndexOrName )

If your Body is rotated and translated, you must add these transformations to the matrix of the head.

the whole calculation is something like this:
HeadModel.World= BodyModel.GetAbsoluteTransform( HeadBoneIndex ) * BodyRotationMatrix * BodyTranslationMatrix;

Edit: I didn't tested it, but maybe you can replace the Rotation and Translation Matrix with the World Matrix of the Body Model:
HeadModel.World= BodyModel.GetAbsoluteTransform( HeadBoneIndex ) * BodyModel.World;
Jun 20, 2008 at 6:01 PM
Edited Jun 20, 2008 at 11:34 PM


JeRET wrote:
Make sure that the zero-point of your head model is at the right position (the zero point will be connected to the Head Bone of the body).
before you draw the model, you must set the Matrix of the Head.
Use this Method inside your Body Model to get the right Position:
GetAbsoluteTransform( HeadBoneIndexOrName )

If your Body is rotated and translated, you must add these transformations to the matrix of the head.

the whole calculation is something like this:
HeadModel.World= BodyModel.GetAbsoluteTransform( HeadBoneIndex ) * BodyRotationMatrix * BodyTranslationMatrix;

Edit: I didn't tested it, but maybe you can replace the Rotation and Translation Matrix with the World Matrix of the Body Model:
HeadModel.World= BodyModel.GetAbsoluteTransform( HeadBoneIndex ) * BodyModel.World;


Ok, so far here is my code. Please correct me. The head doesnt move at all, even if have attach it to the wrong bone.

// Copying the bones absolute trasnform to the table.
this.trans = new Matrix[this.list[0].returnModel().Bones.Count];
this.list[0].returnModel().CopyAbsoluteBoneTransformsTo(trans);

// Here's the code for drawing the head model
       // Draw facial models
        private void DrawFacial(int index)
        {
            Matrix transf = Matrix.Identity;

            transf = Matrix.CreateTranslation(-0.8f, 110f, -0.45f) *
                     //Matrix.CreateScale(0.074f) *
                     Matrix.CreateRotationY(33f) *
                     this.trans[2] *
                     this.list[0].returnModelAnimator().World;
                    
            foreach (ModelMesh mesh in this.list2[index].returnModel().Meshes)
            {
                foreach (Effect effect in mesh.Effects)
                {
                    if (effect is BasicEffect)
                    {
                        BasicEffect basic = (BasicEffect)effect;
                        basic.View = this.camera.ViewMatrix;
                        basic.Projection = this.camera.ProjectionMatrix;
                        //basic.EnableDefaultLighting();
                        //basic.DirectionalLight0.Direction = lightPos;
                        basic.World = transf;
                    }
                }
                mesh.Draw();
            }
        }

Thanks!
Jun 20, 2008 at 11:43 PM
Here are some picture of what i actually try to do.

Model with animation

http://www.cs.ucy.ac.cy/~cs03aa1/how.JPG

The model is with out animation

http://www.cs.ucy.ac.cy/~cs03aa1/ex.JPG

Above code gives completely wrong results
Jun 27, 2008 at 9:15 PM
i think that you didn't used the GetAbsoluteTransform() Method of the ModelAnimator...
Jun 30, 2008 at 4:09 AM
:p So interesting!How to make the face animation?