コード例 #1
0
		protected void EnsureUMADataSetup(UMAData umaData)
		{
			if (umaData.umaRoot == null)
			{
				GameObject newRoot = new GameObject("Root");
				newRoot.transform.parent = umaData.transform;
				newRoot.transform.localPosition = Vector3.zero;
				newRoot.transform.localRotation = Quaternion.Euler(270f, 0, 0f);
				umaData.umaRoot = newRoot;

				GameObject newGlobal = new GameObject("Global");
				newGlobal.transform.parent = newRoot.transform;
				newGlobal.transform.localPosition = Vector3.zero;
				newGlobal.transform.localRotation = Quaternion.Euler(90f, 90f, 0f);

				umaData.skeleton = new UMASkeleton(newGlobal.transform);

				var newRenderer = umaData.umaRoot.AddComponent<SkinnedMeshRenderer>();
				newRenderer.rootBone = newGlobal.transform;
				umaData.myRenderer = newRenderer;
				umaData.myRenderer.enabled = false;
				umaData.myRenderer.sharedMesh = new Mesh();
			}
			else
			{
				umaData.CleanMesh(false);
			}
		}
コード例 #2
0
		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);
		}
コード例 #3
0
		public void characterCreated(UMAData umaCreated)
		{
			head = umaCreated.GetBoneGameObject("Head");

			MoveCamera();

			player = gameObject.GetComponentInChildren<UMAExpressionPlayer>();
			if (player == null)
			{
				Animator umaAnimator = GetComponentInChildren<Animator>();
				if (umaAnimator != null)
				{
					player = umaAnimator.gameObject.AddComponent<UMAExpressionPlayer>();
					player.overrideMecanimNeck = true;
					player.overrideMecanimHead = true;
					player.overrideMecanimJaw = true;
					player.overrideMecanimEyes = true;
				}

#if !UNITY_4_3
				umaAnimator.Rebind();
#endif
			}

			if (player != null)
			{
				if (expressionSet != null)
				{
					player.expressionSet = expressionSet;
				}

				player.Initialize();
				guiValues = new float[UMAExpressionPlayer.PoseCount];
			}
		}
コード例 #4
0
ファイル: UMAGeneratorBuiltin.cs プロジェクト: petesimard/UMA
 /// <inheritdoc/>
 public override void addDirtyUMA(UMAData umaToAdd)
 {
     if (umaToAdd)
     {
         umaDirtyList.Add(umaToAdd);
     }
 }
コード例 #5
0
		public void OnDnaApplied(UMAData umaData)
		{
			if (!hashesFound)
			{
				leftHandHash = UMAUtils.StringToHash("LeftHand");
				rightHandHash = UMAUtils.StringToHash("RightHand");
				leftTwistHash = UMAUtils.StringToHash("LeftForeArmTwist");
				rightTwistHash = UMAUtils.StringToHash("RightForeArmTwist");
				hashesFound = true;
			}

			GameObject leftHand = umaData.GetBoneGameObject(leftHandHash);
			GameObject rightHand = umaData.GetBoneGameObject(rightHandHash);
			GameObject leftTwist = umaData.GetBoneGameObject(leftTwistHash);
			GameObject rightTwist = umaData.GetBoneGameObject(rightTwistHash);

			if ((leftHand == null) || (rightHand == null) || (leftTwist == null) || (rightTwist == null))
			{
				Debug.LogError("Failed to add Forearm Twist to: " + umaData.name);
				return;
			}

			var twist = umaData.umaRoot.AddComponent<TwistBones>();
			twist.twistValue = 0.5f;
			twist.twistBone = new Transform[] {leftTwist.transform, rightTwist.transform};
			twist.refBone = new Transform[] {leftHand.transform, rightHand.transform};
		}
コード例 #6
0
        public void Initialize()
        {
            blinkDelay = Random.Range(minBlinkDelay, maxBlinkDelay);

            if (umaData == null)
            {
                // Find the UMAData, which could be up or down the hierarchy
                umaData = gameObject.GetComponentInChildren<UMAData>();
                if (umaData == null)
                {
            #if UNITY_4_3
                    umaData = transform.root.GetComponentInChildren<UMAData>();
            #else
                    umaData = gameObject.GetComponentInParent<UMAData>();
            #endif
                }
                if (umaData == null)
                {
                    Debug.LogError("Couldn't locate UMAData component");
                }
            }

            if ((expressionSet != null) && (umaData != null) && (umaData.skeleton != null))
            {
                if (umaData.animator != null)
                {
                    Transform jaw = umaData.animator.GetBoneTransform(HumanBodyBones.Jaw);
                    if (jaw != null)
                        jawHash = UMAUtils.StringToHash(jaw.name);
                }
                initialized = true;
            }
        }
