CopyBoneTransformsFrom() public method

Copies bone transforms relative to Model.Root bone from a given array to this model.
public CopyBoneTransformsFrom ( Matrix sourceBoneTransforms ) : void
sourceBoneTransforms Matrix The array of prepared bone transform data.
return void
Example #1
0
        protected override void DrawModel(GraphicsDeviceManager graphics, Model model, Matrix world)
        {
            #region RotateSpine
            int spineBone = model.Bones["Bip01 Spine1"].Index;
            boneTransforms[spineBone] = Matrix.CreateRotationZ(spineElevation) * Matrix.CreateRotationX(spineAzimuth) * boneTransforms[spineBone];
            model.CopyBoneTransformsFrom(boneTransforms);
            model.CopyAbsoluteBoneTransformsTo(absoTransforms);
            #endregion

            base.DrawModel(graphics, model, world);
        }
Example #2
0
        private void DrawModel(GraphicsDeviceManager graphics, Model model, Matrix world)
        {
            // Apply the bone transforms
            Matrix[] absoTransforms = new Matrix[model.Bones.Count];
            model.CopyBoneTransformsFrom(boneTransforms);
            model.CopyAbsoluteBoneTransformsTo(absoTransforms);

            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (Effect effect in mesh.Effects)
                {
                    effect.Parameters["World"].SetValue(absoTransforms[mesh.ParentBone.Index] * world);
                    effect.Parameters["View"].SetValue(game.Camera.View);
                    effect.Parameters["Projection"].SetValue(game.Camera.Projection);
                    effect.Parameters["yValue"].SetValue(1-2*sliming);
                }
                mesh.Draw();
            }
        }
Example #3
0
        private void DrawModel(GraphicsDeviceManager graphics, Model model, Matrix world)
        {
            // Apply the bone transforms
            Matrix[] absoTransforms = new Matrix[model.Bones.Count];
            model.CopyBoneTransformsFrom(boneTransforms);
            model.CopyAbsoluteBoneTransformsTo(absoTransforms);

            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (Effect effect in mesh.Effects)
                {
                    effect.Parameters["World"].SetValue(absoTransforms[mesh.ParentBone.Index] * world);
                    effect.Parameters["View"].SetValue(game.Camera.View);
                    effect.Parameters["Projection"].SetValue(game.Camera.Projection);
                    effect.Parameters["Time"].SetValue((float)game.SlimeTime);

                    // The section the open door is in. (-1 for no open door)
                    int sectionOfOpenDoor = -1;

                    // The door that is open (null for no open door)
                    Door openDoor = GetOpenDoor(section);

                    // If the door is open, get the sectionOfOpenDoor
                    if (openDoor != null)
                    {
                        sectionOfOpenDoor = openDoor.GetSectionNumber();
                    }

                    //If there is an open door, set the openness.
                    if (sectionOfOpenDoor != -1)
                    {
                        // How open the door is (0 for no open door)
                        float opennessOfDoor = GetOpenDoorDegree(openDoor);
                        if (opennessOfDoor < 0) opennessOfDoor = 0;
                        if (opennessOfDoor > 1) opennessOfDoor = 1;

                        //If there is a slightly open door, set the color (turn it on) and set the location.
                        effect.Parameters["Light4Location"].SetValue(LightInfo(sectionOfOpenDoor, 6));
                        effect.Parameters["OpennessOfDoor"].SetValue(opennessOfDoor);
                    }
                    else
                    {
                        effect.Parameters["OpennessOfDoor"].SetValue(0);
                    }
                }

                mesh.Draw();
            }
        }