本文整理汇总了C#中System.Vector3.Mult方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3.Mult方法的具体用法?C# Vector3.Mult怎么用?C# Vector3.Mult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Vector3
的用法示例。
在下文中一共展示了Vector3.Mult方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyJumpVelocity
/// <summary>
/// Changes the relative velocity between the character and its support.
/// </summary>
/// <param name="supportData">Support data to use to jump.</param>
/// <param name="velocityChange">Change to apply to the character and support relative velocity.</param>
/// <param name="delta">multiplier of velocity change</param>
/// <param name="relativeVelocity">Relative velocity to update.</param>
void ApplyJumpVelocity( ref SupportData supportData, ref Vector3 velocityChange, float delta, ref Vector3 relativeVelocity )
{
Vector3 del_velocityChange; velocityChange.Mult( delta, out del_velocityChange );
Vector3 tmp;
Body.LinearVelocity.Add( ref del_velocityChange, out tmp );
Body.LinearVelocity = tmp;
var entityCollidable = supportData.SupportObject as EntityCollidable;
if( entityCollidable != null )
{
if( entityCollidable.Entity.IsDynamic )
{
Vector3 change; velocityChange.Mult( delta * jumpForceFactor, out change );
//Multiple characters cannot attempt to modify another entity's velocity at the same time.
entityCollidable.Entity.Locker.Enter();
try
{
change.Mult( -Body.Mass, out tmp );
entityCollidable.Entity.LinearMomentum.Add( ref tmp, out tmp );
entityCollidable.Entity.LinearMomentum = tmp;
}
finally
{
entityCollidable.Entity.Locker.Exit();
}
change.Add( ref del_velocityChange, out del_velocityChange );
}
}
//Update the relative velocity as well. It's a ref parameter, so this update will be reflected in the calling scope.
Vector3.Add( ref relativeVelocity, ref del_velocityChange, out relativeVelocity );
}
示例2: ComputeVolumeDistribution
/// <summary>
/// Computes the volume distribution and center of the shape.
/// </summary>
/// <param name="entries">Mass-weighted entries of the compound.</param>
/// <param name="volume">Summed volume of the constituent shapes. Intersecting volumes get double counted.</param>
/// <param name="volumeDistribution">Volume distribution of the shape.</param>
/// <param name="center">Center of the compound.</param>
public static void ComputeVolumeDistribution(IList<CompoundShapeEntry> entries, out float volume, out Matrix3x3 volumeDistribution, out Vector3 center)
{
center = new Vector3();
float totalWeight = 0;
volume = 0;
for (int i = 0; i < entries.Count; i++)
{
RigidTransform r = entries[i].LocalTransform;
center.AddScaled( ref r.Position, entries[i].Weight, out center );
volume += entries[i].Shape.Volume;
totalWeight += entries[i].Weight;
}
if (totalWeight <= 0)
throw new NotFiniteNumberException("Cannot compute distribution; the total weight of a compound shape must be positive.");
float totalWeightInverse = 1 / totalWeight;
totalWeightInverse.Validate();
center.Mult( totalWeightInverse, out center );
volumeDistribution = new Matrix3x3();
for (int i = 0; i < entries.Count; i++)
{
RigidTransform transform = entries[i].LocalTransform;
Matrix3x3 contribution;
TransformContribution(ref transform, ref center, ref entries[i].Shape.volumeDistribution, entries[i].Weight, out contribution);
Matrix3x3.Add(ref volumeDistribution, ref contribution, out volumeDistribution);
}
Matrix3x3.Multiply(ref volumeDistribution, totalWeightInverse, out volumeDistribution);
volumeDistribution.Validate();
}
示例3: ApplyJumpVelocity
/// <summary>
/// Changes the relative velocity between the character and its support.
/// </summary>
/// <param name="supportData">Support data to use to jump.</param>
/// <param name="velocityChange">Change to apply to the character and support relative velocity.</param>
///
/// <param name="relativeVelocity">Relative velocity to update.</param>
void ApplyJumpVelocity( ref SupportData supportData, ref Vector3 velocityChange, float delta, ref Vector3 relativeVelocity )
{
Vector3 tmp;
velocityChange.Mult( delta, out tmp );
ApplyJumpVelocity( ref supportData, ref tmp, ref relativeVelocity );
}
示例4: TriangleShape
///<summary>
/// Constructs a triangle shape.
/// The vertices will be recentered.
///</summary>
///<param name="vA">First vertex in the triangle.</param>
///<param name="vB">Second vertex in the triangle.</param>
///<param name="vC">Third vertex in the triangle.</param>
///<param name="center">Computed center of the triangle.</param>
public TriangleShape(Vector3 vA, Vector3 vB, Vector3 vC, out Vector3 center)
{
//Recenter. Convexes should contain the origin.
vA.Add2( ref vB, ref vC, out center );
center.Mult( 1 / 3, out center );
//center = (vA + vB + vC) / 3;
vA.Sub( ref center, out this.vA );
vB.Sub( ref center, out this.vB );
vC.Sub( ref center, out this.vC );
UpdateConvexShapeInfo(ComputeDescription(vA, vB, vC, collisionMargin));
}