コード例 #7
0
    void GenerateUMA()
    {
        // Create a new game object and add UMA components to it
        GameObject GO = new GameObject("MyUMA");
        umaDynamicAvatar = GO.AddComponent<UMADynamicAvatar>();

        // Initialise Avatar and grab a reference to it's data component
        umaDynamicAvatar.Initialize();
        umaData = umaDynamicAvatar.umaData;

        // Attach our generator
        umaDynamicAvatar.umaGenerator = generator;
        umaData.umaGenerator = generator;

        // Set up slot Array
        umaData.umaRecipe.slotDataList = new SlotData[numberOfSlots];

        // Set up our Morph reference
        umaDna = new UMADnaHumanoid();
        umaTutorialDNA = new UMADnaTutorial();
        umaData.umaRecipe.AddDna(umaDna);
        umaData.umaRecipe.AddDna(umaTutorialDNA);

        // Grab a reference to our recipe
        // var umaRecipe = umaDynamicAvatar.umaData.umaRecipe; //moved to subroutine MakeMale

        // >>> This is whee the fun will happen according to Secret Anorak <<<<
        CreateMale();

        // Generate Our UMA
        umaDynamicAvatar.UpdateNewRace();
    }
コード例 #8
0
ファイル: DNARangeAsset.cs プロジェクト: NotYours180/UMA
		/// <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;
		}
コード例 #9
0
ファイル: UMAGeneratorBuiltin.cs プロジェクト: petesimard/UMA
        public virtual bool HandleDirtyUpdate(UMAData data)
        {
            if (data == null)
                return true;

            if (umaData != data)
            {
                umaData = data;

                if (!umaData.Validate())
                    return true;

                if (meshCombiner != null)
                {
                    meshCombiner.Preprocess(umaData);
                }
                umaData.FireCharacterBegunEvents();
            }

            if (umaData.isTextureDirty)
            {
                if (activeGeneratorCoroutine == null)
                {
                    activeGeneratorCoroutine = umaGeneratorCoroutine;
                    TextureProcessBaseCoroutine textureProcessCoroutine;
                    textureProcessCoroutine = new TextureProcessPROCoroutine();
                    textureProcessCoroutine.Prepare(data, this);
                    activeGeneratorCoroutine.Prepare(this, umaData, textureProcessCoroutine, !umaData.isMeshDirty);
                }

                bool workDone = umaGeneratorCoroutine.Work();
                if (workDone)
                {
                    activeGeneratorCoroutine = null;
                    umaData.isTextureDirty = false;
                    umaData.isAtlasDirty = true;
                }

                if (!workDone || !fastGeneration || umaData.isMeshDirty)
                    return false;
            }

            if (umaData.isMeshDirty)
            {
                UpdateUMAMesh(umaData.isAtlasDirty);
                umaData.isAtlasDirty = false;
                umaData.isMeshDirty = false;

                if (!fastGeneration)
                    return false;
            }

            if (umaData.isShapeDirty)
            {
                UpdateUMABody(umaData);
                umaData.isShapeDirty = false;
            }
            UMAReady();
            return true;
        }
コード例 #10
0
ファイル: UMAAvatarBase.cs プロジェクト: NotYours180/UMA
	public void Initialize()
	{
		if (context == null)
		{
			context = UMAContext.FindInstance();
		}

		if (umaData == null)
		{
			umaData = GetComponent<UMAData>();
			if (umaData == null)
			{
				umaData = gameObject.AddComponent<UMAData>();
				if (umaGenerator != null && !umaGenerator.gameObject.activeInHierarchy)
				{
					Debug.LogError("Invalid UMA Generator on Avatar.", gameObject);
					Debug.LogError("UMA generators must be active scene objects!", umaGenerator.gameObject);
					umaGenerator = null;
				}
			}
		}
		if (umaGenerator != null)
		{
			umaData.umaGenerator = umaGenerator;
		}
		if (CharacterCreated != null) umaData.CharacterCreated = CharacterCreated;
		if (CharacterDestroyed != null) umaData.CharacterDestroyed = CharacterDestroyed;
		if (CharacterUpdated != null) umaData.CharacterUpdated = CharacterUpdated;
	}
コード例 #11
0
	/// <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 UpdateUMAGirlyMyRaceDNABones(UMAData umaData, UMASkeleton skeleton)
	{
		var umaDna = umaData.GetDna<UMADnaHumanoid>();
		
		
		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)));
		
		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["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));
		
		
	}
コード例 #12
0
ファイル: DNARangeAsset.cs プロジェクト: NotYours180/UMA
		/// <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;
		}
コード例 #13
0
    void GenerateUMA()
    {
        GameObject myUMA = new GameObject("MyUMA");
        avatar = myUMA.AddComponent<UMADynamicAvatar>();

        avatar.Initialize();
        umaData = avatar.umaData;
        avatar.umaGenerator = generator;
        umaData.umaGenerator = generator;
        umaData.umaRecipe = new UMAData.UMARecipe();
        umaData.umaRecipe.slotDataList = new SlotData[NUM_SLOTS];

        umaDna = new UMADnaHumanoid();
        umaTutorialDna = new UMADnaTutorial();
        
        umaData.umaRecipe.AddDna(umaDna);
        umaData.umaRecipe.AddDna(umaTutorialDna);

        

        CreateMale();

        avatar.animationController = animController;

        avatar.UpdateNewRace();

        myUMA.transform.parent = this.gameObject.transform;
        myUMA.transform.localPosition = Vector3.zero;
        myUMA.transform.localRotation = Quaternion.identity;
    }
 void OnUpdated(UMAData umaData)
 {
     vJoints = null;
     vJoints = GenerateVJoints();
     AddDefaultTargets(umaData);
     _ready = vJoints != null;
     EnableUpdateWhenOffScreen(umaData);
 }
