|
@@ -15,6 +15,7 @@ namespace MetaClient
|
|
|
public RoleCustomData bodyData;
|
|
|
public const float valueFloating = 1f;
|
|
|
public CustomRoleController testPlayer = null;
|
|
|
+ public Dictionary<string, Transform> bones = new Dictionary<string, Transform>();
|
|
|
|
|
|
private void Awake()
|
|
|
{
|
|
@@ -25,6 +26,13 @@ namespace MetaClient
|
|
|
{
|
|
|
GameEntry.Event.Subscribe(CustomRoleBodyEventArgs.EventId, UpdateBody);
|
|
|
|
|
|
+ CreateCustomBodyData();
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 生成玩家自定义数据信息
|
|
|
+ /// </summary>
|
|
|
+ public void CreateCustomBodyData()
|
|
|
+ {
|
|
|
testPlayer = GameObject.Find("标准女").GetComponent<CustomRoleController>();
|
|
|
|
|
|
bodyData = new RoleCustomData();
|
|
@@ -33,22 +41,59 @@ namespace MetaClient
|
|
|
DRCustomBody[] dtCB = drCB.GetAllDataRows();
|
|
|
for (int i = 0; i < dtCB.Length; i++)
|
|
|
{
|
|
|
- bodyData.bodyList.Add(dtCB[i].Id, new PartData(dtCB[i].Id,(EditableBodyPart)dtCB[i].Part, (ModifyType)dtCB[i].ModifyType));
|
|
|
+ var partData = new PartData(
|
|
|
+ dtCB[i].Id,
|
|
|
+ dtCB[i].BoneName.Split(','),
|
|
|
+ dtCB[i].ScaleRangeMin,
|
|
|
+ dtCB[i].ScaleRangeMax,
|
|
|
+ dtCB[i].ScaleChange,
|
|
|
+ dtCB[i].PositionChange,
|
|
|
+ dtCB[i].RotationChange
|
|
|
+ );
|
|
|
+ bodyData.bodyList.Add(dtCB[i].Id, partData);
|
|
|
}
|
|
|
|
|
|
- //初始缩放
|
|
|
- testPlayer.GetNormalAniBonesScale(ref bodyData.orginLocalScaleList);
|
|
|
- testPlayer.GetExtraAniBonesScale(ref bodyData.orginLocalScaleList, EditableBodyPart.Chest);
|
|
|
- testPlayer.GetExtraAniBonesScale(ref bodyData.orginLocalScaleList, EditableBodyPart.UpperArmUp);
|
|
|
- testPlayer.GetExtraAniBonesScale(ref bodyData.orginLocalScaleList, EditableBodyPart.UpperArmDown);
|
|
|
- testPlayer.GetExtraAniBonesScale(ref bodyData.orginLocalScaleList, EditableBodyPart.UpperLegUp);
|
|
|
- testPlayer.GetExtraAniBonesScale(ref bodyData.orginLocalScaleList, EditableBodyPart.UpperLegDown);
|
|
|
- testPlayer.GetExtraAniBonesScale(ref bodyData.orginLocalScaleList, EditableBodyPart.LowerLegUp);
|
|
|
- testPlayer.GetExtraAniBonesScale(ref bodyData.orginLocalScaleList, EditableBodyPart.LowerLegDown);
|
|
|
- //初始位置
|
|
|
- testPlayer.GetExtraAniBonesPosition(ref bodyData.orginLocalPositionList, EditableBodyPart.Chest);
|
|
|
- //初始旋转
|
|
|
- testPlayer.GetExtraAniBonesRotate(ref bodyData.orginLocalRotationList, EditableBodyPart.Chest);
|
|
|
+ bones.Clear();
|
|
|
+ foreach (var item in bodyData.bodyList)
|
|
|
+ {
|
|
|
+ var key = item.Key;
|
|
|
+ var value = item.Value;
|
|
|
+ for (int i = 0; i < value.bones.Length; i++)
|
|
|
+ {
|
|
|
+ var transform = CustomRoleUtility.GetChild(testPlayer.transform, value.bones[i]);
|
|
|
+ if(!transform)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(!bones.ContainsKey(value.bones[i]))
|
|
|
+ {
|
|
|
+ bones.Add(value.bones[i], transform);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Debug.Log( "一共有"+ bones.Count + "部位的骨骼自定义修改");
|
|
|
+
|
|
|
+ //获取自定义骨骼的初始数据
|
|
|
+ foreach (var item in bones)
|
|
|
+ {
|
|
|
+ var key = item.Key;
|
|
|
+ var value = item.Value;
|
|
|
+ bodyData.orginLocalScaleList.Add(key, value.localScale);
|
|
|
+ }
|
|
|
+
|
|
|
+ ////初始缩放
|
|
|
+ //testPlayer.GetNormalAniBonesScale(ref bodyData.orginLocalScaleList);
|
|
|
+ //testPlayer.GetExtraAniBonesScale(ref bodyData.orginLocalScaleList, EditableBodyPart.Chest);
|
|
|
+ //testPlayer.GetExtraAniBonesScale(ref bodyData.orginLocalScaleList, EditableBodyPart.UpperArmUp);
|
|
|
+ //testPlayer.GetExtraAniBonesScale(ref bodyData.orginLocalScaleList, EditableBodyPart.UpperArmDown);
|
|
|
+ //testPlayer.GetExtraAniBonesScale(ref bodyData.orginLocalScaleList, EditableBodyPart.UpperLegUp);
|
|
|
+ //testPlayer.GetExtraAniBonesScale(ref bodyData.orginLocalScaleList, EditableBodyPart.UpperLegDown);
|
|
|
+ //testPlayer.GetExtraAniBonesScale(ref bodyData.orginLocalScaleList, EditableBodyPart.LowerLegUp);
|
|
|
+ //testPlayer.GetExtraAniBonesScale(ref bodyData.orginLocalScaleList, EditableBodyPart.LowerLegDown);
|
|
|
+ ////初始位置
|
|
|
+ //testPlayer.GetExtraAniBonesPosition(ref bodyData.orginLocalPositionList, EditableBodyPart.Chest);
|
|
|
+ ////初始旋转
|
|
|
+ //testPlayer.GetExtraAniBonesRotate(ref bodyData.orginLocalRotationList, EditableBodyPart.Chest);
|
|
|
}
|
|
|
|
|
|
public void Clear()
|
|
@@ -61,51 +106,73 @@ namespace MetaClient
|
|
|
CustomRoleBodyEventArgs crf = (CustomRoleBodyEventArgs)e;
|
|
|
if (crf != null)
|
|
|
{
|
|
|
+
|
|
|
//更新数据
|
|
|
- IDataTable<DRCustomBody> drCB = GameEntry.DataTable.GetDataTable<DRCustomBody>();
|
|
|
- var formData = drCB.GetDataRow(crf.Part);
|
|
|
- if(formData == null)
|
|
|
+ var partData = bodyData.bodyList[crf.Part];
|
|
|
+ if(partData == null)
|
|
|
{
|
|
|
- Debug.LogError(crf.Part + ": 表里不存在此行数据");
|
|
|
+ Debug.LogError("ID :" + crf.Part + " 无数据");
|
|
|
return;
|
|
|
}
|
|
|
- bodyData.bodyList[crf.Part].floatValue = 1 + (crf.ChangeValue.x - 0.5f) * valueFloating;
|
|
|
-
|
|
|
- //通过更新的数据更新骨骼缩放
|
|
|
- if (testPlayer != null)
|
|
|
+ if(crf.ChangeValue.x == 0.5f)
|
|
|
{
|
|
|
- switch ((ModifyType)formData.ModifyType)
|
|
|
+ partData.floatValue = 1;
|
|
|
+ }
|
|
|
+ if(crf.ChangeValue.x < 0.5f)
|
|
|
+ {
|
|
|
+ partData.floatValue = partData.minChangeValue + (1 - partData.minChangeValue) * (crf.ChangeValue.x/0.5f);
|
|
|
+ }
|
|
|
+ if(crf.ChangeValue.x > 0.5f)
|
|
|
+ {
|
|
|
+ partData.floatValue = 1 + (partData.maxChangeValue - 1) * ((crf.ChangeValue.x - 0.5f)/0.5f);
|
|
|
+ }
|
|
|
+ Debug.Log(crf.Part + " : " + crf.ChangeValue + " 转换后 :" + partData.floatValue);
|
|
|
+ if (partData.scaleChange != Vector3.zero)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < partData.bones.Length; i++)
|
|
|
{
|
|
|
- case ModifyType.Length:
|
|
|
- testPlayer.UpdateBoneScale((EditableBodyPart)formData.Part, new Vector3(0, 0, 1), formData.IsKeepChildrenScale, bodyData.bodyList[crf.Part].floatValue);
|
|
|
- break;
|
|
|
- case ModifyType.Width:
|
|
|
- testPlayer.UpdateBoneScale((EditableBodyPart)formData.Part, new Vector3(0, 1, 0), formData.IsKeepChildrenScale, bodyData.bodyList[crf.Part].floatValue);
|
|
|
- break;
|
|
|
- case ModifyType.Thick:
|
|
|
- testPlayer.UpdateBoneScale((EditableBodyPart)formData.Part, new Vector3(1, 0, 0), formData.IsKeepChildrenScale, bodyData.bodyList[crf.Part].floatValue);
|
|
|
- break;
|
|
|
- case ModifyType.LengthWidthThick:
|
|
|
- testPlayer.UpdateBoneScale((EditableBodyPart)formData.Part, new Vector3(1, 1, 1), formData.IsKeepChildrenScale, bodyData.bodyList[crf.Part].floatValue);
|
|
|
- break;
|
|
|
- case ModifyType.Angle:
|
|
|
- break;
|
|
|
- case ModifyType.UpDown:
|
|
|
- break;
|
|
|
- case ModifyType.LeftRight:
|
|
|
- break;
|
|
|
- case ModifyType.ForwardBehind:
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
+ var orginBoneScale = bodyData.orginLocalScaleList[partData.bones[i]];
|
|
|
+ var bone = bones[partData.bones[i]];
|
|
|
+
|
|
|
+ var nowBone = bones[partData.bones[i]];
|
|
|
+ var nowScale = new Vector3(nowBone.localScale.x/orginBoneScale.x, nowBone.localScale.y / orginBoneScale.y, nowBone.localScale.z / orginBoneScale.z);
|
|
|
+ //var newBoneScale = new Vector3(orginBoneScale.x * (partData.scaleChange.x == 1 ? partData.floatValue : 1) * nowScale.x, orginBoneScale.y * (partData.scaleChange.y == 1 ? partData.floatValue : 1) * nowScale.y, orginBoneScale.z * (partData.scaleChange.z == 1 ? partData.floatValue : 1) * nowScale.y);
|
|
|
+
|
|
|
+ var newBoneScale = new Vector3(
|
|
|
+ partData.scaleChange.x == 1 ? partData.floatValue * orginBoneScale.x : nowBone.localScale.x,
|
|
|
+ partData.scaleChange.y == 1 ? partData.floatValue * orginBoneScale.y : nowBone.localScale.y,
|
|
|
+ partData.scaleChange.z == 1 ? partData.floatValue * orginBoneScale.z : nowBone.localScale.z
|
|
|
+ );
|
|
|
+
|
|
|
+ Debug.Log("newBoneScale : " + newBoneScale);
|
|
|
+ bodyData.changedScaleList[partData.bones[i]] = newBoneScale;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ RefreshRole();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public float GetBodyBoneValue(int id)
|
|
|
{
|
|
|
- return 0.5f + (bodyData.bodyList[id].floatValue - 1) / valueFloating;
|
|
|
+ Debug.Log(id +": GetBodyBoneValue + " + bodyData.bodyList[id].scaleChange + " " + bodyData.bodyList[id].floatValue);
|
|
|
+ if (bodyData.bodyList[id].scaleChange.x == 1 || bodyData.bodyList[id].scaleChange.y == 1 || bodyData.bodyList[id].scaleChange.z == 1)
|
|
|
+ {
|
|
|
+ if (bodyData.bodyList[id].floatValue == 1)
|
|
|
+ {
|
|
|
+ return 0.5f;
|
|
|
+ }
|
|
|
+ if (bodyData.bodyList[id].floatValue < 1)
|
|
|
+ {
|
|
|
+ return (bodyData.bodyList[id].floatValue - bodyData.bodyList[id].minChangeValue) / (1 - bodyData.bodyList[id].minChangeValue)/2;
|
|
|
+ }
|
|
|
+ if (bodyData.bodyList[id].floatValue > 1)
|
|
|
+ {
|
|
|
+ return 0.5f + (bodyData.bodyList[id].floatValue - 1) / (bodyData.bodyList[id].maxChangeValue - 1)/2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0.5f;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 重置角色数据
|
|
@@ -131,7 +198,8 @@ namespace MetaClient
|
|
|
{
|
|
|
var key = item.Key;
|
|
|
var value = item.Value;
|
|
|
- testPlayer.SetBoneScale(key, value);
|
|
|
+ //testPlayer.SetBoneScale(key, value);
|
|
|
+ testPlayer.SetBoneWorldScale(key, value);
|
|
|
}
|
|
|
|
|
|
//重置旋转
|
|
@@ -150,5 +218,39 @@ namespace MetaClient
|
|
|
testPlayer.SetBonePos(key, value);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public void RefreshRole()
|
|
|
+ {
|
|
|
+ if (testPlayer == null)
|
|
|
+ {
|
|
|
+ Debug.LogError("没有模型存在");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Debug.Log("刷新模型");
|
|
|
+
|
|
|
+ //刷新缩放
|
|
|
+ //foreach (var item in bodyData.orginLocalScaleList)
|
|
|
+ //{
|
|
|
+ // var key = item.Key;
|
|
|
+ // var value = item.Value;
|
|
|
+
|
|
|
+ // if(bodyData.changedScaleList.ContainsKey(key))
|
|
|
+ // {
|
|
|
+ // testPlayer.SetBoneScale(key, bodyData.changedScaleList[key]);
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // testPlayer.SetBoneScale(key, value);
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+
|
|
|
+ foreach (var item in bodyData.changedScaleList)
|
|
|
+ {
|
|
|
+ var key = item.Key;
|
|
|
+ var value = item.Value;
|
|
|
+
|
|
|
+ testPlayer.SetBoneScale(key, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|