コード例 #1
0
 static public int constructor(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.HumanBone o;
         o = new UnityEngine.HumanBone();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
コード例 #2
0
// fields
    static void HumanDescription_human(JSVCall vc)
    {
        if (vc.bGet)
        {
            UnityEngine.HumanDescription _this = (UnityEngine.HumanDescription)vc.csObj;
            var result = _this.human;
            var arrRet = result;
            for (int i = 0; arrRet != null && i < arrRet.Length; i++)
            {
                JSMgr.datax.setObject((int)JSApi.SetType.SaveAndTempTrace, arrRet[i]);
                JSApi.moveSaveID2Arr(i);
            }
            JSApi.setArrayS((int)JSApi.SetType.Rval, (arrRet != null ? arrRet.Length : 0), true);
        }
        else
        {
            UnityEngine.HumanBone[] arg0 = JSDataExchangeMgr.GetJSArg <UnityEngine.HumanBone[]>(() =>
            {
                int jsObjID = JSApi.getObject((int)JSApi.GetType.Arg);
                int length  = JSApi.getArrayLength(jsObjID);
                var ret     = new UnityEngine.HumanBone[length];
                for (var i = 0; i < length; i++)
                {
                    JSApi.getElement(jsObjID, i);
                    ret[i] = (UnityEngine.HumanBone)JSMgr.datax.getObject((int)JSApi.GetType.SaveAndRemove);
                }
                return(ret);
            });
            UnityEngine.HumanDescription _this = (UnityEngine.HumanDescription)vc.csObj;
            _this.human = arg0;
            JSMgr.changeJSObj(vc.jsObjID, _this);
        }
    }
コード例 #3
0
    public static void CreateAvatar()
    {
        GameObject go = Selection.activeGameObject;

        if (go != null && go.GetComponent("Animator") != null)
        {
            HumanDescription hd = new HumanDescription();

            Dictionary<string,string> boneName = new System.Collections.Generic.Dictionary<string, string>();
            boneName["Chest"] = "spine";
            boneName["Head"] = "head";
            boneName["Hips"] = "hip";
            boneName["LeftFoot"] = "footL";
            boneName["LeftHand"] = "handL";
            boneName["LeftLowerArm"] = "elbowL";
            boneName["LeftLowerLeg"] = "kneeL";
            boneName["LeftShoulder"] = "clavL";
            boneName["LeftUpperArm"] = "armL";
            boneName["LeftUpperLeg"] = "legL";
            boneName["RightFoot"] = "footR";
            boneName["RightHand"] = "handR";
            boneName["RightLowerArm"] = "elbowR";
            boneName["RightLowerLeg"] = "kneeR";
            boneName["RightShoulder"] = "clavR";
            boneName["RightUpperArm"] = "armR";
            boneName["RightUpperLeg"] = "legR";
            boneName["Spine"] = "spine2";
            string[] humanName = HumanTrait.BoneName;
            HumanBone[] humanBones = new HumanBone[boneName.Count];
            int j = 0;
            int i = 0;
            while (i < humanName.Length) {
                if (boneName.ContainsKey(humanName[i])) {
                    HumanBone humanBone = new HumanBone();
                    humanBone.humanName = humanName[i];
                    humanBone.boneName = boneName[humanName[i]];
                    humanBone.limit.useDefaultValues = true;
                    humanBones[j++] = humanBone;
                }
                i++;
            }

            hd.human = humanBones;

            //hd.skeleton = new SkeletonBone[18];
            //hd.skeleton[0].name = ("Hips") ;
            Avatar avatar = AvatarBuilder.BuildHumanAvatar(go, hd);

            avatar.name = (go.name + "_Avatar");
            Debug.Log(avatar.isHuman ? "is human" : "is generic");

            Animator animator = go.GetComponent("Animator") as Animator;
            animator.avatar = avatar;

            string path = AssetDatabase.GenerateUniqueAssetPath(Puppet2D_Editor._puppet2DPath+"/Animation/"+avatar.name+".asset");
            AssetDatabase.CreateAsset(avatar, path);

        }
    }
コード例 #4
0
ファイル: UmaTPose.cs プロジェクト: jlu3389/UMA
 private HumanBone DeSerializeHumanBone(BinaryReader br)
 {
     var res = new HumanBone();
     res.boneName = br.ReadString();
     res.humanName = br.ReadString();
     res.limit = DeSerializeHumanLimit(br);
     return res;
 }
コード例 #5
0
 static public int set_limit(IntPtr l)
 {
     UnityEngine.HumanBone  o = (UnityEngine.HumanBone)checkSelf(l);
     UnityEngine.HumanLimit v;
     checkType(l, 2, out v);
     o.limit = v;
     setBack(l, o);
     return(0);
 }
コード例 #6
0
    static public int set_humanName(IntPtr l)
    {
        UnityEngine.HumanBone o = (UnityEngine.HumanBone)checkSelf(l);
        string v;

        checkType(l, 2, out v);
        o.humanName = v;
        setBack(l, o);
        return(0);
    }
コード例 #7
0
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.HumanBone o;
			o=new UnityEngine.HumanBone();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
コード例 #8
0
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.HumanBone o;
         o=new UnityEngine.HumanBone();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
コード例 #9
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.HumanBone o;
         o = new UnityEngine.HumanBone();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #10
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.HumanBone o;
         o = new UnityEngine.HumanBone();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
コード例 #11
0
 static void HumanBone_humanName(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.HumanBone _this = (UnityEngine.HumanBone)vc.csObj;
         var result = _this.humanName;
         JSApi.setStringS((int)JSApi.SetType.Rval, result);
     }
     else
     {
         System.String         arg0  = (System.String)JSApi.getStringS((int)JSApi.GetType.Arg);
         UnityEngine.HumanBone _this = (UnityEngine.HumanBone)vc.csObj;
         _this.humanName = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
コード例 #12
0
// fields
    static void HumanBone_limit(JSVCall vc)
    {
        if (vc.bGet)
        {
            UnityEngine.HumanBone _this = (UnityEngine.HumanBone)vc.csObj;
            var result = _this.limit;
            JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
        }
        else
        {
            UnityEngine.HumanLimit arg0  = (UnityEngine.HumanLimit)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.HumanBone  _this = (UnityEngine.HumanBone)vc.csObj;
            _this.limit = arg0;
            JSMgr.changeJSObj(vc.jsObjID, _this);
        }
    }
コード例 #13
0
ファイル: UmaTPose.cs プロジェクト: NotYours180/UMA
	    private void Serialize(BinaryWriter bn, HumanBone value)
	    {
	        bn.Write(value.boneName);
	        bn.Write(value.humanName);
	        Serialize(bn, value.limit);
	    }
コード例 #14
0
ファイル: UMAGeneratorBase.cs プロジェクト: BillDStrong/UMA
		private static void SkeletonModifier(UMAData umaData, ref SkeletonBone[] bones, HumanBone[] human)
		{
//            Dictionary<Transform, Transform> animatedBones = new Dictionary<Transform,Transform>();
			Dictionary<int, Transform> animatedBones = new Dictionary<int, Transform>();
			for (var i = 0; i < umaData.animatedBones.Length; i++)
			{
//                animatedBones.Add(umaData.animatedBones[i], umaData.animatedBones[i]);
				animatedBones.Add(UMAUtils.StringToHash(umaData.animatedBones[i].name), umaData.animatedBones[i]);
			}

			for (int i = 0; i < human.Length; i++)
			{
				int boneHash = UMAUtils.StringToHash(human[i].boneName);
				animatedBones[boneHash] = null;
			}

			for (var i = 0; i < bones.Length; i++)
			{
				var skeletonbone = bones[i];
				UMAData.BoneData entry;
				int boneHash = UMAUtils.StringToHash(skeletonbone.name);
				GameObject boneGO = umaData.skeleton.GetBoneGameObject(boneHash);
				if (boneGO != null)
				{
					skeletonbone.position = boneGO.transform.localPosition;
					//skeletonbone.rotation = boneGO.transform.localRotation;
					skeletonbone.scale = boneGO.transform.localScale;
					bones[i] = skeletonbone;
					animatedBones.Remove(boneHash);
				}
			}
			bool foundSkelRoot = umaData.skeleton.HasBone(UMAUtils.StringToHash(bones[0].name));
			if ((animatedBones.Count > 0) || !foundSkelRoot)
			{
				var newBones = new List<SkeletonBone>(bones);

				if (!foundSkelRoot)
				{
					int missingBoneCount = 0;
					int rootBoneHash = 0;
					while (!foundSkelRoot)
					{
						missingBoneCount++;
						rootBoneHash = UMAUtils.StringToHash(bones[missingBoneCount].name);
						foundSkelRoot = umaData.skeleton.HasBone(rootBoneHash);
					}
					if (missingBoneCount > 0)
					{
						missingBoneCount -= 2;
						newBones.RemoveRange(0, missingBoneCount);
						var realRootBone = umaData.transform;
						var newBone = newBones[0];
						newBone.position = realRootBone.localPosition;
						newBone.rotation = realRootBone.localRotation;
						newBone.scale = realRootBone.localScale;
						newBone.name = realRootBone.name;
						newBones[0] = newBone;

						var rootBoneTransform = umaData.umaRoot.transform;
						newBone = newBones[1];
						newBone.position = rootBoneTransform.localPosition;
						newBone.rotation = rootBoneTransform.localRotation;
						newBone.scale = rootBoneTransform.localScale;
						newBone.name = rootBoneTransform.name;
						newBones[1] = newBone;
					}
				}

				// iterate original list rather than dictionary to ensure that relative order is preserved
				for (var i = 0; i < umaData.animatedBones.Length; i++)
				{
					var animatedBone = umaData.animatedBones[i];
					var animatedBoneHash = UMAUtils.StringToHash(animatedBone.name);
					if (animatedBones.ContainsKey(animatedBoneHash))
					{
						var newBone = new SkeletonBone();
						newBone.name = animatedBone.name;
						newBone.position = animatedBone.localPosition;
						newBone.rotation = animatedBone.localRotation;
						newBone.scale = animatedBone.localScale;
						newBones.Add(newBone);
					}
				}
				bones = newBones.ToArray();
			}

		}
コード例 #15
0
ファイル: UMAGeneratorBase.cs プロジェクト: NotYours180/UMA
		private static void SkeletonModifier(UMAData umaData, ref SkeletonBone[] bones, HumanBone[] human)
		{
			int missingBoneCount = 0;
			var newBones = new List<SkeletonBone>(bones.Length);

			while (!umaData.skeleton.HasBone(UMAUtils.StringToHash(bones[missingBoneCount].name)))
			{
				missingBoneCount++;
			}
			if (missingBoneCount > 0)
			{
				// force the two root transforms, reuse old bones entries to ensure any humanoid identifiers stay intact
				var realRootBone = umaData.transform;
				var newBone = bones[missingBoneCount - 2];
				newBone.position = realRootBone.localPosition;
				newBone.rotation = realRootBone.localRotation;
				newBone.scale = realRootBone.localScale;
				//				Debug.Log(newBone.name + "<-"+realRootBone.name);
				newBone.name = realRootBone.name;
				newBones.Add(newBone);

				var rootBoneTransform = umaData.umaRoot.transform;
				newBone = bones[missingBoneCount - 1];
				newBone.position = rootBoneTransform.localPosition;
				newBone.rotation = rootBoneTransform.localRotation;
				newBone.scale = rootBoneTransform.localScale;
				//				Debug.Log(newBone.name + "<-" + rootBoneTransform.name);
				newBone.name = rootBoneTransform.name;
				newBones.Add(newBone);
			}

			for (var i = missingBoneCount; i < bones.Length; i++)
			{
				var skeletonbone = bones[i];
				int boneHash = UMAUtils.StringToHash(skeletonbone.name);
				GameObject boneGO = umaData.skeleton.GetBoneGameObject(boneHash);
				if (boneGO != null)
				{
					skeletonbone.position = boneGO.transform.localPosition;
					skeletonbone.scale = boneGO.transform.localScale;
					skeletonbone.rotation = umaData.skeleton.GetTPoseCorrectedRotation(boneHash, skeletonbone.rotation);
					newBones.Add(skeletonbone);
				}
			}
			bones = newBones.ToArray();
		}
コード例 #16
0
    /// <summary>
    /// MMD用ヒューマノイドボーン作成
    /// </summary>
    /// <returns>ヒューマノイドボーン</returns>
    HumanBone[] CreateHumanBone()
    {
        System.Func<string, string, HumanBone> CreateHint = (key, value)=>{
                                                                            HumanBone human_bone = new HumanBone();
                                                                            human_bone.humanName = key;
                                                                            human_bone.boneName = value;
                                                                            human_bone.limit.useDefaultValues = true;
                                                                            return human_bone;
                                                                        };

        List<HumanBone> bone_name = new List<HumanBone>();

        //◆必須
        //△標準逸脱モデル対策

        //顔系
        //ヒューマノイドボーンは"ヒップ→背骨"のボーンを要求するが、MMDは"上半身→下半身"と接続方向が逆なのでこれらを割り当てる事は出来ない
        if (HasBone("腰")) {
            bone_name.Add(CreateHint("Hips",	"腰"		));	//ヒップ◆△
        } else {
            bone_name.Add(CreateHint("Hips",	"センター"	));	//ヒップ◆
        }
        bone_name.Add(CreateHint("Spine",		"上半身"	));	//背骨◆
        if (HasBone("胸")) {
            bone_name.Add(CreateHint("Chest",	"胸"		));	//胸△
        } else {
            bone_name.Add(CreateHint("Chest",	"上半身2"	));	//胸
        }
        bone_name.Add(CreateHint("Neck",		"首"		));	//首
        bone_name.Add(CreateHint("Head",		"頭"		));	//頭◆
        bone_name.Add(CreateHint("LeftEye",		"左目"		));	//左目
        bone_name.Add(CreateHint("RightEye",	"右目"		));	//右目
        if (HasBone("あご")) {
            bone_name.Add(CreateHint("Jaw",		"あご"		));	//あご△
        } else if (HasBone("顎")) {
            bone_name.Add(CreateHint("Jaw",		"顎"		));	//あご△
        }

        //足系
        bone_name.Add(CreateHint("LeftUpperLeg",	"左足"		));	//左脚上部◆
        bone_name.Add(CreateHint("RightUpperLeg",	"右足"		));	//右脚上部◆
        bone_name.Add(CreateHint("LeftLowerLeg",	"左ひざ"	));	//左脚◆
        bone_name.Add(CreateHint("RightLowerLeg",	"右ひざ"	));	//右脚◆
        bone_name.Add(CreateHint("LeftFoot",		"左足首"	));	//左足◆
        bone_name.Add(CreateHint("RightFoot",		"右足首"	));	//右足◆
        bone_name.Add(CreateHint("LeftToes",		"左つま先"	));	//左足指
        bone_name.Add(CreateHint("RightToes",		"右つま先"	));	//右足指

        //手系
        bone_name.Add(CreateHint("LeftShoulder",	"左肩"		));	//左肩
        bone_name.Add(CreateHint("RightShoulder",	"右肩"		));	//右肩
        bone_name.Add(CreateHint("LeftUpperArm",	"左腕"		));	//左腕上部◆
        bone_name.Add(CreateHint("RightUpperArm",	"右腕"		));	//右腕上部◆
        bone_name.Add(CreateHint("LeftLowerArm",	"左ひじ"	));	//左腕◆
        bone_name.Add(CreateHint("RightLowerArm",	"右ひじ"	));	//右腕◆
        bone_name.Add(CreateHint("LeftHand",		"左手首"	));	//左手◆
        bone_name.Add(CreateHint("RightHand",		"右手首"	));	//右手◆

        //指系
        bone_name.Add(CreateHint("Left Thumb Proximal",			"左親指1"		));	//左親指(付根)
        bone_name.Add(CreateHint("Left Thumb Intermediate",		"左親指2"		));	//左親指(間接)
        bone_name.Add(CreateHint("Left Thumb Distal",			"左親指先"		));	//左親指(先)
        bone_name.Add(CreateHint("Left Index Proximal",			"左人指1"		));	//左人差し指(付根)
        bone_name.Add(CreateHint("Left Index Intermediate",		"左人指2"		));	//左人差し指(間接)
        if (HasBone("左人指先")) {
            bone_name.Add(CreateHint("Left Index Distal",		"左人指先"		));	//左人差し指(先)△
        } else {
            bone_name.Add(CreateHint("Left Index Distal",		"左人差指先"	));	//左人差し指(先)
        }
        bone_name.Add(CreateHint("Left Middle Proximal",		"左中指1"		));	//左中指(付根)
        bone_name.Add(CreateHint("Left Middle Intermediate",	"左中指2"		));	//左中指(間接)
        bone_name.Add(CreateHint("Left Middle Distal",			"左中指先"		));	//左中指(先)
        bone_name.Add(CreateHint("Left Ring Proximal",			"左薬指1"		));	//左薬指(付根)
        bone_name.Add(CreateHint("Left Ring Intermediate",		"左薬指2"		));	//左薬指(間接)
        bone_name.Add(CreateHint("Left Ring Distal",			"左薬指先"		));	//左薬指(先)
        bone_name.Add(CreateHint("Left Little Proximal",		"左小指1"		));	//左小指(付根)
        bone_name.Add(CreateHint("Left Little Intermediate",	"左小指2"		));	//左小指(間接)
        bone_name.Add(CreateHint("Left Little Distal",			"左小指先"		));	//左小指(先)
        bone_name.Add(CreateHint("Right Thumb Proximal",		"右親指1"		));	//右親指(付根)
        bone_name.Add(CreateHint("Right Thumb Intermediate",	"右親指2"		));	//右親指(間接)
        bone_name.Add(CreateHint("Right Thumb Distal",			"右親指先"		));	//右親指(先)
        bone_name.Add(CreateHint("Right Index Proximal",		"右人指1"		));	//右人差し指(付根)
        bone_name.Add(CreateHint("Right Index Intermediate",	"右人指2"		));	//右人差し指(間接)
        if (HasBone("右人指先")) {
            bone_name.Add(CreateHint("Right Index Distal",		"右人指先"		));	//右人差し指(先)△
        } else {
            bone_name.Add(CreateHint("Right Index Distal",		"右人差指先"	));	//右人差し指(先)
        }
        bone_name.Add(CreateHint("Right Middle Proximal",		"右中指1"		));	//右中指(付根)
        bone_name.Add(CreateHint("Right Middle Intermediate",	"右中指2"		));	//右中指(間接)
        bone_name.Add(CreateHint("Right Middle Distal",			"右中指先"		));	//右中指(先)
        bone_name.Add(CreateHint("Right Ring Proximal",			"右薬指1"		));	//右薬指(付根)
        bone_name.Add(CreateHint("Right Ring Intermediate",		"右薬指2"		));	//右薬指(間接)
        bone_name.Add(CreateHint("Right Ring Distal",			"右薬指先"		));	//右薬指(先)
        bone_name.Add(CreateHint("Right Little Proximal",		"右小指1"		));	//右小指(付根)
        bone_name.Add(CreateHint("Right Little Intermediate",	"右小指2"		));	//右小指(間接)
        bone_name.Add(CreateHint("Right Little Distal",			"右小指先"		));	//右小指(先)

        return bone_name.Where(x=>!string.IsNullOrEmpty(x.boneName)).ToArray();
    }
コード例 #17
0
 static int _CreateHumanBone(IntPtr L)
 {
     LuaScriptMgr.CheckArgsCount(L, 0);
     HumanBone obj = new HumanBone();
     LuaScriptMgr.PushValue(L, obj);
     return 1;
 }
コード例 #18
0
 static public int get_humanName(IntPtr l)
 {
     UnityEngine.HumanBone o = (UnityEngine.HumanBone)checkSelf(l);
     pushValue(l, o.humanName);
     return(1);
 }
コード例 #19
0
 static public int get_limit(IntPtr l)
 {
     UnityEngine.HumanBone o = (UnityEngine.HumanBone)checkSelf(l);
     pushValue(l, o.limit);
     return(1);
 }