コード例 #15
0
 public void CharacterUpdated(UMAData data)
 {
     if (lodDisplay != null)
     {
         var renderer = lodDisplay.GetComponent <Renderer>();
         renderer.material.SetColor("_EmissionColor", Color.white);
     }
 }
コード例 #16
0
ファイル: UMAGeneratorBase.cs プロジェクト: RapsFan/UMA
 public static Avatar CreateAvatar(UMAData umaData, UmaTPose umaTPose)
 {
     umaTPose.DeSerialize();
     HumanDescription description = CreateHumanDescription(umaData, umaTPose);
     //DebugLogHumanAvatar(umaData.umaRoot, description);
     Avatar res = AvatarBuilder.BuildHumanAvatar(umaData.umaRoot, description);
     return res;
 }
コード例 #17
0
        private void UMARestoreReplacedSlot(UMAData umaData, UMAEquipSlotData equipSlotData)
        {
            var l = new List <SlotData>(umaData.umaRecipe.slotDataList);

            l.Add(equipSlotData.umaReplacedSlot);
            l.Remove(equipSlotData.umaPrevReplacedSlot);
            umaData.umaRecipe.slotDataList = l.ToArray();
        }
コード例 #18
0
ファイル: TextureMerge.cs プロジェクト: NotYours180/UMA
		public void SetupModule(UMAData.MaterialFragment source, int textureType)
		{
			textureMergeRects[textureMergeRectCount].rect = source.atlasRegion;
			textureMergeRects[textureMergeRectCount].rect.y = height - textureMergeRects[textureMergeRectCount].rect.y - textureMergeRects[textureMergeRectCount].rect.height;
			atlasRect = textureMergeRects[textureMergeRectCount].rect;
			SetupMaterial(ref textureMergeRects[textureMergeRectCount], source, textureType);
			textureMergeRectCount++;
		}
コード例 #19
0
		public void OnCharacterBegun(UMAData umaData)
		{
			var expressionPlayer = umaData.GetComponent<UMAExpressionPlayer>();
			if (expressionPlayer != null)
			{
				expressionPlayer.SlotUpdateVsCharacterUpdate++;
			}
		}
コード例 #20
0
 public void Update()
 {
     if (umaData == null)
     {
         umaData = this.GetComponent <UMADynamicAvatar> ().umaData;
         umaDNA  = umaData.GetDna <UMADnaHumanoid> ();
     }
 }
コード例 #21
0
        static void RandomizeRecipe(UMAData umaData, UMA.Examples.UMARecipeMixer[] recipeMixers, UMAContext context, SharedColorTable[] sharedColors)
        {
            UMA.Examples.UMARecipeMixer mixer = recipeMixers[Random.Range(0, recipeMixers.Length)];

            mixer.FillUMARecipe(umaData.umaRecipe, context);

            OverlayColorData[] recipeColors = umaData.umaRecipe.sharedColors;
            if ((recipeColors != null) && (recipeColors.Length > 0))
            {
                foreach (var sharedColor in sharedColors)
                {
                    if (sharedColor == null)
                    {
                        continue;
                    }
                    int index = Random.Range(0, sharedColor.colors.Length);
                    for (int i = 0; i < recipeColors.Length; i++)
                    {
                        if (recipeColors[i].name == sharedColor.sharedColorName)
                        {
                            recipeColors[i].color = sharedColor.colors[index].color;
                        }
                    }
                }
            }

            //This is a HACK - maybe there should be a clean way
            // of removing a conflicting slot via the recipe?
            int maleJeansIndex = -1;
            int maleLegsIndex  = -1;

            SlotData[] slots = umaData.umaRecipe.GetAllSlots();
            for (int i = 0; i < slots.Length; i++)
            {
                SlotData slot = slots[i];
                if (slot == null)
                {
                    continue;
                }
                if (slot.asset.name == null)
                {
                    continue;
                }

                if (slot.asset.slotName == "MaleJeans01")
                {
                    maleJeansIndex = i;
                }
                else if (slot.asset.slotName == "MaleLegs")
                {
                    maleLegsIndex = i;
                }
            }
            if ((maleJeansIndex >= 0) && (maleLegsIndex >= 0))
            {
                umaData.umaRecipe.SetSlot(maleLegsIndex, null);
            }
        }
