/// <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)); }
//The legacy method for applying skeletonModifiers defined inside this converter private void ApplySkeletonModifiers(UMAData umaData, UMADnaBase umaDna, UMASkeleton skeleton) { for (int i = 0; i < _skeletonModifiers.Count; i++) { _skeletonModifiers[i].umaDNA = umaDna; //getting rid of BoneHashes list - when a bone name is added in the editor the skeleton modifier always generates the hash var thisHash = (_skeletonModifiers[i].hash != 0) ? _skeletonModifiers[i].hash : UMAUtils.StringToHash(_skeletonModifiers[i].hashName); //These are a Vector3 where Value?.x is the calculated value and Value?.y is min and Value?.z is max var thisValueX = _skeletonModifiers[i].CalculateValueX(umaDna); var thisValueY = _skeletonModifiers[i].CalculateValueY(umaDna); var thisValueZ = _skeletonModifiers[i].CalculateValueZ(umaDna); //use the overallScaleBoneHash property instead so the user can define the bone that is used here (by default its the 'Position' bone in an UMA Rig) /*if (_skeletonModifiers[i].hash == overallScaleBoneHash && _skeletonModifiers[i].property == SkeletonModifier.SkeletonPropType.Scale) * { * var calcVal = thisValueX.x - _skeletonModifiers[i].valuesX.val.value + overallScale;//effectively (when dna is 0)1-1+0.88 * Debug.Log("DCSUMA overallScale calcVal[" + calcVal + "] = (thisValueX.x [" + thisValueX.x + "] - _skeletonModifiers[i].valuesX.val.value[" + _skeletonModifiers[i].valuesX.val.value + "] + overallScale[" + overallScale+"]"); * var overallScaleCalc = Mathf.Clamp(calcVal, thisValueX.y, thisValueX.z); * skeleton.SetScale(_skeletonModifiers[i].hash, new Vector3(overallScaleCalc, overallScaleCalc, overallScaleCalc)); * } * else*/if (_skeletonModifiers[i].property == SkeletonModifier.SkeletonPropType.Position) { skeleton.SetPositionRelative(thisHash, new Vector3( Mathf.Clamp(thisValueX.x, thisValueX.y, thisValueX.z), Mathf.Clamp(thisValueY.x, thisValueY.y, thisValueY.z), Mathf.Clamp(thisValueZ.x, thisValueZ.y, thisValueZ.z))); } else if (_skeletonModifiers[i].property == SkeletonModifier.SkeletonPropType.Rotation) { skeleton.SetRotationRelative(thisHash, Quaternion.Euler(new Vector3( Mathf.Clamp(thisValueX.x, thisValueX.y, thisValueX.z), Mathf.Clamp(thisValueY.x, thisValueY.y, thisValueY.z), Mathf.Clamp(thisValueZ.x, thisValueZ.y, thisValueZ.z))), 1f); } else if (_skeletonModifiers[i].property == SkeletonModifier.SkeletonPropType.Scale) { skeleton.SetScale(thisHash, new Vector3( Mathf.Clamp(thisValueX.x, thisValueX.y, thisValueX.z), Mathf.Clamp(thisValueY.x, thisValueY.y, thisValueY.z), Mathf.Clamp(thisValueZ.x, thisValueZ.y, thisValueZ.z))); } } }
/// <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 UpdateUMAMaleDNABones(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(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(spineAdjustHash, 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(lowerBackBellyHash, new Vector3( Mathf.Clamp(1 + (umaDna.belly - 0.5f) * 1.0f, 0.35f, 1.75f), Mathf.Clamp(1 + (umaDna.belly - 0.5f) * 0.35f, 0.35f, 1.75f), Mathf.Clamp(1 + (umaDna.belly - 0.5f) * 1.25f, 0.35f, 1.75f))); //umaData.boneList["LowerBackBelly"].boneTransform.localScale = new Vector3( //Mathf.Clamp(1 + (umaDna.belly - 0.5f) * 1.0f, 0.35f, 1.75f), //Mathf.Clamp(1 + (umaDna.belly - 0.5f) * 0.35f, 0.35f, 1.75f), //Mathf.Clamp(1 + (umaDna.belly - 0.5f) * 1.25f, 0.35f, 1.75f)); skeleton.SetScale(lowerBackAdjustHash, new Vector3( Mathf.Clamp(1 + (umaDna.upperWeight - 0.5f) * 0.25f + (umaDna.lowerWeight - 0.5f) * 0.15f, 0.85f, 1.5f), Mathf.Clamp(1 + (umaDna.upperWeight - 0.5f) * 0.25f + (umaDna.lowerWeight - 0.5f) * 0.15f + (umaDna.waist - 0.5f) * 0.45f, 0.65f, 1.75f), Mathf.Clamp(1 + (umaDna.upperWeight - 0.5f) * 0.25f + (umaDna.lowerWeight - 0.5f) * 0.15f, 0.85f, 1.5f))); //umaData.boneList["LowerBackAdjust"].boneTransform.localScale = new Vector3( //Mathf.Clamp(1 + (umaDna.upperWeight - 0.5f) * 0.25f + (umaDna.lowerWeight - 0.5f) * 0.15f, 0.85f, 1.5f), //Mathf.Clamp(1 + (umaDna.upperWeight - 0.5f) * 0.25f + (umaDna.lowerWeight - 0.5f) * 0.15f + (umaDna.waist - 0.5f) * 0.45f, 0.65f, 1.75f), //Mathf.Clamp(1 + (umaDna.upperWeight - 0.5f) * 0.25f + (umaDna.lowerWeight - 0.5f) * 0.15f, 0.85f, 1.5f)); skeleton.SetScale(leftTrapeziusHash, new Vector3( Mathf.Clamp(1 + (umaDna.upperMuscle - 0.5f) * 1.35f, 0.65f, 1.35f), Mathf.Clamp(1 + (umaDna.upperMuscle - 0.5f) * 1.35f, 0.65f, 1.35f), Mathf.Clamp(1 + (umaDna.upperMuscle - 0.5f) * 1.35f, 0.65f, 1.35f))); skeleton.SetScale(rightTrapeziusHash, new Vector3( Mathf.Clamp(1 + (umaDna.upperMuscle - 0.5f) * 1.35f, 0.65f, 1.35f), Mathf.Clamp(1 + (umaDna.upperMuscle - 0.5f) * 1.35f, 0.65f, 1.35f), Mathf.Clamp(1 + (umaDna.upperMuscle - 0.5f) * 1.35f, 0.65f, 1.35f))); //umaData.boneList["LeftTrapezius"].boneTransform.localScale = new Vector3( //Mathf.Clamp(1 + (umaDna.upperMuscle - 0.5f) * 1.35f, 0.65f, 1.35f), //Mathf.Clamp(1 + (umaDna.upperMuscle - 0.5f) * 1.35f, 0.65f, 1.35f), //Mathf.Clamp(1 + (umaDna.upperMuscle - 0.5f) * 1.35f, 0.65f, 1.35f)); //umaData.boneList["RightTrapezius"].boneTransform.localScale = new Vector3( //Mathf.Clamp(1 + (umaDna.upperMuscle - 0.5f) * 1.35f, 0.65f, 1.35f), //Mathf.Clamp(1 + (umaDna.upperMuscle - 0.5f) * 1.35f, 0.65f, 1.35f), //Mathf.Clamp(1 + (umaDna.upperMuscle - 0.5f) * 1.35f, 0.65f, 1.35f)); skeleton.SetScale(leftArmAdjustHash, new Vector3( Mathf.Clamp(1, 0.6f, 2), Mathf.Clamp(1 + (umaDna.armWidth - 0.5f) * 0.65f, 0.65f, 1.65f), Mathf.Clamp(1 + (umaDna.armWidth - 0.5f) * 0.65f, 0.65f, 1.65f))); skeleton.SetScale(rightArmAdjustHash, new Vector3( Mathf.Clamp(1, 0.6f, 2), Mathf.Clamp(1 + (umaDna.armWidth - 0.5f) * 0.65f, 0.65f, 1.65f), Mathf.Clamp(1 + (umaDna.armWidth - 0.5f) * 0.65f, 0.65f, 1.65f))); //umaData.boneList["LeftArmAdjust"].boneTransform.localScale = new Vector3( //Mathf.Clamp(1, 0.6f, 2), //Mathf.Clamp(1 + (umaDna.armWidth - 0.5f) * 0.65f, 0.65f, 1.65f), //Mathf.Clamp(1 + (umaDna.armWidth - 0.5f) * 0.65f, 0.65f, 1.65f)); //umaData.boneList["RightArmAdjust"].boneTransform.localScale = new Vector3( //Mathf.Clamp(1, 0.6f, 2), //Mathf.Clamp(1 + (umaDna.armWidth - 0.5f) * 0.65f, 0.65f, 1.65f), //Mathf.Clamp(1 + (umaDna.armWidth - 0.5f) * 0.65f, 0.65f, 1.65f)); skeleton.SetScale(leftForeArmAdjustHash, new Vector3( Mathf.Clamp(1, 0.6f, 2), Mathf.Clamp(1 + (umaDna.forearmWidth - 0.5f) * 0.65f, 0.75f, 1.25f), Mathf.Clamp(1 + (umaDna.forearmWidth - 0.5f) * 0.65f, 0.75f, 1.25f))); skeleton.SetScale(rightForeArmAdjustHash, new Vector3( Mathf.Clamp(1, 0.6f, 2), Mathf.Clamp(1 + (umaDna.forearmWidth - 0.5f) * 0.65f, 0.75f, 1.25f), Mathf.Clamp(1 + (umaDna.forearmWidth - 0.5f) * 0.65f, 0.75f, 1.25f))); //umaData.boneList["LeftForeArmAdjust"].boneTransform.localScale = new Vector3( //Mathf.Clamp(1, 0.6f, 2), //Mathf.Clamp(1 + (umaDna.forearmWidth - 0.5f) * 0.65f, 0.75f, 1.25f), //Mathf.Clamp(1 + (umaDna.forearmWidth - 0.5f) * 0.65f, 0.75f, 1.25f)); //umaData.boneList["RightForeArmAdjust"].boneTransform.localScale = new Vector3( //Mathf.Clamp(1, 0.6f, 2), //Mathf.Clamp(1 + (umaDna.forearmWidth - 0.5f) * 0.65f, 0.75f, 1.25f), //Mathf.Clamp(1 + (umaDna.forearmWidth - 0.5f) * 0.65f, 0.75f, 1.25f)); skeleton.SetScale(leftForeArmTwistAdjustHash, new Vector3( Mathf.Clamp(1, 0.6f, 2), Mathf.Clamp(1 + (umaDna.forearmWidth - 0.5f) * 0.35f, 0.75f, 1.25f), Mathf.Clamp(1 + (umaDna.forearmWidth - 0.5f) * 0.35f, 0.75f, 1.25f))); skeleton.SetScale(rightForeArmTwistAdjustHash, new Vector3( Mathf.Clamp(1, 0.6f, 2), Mathf.Clamp(1 + (umaDna.forearmWidth - 0.5f) * 0.35f, 0.75f, 1.25f), Mathf.Clamp(1 + (umaDna.forearmWidth - 0.5f) * 0.35f, 0.75f, 1.25f))); //umaData.boneList["LeftForeArmTwistAdjust"].boneTransform.localScale = new Vector3( //Mathf.Clamp(1, 0.6f, 2), //Mathf.Clamp(1 + (umaDna.forearmWidth - 0.5f) * 0.35f, 0.75f, 1.25f), //Mathf.Clamp(1 + (umaDna.forearmWidth - 0.5f) * 0.35f, 0.75f, 1.25f)); //umaData.boneList["RightForeArmTwistAdjust"].boneTransform.localScale = new Vector3( //Mathf.Clamp(1, 0.6f, 2), //Mathf.Clamp(1 + (umaDna.forearmWidth - 0.5f) * 0.35f, 0.75f, 1.25f), //Mathf.Clamp(1 + (umaDna.forearmWidth - 0.5f) * 0.35f, 0.75f, 1.25f)); skeleton.SetScale(leftShoulderAdjustHash, new Vector3( Mathf.Clamp(1, 0.6f, 2), Mathf.Clamp(1 + (umaDna.upperWeight - 0.5f) * 0.35f + (umaDna.upperMuscle - 0.5f) * 0.55f, 0.75f, 1.25f), Mathf.Clamp(1 + (umaDna.upperWeight - 0.5f) * 0.35f + (umaDna.upperMuscle - 0.5f) * 0.55f, 0.75f, 1.25f))); skeleton.SetScale(rightShoulderAdjustHash, new Vector3( Mathf.Clamp(1, 0.6f, 2), Mathf.Clamp(1 + (umaDna.upperWeight - 0.5f) * 0.35f + (umaDna.upperMuscle - 0.5f) * 0.55f, 0.75f, 1.25f), Mathf.Clamp(1 + (umaDna.upperWeight - 0.5f) * 0.35f + (umaDna.upperMuscle - 0.5f) * 0.55f, 0.75f, 1.25f))); //umaData.boneList["LeftShoulderAdjust"].boneTransform.localScale = new Vector3( //Mathf.Clamp(1, 0.6f, 2), //Mathf.Clamp(1 + (umaDna.upperWeight - 0.5f) * 0.35f + (umaDna.upperMuscle - 0.5f) * 0.55f, 0.75f, 1.25f), //Mathf.Clamp(1 + (umaDna.upperWeight - 0.5f) * 0.35f + (umaDna.upperMuscle - 0.5f) * 0.55f, 0.75f, 1.25f)); //umaData.boneList["RightShoulderAdjust"].boneTransform.localScale = new Vector3( //Mathf.Clamp(1, 0.6f, 2), //Mathf.Clamp(1 + (umaDna.upperWeight - 0.5f) * 0.35f + (umaDna.upperMuscle - 0.5f) * 0.55f, 0.75f, 1.25f), //Mathf.Clamp(1 + (umaDna.upperWeight - 0.5f) * 0.35f + (umaDna.upperMuscle - 0.5f) * 0.55f, 0.75f, 1.25f)); skeleton.SetScale(leftUpLegAdjustHash, new Vector3( Mathf.Clamp(1, 0.6f, 2), Mathf.Clamp(1 + (umaDna.lowerWeight - 0.5f) * 0.45f + (umaDna.lowerMuscle - 0.5f) * 0.15f - (umaDna.legsSize - 0.5f), 0.45f, 1.15f), Mathf.Clamp(1 + (umaDna.lowerWeight - 0.5f) * 0.45f + (umaDna.lowerMuscle - 0.5f) * 0.15f - (umaDna.legsSize - 0.5f), 0.45f, 1.15f))); skeleton.SetScale(rightUpLegAdjustHash, new Vector3( Mathf.Clamp(1, 0.6f, 2), Mathf.Clamp(1 + (umaDna.lowerWeight - 0.5f) * 0.45f + (umaDna.lowerMuscle - 0.5f) * 0.15f - (umaDna.legsSize - 0.5f), 0.45f, 1.15f), Mathf.Clamp(1 + (umaDna.lowerWeight - 0.5f) * 0.45f + (umaDna.lowerMuscle - 0.5f) * 0.15f - (umaDna.legsSize - 0.5f), 0.45f, 1.15f))); //umaData.boneList["LeftUpLegAdjust"].boneTransform.localScale = new Vector3( //Mathf.Clamp(1, 0.6f, 2), //Mathf.Clamp(1 + (umaDna.lowerWeight - 0.5f) * 0.45f + (umaDna.lowerMuscle - 0.5f) * 0.15f - (umaDna.legsSize - 0.5f), 0.45f, 1.15f), //Mathf.Clamp(1 + (umaDna.lowerWeight - 0.5f) * 0.45f + (umaDna.lowerMuscle - 0.5f) * 0.15f - (umaDna.legsSize - 0.5f), 0.45f, 1.15f)); //umaData.boneList["RightUpLegAdjust"].boneTransform.localScale = new Vector3( //Mathf.Clamp(1, 0.6f, 2), //Mathf.Clamp(1 + (umaDna.lowerWeight - 0.5f) * 0.45f + (umaDna.lowerMuscle - 0.5f) * 0.15f - (umaDna.legsSize - 0.5f), 0.45f, 1.15f), //Mathf.Clamp(1 + (umaDna.lowerWeight - 0.5f) * 0.45f + (umaDna.lowerMuscle - 0.5f) * 0.15f - (umaDna.legsSize - 0.5f), 0.45f, 1.15f)); skeleton.SetScale(leftLegAdjustHash, new Vector3( Mathf.Clamp(1, 0.6f, 2), Mathf.Clamp(1 + (umaDna.lowerWeight - 0.5f) * 0.15f + (umaDna.lowerMuscle - 0.5f) * 0.95f - (umaDna.legsSize - 0.5f), 0.65f, 1.45f), Mathf.Clamp(1 + (umaDna.lowerWeight - 0.5f) * 0.15f + (umaDna.lowerMuscle - 0.5f) * 0.75f - (umaDna.legsSize - 0.5f), 0.65f, 1.45f))); skeleton.SetScale(rightLegAdjustHash, new Vector3( Mathf.Clamp(1, 0.6f, 2), Mathf.Clamp(1 + (umaDna.lowerWeight - 0.5f) * 0.15f + (umaDna.lowerMuscle - 0.5f) * 0.95f - (umaDna.legsSize - 0.5f), 0.65f, 1.45f), Mathf.Clamp(1 + (umaDna.lowerWeight - 0.5f) * 0.15f + (umaDna.lowerMuscle - 0.5f) * 0.75f - (umaDna.legsSize - 0.5f), 0.65f, 1.45f))); //umaData.boneList["LeftLegAdjust"].boneTransform.localScale = new Vector3( //Mathf.Clamp(1, 0.6f, 2), //Mathf.Clamp(1 + (umaDna.lowerWeight - 0.5f) * 0.15f + (umaDna.lowerMuscle - 0.5f) * 0.95f - (umaDna.legsSize - 0.5f), 0.65f, 1.45f), //Mathf.Clamp(1 + (umaDna.lowerWeight - 0.5f) * 0.15f + (umaDna.lowerMuscle - 0.5f) * 0.75f - (umaDna.legsSize - 0.5f), 0.65f, 1.45f)); //umaData.boneList["RightLegAdjust"].boneTransform.localScale = new Vector3( //Mathf.Clamp(1, 0.6f, 2), //Mathf.Clamp(1 + (umaDna.lowerWeight - 0.5f) * 0.15f + (umaDna.lowerMuscle - 0.5f) * 0.95f - (umaDna.legsSize - 0.5f), 0.65f, 1.45f), //Mathf.Clamp(1 + (umaDna.lowerWeight - 0.5f) * 0.15f + (umaDna.lowerMuscle - 0.5f) * 0.75f - (umaDna.legsSize - 0.5f), 0.65f, 1.45f)); skeleton.SetScale(leftGluteusHash, new Vector3( Mathf.Clamp(1 + (umaDna.gluteusSize - 0.5f) * 1.35f, 0.25f, 2.35f), Mathf.Clamp(1 + (umaDna.gluteusSize - 0.5f) * 1.35f, 0.25f, 2.35f), Mathf.Clamp(1 + (umaDna.gluteusSize - 0.5f) * 1.35f, 0.25f, 2.35f))); skeleton.SetScale(rightGluteusHash, new Vector3( Mathf.Clamp(1 + (umaDna.gluteusSize - 0.5f) * 1.35f, 0.25f, 2.35f), Mathf.Clamp(1 + (umaDna.gluteusSize - 0.5f) * 1.35f, 0.25f, 2.35f), Mathf.Clamp(1 + (umaDna.gluteusSize - 0.5f) * 1.35f, 0.25f, 2.35f))); //umaData.boneList["LeftGluteus"].boneTransform.localScale = new Vector3( //Mathf.Clamp(1 + (umaDna.gluteusSize - 0.5f) * 1.35f , 0.25f, 2.35f), //Mathf.Clamp(1 + (umaDna.gluteusSize - 0.5f) * 1.35f , 0.25f, 2.35f), //Mathf.Clamp(1 + (umaDna.gluteusSize - 0.5f) * 1.35f , 0.25f, 2.35f)); //umaData.boneList["RightGluteus"].boneTransform.localScale = new Vector3( //Mathf.Clamp(1 + (umaDna.gluteusSize - 0.5f) * 1.35f , 0.25f, 2.35f), //Mathf.Clamp(1 + (umaDna.gluteusSize - 0.5f) * 1.35f , 0.25f, 2.35f), //Mathf.Clamp(1 + (umaDna.gluteusSize - 0.5f) * 1.35f , 0.25f, 2.35f)); skeleton.SetScale(leftEarAdjustHash, new Vector3( Mathf.Clamp(1 + (umaDna.earsSize - 0.5f) * 1.0f, 0.75f, 1.5f), Mathf.Clamp(1 + (umaDna.earsSize - 0.5f) * 1.0f, 0.75f, 1.5f), Mathf.Clamp(1 + (umaDna.earsSize - 0.5f) * 1.0f, 0.75f, 1.5f))); skeleton.SetScale(rightEarAdjustHash, new Vector3( Mathf.Clamp(1 + (umaDna.earsSize - 0.5f) * 1.0f, 0.75f, 1.5f), Mathf.Clamp(1 + (umaDna.earsSize - 0.5f) * 1.0f, 0.75f, 1.5f), Mathf.Clamp(1 + (umaDna.earsSize - 0.5f) * 1.0f, 0.75f, 1.5f))); //umaData.boneList["LeftEarAdjust"].boneTransform.localScale = new Vector3( //Mathf.Clamp(1 + (umaDna.earsSize - 0.5f) * 1.0f, 0.75f, 1.5f), //Mathf.Clamp(1 + (umaDna.earsSize - 0.5f) * 1.0f, 0.75f, 1.5f), //Mathf.Clamp(1 + (umaDna.earsSize - 0.5f) * 1.0f, 0.75f, 1.5f)); //umaData.boneList["RightEarAdjust"].boneTransform.localScale = new Vector3( //Mathf.Clamp(1 + (umaDna.earsSize - 0.5f) * 1.0f, 0.75f, 1.5f), //Mathf.Clamp(1 + (umaDna.earsSize - 0.5f) * 1.0f, 0.75f, 1.5f), //Mathf.Clamp(1 + (umaDna.earsSize - 0.5f) * 1.0f, 0.75f, 1.5f)); skeleton.SetPositionRelative(leftEarAdjustHash, new Vector3( Mathf.Clamp(0 + (umaDna.headWidth - 0.5f) * -0.01f, -0.01f, 0.01f), Mathf.Clamp(0 + (umaDna.headWidth - 0.5f) * -0.03f, -0.03f, 0.03f), Mathf.Clamp(0 + (umaDna.earsPosition - 0.5f) * 0.02f, -0.02f, 0.02f))); skeleton.SetPositionRelative(rightEarAdjustHash, new Vector3( Mathf.Clamp(0 + (umaDna.headWidth - 0.5f) * -0.01f, -0.01f, 0.01f), Mathf.Clamp(0 + (umaDna.headWidth - 0.5f) * 0.03f, -0.03f, 0.03f), Mathf.Clamp(0 + (umaDna.earsPosition - 0.5f) * 0.02f, -0.02f, 0.02f))); skeleton.SetRotation(leftEarAdjustHash, Quaternion.Euler(new Vector3( Mathf.Clamp(0, -30, 80), Mathf.Clamp(0, -30, 80), Mathf.Clamp((umaDna.earsRotation - 0.5f) * 40, -15, 40)))); skeleton.SetRotation(rightEarAdjustHash, Quaternion.Euler(new Vector3( Mathf.Clamp(0, -30, 80), Mathf.Clamp(0, -30, 80), Mathf.Clamp((umaDna.earsRotation - 0.5f) * -40, -40, 15)))); skeleton.SetScale(noseBaseAdjustHash, new Vector3( Mathf.Clamp(1 + (umaDna.noseSize - 0.5f) * 1.5f, 0.25f, 3.0f), Mathf.Clamp(1 + (umaDna.noseSize - 0.5f) * 0.15f + (umaDna.noseWidth - 0.5f) * 1.0f, 0.25f, 3.0f), Mathf.Clamp(1 + (umaDna.noseSize - 0.5f) * 0.15f + (umaDna.noseFlatten - 0.5f) * 0.75f, 0.25f, 3.0f))); skeleton.SetScale(noseMiddleAdjustHash, new Vector3( Mathf.Clamp(1 + (umaDna.noseCurve - 0.5f) * 1.5f + (umaDna.noseSize - 0.5f) * 1.0f, 0.5f, 3.0f), Mathf.Clamp(1 + (umaDna.noseCurve - 0.5f) * 0.15f + (umaDna.noseSize - 0.5f) * 0.25f + (umaDna.noseWidth - 0.5f) * 0.5f, 0.5f, 3.0f), Mathf.Clamp(1 + (umaDna.noseCurve - 0.5f) * 0.15f + (umaDna.noseSize - 0.5f) * 0.10f, 0.5f, 3.0f))); skeleton.SetRotation(noseBaseAdjustHash, Quaternion.Euler(new Vector3( Mathf.Clamp(0, -30, 80), Mathf.Clamp((umaDna.noseInclination - 0.5f) * 60, -60, 30), Mathf.Clamp(0, -30, 80)))); skeleton.SetPositionRelative(noseBaseAdjustHash, new Vector3( Mathf.Clamp(0 + (umaDna.nosePronounced - 0.5f) * -0.025f, -0.025f, 0.025f), Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0 + (umaDna.nosePosition - 0.5f) * 0.025f, -0.025f, 0.025f))); skeleton.SetPositionRelative(noseMiddleAdjustHash, new Vector3( Mathf.Clamp(0 + (umaDna.nosePronounced - 0.5f) * -0.012f, -0.012f, 0.012f), Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0 + (umaDna.nosePosition - 0.5f) * 0.015f, -0.015f, 0.015f))); skeleton.SetPositionRelative(leftNoseAdjustHash, new Vector3( Mathf.Clamp(0 + (umaDna.nosePronounced - 0.5f) * -0.025f, -0.025f, 0.025f), Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0 + (umaDna.nosePosition - 0.5f) * 0.025f, -0.025f, 0.025f))); skeleton.SetPositionRelative(rightNoseAdjustHash, new Vector3( Mathf.Clamp(0 + (umaDna.nosePronounced - 0.5f) * -0.025f, -0.025f, 0.025f), Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0 + (umaDna.nosePosition - 0.5f) * 0.025f, -0.025f, 0.025f))); skeleton.SetPositionRelative(upperLipsAdjustHash, new Vector3( Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0 + (umaDna.nosePosition - 0.5f) * 0.0045f, -0.0045f, 0.0045f))); skeleton.SetScale(mandibleAdjustHash, new Vector3( Mathf.Clamp(1 + (umaDna.chinPronounced - 0.5f) * 0.18f, 0.55f, 1.75f), Mathf.Clamp(1 + (umaDna.chinSize - 0.5f) * 1.3f, 0.75f, 1.3f), Mathf.Clamp(1, 0.4f, 1.5f))); skeleton.SetPositionRelative(mandibleAdjustHash, new Vector3( Mathf.Clamp(0, -0.0125f, 0.0125f), Mathf.Clamp(0, -0.0125f, 0.0125f), Mathf.Clamp(0 + (umaDna.chinPosition - 0.5f) * 0.0075f, -0.0075f, 0.0075f))); skeleton.SetPositionRelative(leftLowMaxilarAdjustHash, new Vector3( Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0 + (umaDna.jawsSize - 0.5f) * 0.025f, -0.025f, 0.025f), Mathf.Clamp(0 + (umaDna.jawsPosition - 0.5f) * 0.03f, -0.03f, 0.03f))); skeleton.SetPositionRelative(rightLowMaxilarAdjustHash, new Vector3( Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0 + (umaDna.jawsSize - 0.5f) * -0.025f, -0.025f, 0.025f), Mathf.Clamp(0 + (umaDna.jawsPosition - 0.5f) * 0.03f, -0.03f, 0.03f))); skeleton.SetScale(leftCheekAdjustHash, new Vector3( Mathf.Clamp(1 + (umaDna.cheekSize - 0.5f) * 1.05f, 0.35f, 2.05f), Mathf.Clamp(1 + (umaDna.cheekSize - 0.5f) * 1.05f, 0.35f, 2.05f), Mathf.Clamp(1 + (umaDna.cheekSize - 0.5f) * 1.05f, 0.35f, 2.05f))); skeleton.SetScale(rightCheekAdjustHash, new Vector3( Mathf.Clamp(1 + (umaDna.cheekSize - 0.5f) * 1.05f, 0.35f, 2.05f), Mathf.Clamp(1 + (umaDna.cheekSize - 0.5f) * 1.05f, 0.35f, 2.05f), Mathf.Clamp(1 + (umaDna.cheekSize - 0.5f) * 1.05f, 0.35f, 2.05f))); skeleton.SetPositionRelative(leftCheekAdjustHash, new Vector3( Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0 + (umaDna.cheekPosition - 0.5f) * 0.03f, -0.03f, 0.03f))); skeleton.SetPositionRelative(rightCheekAdjustHash, new Vector3( Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0 + (umaDna.cheekPosition - 0.5f) * 0.03f, -0.03f, 0.03f))); skeleton.SetPositionRelative(leftLowCheekAdjustHash, new Vector3( Mathf.Clamp(0 + (umaDna.lowCheekPronounced - 0.5f) * -0.07f, -0.07f, 0.07f), Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0 + (umaDna.lowCheekPosition - 0.5f) * 0.06f, -0.06f, 0.06f))); skeleton.SetPositionRelative(rightLowCheekAdjustHash, new Vector3( Mathf.Clamp(0 + (umaDna.lowCheekPronounced - 0.5f) * -0.07f, -0.07f, 0.07f), Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0 + (umaDna.lowCheekPosition - 0.5f) * 0.06f, -0.06f, 0.06f))); skeleton.SetPositionRelative(noseTopAdjustHash, new Vector3( Mathf.Clamp(0 + (umaDna.foreheadSize - 0.5f) * -0.015f, -0.025f, 0.005f), Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0 + (umaDna.foreheadPosition - 0.5f) * -0.025f + (umaDna.foreheadSize - 0.5f) * -0.0015f, -0.015f, 0.0025f))); skeleton.SetPositionRelative(leftEyebrowLowAdjustHash, new Vector3( Mathf.Clamp(0 + (umaDna.foreheadSize - 0.5f) * -0.015f, -0.025f, 0.005f), Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0 + (umaDna.foreheadPosition - 0.5f) * -0.02f + (umaDna.foreheadSize - 0.5f) * -0.005f, -0.015f, 0.005f))); skeleton.SetPositionRelative(leftEyebrowMiddleAdjustHash, new Vector3( Mathf.Clamp(0 + (umaDna.foreheadSize - 0.5f) * -0.015f, -0.025f, 0.005f), Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0 + (umaDna.foreheadPosition - 0.5f) * -0.05f + (umaDna.foreheadSize - 0.5f) * -0.005f, -0.025f, 0.005f))); skeleton.SetPositionRelative(leftEyebrowUpAdjustHash, new Vector3( Mathf.Clamp(0 + (umaDna.foreheadSize - 0.5f) * -0.015f, -0.025f, 0.005f), Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0 + (umaDna.foreheadPosition - 0.5f) * -0.007f + (umaDna.foreheadSize - 0.5f) * -0.005f, -0.010f, 0.005f))); skeleton.SetPositionRelative(rightEyebrowLowAdjustHash, new Vector3( Mathf.Clamp(0 + (umaDna.foreheadSize - 0.5f) * -0.015f, -0.025f, 0.005f), Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0 + (umaDna.foreheadPosition - 0.5f) * -0.02f + (umaDna.foreheadSize - 0.5f) * -0.005f, -0.015f, 0.005f))); skeleton.SetPositionRelative(rightEyebrowMiddleAdjustHash, new Vector3( Mathf.Clamp(0 + (umaDna.foreheadSize - 0.5f) * -0.015f, -0.025f, 0.005f), Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0 + (umaDna.foreheadPosition - 0.5f) * -0.05f + (umaDna.foreheadSize - 0.5f) * -0.005f, -0.025f, 0.005f))); skeleton.SetPositionRelative(rightEyebrowUpAdjustHash, new Vector3( Mathf.Clamp(0 + (umaDna.foreheadSize - 0.5f) * -0.015f, -0.025f, 0.005f), Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0 + (umaDna.foreheadPosition - 0.5f) * -0.007f + (umaDna.foreheadSize - 0.5f) * -0.005f, -0.010f, 0.005f))); skeleton.SetScale(lipsSuperiorAdjustHash, new Vector3( Mathf.Clamp(1 + (umaDna.lipsSize - 0.5f) * 0.05f, 1.0f, 1.05f), Mathf.Clamp(1 + (umaDna.lipsSize - 0.5f) * 0.9f, 0.65f, 1.5f), Mathf.Clamp(1 + (umaDna.lipsSize - 0.5f) * 0.9f, 0.65f, 1.5f))); skeleton.SetScale(lipsInferiorAdjustHash, new Vector3( Mathf.Clamp(1 + (umaDna.lipsSize - 0.5f) * 0.05f, 1.0f, 1.05f), Mathf.Clamp(1 + (umaDna.lipsSize - 0.5f) * 1.0f, 0.65f, 1.5f), Mathf.Clamp(1 + (umaDna.lipsSize - 0.5f) * 1.0f, 0.65f, 1.5f))); skeleton.SetScale(leftLipsSuperiorMiddleAdjustHash, new Vector3( Mathf.Clamp(1 + (umaDna.lipsSize - 0.5f) * 0.05f, 1.0f, 1.05f), Mathf.Clamp(1 + (umaDna.lipsSize - 0.5f) * 0.9f, 0.65f, 1.5f), Mathf.Clamp(1 + (umaDna.lipsSize - 0.5f) * 0.9f, 0.65f, 1.5f))); skeleton.SetScale(rightLipsSuperiorMiddleAdjustHash, new Vector3( Mathf.Clamp(1 + (umaDna.lipsSize - 0.5f) * 0.05f, 1.0f, 1.05f), Mathf.Clamp(1 + (umaDna.lipsSize - 0.5f) * 0.9f, 0.65f, 1.5f), Mathf.Clamp(1 + (umaDna.lipsSize - 0.5f) * 0.9f, 0.65f, 1.5f))); skeleton.SetScale(leftLipsInferiorAdjustHash, new Vector3( Mathf.Clamp(1 + (umaDna.lipsSize - 0.5f) * 0.05f, 1.0f, 1.05f), Mathf.Clamp(1 + (umaDna.lipsSize - 0.5f) * 0.9f, 0.65f, 1.5f), Mathf.Clamp(1 + (umaDna.lipsSize - 0.5f) * 0.9f, 0.65f, 1.5f))); skeleton.SetScale(rightLipsInferiorAdjustHash, new Vector3( Mathf.Clamp(1 + (umaDna.lipsSize - 0.5f) * 0.05f, 1.0f, 1.05f), Mathf.Clamp(1 + (umaDna.lipsSize - 0.5f) * 0.9f, 0.65f, 1.5f), Mathf.Clamp(1 + (umaDna.lipsSize - 0.5f) * 0.9f, 0.65f, 1.5f))); skeleton.SetPositionRelative(lipsInferiorAdjustHash, new Vector3( Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0 + (umaDna.lipsSize - 0.5f) * -0.008f, -0.1f, 0.1f))); skeleton.SetPositionRelative(leftLipsAdjustHash, new Vector3( Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0 + (umaDna.mouthSize - 0.5f) * 0.03f, -0.02f, 0.005f), Mathf.Clamp(0, -0.05f, 0.05f))); skeleton.SetPositionRelative(rightLipsAdjustHash, new Vector3( Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0 + (umaDna.mouthSize - 0.5f) * -0.03f, -0.005f, 0.02f), Mathf.Clamp(0, -0.05f, 0.05f))); skeleton.SetPositionRelative(leftLipsSuperiorMiddleAdjustHash, new Vector3( Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0 + (umaDna.mouthSize - 0.5f) * 0.007f, -0.02f, 0.005f), Mathf.Clamp(0, -0.05f, 0.05f))); skeleton.SetPositionRelative(rightLipsSuperiorMiddleAdjustHash, new Vector3( Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0 + (umaDna.mouthSize - 0.5f) * -0.007f, -0.005f, 0.02f), Mathf.Clamp(0, -0.05f, 0.05f))); skeleton.SetPositionRelative(leftLipsInferiorAdjustHash, new Vector3( Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0 + (umaDna.mouthSize - 0.5f) * 0.007f, -0.02f, 0.005f), Mathf.Clamp(0 + (umaDna.lipsSize - 0.5f) * -0.008f, -0.1f, 0.1f))); skeleton.SetPositionRelative(rightLipsInferiorAdjustHash, new Vector3( Mathf.Clamp(0, -0.05f, 0.05f), Mathf.Clamp(0 + (umaDna.mouthSize - 0.5f) * -0.007f, -0.005f, 0.02f), Mathf.Clamp(0 + (umaDna.lipsSize - 0.5f) * -0.008f, -0.1f, 0.1f))); ////Bone structure change float overallScale = 0.88f + (umaDna.height - 0.5f) * 1.0f + (umaDna.legsSize - 0.5f) * 1.0f; overallScale = Mathf.Clamp(overallScale, 0.5f, 2f); skeleton.SetScale(positionHash, new Vector3(overallScale, overallScale, overallScale)); skeleton.SetPositionRelative(positionHash, new Vector3( Mathf.Clamp((umaDna.feetSize - 0.5f) * -0.27f, -0.15f, 0.0675f), Mathf.Clamp(0, -10, 10), Mathf.Clamp(0, -10, 10))); float lowerBackScale = Mathf.Clamp(1 - (umaDna.legsSize - 0.5f) * 1.0f, 0.5f, 3.0f); skeleton.SetScale(lowerBackHash, new Vector3(lowerBackScale, lowerBackScale, lowerBackScale)); skeleton.SetScale(headHash, new Vector3( Mathf.Clamp(1 + (umaDna.headSize - 0.5f) * 2.0f, 0.5f, 2), Mathf.Clamp(1 + (umaDna.headSize - 0.5f) * 2.0f, 0.5f, 2), Mathf.Clamp(1 + (umaDna.headSize - 0.5f) * 2.0f, 0.5f, 2))); skeleton.SetScale(leftArmHash, new Vector3( Mathf.Clamp(1 + (umaDna.armLength - 0.5f) * 2.0f, 0.5f, 2.0f), Mathf.Clamp(1 + (umaDna.armLength - 0.5f) * 2.0f, 0.5f, 2.0f), Mathf.Clamp(1 + (umaDna.armLength - 0.5f) * 2.0f, 0.5f, 2.0f))); skeleton.SetScale(rightArmHash, new Vector3( Mathf.Clamp(1 + (umaDna.armLength - 0.5f) * 2.0f, 0.5f, 2.0f), Mathf.Clamp(1 + (umaDna.armLength - 0.5f) * 2.0f, 0.5f, 2.0f), Mathf.Clamp(1 + (umaDna.armLength - 0.5f) * 2.0f, 0.5f, 2.0f))); skeleton.SetScale(leftForeArmHash, new Vector3( Mathf.Clamp(1 + (umaDna.forearmLength - 0.5f) * 2.0f, 0.5f, 2.0f), Mathf.Clamp(1 + (umaDna.forearmLength - 0.5f) * 2.0f, 0.5f, 2.0f), Mathf.Clamp(1 + (umaDna.forearmLength - 0.5f) * 2.0f, 0.5f, 2.0f))); skeleton.SetScale(rightForeArmHash, new Vector3( Mathf.Clamp(1 + (umaDna.forearmLength - 0.5f) * 2.0f, 0.5f, 2.0f), Mathf.Clamp(1 + (umaDna.forearmLength - 0.5f) * 2.0f, 0.5f, 2.0f), Mathf.Clamp(1 + (umaDna.forearmLength - 0.5f) * 2.0f, 0.5f, 2.0f))); skeleton.SetScale(leftHandHash, new Vector3( Mathf.Clamp(1 + (umaDna.handsSize - 0.5f) * 2.0f, 0.5f, 2.0f), Mathf.Clamp(1 + (umaDna.handsSize - 0.5f) * 2.0f, 0.5f, 2.0f), Mathf.Clamp(1 + (umaDna.handsSize - 0.5f) * 2.0f, 0.5f, 2.0f))); skeleton.SetScale(rightHandHash, new Vector3( Mathf.Clamp(1 + (umaDna.handsSize - 0.5f) * 2.0f, 0.5f, 2.0f), Mathf.Clamp(1 + (umaDna.handsSize - 0.5f) * 2.0f, 0.5f, 2.0f), Mathf.Clamp(1 + (umaDna.handsSize - 0.5f) * 2.0f, 0.5f, 2.0f))); skeleton.SetScale(leftFootHash, new Vector3( Mathf.Clamp(1 + (umaDna.feetSize - 0.5f) * 2.0f, 0.5f, 2.0f), Mathf.Clamp(1 + (umaDna.feetSize - 0.5f) * 2.0f, 0.5f, 2.0f), Mathf.Clamp(1 + (umaDna.feetSize - 0.5f) * 2.0f, 0.5f, 2.0f))); skeleton.SetScale(rightFootHash, new Vector3( Mathf.Clamp(1 + (umaDna.feetSize - 0.5f) * 2.0f, 0.5f, 2.0f), Mathf.Clamp(1 + (umaDna.feetSize - 0.5f) * 2.0f, 0.5f, 2.0f), Mathf.Clamp(1 + (umaDna.feetSize - 0.5f) * 2.0f, 0.5f, 2.0f))); skeleton.SetPositionRelative(leftUpLegHash, new Vector3( Mathf.Clamp(0, -10, 10), Mathf.Clamp((umaDna.legSeparation - 0.5f) * -0.15f + (umaDna.lowerWeight - 0.5f) * -0.035f + (umaDna.legsSize - 0.5f) * 0.1f, -0.025f, 0.025f), Mathf.Clamp(0, -10, 10))); skeleton.SetPositionRelative(rightUpLegHash, new Vector3( Mathf.Clamp(0, -10, 10), Mathf.Clamp((umaDna.legSeparation - 0.5f) * 0.15f + (umaDna.lowerWeight - 0.5f) * 0.035f + (umaDna.legsSize - 0.5f) * -0.1f, -0.025f, 0.025f), Mathf.Clamp(0, -10, 10))); skeleton.SetPositionRelative(leftShoulderHash, new Vector3( Mathf.Clamp(0, -10, 10), Mathf.Clamp(0.003f + (umaDna.upperMuscle - 0.5f) * -0.265f, -0.085f, 0.015f), Mathf.Clamp(0, -10, 10))); skeleton.SetPositionRelative(rightShoulderHash, new Vector3( Mathf.Clamp(0, -10, 10), Mathf.Clamp(0.003f + (umaDna.upperMuscle - 0.5f) * 0.265f, -0.015f, 0.085f), Mathf.Clamp(0, -10, 10))); skeleton.SetScale(mandibleHash, new Vector3( Mathf.Clamp(1 + (umaDna.mandibleSize - 0.5f) * 0.35f, 0.35f, 1.35f), Mathf.Clamp(1 + (umaDna.mandibleSize - 0.5f) * 0.35f, 0.35f, 1.35f), Mathf.Clamp(1 + (umaDna.mandibleSize - 0.5f) * 0.35f, 0.35f, 1.35f))); umaData.characterHeight = overallScale * (0.85f + 1.2f * lowerBackScale); umaData.characterRadius = 0.28f * overallScale; umaData.characterMass = 46f * overallScale + 26f * umaDna.upperWeight + 26f * umaDna.lowerWeight; }
public void UpdateDynamicUMADnaBones(UMAData umaData, UMASkeleton skeleton, bool asReset = false) { UMADnaBase umaDna; //need to use the typehash umaDna = umaData.GetDna(DNATypeHash); if (umaDna == null || asReset == true) { umaDna = null; } //Make the DNAAssets match if they dont already... if (umaDna != null) { if (((DynamicUMADnaBase)umaDna).dnaAsset != dnaAsset) { ((DynamicUMADnaBase)umaDna).dnaAsset = dnaAsset; } } float overallScaleCalc = 0; //float lowerBackScale = 0; //bool overallScaleFound = false; //bool lowerBackScaleFound = false; for (int i = 0; i < skeletonModifiers.Count; i++) { skeletonModifiers[i].umaDNA = umaDna; var thisHash = (skeletonModifiers[i].hash != 0) ? skeletonModifiers[i].hash : GetHash(skeletonModifiers[i].hashName); //With these ValueX.x is the calculated value and ValueX.y is min and ValueX.z is max var thisValueX = skeletonModifiers[i].ValueX; var thisValueY = skeletonModifiers[i].ValueY; var thisValueZ = skeletonModifiers[i].ValueZ; if (skeletonModifiers[i].hashName == "Position" && skeletonModifiers[i].property == SkeletonModifier.SkeletonPropType.Scale) { //TODO eli added something for overall scale to RaceData- whats that supposed to do? var calcVal = thisValueX.x - skeletonModifiers[i].valuesX.val.value + overallScale; overallScaleCalc = Mathf.Clamp(calcVal, thisValueX.y, thisValueX.z); skeleton.SetScale(skeletonModifiers[i].hash, new Vector3(overallScaleCalc, overallScaleCalc, overallScaleCalc)); //overallScaleFound = true; //Debug.Log("overallScaleCalc was " + overallScaleCalc); } /*else if (skeletonModifiers[i].hashName == "LowerBack" && skeletonModifiers[i].property == SkeletonModifier.SkeletonPropType.Scale) * { * lowerBackScale = Mathf.Clamp(thisValueX.x, thisValueX.y, thisValueX.z); * skeleton.SetScale(skeletonModifiers[i].hash, new Vector3(lowerBackScale, lowerBackScale, lowerBackScale)); * lowerBackScaleFound = true; * }*/ else if (skeletonModifiers[i].property == SkeletonModifier.SkeletonPropType.Position) { skeleton.SetPositionRelative(thisHash, new Vector3( Mathf.Clamp(thisValueX.x, thisValueX.y, thisValueX.z), Mathf.Clamp(thisValueY.x, thisValueY.y, thisValueY.z), Mathf.Clamp(thisValueZ.x, thisValueZ.y, thisValueZ.z))); } else if (skeletonModifiers[i].property == SkeletonModifier.SkeletonPropType.Rotation) { skeleton.SetRotationRelative(thisHash, Quaternion.Euler(new Vector3( Mathf.Clamp(thisValueX.x, thisValueX.y, thisValueX.z), Mathf.Clamp(thisValueY.x, thisValueY.y, thisValueY.z), Mathf.Clamp(thisValueZ.x, thisValueZ.y, thisValueZ.z))), 1f); } else if (skeletonModifiers[i].property == SkeletonModifier.SkeletonPropType.Scale) { skeleton.SetScale(thisHash, new Vector3( Mathf.Clamp(thisValueX.x, thisValueX.y, thisValueX.z), Mathf.Clamp(thisValueY.x, thisValueY.y, thisValueY.z), Mathf.Clamp(thisValueZ.x, thisValueZ.y, thisValueZ.z))); } } if (startingPose != null && asReset == false) { for (int i = 0; i < startingPose.poses.Length; i++) { skeleton.Morph(startingPose.poses[i].hash, startingPose.poses[i].position, startingPose.poses[i].scale, startingPose.poses[i].rotation, startingPoseWeight); } } //overall modifiers //Try to use updated Bounds to set the height. if (overallModifiersEnabled && umaData.GetRenderer(0) != null) { if (umaData.rendererCount < 1) { return; } if (!umaData.GetRenderer(0).enabled) { return; } if (umaData.GetRenderer(0).localBounds.size.y == 0) { return; } var currentSMROffscreenSetting = umaData.GetRenderer(0).updateWhenOffscreen; Bounds newBounds; //for this to properly calculate if the character is in a scaled game object it needs to be moved into the root var umaTransform = umaData.transform; var oldParent = umaTransform.parent; var originalRot = umaTransform.localRotation; var originalPos = umaTransform.localPosition; //we also need to disable any collider that is on it so it doesn't hit anything when its moved var thisCollider = umaData.gameObject.GetComponent <Collider>(); bool thisColliderEnabled = false; if (thisCollider) { thisColliderEnabled = thisCollider.enabled; thisCollider.enabled = false; } //Now move into the root umaTransform.SetParent(null, false); umaTransform.localRotation = Quaternion.identity; umaTransform.localPosition = Vector3.zero; //Do the calculations umaData.GetRenderer(0).updateWhenOffscreen = true; newBounds = new Bounds(umaData.GetRenderer(0).localBounds.center, umaData.GetRenderer(0).localBounds.size); umaData.GetRenderer(0).updateWhenOffscreen = currentSMROffscreenSetting; //move it back umaTransform.SetParent(oldParent, false); umaTransform.localRotation = originalRot; umaTransform.localPosition = originalPos; //set any collider to its original setting if (thisCollider) { thisCollider.enabled = thisColliderEnabled; } //somehow the bounds end up beneath the floor i.e. newBounds.center.y - newBounds.extents.y is actually a minus number //tighten bounds fixes this if (tightenBounds) { Vector3 newCenter = new Vector3(newBounds.center.x, newBounds.center.y, newBounds.center.z); Vector3 newSize = new Vector3(newBounds.size.x, newBounds.size.y, newBounds.size.z); if (newBounds.center.y - newBounds.extents.y < 0) { var underAmount = newBounds.center.y - newBounds.extents.y; newSize.y = (newBounds.center.y * 2) - underAmount; newCenter.y = newSize.y / 2; } Bounds modifiedBounds = new Bounds(newCenter, newSize); newBounds = modifiedBounds; } //character height can be based on the resulting height umaData.characterHeight = newBounds.size.y * (1 + radiusAdjust.y); //radius could be based on the resulting width umaData.characterRadius = (newBounds.size.x * (radiusAdjust.x /*/2*/) + newBounds.size.z * (radiusAdjust.x /*/ 2*/)) / 2; //then base the mass on a compond of those two modified by the mass modifiers values var radiusAsDNA = (umaData.characterRadius * 2) * overallScaleCalc; var radiusYAsDNA = ((1 + radiusAdjust.y) * 0.5f) * overallScaleCalc; umaData.characterMass = (massModifiers.x * overallScaleCalc) + massModifiers.y * radiusYAsDNA + massModifiers.z * radiusAsDNA; //add bounds padding if any was set if (boundsAdjust != Vector3.zero) { newBounds.Expand(boundsAdjust); } //set the padded bounds umaData.GetRenderer(0).localBounds = newBounds; } }