本文整理汇总了C#中System.Vector3.Normalized方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3.Normalized方法的具体用法?C# Vector3.Normalized怎么用?C# Vector3.Normalized使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Vector3
的用法示例。
在下文中一共展示了Vector3.Normalized方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public static ArrowHelper Create(Renderer renderer, Vector3 dir, Vector3 origin, float length = 1, Color? color = null, float? headLength = null, float? headWidth = null)
{
var c = color.HasValue ? color.Value : new Color(0xffff00);
if (lineGeometry == null)
{
lineGeometry = new Geometry();
lineGeometry.vertices.Add(Vector3.Zero);
lineGeometry.vertices.Add(Vector3.UnitY);
lineGeometry.vertexColors = new List<Color>()
{
c,
c,
};
}
if (coneGeometry == null)
{
coneGeometry = new CylinderGeometry(0, 0.5f, 1, 5, 1);
var m = Matrix4.MakeTranslation(0, -0.5f, 0);
coneGeometry.Apply(m);
}
var arrowHelper = new ArrowHelper();
// dir is assumed to be normalized
var head = headLength.HasValue ? headLength.Value : 0.2f * length;
var width = headWidth.HasValue ? headWidth.Value : 0.2f * head;
arrowHelper.Position = origin;
arrowHelper.line = new Line(lineGeometry, new LineBasicMaterial(renderer)
{
Diffuse = c,
VertexColors = Net.Renderers.VertexColorMode.Vertex
});
arrowHelper.line.matrixAutoUpdate = false;
arrowHelper.Add(arrowHelper.line);
arrowHelper.cone = new Mesh(coneGeometry, new MeshBasicMaterial(renderer)
{
Diffuse = c
});
arrowHelper.cone.matrixAutoUpdate = false;
arrowHelper.Add(arrowHelper.cone);
arrowHelper.SetDirection(dir.Normalized());
arrowHelper.SetLength(length, head, width);
return arrowHelper;
}
示例2: Prepare
// Project vector onto sphere's surface
private VertexInfo Prepare(Vector3 vector, List<VertexInfo> vertexSet)
{
var p = vector.Normalized();
var i = vertexSet.Count;
var u = Azimuth(vector) / 2 / Mathf.Pi + 0.5f;
var v = Inclination(vector) / Mathf.Pi + 0.5f;
var vertex = new VertexInfo()
{
Position = p,
Index = i,
// Texture coords are equivalent to map coords, calculate angle and convert to fraction of a circle.
UV = new Vector2(u, 1 - v)
};
vertexSet.Add(vertex);
return vertex;
}
示例3: ShouldLookAt
private static void ShouldLookAt(Vector3 direction)
{
direction = direction.Normalized();
var quaternionLook = Quaternion.LookAt(direction)*Vector3.Forward;
Compare(quaternionLook, direction);
}
示例4: SunColor
Color4 SunColor ( Vector3 dir )
{
Color4 dusk = new Color4(Temperature.Get(2000), 1);
Color4 zenith = new Color4(Temperature.Get(Params.SunTemperature), 1);
Vector3 ndir = dir.Normalized();
return Color4.Lerp( dusk, zenith, (float)Math.Pow(ndir.Y, 0.5f) );
}
示例5: Test_Vector3_Generic_Normalization_Against_Unity3D
public static void Test_Vector3_Generic_Normalization_Against_Unity3D(float a, float b, float c)
{
//arrange
Vector3<float> genericVec3 = new Vector3<float>(a, b, c);
UnityEngine.Vector3 unityVec3 = new UnityEngine.Vector3(a, b, c);
//act
Vector3<float> genericNormalized = genericVec3.Normalized();
UnityEngine.Vector3 unityNormalized = unityVec3.normalized;
//assert
//Warning: We provide more accurate normalized components than Unity. Magnitudes are almost exactly the same
//For example see: http://www.wolframalpha.com/input/?i=normalize%285.3%2C+6.5%2C+7.6%29 in this case Unity provides nearly even components
//we provide exactly what Wolfram does.
Assert.AreEqual(unityNormalized.magnitude, genericNormalized.Magnitude(), 1.1E-6, "Normalization failed. Generic:{0} Unity:{1}", genericNormalized, unityNormalized);
}
示例6: Damage
/// <summary>
///
/// </summary>
/// <param name="targetID"></param>
/// <param name="attackerID"></param>
/// <param name="damage"></param>
/// <param name="kickImpulse"></param>
/// <param name="kickPoint"></param>
/// <param name="damageType"></param>
public override bool Damage ( uint targetID, uint attackerID, short damage, Vector3 kickImpulse, Vector3 kickPoint, DamageType damageType )
{
if (damage<=0) {
return false;
}
var c = controller;
var e = Entity;
c.SupportFinder.ClearSupportData();
var i = MathConverter.Convert( kickImpulse );
var p = MathConverter.Convert( kickPoint );
c.Body.ApplyImpulse( p, i );
/**************************************************
*
* 1. Accumulate damage and emit FX according to
* maximum inflicted damage.
* Probably we have to add new controller stage
* for FX processing (e.g. Update and UpdateFX).
*
* 2. Do not scream at each damage.
* Screams should not overlap!
*
**************************************************/
//
// calc health :
//
var health = e.GetItemCount( Inventory.Health );
health -= damage;
var dir = kickImpulse.Normalized();
if (health>75) {
World.SpawnFX("PlayerPain25", targetID, kickPoint, dir );
} else
if (health>50) {
World.SpawnFX("PlayerPain50", targetID, kickPoint, dir );
} else
if (health>25) {
World.SpawnFX("PlayerPain75", targetID, kickPoint, dir );
} else
if (health>0) {
World.SpawnFX("PlayerPain100", targetID, kickPoint, dir );
} else
if (health>-25) {
World.SpawnFX("PlayerDeath", targetID, e.Position, dir );
} else {
World.SpawnFX("PlayerDeathMeat", targetID, e.Position, kickImpulse, dir );
}
if (health<=0) {
World.Kill( targetID );
return true;
}
e.SetItemCount( Inventory.Health, health );
return false;
}
示例7: Combo
private static bool Combo()
{
var flags = Orbwalker.ActiveModesFlags;
if (flags.HasFlag(Orbwalker.ActiveModes.Combo) && menuIni.Get<CheckBox>("Combo").CurrentValue)
{
var qm = ComboMenu.Get<CheckBox>("CUse_Q").CurrentValue;
var wm = ComboMenu.Get<CheckBox>("CUse_W").CurrentValue;
var em = ComboMenu.Get<CheckBox>("CUse_E").CurrentValue;
{
if (eTarget == null && E.Handle.ToggleState == 2)
{
E.Cast();
}
if (eTarget != null)
{
if (em && E.IsReady() && !player.IsZombie)
{
if (eTarget.IsValidTarget(E.Range) && E.Handle.ToggleState != 2)
{
E.Cast();
}
}
}
double countmana = W.Handle.SData.Mana;
if (wm && W.IsReady() && wTarget.IsValid && wTarget != null)
{
double ds = 0;
if (R.IsReady())
{
ds += player.GetSpellDamage(qTarget, SpellSlot.R);
countmana += R.Handle.SData.Mana;
}
while (qTarget != null && ds < qTarget.MaxHealth)
{
var qd = player.GetSpellDamage(qTarget, SpellSlot.Q);
ds += qd;
if (Q.Handle != null)
{
countmana += Q.Handle.SData.Mana;
}
}
var predW = W.GetPrediction(wTarget);
if (player.ManaPercent >= LaneMenu.Get<Slider>("LHQPercent").CurrentValue || qTarget.CountAlliesInRange(W.Range) > 3 || player.IsZombie)
{
W.Cast(predW.CastPosition);
}
}
if (qTarget == null || (!qm || !Q.IsReady() || !qTarget.IsValid))
{
return false;
}
var predQ = Q2.GetPrediction(qTarget);
var RDPos = qTarget.ServerPosition.X - Player.Instance.ServerPosition.X;
var RDPos2 = qTarget.ServerPosition.Y - Player.Instance.ServerPosition.Y;
var RPos = new Vector3(predQ.CastPosition.X + RDPos, predQ.CastPosition.Y + RDPos2, predQ.CastPosition.Z);
var RPosn = (RPos.Normalized());
if (!cz && predQ.HitChance >= HitChance.High)
{
if (ObjectManager.Player.Position.Distance(qTarget.ServerPosition) <= 900)
{
Q.Cast(predQ.CastPosition);
}
}
else
{
Q.Cast(predQ.CastPosition);
}
}
}
return true;
}