コード例 #22
0
ファイル: TextureMerge.cs プロジェクト: NotYours180/UMA
		private void SetupMaterial(ref TextureMergeRect textureMergeRect, UMAData.MaterialFragment source, int textureType)
		{
			textureMergeRect.tex = source.baseTexture[textureType];
			textureMergeRect.mat.shader = (textureType == 1)? normalShader : diffuseShader;
			textureMergeRect.mat.SetTexture("_MainTex", source.baseTexture[textureType]);
			textureMergeRect.mat.SetTexture("_ExtraTex", source.baseTexture[0]);
			textureMergeRect.mat.SetColor("_Color", source.GetMultiplier(0, textureType));
			textureMergeRect.mat.SetColor("_AdditiveColor", source.GetAdditive(0, textureType));
		}
コード例 #23
0
 //When UMA has finished loaded:
 private void UMAFemaleFinished(UMAData umaData)
 {
     // and finally lets give him a sword
     HumanoidStructure.AttachmentsAdd(humanf, "Item AngelicSword 01");
     // activate his sword
     HumanoidStructure.AttachmentSetActive(humanf, "Item AngelicSword 01");
     // Update UMA
     HumanoidBuilder.Update(myumaf.name, humanf, false, false);
 }
コード例 #24
0
        static void SaveRecipe(UMAData umaData, UMAContext context)
        {
            string assetPath = AssetDatabase.GenerateUniqueAssetPath(Path.Combine(CommonNames.umaCharacterAssetPath, umaData.umaRecipe.raceData.raceName + ".asset"));
            var    asset     = ScriptableObject.CreateInstance <UMATextRecipe>();

            asset.Save(umaData.umaRecipe, context);
            AssetDatabase.CreateAsset(asset, assetPath);
            AssetDatabase.SaveAssets();
        }
コード例 #25
0
	/// <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));
	}
コード例 #26
0
        public void OnCharacterBegun(UMAData umaData)
        {
            var expressionPlayer = umaData.GetComponent <UMAExpressionPlayer>();

            if (expressionPlayer != null)
            {
                expressionPlayer.SlotUpdateVsCharacterUpdate++;
            }
        }
コード例 #27
0
 private void OnUmaCharacterCreated(UMAData data)
 {
     IsUmaCharacterCreated = true;
     ApplyPendingAvatarData();
     if (onUmaCharacterCreated != null)
     {
         onUmaCharacterCreated.Invoke();
     }
 }
コード例 #28
0
    /// <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));
    }
コード例 #29
0
        public void OnDnaApplied(UMAData umaData)
        {
            var locomotion = umaData.GetComponent <Locomotion>();

            if (locomotion == null)
            {
                umaData.gameObject.AddComponent <Locomotion>();
            }
        }
コード例 #30
0
 public void SetCharacterReadyAfterColorChange(UMAData umaData)
 {
     avatarToPhoto.CharacterUpdated.RemoveListener(SetCharacterReadyAfterColorChange);
     if (freezeAnimation)
     {
         SetAnimationFrame();
     }
     canTakePhoto = true;
 }
コード例 #31
0
        public override void UpdateUMAMesh(bool updatedAtlas, UMAData umaData, string[] textureNameList, int atlasResolution)
        {
            this.umaData = umaData;
            this.textureNameList = textureNameList;
            this.atlasResolution = atlasResolution;

            combinedMeshList = new List<SkinnedMeshCombiner.CombineInstance>();
            combinedMaterialList = new List<Material>();

            if (updatedAtlas)
            {
                CombineByShader();
            }
            else
            {
                CombineByMaterial();
            }

            if (umaData.firstBake)
            {
                umaData.myRenderer.sharedMesh = new Mesh();
            }
            else
            {
                umaData.cleanMesh(false);
            }

            var boneMap = new Dictionary<Transform, Transform>();
            SkinnedMeshCombiner.CombineMeshes(umaData.myRenderer, combinedMeshList.ToArray(), boneMap);

            if (updatedAtlas)
            {
                RecalculateUV();
            }

            umaData.umaRecipe.ClearDNAConverters();
            for (int i = 0; i < umaData.umaRecipe.slotDataList.Length; i++)
            {
                SlotData slotData = umaData.umaRecipe.slotDataList[i];
                if (slotData != null)
                {

                    umaData.EnsureBoneData(slotData.umaBoneData, slotData.animatedBones, boneMap);

                    umaData.umaRecipe.AddDNAUpdater(slotData.slotDNA);
                }
            }

            umaData.myRenderer.quality = SkinQuality.Bone4;
            //umaData.myRenderer.useLightProbes = true;
            umaData.myRenderer.sharedMaterials = combinedMaterialList.ToArray();
            //umaData.myRenderer.sharedMesh.RecalculateBounds();
            umaData.myRenderer.sharedMesh.name = "UMAMesh";

            umaData.firstBake = false;
        }
