当前位置: 首页>>代码示例>>C#>>正文


C# Quaternion.FromAxes方法代码示例

本文整理汇总了C#中Quaternion.FromAxes方法的典型用法代码示例。如果您正苦于以下问题:C# Quaternion.FromAxes方法的具体用法?C# Quaternion.FromAxes怎么用?C# Quaternion.FromAxes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Quaternion的用法示例。


在下文中一共展示了Quaternion.FromAxes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: _computeQuaternion

 public static Quaternion _computeQuaternion(Vector3 direction, Vector3 upVector) {
     Quaternion q = new Quaternion();
     Vector3 zVec = direction;
     zVec = zVec.NormalisedCopy;
     Vector3 xVec = upVector.CrossProduct(zVec);
     if (xVec.IsZeroLength)
         xVec = Vector3.UNIT_X;
     xVec = xVec.NormalisedCopy;
     Vector3 yVec = zVec.CrossProduct(xVec);
     yVec = yVec.NormalisedCopy;
     q.FromAxes(xVec, yVec, zVec);
     return q;
 }
开发者ID:andyhebear,项目名称:mogre-procedural,代码行数:13,代码来源:Utils.cs

示例2: root_FrameStarted

        bool root_FrameStarted(FrameEvent evt)
        {
            animTime += evt.timeSinceLastFrame;
            while (animTime > FISH_PATH_LENGTH)
                animTime -= FISH_PATH_LENGTH;

            for (int fish = 0; fish < NUM_FISH; ++fish)
            {
                // Animate the fish
                fishAnimations[fish].AddTime(evt.timeSinceLastFrame * 2);
                // Move the fish
                Vector3 newPos = fishSplines[fish].Interpolate(animTime / FISH_PATH_LENGTH);
                fishNodes[fish].Position = newPos;
                // Work out the direction
                Vector3 direction = fishLastPosition[fish] - newPos;
                direction.Normalise();
                // Test for opposite vectors
                float d = 1.0f + Vector3.UNIT_X.DotProduct(direction);
                if (System.Math.Abs(d) < 0.00001)
                {
                    // Diametrically opposed vectors
                    Quaternion orientation = new Quaternion();
                    orientation.FromAxes(Vector3.NEGATIVE_UNIT_X,
                        Vector3.UNIT_Y, Vector3.NEGATIVE_UNIT_Z);
                    fishNodes[fish].Orientation = orientation;
                }
                else
                {
                    fishNodes[fish].Orientation =
                        Vector3.UNIT_X.GetRotationTo(direction);
                }
                fishLastPosition[fish] = newPos;

            }

            return true;
        }
开发者ID:andyhebear,项目名称:likeleon,代码行数:37,代码来源:Fresnel.cs

示例3: MoveBoid

 /// <summary>
 /// Boid movement is a rotation and a translation, which use
 /// the current boid velocity and position.
 /// </summary>
 private void MoveBoid(SceneNode boidNode, Boid b)
 {
     boidNode.Position = b.Position;
     Vector3 direction = b.Velocity;
     direction.Normalise();
     // Test for opposite vectors
     float d = 1.0f + Vector3.UNIT_Z.DotProduct(direction);
     if (System.Math.Abs(d) < 0.00001)
     {
         // Diametrically opposed vectors
         Quaternion orientation = new Quaternion();
         orientation.FromAxes(Vector3.NEGATIVE_UNIT_X,
                              Vector3.UNIT_Y,
                              Vector3.NEGATIVE_UNIT_Z);
         boidNode.Orientation = orientation;
     }
     else
     {
         boidNode.Orientation =
             Vector3.UNIT_Z.GetRotationTo(direction);
     }
 }
开发者ID:superliujian,项目名称:Sxta,代码行数:26,代码来源:BoidsSample.cs


注:本文中的Quaternion.FromAxes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。