本文整理汇总了C#中UMAData.GetDna方法的典型用法代码示例。如果您正苦于以下问题:C# UMAData.GetDna方法的具体用法?C# UMAData.GetDna怎么用?C# UMAData.GetDna使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UMAData
的用法示例。
在下文中一共展示了UMAData.GetDna方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RandomizeDNAGaussian
/// <summary>
/// Randomizes each value in the DNA using a Gaussian distribution.
/// </summary>
/// <param name="data">UMA data.</param>
public void RandomizeDNAGaussian(UMAData data)
{
if (dnaConverter == null)
return;
UMADnaBase dna = data.GetDna(dnaConverter.DNAType);
if (dna == null)
return;
int entryCount = dna.Count;
if (means.Length != entryCount)
{
Debug.LogWarning("Range settings out of sync with DNA, cannot apply!");
return;
}
if (values == null)
values = new float[entryCount];
for (int i = 0; i < entryCount; i++)
{
values[i] = UMAUtils.GaussianRandom(means[i], deviations[i]);
}
dna.Values = values;
}
示例2: RandomizeDNA
/// <summary>
/// Uniformly randomizes each value in the DNA.
/// </summary>
/// <param name="data">UMA data.</param>
public void RandomizeDNA(UMAData data)
{
if (dnaConverter == null)
return;
UMADnaBase dna = data.GetDna(dnaConverter.DNAType);
if (dna == null)
return;
int entryCount = dna.Count;
if (means.Length != entryCount)
{
Debug.LogWarning("Range settings out of sync with DNA, cannot apply!");
return;
}
if ((values == null) || (values.Length != entryCount))
values = new float[entryCount];
for (int i = 0; i < entryCount; i++)
{
values[i] = means[i] + (Random.value - 0.5f) * spreads[i];
}
dna.Values = values;
}
示例3: OnDnaApplied
public void OnDnaApplied(UMAData umaData)
{
var umaDna = umaData.GetDna<UMADnaHumanoid>();
if (umaDna == null)
{
Debug.LogError("Failed to add Capsule Collider to: " + umaData.name);
return;
}
var rigid = umaData.gameObject.GetComponent<Rigidbody>();
if (rigid == null)
{
rigid = umaData.gameObject.AddComponent<Rigidbody>();
}
rigid.constraints = RigidbodyConstraints.FreezeRotation;
rigid.mass = umaData.characterMass;
var capsule = umaData.gameObject.GetComponent<CapsuleCollider>();
if (capsule == null)
{
capsule = umaData.gameObject.AddComponent<CapsuleCollider>();
}
capsule.radius = umaData.characterRadius;
capsule.height = umaData.characterHeight;
capsule.center = new Vector3(0, capsule.height * 0.5f - 0.04f, 0);
}
示例4: UpdateTutorialBones
/// <summary>
/// Apply the DNA information about eye spacing to a skeleton.
/// </summary>
/// <param name="umaData">The character data.</param>
/// <param name="skeleton">Skeleton.</param>
public static void UpdateTutorialBones(UMAData umaData, UMASkeleton skeleton)
{
var umaDna = umaData.GetDna<UMADnaTutorial>();
float spacing = (umaDna.eyeSpacing - 0.5f) * 0.01f;
skeleton.SetPositionRelative(UMAUtils.StringToHash("LeftEye"), new Vector3(0f, -spacing, 0f));
skeleton.SetPositionRelative(UMAUtils.StringToHash("RightEye"), new Vector3(0f, spacing, 0f));
}
示例5: Update
public void Update() {
if (umaData == null) {
umaData = this.GetComponent<UMADynamicAvatar> ().umaData;
umaDNA = umaData.GetDna<UMADnaHumanoid> ();
}
}
示例6: UpdateUMAMaleDNABones
public static void UpdateUMAMaleDNABones(UMAData umaData, UMASkeleton skeleton)
{
var umaDna = umaData.GetDna<UMADnaHumanoid>();
skeleton.SetScale(UMASkeleton.StringToHash("HeadAdjust"),
new Vector3(
Mathf.Clamp(1, 1, 1),
Mathf.Clamp(1 + (umaDna.headWidth - 0.5f) * 0.30f, 0.5f, 1.6f),
Mathf.Clamp(1 , 1, 1)));
//umaData.boneList["HeadAdjust"].boneTransform.localScale = new Vector3(
//Mathf.Clamp(1, 1, 1),
//Mathf.Clamp(1 + (umaDna.headWidth - 0.5f) * 0.30f, 0.5f, 1.6f),
//Mathf.Clamp(1 , 1, 1));
skeleton.SetScale(UMASkeleton.StringToHash("NeckAdjust"),
new Vector3(
Mathf.Clamp(1, 0.6f, 2),
Mathf.Clamp(1 + (umaDna.neckThickness - 0.5f) * 0.80f, 0.5f, 1.6f),
Mathf.Clamp(1 + (umaDna.neckThickness - 0.5f) * 1.2f, 0.5f, 1.6f)));
//umaData.boneList["NeckAdjust"].boneTransform.localScale = new Vector3(
//Mathf.Clamp(1, 0.6f, 2),
//Mathf.Clamp(1 + (umaDna.neckThickness - 0.5f) * 0.80f, 0.5f, 1.6f),
//Mathf.Clamp(1 + (umaDna.neckThickness - 0.5f) * 1.2f, 0.5f, 1.6f));
skeleton.SetScale(UMASkeleton.StringToHash("LeftOuterBreast"),
new Vector3(
Mathf.Clamp(1 + (umaDna.breastSize - 0.5f) * 1.50f + (umaDna.upperWeight - 0.5f) * 0.10f, 0.6f, 1.5f),
Mathf.Clamp(1 + (umaDna.breastSize - 0.5f) * 1.50f + (umaDna.upperWeight - 0.5f) * 0.10f, 0.6f, 1.5f),
Mathf.Clamp(1 + (umaDna.breastSize - 0.5f) * 1.50f + (umaDna.upperWeight - 0.5f) * 0.10f, 0.6f, 1.5f)));
skeleton.SetScale(UMASkeleton.StringToHash("RightOuterBreast"),
new Vector3(
Mathf.Clamp(1 + (umaDna.breastSize - 0.5f) * 1.50f + (umaDna.upperWeight - 0.5f) * 0.10f, 0.6f, 1.5f),
Mathf.Clamp(1 + (umaDna.breastSize - 0.5f) * 1.50f + (umaDna.upperWeight - 0.5f) * 0.10f, 0.6f, 1.5f),
Mathf.Clamp(1 + (umaDna.breastSize - 0.5f) * 1.50f + (umaDna.upperWeight - 0.5f) * 0.10f, 0.6f, 1.5f)));
//umaData.boneList["LeftOuterBreast"].boneTransform.localScale = new Vector3(
//Mathf.Clamp(1 + (umaDna.breastSize - 0.5f) * 1.50f + (umaDna.upperWeight - 0.5f) * 0.10f, 0.6f, 1.5f),
//Mathf.Clamp(1 + (umaDna.breastSize - 0.5f) * 1.50f + (umaDna.upperWeight - 0.5f) * 0.10f, 0.6f, 1.5f),
//Mathf.Clamp(1 + (umaDna.breastSize - 0.5f) * 1.50f + (umaDna.upperWeight - 0.5f) * 0.10f, 0.6f, 1.5f));
//umaData.boneList["RightOuterBreast"].boneTransform.localScale = new Vector3(
//Mathf.Clamp(1 + (umaDna.breastSize - 0.5f) * 1.50f + (umaDna.upperWeight - 0.5f) * 0.10f, 0.6f, 1.5f),
//Mathf.Clamp(1 + (umaDna.breastSize - 0.5f) * 1.50f + (umaDna.upperWeight - 0.5f) * 0.10f, 0.6f, 1.5f),
//Mathf.Clamp(1 + (umaDna.breastSize - 0.5f) * 1.50f + (umaDna.upperWeight - 0.5f) * 0.10f, 0.6f, 1.5f));
skeleton.SetScale(UMASkeleton.StringToHash("LeftEye"),
new Vector3(
Mathf.Clamp(1 + (umaDna.eyeSize - 0.5f) * 0.3f , 0.7f, 1.4f),
Mathf.Clamp(1 + (umaDna.eyeSize - 0.5f) * 0.3f , 0.7f, 1.4f),
Mathf.Clamp(1 + (umaDna.eyeSize - 0.5f) * 0.3f , 0.7f, 1.4f)));
skeleton.SetScale(UMASkeleton.StringToHash("RightEye"),
new Vector3(
Mathf.Clamp(1 + (umaDna.eyeSize - 0.5f) * 0.3f , 0.7f, 1.4f),
Mathf.Clamp(1 + (umaDna.eyeSize - 0.5f) * 0.3f , 0.7f, 1.4f),
Mathf.Clamp(1 + (umaDna.eyeSize - 0.5f) * 0.3f , 0.7f, 1.4f)));
//umaData.boneList["LeftEye"].boneTransform.localScale = new Vector3(
//Mathf.Clamp(1 + (umaDna.eyeSize - 0.5f) * 0.3f , 0.7f, 1.4f),
//Mathf.Clamp(1 + (umaDna.eyeSize - 0.5f) * 0.3f , 0.7f, 1.4f),
//Mathf.Clamp(1 + (umaDna.eyeSize - 0.5f) * 0.3f , 0.7f, 1.4f));
//umaData.boneList["RightEye"].boneTransform.localScale = new Vector3(
//Mathf.Clamp(1 + (umaDna.eyeSize - 0.5f) * 0.3f , 0.7f, 1.4f),
//Mathf.Clamp(1 + (umaDna.eyeSize - 0.5f) * 0.3f , 0.7f, 1.4f),
//Mathf.Clamp(1 + (umaDna.eyeSize - 0.5f) * 0.3f , 0.7f, 1.4f));
skeleton.SetRotation(UMASkeleton.StringToHash("LeftEye"),
Quaternion.Euler(new Vector3((umaDna.eyeRotation - 0.5f) * 20, -90, -180)));
skeleton.SetRotation(UMASkeleton.StringToHash("RightEye"),
Quaternion.Euler(new Vector3(-(umaDna.eyeRotation - 0.5f) * 20, -90, -180)));
//umaData.boneList["LeftEye"].boneTransform.localEulerAngles = new Vector3((umaDna.eyeRotation - 0.5f) * 20, -90, -180);
//umaData.boneList["RightEye"].boneTransform.localEulerAngles = new Vector3(-(umaDna.eyeRotation - 0.5f) * 20, -90, -180);
skeleton.SetScale(UMASkeleton.StringToHash("Spine1Adjust"),
new Vector3(
Mathf.Clamp(1, 0.6f, 2),
Mathf.Clamp(0.9f + (umaDna.upperWeight - 0.5f) * 0.10f + (umaDna.upperMuscle - 0.5f) * 0.5f, 0.45f, 1.50f),
Mathf.Clamp(0.7f + (umaDna.upperWeight - 0.5f) * 0.45f + (umaDna.upperMuscle - 0.5f) * 0.45f, 0.55f, 1.15f)));
//umaData.boneList["Spine1Adjust"].boneTransform.localScale = new Vector3(
//Mathf.Clamp(1, 0.6f, 2),
//Mathf.Clamp(0.9f + (umaDna.upperWeight - 0.5f) * 0.10f + (umaDna.upperMuscle - 0.5f) * 0.5f, 0.45f, 1.50f),
//Mathf.Clamp(0.7f + (umaDna.upperWeight - 0.5f) * 0.45f + (umaDna.upperMuscle - 0.5f) * 0.45f, 0.55f, 1.15f));
skeleton.SetScale(UMASkeleton.StringToHash("SpineAdjust"),
new Vector3(
Mathf.Clamp(1, 0.6f, 2),
Mathf.Clamp(0.9f + (umaDna.upperWeight - 0.5f) * 0.35f + (umaDna.upperMuscle - 0.5f) * 0.45f, 0.75f, 1.350f),
Mathf.Clamp(0.8f + (umaDna.upperWeight - 0.5f) * 0.35f + (umaDna.upperMuscle - 0.5f) * 0.25f, 0.75f, 1.350f)));
//umaData.boneList["SpineAdjust"].boneTransform.localScale = new Vector3(
//Mathf.Clamp(1, 0.6f, 2),
//Mathf.Clamp(0.9f + (umaDna.upperWeight - 0.5f) * 0.35f + (umaDna.upperMuscle - 0.5f) * 0.45f, 0.75f, 1.350f),
//Mathf.Clamp(0.8f + (umaDna.upperWeight - 0.5f) * 0.35f + (umaDna.upperMuscle - 0.5f) * 0.25f, 0.75f, 1.350f));
skeleton.SetScale(UMASkeleton.StringToHash("LowerBackBelly"),
new Vector3(
//.........这里部分代码省略.........
示例7: UpdateUMAFemaleDNABones
/// <summary>
/// Adjusts a skeleton to reflect the DNA values from UMA character data.
/// </summary>
/// <remarks>
/// This will set the postion, rotation, and scale of the various adjustment
/// bones used by the UMA human rigs to generate a unique character shape.
/// Also calculates a somewhat realistic mass for the character and the
/// height and radius of their default collider.
/// </remarks>
/// <param name="umaData">UMA data.</param>
/// <param name="skeleton">Skeleton.</param>
public static void UpdateUMAFemaleDNABones(UMAData umaData, UMASkeleton skeleton)
{
var umaDna = umaData.GetDna<UMADnaHumanoid>();
skeleton.SetScale(headAdjustHash,
new Vector3(
Mathf.Clamp(1, 1, 1),
Mathf.Clamp(1 + (umaDna.headWidth - 0.5f) * 0.30f, 0.5f, 1.6f),
Mathf.Clamp(1 , 1, 1)));
//umaData.boneList["HeadAdjust"].boneTransform.localScale = new Vector3(
//Mathf.Clamp(1, 1, 1),
//Mathf.Clamp(1 + (umaDna.headWidth - 0.5f) * 0.30f, 0.5f, 1.6f),
//Mathf.Clamp(1 , 1, 1));
skeleton.SetScale(neckAdjustHash,
new Vector3(
Mathf.Clamp(1, 0.6f, 2),
Mathf.Clamp(1 + (umaDna.neckThickness - 0.5f) * 0.80f, 0.5f, 1.6f),
Mathf.Clamp(1 + (umaDna.neckThickness - 0.5f) * 1.2f, 0.5f, 1.6f)));
//umaData.boneList["NeckAdjust"].boneTransform.localScale = new Vector3(
//Mathf.Clamp(1, 0.6f, 2),
//Mathf.Clamp(1 + (umaDna.neckThickness - 0.5f) * 0.80f, 0.5f, 1.6f),
//Mathf.Clamp(1 + (umaDna.neckThickness - 0.5f) * 1.2f, 0.5f, 1.6f));
skeleton.SetScale(leftOuterBreastHash,
new Vector3(
Mathf.Clamp(1 + (umaDna.breastSize - 0.5f) * 1.50f + (umaDna.upperWeight - 0.5f) * 0.10f, 0.6f, 1.5f),
Mathf.Clamp(1 + (umaDna.breastSize - 0.5f) * 1.50f + (umaDna.upperWeight - 0.5f) * 0.10f, 0.6f, 1.5f),
Mathf.Clamp(1 + (umaDna.breastSize - 0.5f) * 1.50f + (umaDna.upperWeight - 0.5f) * 0.10f, 0.6f, 1.5f)));
skeleton.SetScale(rightOuterBreastHash,
new Vector3(
Mathf.Clamp(1 + (umaDna.breastSize - 0.5f) * 1.50f + (umaDna.upperWeight - 0.5f) * 0.10f, 0.6f, 1.5f),
Mathf.Clamp(1 + (umaDna.breastSize - 0.5f) * 1.50f + (umaDna.upperWeight - 0.5f) * 0.10f, 0.6f, 1.5f),
Mathf.Clamp(1 + (umaDna.breastSize - 0.5f) * 1.50f + (umaDna.upperWeight - 0.5f) * 0.10f, 0.6f, 1.5f)));
//umaData.boneList["LeftOuterBreast"].boneTransform.localScale = new Vector3(
//Mathf.Clamp(1 + (umaDna.breastSize - 0.5f) * 1.50f + (umaDna.upperWeight - 0.5f) * 0.10f, 0.6f, 1.5f),
//Mathf.Clamp(1 + (umaDna.breastSize - 0.5f) * 1.50f + (umaDna.upperWeight - 0.5f) * 0.10f, 0.6f, 1.5f),
//Mathf.Clamp(1 + (umaDna.breastSize - 0.5f) * 1.50f + (umaDna.upperWeight - 0.5f) * 0.10f, 0.6f, 1.5f));
//umaData.boneList["RightOuterBreast"].boneTransform.localScale = new Vector3(
//Mathf.Clamp(1 + (umaDna.breastSize - 0.5f) * 1.50f + (umaDna.upperWeight - 0.5f) * 0.10f, 0.6f, 1.5f),
//Mathf.Clamp(1 + (umaDna.breastSize - 0.5f) * 1.50f + (umaDna.upperWeight - 0.5f) * 0.10f, 0.6f, 1.5f),
//Mathf.Clamp(1 + (umaDna.breastSize - 0.5f) * 1.50f + (umaDna.upperWeight - 0.5f) * 0.10f, 0.6f, 1.5f));
skeleton.SetScale(leftEyeHash,
new Vector3(
Mathf.Clamp(1 + (umaDna.eyeSize - 0.5f) * 0.3f , 0.7f, 1.4f),
Mathf.Clamp(1 + (umaDna.eyeSize - 0.5f) * 0.3f , 0.7f, 1.4f),
Mathf.Clamp(1 + (umaDna.eyeSize - 0.5f) * 0.3f , 0.7f, 1.4f)));
skeleton.SetScale(rightEyeHash,
new Vector3(
Mathf.Clamp(1 + (umaDna.eyeSize - 0.5f) * 0.3f , 0.7f, 1.4f),
Mathf.Clamp(1 + (umaDna.eyeSize - 0.5f) * 0.3f , 0.7f, 1.4f),
Mathf.Clamp(1 + (umaDna.eyeSize - 0.5f) * 0.3f , 0.7f, 1.4f)));
//umaData.boneList["LeftEye"].boneTransform.localScale = new Vector3(
//Mathf.Clamp(1 + (umaDna.eyeSize - 0.5f) * 0.3f , 0.7f, 1.4f),
//Mathf.Clamp(1 + (umaDna.eyeSize - 0.5f) * 0.3f , 0.7f, 1.4f),
//Mathf.Clamp(1 + (umaDna.eyeSize - 0.5f) * 0.3f , 0.7f, 1.4f));
//umaData.boneList["RightEye"].boneTransform.localScale = new Vector3(
//Mathf.Clamp(1 + (umaDna.eyeSize - 0.5f) * 0.3f , 0.7f, 1.4f),
//Mathf.Clamp(1 + (umaDna.eyeSize - 0.5f) * 0.3f , 0.7f, 1.4f),
//Mathf.Clamp(1 + (umaDna.eyeSize - 0.5f) * 0.3f , 0.7f, 1.4f));
skeleton.SetRotation(leftEyeAdjustHash,
Quaternion.Euler(new Vector3((umaDna.eyeRotation - 0.5f) * 20, 0, 0)));
skeleton.SetRotation(rightEyeAdjustHash,
Quaternion.Euler(new Vector3(-(umaDna.eyeRotation - 0.5f) * 20, 0, 0)));
//umaData.boneList["LeftEye"].boneTransform.localEulerAngles = new Vector3((umaDna.eyeRotation - 0.5f) * 20, -90, -180);
//umaData.boneList["RightEye"].boneTransform.localEulerAngles = new Vector3(-(umaDna.eyeRotation - 0.5f) * 20, -90, -180);
skeleton.SetScale(spine1AdjustHash,
new Vector3(
Mathf.Clamp(1, 0.6f, 2),
Mathf.Clamp(1 + (umaDna.upperWeight - 0.5f) * 0.10f + (umaDna.upperMuscle - 0.5f) * 0.15f, 0.75f, 1.10f),
Mathf.Clamp(1 + (umaDna.upperWeight - 0.5f) * 0.10f + (umaDna.upperMuscle - 0.5f) * 0.25f, 0.85f, 1.00f)));
//umaData.boneList["Spine1Adjust"].boneTransform.localScale = new Vector3(
//Mathf.Clamp(1, 0.6f, 2),
//Mathf.Clamp(1 + (umaDna.upperWeight - 0.5f) * 0.10f + (umaDna.upperMuscle - 0.5f) * 0.15f, 0.75f, 1.10f),
//Mathf.Clamp(1 + (umaDna.upperWeight - 0.5f) * 0.10f + (umaDna.upperMuscle - 0.5f) * 0.25f, 0.85f, 1.00f));
skeleton.SetScale(spineAdjustHash,
new Vector3(
Mathf.Clamp(1, 0.6f, 2),
Mathf.Clamp(1 + (umaDna.upperWeight - 0.5f) * 0.25f + (umaDna.upperMuscle - 0.5f) * 0.25f, 0.85f, 1.350f),
Mathf.Clamp(1 + (umaDna.upperWeight - 0.5f) * 0.25f + (umaDna.upperMuscle - 0.5f) * 0.25f, 0.85f, 1.450f)));
//.........这里部分代码省略.........