コード例 #32
0
ファイル: UMAGenerator.cs プロジェクト: jlu3389/UMA
        public virtual bool HandleDirtyUpdate(UMAData data)
        {
            umaData = data;
            if (umaData.isMeshDirty)
            {
                if (!umaData.isTextureDirty)
                {
                    UpdateUMAMesh(false);
                }
                umaData.isMeshDirty = false;
            }
            if (umaData.isTextureDirty)
            {
                if( activeGeneratorCoroutine == null )
                {
                    activeGeneratorCoroutine = umaGeneratorCoroutine;
                    TextureProcessBaseCoroutine textureProcessCoroutine;
                    if (usePRO)
                    {
                        textureProcessCoroutine = new TextureProcessPROCoroutine();
                        textureProcessCoroutine.Prepare(data, this);
                    }
                    else
                    {
                        textureProcessCoroutine = new TextureProcessIndieCoroutine();
                    }
                    activeGeneratorCoroutine.Prepare(this, umaData, textureProcessCoroutine);
                }

                if (umaGeneratorCoroutine.Work())
                {
                    activeGeneratorCoroutine = null;
                    UpdateUMAMesh(true);
                    umaData.isTextureDirty = false;
                }
                else
                {
                    return false;
                }
            }
            else if (umaData.isShapeDirty)
            {
                UpdateUMABody(umaData);
                umaData.isShapeDirty = false;

                UMAReady();
                return true;

            }
            else
            {
                UMAReady();
                return true;
            }
            return false;
        }
コード例 #33
0
 public override void OnEnter()
 {
     avatar  = ((GameObject)gameObject.Value).GetComponent <UMAAvatarBase> ();
     umaData = avatar.umaData;
     umaData.GetSlot(slotIndex).RemoveOverlay(((OverlayData)overlay.Value).overlayName);
     umaData.isShapeDirty   = true;
     umaData.isTextureDirty = true;
     umaData.Dirty();
     Finish();
 }
コード例 #34
0
ファイル: UMARecipeCrowd.cs プロジェクト: NotYours180/UMA
	void CharacterCreatedCallback(UMAData umaData)
	{
		if (hideWhileGenerating)
		{
			if (umaData.animator != null)
				umaData.animator.enabled = false;
			if (umaData.myRenderer != null)
				umaData.myRenderer.enabled = false;
		}
	}
コード例 #35
0
		void umaData_OnCharacterUpdated(UMAData umaData)
		{
			var expressionPlayer = umaData.GetComponent<UMAExpressionPlayer>();
			if (expressionPlayer.SlotUpdateVsCharacterUpdate-- == 0)
			{
				Destroy(expressionPlayer);
				umaData.CharacterUpdated.RemoveListener(new UnityAction<UMAData>(umaData_OnCharacterUpdated));
				return;
			}
		}
コード例 #36
0
ファイル: UMAGenerator.cs プロジェクト: NotYours180/UMA
 public override void addDirtyUMA(UMAData umaToAdd)
 {
     if (!gameObject.activeInHierarchy)
     {
         Debug.LogError("Adding Dirty UMA to a Generator that is not an active scene object, UMA generators must be active scene objects!", gameObject);
         Debug.LogError("UMA Data ", umaToAdd.gameObject);
         return;
     }
     base.addDirtyUMA(umaToAdd);
 }
コード例 #37
0
ファイル: UMAGenerator.cs プロジェクト: hafewa/UMA-1
 public override void addDirtyUMA(UMAData umaToAdd)
 {
     if (!gameObject.activeInHierarchy)
     {
         Debug.LogError("Adding Dirty UMA to a Generator that is not an active scene object, UMA generators must be active scene objects!", gameObject);
         Debug.LogError("UMA Data ", umaToAdd.gameObject);
         return;
     }
     base.addDirtyUMA(umaToAdd);
 }
コード例 #38
0
 public void CheckRaceChange(UMAData umaData)
 {
     if (umaData.umaRecipe.raceData)
     {
         if (umaData.umaRecipe.raceData != lastRace)
         {
             SetUpDNADelegates(umaData);
         }
     }
 }
コード例 #39
0
        void umaData_OnCharacterUpdated(UMAData umaData)
        {
            var expressionPlayer = umaData.GetComponent <UMAExpressionPlayer>();

            if (expressionPlayer.SlotUpdateVsCharacterUpdate-- == 0)
            {
                UMAUtils.DestroySceneObject(expressionPlayer);
                umaData.CharacterUpdated.RemoveListener(new UnityAction <UMAData>(umaData_OnCharacterUpdated));
                return;
            }
        }
コード例 #40
0
    /***************************************************************************
    *  Name: PlayerUpdated
    *  Description: This function is called when the object becomes enabled and active.
    *  Input: UMAData for all of the players current physical data
    *  Output: None
    ***************************************************************************/
    void PlayerUpdated(UMAData data)
    {
        //grabs the player's current DNA information
        dna = player.GetDNA();

        //gets the current value of each slider and sets them accordingly in Unity
        foreach (Transform child in sliders.transform)
        {
            child.gameObject.GetComponent <Slider>().value = dna[child.gameObject.name].Get();
        }
    }
コード例 #41
0
    void OnCreated(UMAData data)
    {
        expression = GetComponent <ExpressionPlayer>();
        expression.enableBlinking = true;
        expression.enableSaccades = true;
        //     gameObject.AddComponent<NPC>();
        connected = true;
        int rnd = Random.Range(0, 4);

        RandomMood(rnd);
    }
