本文整理汇总了C#中Vector3.Validate方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3.Validate方法的具体用法?C# Vector3.Validate怎么用?C# Vector3.Validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector3
的用法示例。
在下文中一共展示了Vector3.Validate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompoundShapeEntry
///<summary>
/// Constructs a new compound shape entry using the volume of the shape as a weight.
///</summary>
///<param name="shape">Shape to use.</param>
///<param name="position">Local position of the shape.</param>
///<param name="weight">Weight of the entry. This defines how much the entry contributes to its owner
/// for the purposes of center of mass and inertia computation.</param>
public CompoundShapeEntry(EntityShape shape, Vector3 position, float weight)
{
position.Validate();
LocalTransform = new RigidTransform(position);
Shape = shape;
Weight = weight;
}
示例2: SetPosition
protected void SetPosition(Vector3 position)
{
position.Validate();
this.Position = position;
ResetViewMatrix();
}
示例3: ComputeCenter
/// <summary>
/// Computes the center of the shape. This can be considered its
/// center of mass, based on the weightings of entries in the shape.
/// For properly calibrated compound shapes, this will return a zero vector,
/// since the shape recenters itself on construction.
/// </summary>
/// <returns>Center of the shape.</returns>
public override Vector3 ComputeCenter()
{
float totalWeight = 0;
var center = new Vector3();
for (int i = 0; i < shapes.Count; i++)
{
totalWeight += shapes.Elements[i].Weight;
Vector3 centerContribution;
Vector3.Multiply(ref shapes.Elements[i].LocalTransform.Position, shapes.Elements[i].Weight, out centerContribution);
Vector3.Add(ref center, ref centerContribution, out center);
}
if (totalWeight <= 0)
throw new NotFiniteNumberException("Cannot compute center; the total weight of a compound shape must be positive.");
Vector3.Divide(ref center, totalWeight, out center);
center.Validate();
return center;
}