本文整理汇总了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;
}
示例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;
}
示例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);
}
}