Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# XNA-通过代码对单个骨骼执行旋转和变换_C#_Xna - Fatal编程技术网

C# XNA-通过代码对单个骨骼执行旋转和变换

C# XNA-通过代码对单个骨骼执行旋转和变换,c#,xna,C#,Xna,我使用的是fbx文件格式的xna框架,没有skinnedprocessor 我遵循了一些关于在人体中创建手势的单个骨骼的旋转或平移的帖子。我使用XNA样本显示fbx模型,我甚至可以左右移动全身 现在我的问题是我写了一个代码来旋转一些有效的骨骼,但是只显示正常的模型,而不是旋转骨骼9的模型 这部分代码是在skindmodelprocessor.cs中编写的 看起来我在什么地方搞砸了 我有三个模型用于第一个和第三个模型,错误提示为“无蒙皮数据”,但我加载了所有内容(纹理、更改的内容处理器) 第二

我使用的是fbx文件格式的xna框架,没有skinnedprocessor

我遵循了一些关于在人体中创建手势的单个骨骼的旋转或平移的帖子。我使用XNA样本显示fbx模型,我甚至可以左右移动全身

现在我的问题是我写了一个代码来旋转一些有效的骨骼,但是只显示正常的模型,而不是旋转骨骼9的模型

这部分代码是在skindmodelprocessor.cs中编写的

看起来我在什么地方搞砸了

我有三个模型用于第一个和第三个模型,错误提示为“无蒙皮数据”,但我加载了所有内容(纹理、更改的内容处理器)


第二个模型只是提供了一个空白屏幕。

欢迎使用堆栈溢出。提问时,假设您需要发布代码,并描述您目前所做的工作所面临的具体问题。否则我们帮不了什么忙。请发布代码的相关部分。“如果需要,我准备好分享我的代码。”——是的,你应该这样做。我为我的写作方式给您带来的不便表示歉意。现在我编辑了这篇文章,请大家看一看。
   List<Matrix> bindPose = new List<Matrix>();
   List<Matrix> inverseBindPose = new List<Matrix>();
  List<int> skeletonHierarchy = new List<int>();

     foreach (BoneContent bone in bones)
            {
                bindPose.Add(bone.Transform);
                inverseBindPose.Add(Matrix.Invert(bone.AbsoluteTransform));
                skeletonHierarchy.Add(bones.IndexOf(bone.Parent as BoneContent));
            }

 //code for updating the position of a particular bone
        int idbone = 9;
    bindPose[idbone] = bindPose[idbone]*Matrix.CreateRotationX(MathHelper.ToRadians(45.0f));
            Matrix[] bones = animationPlayer.GetSkinTransforms();

            Matrix view = Matrix.CreateTranslation(0, -40, 0) * Matrix.CreateRotationY(MathHelper.ToRadians(camerarotation))
                          * Matrix.CreateRotationX(MathHelper.ToRadians(cameraArc))
                          * Matrix.CreateLookAt(new Vector3(0, 0, -cameraArc), new Vector3(0, 0, 0), Vector3.Up);

            Matrix projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, GraphicsDevice.Viewport.AspectRatio, 1, 10000);
         //Looping over multiple meshes
            foreach (ModelMesh mesh in firstmodel.Meshes)
            {
                foreach (SkinnedEffect effect in mesh.Effects)
                {
                    effect.SetBoneTransforms(bones);
                    effect.EnableDefaultLighting();
                    effect.World = worldtransformations[mesh.ParentBone.Index];
                    effect.View = view;
                    effect.Projection = projection;
                    effect.SpecularColor = new Vector3(0.25f);
                    effect.SpecularPower = 16;
                }
                mesh.Draw();
            }
}