コード例 #42
0
ファイル: BlendShapeDnaSlider.cs プロジェクト: imerr/UMA-1
        public void OnCharacterCreated(UMAData umaData)
        {
            this.data = umaData;
            Slider slider = gameObject.GetComponent <Slider>();

            dna = umaData.GetDna(dnaTypeHash);
            if (dna != null)
            {
                slider.value = dna.GetValue(dnaEntryIndex);
            }
        }
コード例 #43
0
        private void GetUMAData(GameObject myUma)
        {
            UMAData tempUMA = myUma.GetComponent <UMAData>();

            if (tempUMA)
            {
                umaData = tempUMA;
                umaDna  = umaData.umaRecipe.GetDna <UMADnaHumanoid>();
                ReceiveValues();
            }
        }
コード例 #44
0
ファイル: UMAGeneratorBase.cs プロジェクト: jlu3389/UMA
 public static Animator CreateAnimator(UMAData umaData, UmaTPose umaTPose, RuntimeAnimatorController controller, bool applyRootMotion, bool animatePhysics, AnimatorCullingMode cullingMode)
 {
     umaTPose.DeSerialize();
     var animator = umaData.umaRoot.AddComponent<Animator>();
     animator.avatar = CreateAvatar(umaData, umaTPose);
     animator.runtimeAnimatorController = controller;
     animator.applyRootMotion = applyRootMotion;
     animator.animatePhysics = animatePhysics;
     animator.cullingMode = cullingMode;
     return animator;
 }
コード例 #45
0
    private void TextureMover(UMAData umaData)
    {
        trackedItems.Clear();
        List <RenderTextureSource> textureSources = GetRenderTextures(umaData);

        Debug.Log("RenderTextures found: " + textureSources.Count); // get rid of this after testing.
        foreach (RenderTextureSource rts in textureSources)
        {
            MoveRenderTexture(umaData, rts);
        }
    }
コード例 #46
0
ファイル: UMACrowd.cs プロジェクト: hafewa/UMA-1
    void myColliderUpdateMethod(UMAData umaData)
    {
        CapsuleCollider tempCollider = umaData.umaRoot.gameObject.GetComponent("CapsuleCollider") as CapsuleCollider;

        if (tempCollider)
        {
            UMADnaHumanoid umaDna = umaData.umaRecipe.GetDna <UMADnaHumanoid>();
            tempCollider.height = (umaDna.height + 0.5f) * 2 + 0.1f;
            tempCollider.center = new Vector3(0, tempCollider.height * 0.5f - 0.04f, 0);
        }
    }
コード例 #47
0
 public override void OnEnter()
 {
     umaData     = ((GameObject)gameObject.Value).GetComponent <UMAData> ();
     umaDna      = umaData.GetDna <UMADnaHumanoid> ();
     info        = umaDna.GetType().GetField(dna.ToString());
     store.Value = (float)info.GetValue(umaDna);
     if (!everyFrame)
     {
         Finish();
     }
 }
コード例 #48
0
        public void SubscribeToUMACreate()
        {
            // is this stuff necessary on ai characters?
            baseCharacter.MyAnimatedUnit.MyCharacterAnimator.InitializeAnimator();
            dynamicCharacterAvatar.Initialize();
            // is this stuff necessary end

            UMAData umaData = dynamicCharacterAvatar.umaData;

            umaData.OnCharacterCreated += HandleCharacterCreated;
        }
コード例 #49
0
    void GenerateUMA()
    {
        //UMA naming
        // Check a list of UMA objects.

        int umaCount = GameObject.FindGameObjectsWithTag("UMA").Length;

        UMAName = "UMA_" + umaCount.ToString();


        // Create a new game object and add UMA components to it
        GameObject GO = new GameObject("myUMA");

        GO.tag           = "UMA";
        umaDynamicAvatar = GO.AddComponent <UMADynamicAvatar>();

        // Initialise Avatar and grab a reference to it's data component
        umaDynamicAvatar.Initialize();
        umaData = umaDynamicAvatar.umaData;

        //practical guide to uma part 15 uma events https://youtu.be/_k-SZRCvgIk?t=8m20s
        umaData.OnCharacterCreated += CharacterCreatedCallback;

        // Attach our generator
        umaDynamicAvatar.umaGenerator = generator;
        umaData.umaGenerator          = generator;

        // Set up slot Array
        umaData.umaRecipe.slotDataList = new SlotData[numberOfSlots];

        // Set up our Morph reference
        umaDna         = new UMADnaHumanoid();
        umaTutorialDNA = new UMADnaTutorial();
        umaData.umaRecipe.AddDna(umaDna);
        umaData.umaRecipe.AddDna(umaTutorialDNA);

        // Grab a reference to our recipe
        // var umaRecipe = umaDynamicAvatar.umaData.umaRecipe; //moved to subroutine MakeMale

        // >>> This is whee the fun will happen according to Secret Anorak <<<<
        CreateMale();

        // dynamic animation controller
        umaDynamicAvatar.animationController = animController;

        // Generate Our UMA
        umaDynamicAvatar.UpdateNewRace();

        // parent the new uma into the host game object
        GO.transform.parent        = this.gameObject.transform;
        GO.transform.localPosition = Vector3.zero;
        GO.transform.localRotation = Quaternion.identity;
    }
