【问题标题】:How to rotate and translate grandparent to position grandchild in world space如何旋转和平移祖父母以在世界空间中定位孙子
【发布时间】:2018-04-11 11:54:36
【问题描述】:

我需要将孙对象移动到世界空间中的给定目标位置和方向。必须通过操纵祖父母(根)位置和旋转来移动孙子(子 2)。

如果我有一个给定的目标世界矩阵, 我必须对祖父母应用什么矩阵才能使孙子匹配目标?

before transformation

after transformation, child 2 moved to target

我的问题有所不同,因为我不是在寻找“可用的 IK 系统”。我只需要计算祖父母的矩阵。我得到了你的答案,但他们似乎都没有评估正确的矩阵。与此同时,我想出了一个可行的解决方案。我会在我的代码中做一些清理并发布它。

【问题讨论】:

标签: three.js


【解决方案1】:

您希望将矩阵应用于祖父对象,以便孙对象的世界矩阵与目标对象的世界矩阵匹配。

为此,请使用以下模式:

var matrix = new THREE.Matrix4(); //create once and reuse

. . .

scene.updateMatrixWorld(); // the renderer does this for you in the render loop

matrix.getInverse( gchild.matrixWorld ).premultiply( target.matrixWorld );

parent.applyMatrix( matrix );

既然您知道了答案,那么您应该很清楚它为什么有效。

three.js r.87

【讨论】:

    【解决方案2】:

    对于对象局部坐标系中的一点,

    object.localToWorld( point );
    

    将返回该点的世界坐标,假设应用于点的变换与应用于对象的变换相同。

    THREE.js: Calculate world space position of a point on an object

    【讨论】:

      猜你喜欢
      • 2021-10-17
      • 2013-06-29
      • 2013-03-21
      • 1970-01-01
      • 2013-02-06
      • 1970-01-01
      • 2018-09-04
      • 1970-01-01
      • 2021-05-25
      相关资源
      最近更新 更多