【问题标题】:unity3d. How to get the result of transform.rotate without actually changing the gameobjects transformunity3d.如何在不实际更改游戏对象变换的情况下获得 transform.rotate 的结果
【发布时间】:2014-06-24 15:31:57
【问题描述】:

在 Unity3d 中,我将转换位置、旋转和缩放输入到 Matrix4x4 中以绘制一些小玩意。我希望输入到矩阵中的旋转四元数旋转一定量的欧拉角(Angle) 这是我的尝试,我正在制作变换 (temp) 的副本,在其上调用 rotate(),然后将其旋转四元数传递到矩阵中。

    Transform temp = transform;
    temp.Rotate(new Vector3(0f,0f,Angle));
    Matrix4x4 rotationMatrix = Matrix4x4.TRS(transform.position,temp.rotation,transform.lossyScale);

不幸的是,当我这样做时,它实际上会旋转原始变换,而不仅仅是我想要的它的临时副本。 如何向四元数添加一定量的欧拉角旋转?

【问题讨论】:

    标签: rotation unity3d quaternions


    【解决方案1】:

    我想我已经回答了这个问题,但它实际上并没有解决我的问题......

     Matrix4x4 rotationMatrix = Matrix4x4.TRS(transform.position,transform.rotation*Quaternion.AngleAxis(Angle,Vector3.forward),transform.lossyScale);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-22
      • 2019-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多