コード例 #50
0
	private void SelectUMA(UMAData umaData){
		if (sliderControlList != null){
			foreach (var slider in sliderControlList){
				GameObject.Destroy(slider.gameObject);
			}
			sliderControlList = new Slider[0];
		}
		this.umaData = umaData;
		if (umaData){
			AvatarSetup();
		}
	}
コード例 #51
0
        public virtual void RandomizeDNAGaussian(UMAData umaData)
        {
            RaceData race = umaData.umaRecipe.GetRace();

            if ((race != null) && (race.dnaRanges != null))
            {
                foreach (DNARangeAsset dnaRange in race.dnaRanges)
                {
                    dnaRange.RandomizeDNAGaussian(umaData);
                }
            }
        }
コード例 #52
0
 void Update()
 {
     if (avatarDNAisDirty)
     {
         avatarDNAisDirty = false;
         UMAData umaPostDNA = tempAvatarPostDNA.GetComponent <UMADynamicAvatar>().umaData;
         if (umaPostDNA != null)
         {
             umaPostDNA.Dirty(true, false, false);
         }
     }
 }
コード例 #53
0
		public void OnCreated(UMAData umaData)
		{
			var RT = umaData.GetFirstRenderTexture();
			if( RT == null) return;
			if (allUMACharacters == null) allUMACharacters = new Dictionary<UMAData, RenderTexture>();
			allUMACharacters.Add(umaData, RT);
			anyRT = RT;
			if (!enabled)
			{
				enabled = true;
			}
		}
コード例 #54
0
        static void RandomizeDNA(UMAData umaData)
        {
            RaceData race = umaData.umaRecipe.GetRace();

            if ((race != null) && (race.dnaRanges != null))
            {
                foreach (DNARangeAsset dnaRange in race.dnaRanges)
                {
                    dnaRange.RandomizeDNA(umaData);
                }
            }
        }
コード例 #55
0
    void GenerateUMA()
    {
        // Create a new game object and add UMA components to it
        GameObject GO = new GameObject("MyUMA");

        umaDynamicAvatar = GO.AddComponent <UMADynamicAvatar>();

        // Initialise Avatar and grab a reference to it's data component
        umaDynamicAvatar.Initialize();
        umaData = umaDynamicAvatar.umaData;

        //practical guide to uma part 15 uma events https://youtu.be/_k-SZRCvgIk?t=8m20s
        umaData.OnCharacterCreated += CharacterCreatedCallback;

        // Attach our generator
        umaDynamicAvatar.umaGenerator = generator;
        umaData.umaGenerator          = generator;

        // Set up slot Array
        umaData.umaRecipe.slotDataList = new SlotData[numberOfSlots];

        // Set up our Morph reference
        umaDna         = new UMADnaHumanoid();
        umaTutorialDNA = new UMADnaTutorial();
        umaData.umaRecipe.AddDna(umaDna);
        umaData.umaRecipe.AddDna(umaTutorialDNA);

        // Grab a reference to our recipe
        // var umaRecipe = umaDynamicAvatar.umaData.umaRecipe; //moved to subroutine MakeMale

        // >>> This is whee the fun will happen according to Secret Anorak <<<<
        CreateMale();

        // dynamic animation controller
        umaDynamicAvatar.animationController = animController;

        // Generate Our UMA
        umaDynamicAvatar.UpdateNewRace();

        // parent the new uma into the host game object
        GO.transform.parent        = this.gameObject.transform;
        GO.transform.localPosition = Vector3.zero;
        GO.transform.localRotation = Quaternion.identity;
        // GO.AddComponent(typeof(Animator));
        GO.AddComponent(typeof(UnityEngine.AI.NavMeshAgent));
        GO.AddComponent(typeof(Rigidbody));
        GO.AddComponent(typeof(CapsuleCollider));
        var goCol = GO.GetComponent <CapsuleCollider>();

        goCol.center = new Vector3(0f, 0.78f, 0f);
        goCol.height = 1.7f;
        goCol.radius = 0.2f;
    }
    public static void UpdateRACFemaleDNABones(UMAData umaData, UMASkeleton skeleton)
    {
        if (RACHumanFemaleDNAConverterBehaviour.customisation == null)
            RACHumanFemaleDNAConverterBehaviour.customisation = GameObject.FindObjectOfType(typeof(RACCustomization)) as RACCustomization;

        HumanFemaleDNAConverterBehaviour.UpdateUMAFemaleDNABones (umaData, skeleton);

        List<RACModifiableControl> controls = RACHumanFemaleDNAConverterBehaviour.customisation.ControlList;

        for (int iSliderIndex = 0; iSliderIndex < controls.Count; ++iSliderIndex)
        {
            RACModifiableControl curControl = controls[iSliderIndex];

            for (int iBodyPartIndex = 0; iBodyPartIndex < curControl.modifiedBodyParts.Length; ++iBodyPartIndex)
            {
                int skeletonStringToHash = UMASkeleton.StringToHash(curControl.modifiedBodyParts[iBodyPartIndex]);

                //Get the starting information
                Vector3 startingInformation = Vector3.zero;
                if (curControl.sliderStyle == RACModifiableControl.SliderStyle.POSITION)
                {
                    startingInformation = skeleton.GetPosition(skeletonStringToHash);

                    Vector3 scale = skeleton.GetScale(skeletonStringToHash);

                    //Modify it
                    if (curControl.effectsX)
                        startingInformation.x += curControl.sliderControl.actualValue*(1/scale.x);
                    if (curControl.effectsY)
                        startingInformation.y += curControl.sliderControl.actualValue*(1/scale.y);
                    if (curControl.effectsZ)
                        startingInformation.z += curControl.sliderControl.actualValue*(1/scale.z);

                    skeleton.SetPosition(skeletonStringToHash, startingInformation);
                }
                else if (curControl.sliderStyle == RACModifiableControl.SliderStyle.SCALE)
                {
                    startingInformation = skeleton.GetScale(skeletonStringToHash);

                    //Modify it
                    if (curControl.effectsX)
                        startingInformation.x = curControl.sliderControl.actualValue;
                    if (curControl.effectsY)
                        startingInformation.y = curControl.sliderControl.actualValue;
                    if (curControl.effectsZ)
                        startingInformation.z = curControl.sliderControl.actualValue;

                    skeleton.SetScale(skeletonStringToHash, startingInformation);
                }
            }
        }
    }
