private void DrawTwist() { if (null == mAppearData) { return; } GUILayout.BeginVertical(); for (int i = 0; i < (int)EMorphItem.Max; i++) { if (i == (int)EMorphItem.LegBelly || i == (int)EMorphItem.LegWaist || i == (int)EMorphItem.Foot || i == (int)EMorphItem.Hand || i == (int)EMorphItem.TorsoUpperLeg) { continue; } GUILayout.BeginHorizontal(); EMorphItem eItem = (EMorphItem)i; GUILayout.Label(eItem.ToString()); float weight = mAppearData.GetWeight(eItem); float newWeight = GUILayout.HorizontalSlider(weight, -1f, 1f); if (!Mathf.Approximately(weight, newWeight)) { mAppearData.SetWeight(eItem, newWeight); Apply(); } GUILayout.EndHorizontal(); } DrawBuild(); GUILayout.EndVertical(); }
public void SetWeight(EMorphItem eMorphItem, float weight) { if (eMorphItem == EMorphItem.LegBelly || eMorphItem == EMorphItem.LegWaist || eMorphItem == EMorphItem.Foot || eMorphItem == EMorphItem.Hand || eMorphItem == EMorphItem.TorsoUpperLeg) { return; } mMorphWeightArray[(int)eMorphItem] = Mathf.Clamp(weight, -1f, 1f); if (eMorphItem == EMorphItem.Belly) { mMorphWeightArray[(int)EMorphItem.LegBelly] = mMorphWeightArray[(int)EMorphItem.Belly]; } if (eMorphItem == EMorphItem.Waist) { mMorphWeightArray[(int)EMorphItem.LegWaist] = mMorphWeightArray[(int)EMorphItem.Waist]; } if (eMorphItem == EMorphItem.LowerLeg) { mMorphWeightArray[(int)EMorphItem.Foot] = mMorphWeightArray[(int)EMorphItem.LowerLeg]; } if (eMorphItem == EMorphItem.LowerArm) { mMorphWeightArray[(int)EMorphItem.Hand] = mMorphWeightArray[(int)EMorphItem.LowerArm]; } if (eMorphItem == EMorphItem.UpperLeg) { mMorphWeightArray[(int)EMorphItem.TorsoUpperLeg] = mMorphWeightArray[(int)EMorphItem.UpperLeg]; } }
public float GetWeight(EMorphItem eMorphItem) { return(Mathf.Clamp(mMorphWeightArray[(int)eMorphItem] + mSubMorphWeightArray[(int)eMorphItem], -1f, 1f)); }
static Mesh BakeToMesh(CustomPartInfo partInfo, AppearData appearData) { SkinnedMeshRenderer smr = partInfo.Smr; if (string.IsNullOrEmpty(partInfo.ModelName) || smr.sharedMesh.blendShapeCount == 0) { return(smr.sharedMesh); } EMorphItem indexStart = EMorphItem.Max; EMorphItem indexEnd = EMorphItem.Max; if (partInfo.ModelName.Contains("head")) { indexStart = EMorphItem.MinFace; indexEnd = EMorphItem.MaxFace; } else if (partInfo.ModelName.Contains("torso")) { indexStart = EMorphItem.MinUpperbody; indexEnd = EMorphItem.MaxUpperbody; } else if (partInfo.ModelName.Contains("legs")) { indexStart = EMorphItem.MinLowerbody; indexEnd = EMorphItem.MaxLowerbody; } else if (partInfo.ModelName.Contains("feet")) { indexStart = EMorphItem.MinFoot; indexEnd = EMorphItem.MaxFoot; } else if (partInfo.ModelName.Contains("hand")) { indexStart = EMorphItem.MinHand; indexEnd = EMorphItem.MaxHand; } if (indexStart != indexEnd) { _tmpWeightIdxs.Clear(); _tmpWeightVals.Clear(); for (int i = (int)indexStart; i < (int)indexEnd; i++) { float w = appearData.GetWeight((EMorphItem)i) * 100f; int index = i - (int)indexStart; if (w > 0f) { index = index * 2; } else { w = -w; index = index * 2 + 1; } if (smr.sharedMesh.blendShapeCount > index) { _tmpWeightIdxs.Add(index); _tmpWeightVals.Add(smr.GetBlendShapeWeight(index)); smr.SetBlendShapeWeight(index, w); } } Mesh msh = PeekTmpMesh(); smr.BakeMesh(msh); msh.boneWeights = smr.sharedMesh.boneWeights; msh.bindposes = smr.sharedMesh.bindposes; if (_tmpWeightIdxs.Count > 0) { for (int i = 0; i < _tmpWeightIdxs.Count; i++) { smr.SetBlendShapeWeight(_tmpWeightIdxs[i], _tmpWeightVals[i]); } } return(msh); } return(smr.sharedMesh); }
public ScrollItem(UIScrollBar bar, EMorphItem type) { mScrollBar = bar; mType = type; }