Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/291.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# 骨wrt模型的局部定位_C#_Xna - Fatal编程技术网

C# 骨wrt模型的局部定位

C# 骨wrt模型的局部定位,c#,xna,C#,Xna,我需要得到骨骼(比如车轮)相对于模型(汽车)的位置矩阵或位置向量 我试过的- Vector3.Transform(mesh.BoundingSphere.Center , transforms[mesh.ParentBone.Index]*Matrix.CreateScale(o.Scaling ))) 上面没有给出准确的结果。您需要的是计算每个骨骼的绝对变换。这个方法可以帮你 它相当于以下代码: /// <summary>Calculates the absolute b

我需要得到骨骼(比如车轮)相对于模型(汽车)的位置矩阵或位置向量

我试过的-

Vector3.Transform(mesh.BoundingSphere.Center , transforms[mesh.ParentBone.Index]*Matrix.CreateScale(o.Scaling )))

上面没有给出准确的结果。

您需要的是计算每个骨骼的绝对变换。这个方法可以帮你

它相当于以下代码:

    /// <summary>Calculates the absolute bone transformation matrices in model space</summary>
    private void calculateAbsoluteBoneTransforms() {

      // Obtain the local transform for the bind pose of all bones
      this.model.CopyBoneTransformsTo(this.absoluteBoneTransforms);

      // Convert the relative bone transforms into absolute transforms
      ModelBoneCollection bones = this.model.Bones;
      for (int index = 0; index < bones.Count; ++index) {

        // Take over the bone transform and apply its user-specified transformation
        this.absoluteBoneTransforms[index] =
          this.boneTransforms[index] * bones[index].Transform;

        // Calculate the absolute transform of the bone in model space.
        // Content processors sort bones so that parent bones always appear
        // before their children, thus this works like a matrix stack,
        // resolving the full bone hierarchy in minimal steps.
        ModelBone bone = bones[index];
        if (bone.Parent != null) {
          int parentIndex = bone.Parent.Index;
          this.absoluteBoneTransforms[index] *= this.absoluteBoneTransforms[parentIndex];
        }
      }

    }
///计算模型空间中的绝对骨骼变换矩阵
私有void可计算的SolutionBonetTransforms(){
//获取所有骨骼的绑定姿势的局部变换
this.model.CopyBonetTransformsTo(this.AbsoluteBonetTransforms);
//将相对骨骼变换转换为绝对变换
ModelBoneCollection bones=this.model.bones;
for(int index=0;index
取自。

优秀的thanx;)我尝试过类似-model.copyAbsoluteBonetTransformsTo(transforms)的东西;wheelShape[i].LocalPose=transforms[mesh.ParentBone.Index]*Matrix.CreateScale(WheelScale)最初是正确的,但随着汽车的旋转,车轮变形,解决方案非常有效