コード例 #57
0
ファイル: UMAGeneratorBase.cs プロジェクト: CStudios15/UMA
        public virtual void UpdateAvatar(UMAData umaData)
        {
            if (umaData)
            {
                AnimationState[] snapshot = null;
                if (umaData.animationController)
                {
                    var animator = umaData.animator;

					bool animating = false;
                    bool applyRootMotion = false;
                    bool animatePhysics = false;
                    AnimatorCullingMode cullingMode = AnimatorCullingMode.AlwaysAnimate;

                    if (animator)
                    {
						animating = animator.enabled;
                        applyRootMotion = animator.applyRootMotion;
                        animatePhysics = animator.animatePhysics;
                        cullingMode = animator.cullingMode;
                        
						if (umaData.animationController == animator.runtimeAnimatorController)
						{
							snapshot = new AnimationState[animator.layerCount];
							for (int i = 0; i < animator.layerCount; i++)
							{
								var state = animator.GetCurrentAnimatorStateInfo(i);
								snapshot[i].stateHash = state.nameHash;
								snapshot[i].stateTime = Mathf.Max(0, state.normalizedTime - Time.deltaTime / state.length);
							}
						}
						
						Object.DestroyImmediate(animator);
                    }
                    var oldParent = umaData.umaRoot.transform.parent;
                    umaData.umaRoot.transform.parent = null;
                    animator = CreateAnimator(umaData, umaData.umaRecipe.raceData.TPose, umaData.animationController, applyRootMotion, animatePhysics, cullingMode);
                    umaData.animator = animator;
                    umaData.umaRoot.transform.parent = oldParent;
                    if (snapshot != null)
                    {
                        for (int i = 0; i < animator.layerCount; i++)
                        {
                            animator.Play(snapshot[i].stateHash, i, snapshot[i].stateTime);
                        }
                
                        animator.Update(0);
                        animator.enabled = animating;
                    }
                }
            }
        }
コード例 #58
0
ファイル: UMASimpleLOD.cs プロジェクト: argallegos/UMA-test
 public void CharacterCreated(UMAData umaData)
 {
     if (!_cameraTransform)
     {
         _cameraTransform = Camera.main.transform;
         if (!_cameraTransform)
         {
             Debug.LogError("Unable to find main camera!!!");
             return;
         }
     }
     initialized = true;
 }
コード例 #59
0
ファイル: TextureMerge.cs プロジェクト: BillDStrong/UMA
        public void SetupModule(UMAData.GeneratedMaterial atlas, int idx, int textureType)
        {
            var atlasElement = atlas.materialFragments[idx];
            if (atlasElement.isRectShared) return;

            height = Mathf.FloorToInt(atlas.cropResolution.y);
            SetupModule(atlasElement, textureType);
            resolutionScale = atlas.resolutionScale * atlasElement.slotData.overlayScale;

            for (int i2 = 0; i2 < atlasElement.overlays.Length; i2++)
            {
                SetupOverlay(atlasElement, i2, textureType);
            }
        }
コード例 #60
0
		public void OnUpdate(UMAData umaData)
		{
			if (updatingCount > 0) updatingCount--;
			var RT = umaData.GetFirstRenderTexture();
			if (RT == null) return;
			if (allUMACharacters == null) allUMACharacters = new Dictionary<UMAData, RenderTexture>();

			allUMACharacters[umaData] = RT;
			anyRT = RT;
			if (!enabled)
			{
				enabled = true;
			}
		}