本文整理汇总了C#中UnityEngine.Normalize方法的典型用法代码示例。如果您正苦于以下问题:C# UnityEngine.Normalize方法的具体用法?C# UnityEngine.Normalize怎么用?C# UnityEngine.Normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine
的用法示例。
在下文中一共展示了UnityEngine.Normalize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateFrame
public bool CreateFrame(UnityEngine.Vector3 forward, UnityEngine.Vector3 up, UnityEngine.Vector3 constraintPoint, ref BulletSharp.Math.Matrix m, ref string errorMsg)
{
BulletSharp.Math.Vector4 x;
BulletSharp.Math.Vector4 y;
BulletSharp.Math.Vector4 z;
if (forward == Vector3.zero)
{
errorMsg = "forward vector must not be zero";
return false;
}
forward.Normalize();
if (up == Vector3.zero)
{
errorMsg = "up vector must not be zero";
return false;
}
Vector3 right = Vector3.Cross(forward, up);
if (right == Vector3.zero)
{
errorMsg = "forward and up vector must not be colinear";
return false;
}
up = Vector3.Cross(right, forward);
right.Normalize();
up.Normalize();
x.X = forward.x; x.Y = forward.y; x.Z = forward.z; x.W = 0f;
y.X = up.x; y.Y = up.y; y.Z = up.z; y.W = 0f;
z.X = right.x; z.Y = right.y; z.Z = right.z; z.W = 0f;
m.Row1 = x;
m.Row2 = y;
m.Row3 = z;
m.Origin = constraintPoint.ToBullet();
return true;
}