// Show Window
        //------------------------------------------------------------------
        public static object ShowDialog(apEditor editor, apBone bone, FUNC_DUPLICATE_BONE_RESULT funcResult)
        {
            CloseDialog();

            if (editor == null || editor._portrait == null || editor._portrait._controller == null || bone == null || funcResult == null)
            {
                return(null);
            }

            EditorWindow           curWindow = EditorWindow.GetWindow(typeof(apDialog_DuplicateBone), true, "Duplicate", true);
            apDialog_DuplicateBone curTool   = curWindow as apDialog_DuplicateBone;

            object loadKey = new object();

            if (curTool != null && curTool != s_window)
            {
                int width  = 300;
                int height = 150;
                s_window          = curTool;
                s_window.position = new Rect((editor.position.xMin + editor.position.xMax) / 2 - (width / 2),
                                             (editor.position.yMin + editor.position.yMax) / 2 - (height / 2),
                                             width, height);

                s_window.Init(editor, bone, loadKey, funcResult);

                return(loadKey);
            }
            else
            {
                return(null);
            }
        }
        //2레벨 이내의 연결된 본들인가?
        private static bool IsIn2LevelLinkedBone(apBone boneA, apBone boneB)
        {
            if (boneA == null || boneB == null)
            {
                return(false);
            }
            if (boneA == boneB)
            {
                return(true);
            }
            apBone parentA_1 = boneA._parentBone;
            apBone parentA_2 = (parentA_1 != null ? parentA_1._parentBone : null);
            apBone parentB_1 = boneB._parentBone;
            apBone parentB_2 = (parentB_1 != null ? parentB_1._parentBone : null);

            if (parentA_1 != null && parentA_1 == boneB)
            {
                return(true);
            }
            if (parentA_2 != null && parentA_2 == boneB)
            {
                return(true);
            }
            if (parentB_1 != null && parentB_1 == boneA)
            {
                return(true);
            }
            if (parentB_2 != null && parentB_2 == boneA)
            {
                return(true);
            }

            return(false);
        }
 // Init
 //----------------------------------------------
 public apRetargetSubUnit()
 {
     _isImported               = false;
     _targetMeshTransform      = null;
     _targetMeshGroupTransform = null;
     _targetBone               = null;
 }
        // Functions
        //-----------------------------------------------------
        public void SetPose(apMeshGroup targetMeshGroup, apBone selectedBone, string sceneName)
        {
            Clear();

            _poseName          = "<No Name Pose>";
            _description       = "<No Description>";
            _sceneName         = sceneName;
            _portraitName      = targetMeshGroup._parentPortrait.name;
            _meshGroupName     = targetMeshGroup._name;
            _meshGroupUniqueID = targetMeshGroup._uniqueID;

            List <apBone> rootBones = new List <apBone>();

            for (int i = 0; i < targetMeshGroup._boneList_Root.Count; i++)
            {
                rootBones.Add(targetMeshGroup._boneList_Root[i]);
            }

            rootBones.Sort(delegate(apBone a, apBone b)
            {
                return(b._depth - a._depth);
            });

            int curUnitID = 0;

            for (int i = 0; i < rootBones.Count; i++)
            {
                curUnitID = SetBonesRecursive(rootBones[i], selectedBone, curUnitID);
            }

            //for (int i = 0; i < targetMeshGroup._boneList_All.Count; i++)
            //{
            //	apBone srcBone = targetMeshGroup._boneList_All[i];

            //	apRetargetBonePoseUnit dstPoseBone = new apRetargetBonePoseUnit();

            //	dstPoseBone.SetBone(i, srcBone);

            //	if(selectedBone == srcBone)
            //	{
            //		//이건 일단 Export를 건다
            //		dstPoseBone._isExported = true;

            //	}
            //	_bones.Add(dstPoseBone);
            //}

            //Sort를 하자
            //_bones.Sort(delegate (apRetargetBonePoseUnit a, apRetargetBonePoseUnit b)
            //{
            //	if (a._targetBone._level == b._targetBone._level)
            //	{
            //		return b._targetBone._depth - a._targetBone._depth;
            //	}

            //	return a._targetBone._level * 1000 - b._targetBone._level * 1000;

            //	//return b._targetBone._depth - a._targetBone._depth;
            //});
        }
            public void LinkEnvelopeInfo(Dictionary <apBone, EnvelopeInfo> bone2EnvInfo)
            {
                _linkedEnvInfo_ToStart.Clear();
                _linkedEnvInfo_ToEnd.Clear();

                //Debug.LogError("Linked Env List : [" + _bone._name + "]");
                //Debug.LogWarning(">> Start");

                //"연결된 본" 정보를 기준으로 "연결된 EnvelopeInfo"도 만들자.
                apBone linkedBone = null;

                for (int i = 0; i < _linkedBone_ToStart.Count; i++)
                {
                    linkedBone = _linkedBone_ToStart[i];
                    if (bone2EnvInfo.ContainsKey(linkedBone))
                    {
                        _linkedEnvInfo_ToStart.Add(bone2EnvInfo[linkedBone]);

                        //Debug.Log("- " + linkedBone._name);
                    }
                }

                //Debug.LogWarning(">> End");
                for (int i = 0; i < _linkedBone_ToEnd.Count; i++)
                {
                    linkedBone = _linkedBone_ToEnd[i];
                    if (bone2EnvInfo.ContainsKey(linkedBone))
                    {
                        _linkedEnvInfo_ToEnd.Add(bone2EnvInfo[linkedBone]);

                        //Debug.Log("- " + linkedBone._name);
                    }
                }
            }
Esempio n. 6
0
        private void AddBoneUnit(apBone bone)
        {
            BoneUnit boneUnit = new BoneUnit(bone, true, false, null, 0);

            _boneUnits.Add(boneUnit);
            _boneUnits_Root.Add(boneUnit);
        }
Esempio n. 7
0
        ///// <summary>
        ///// Rigging Modifier를 제외한 Modifier에서 실제 Mod값을 변경한다.
        ///// 회전값을 수정한다.
        ///// IK의 영향을 받지 않는다.
        ///// </summary>
        ///// <param name="deltaAngleW"></param>
        //public void Rotate__Bone_Modifier(float deltaAngleW)
        //{
        //	if(Editor.Select.MeshGroup == null
        //		|| Editor.Select.Bone == null
        //		|| !Editor._isBoneGUIVisible
        //		|| Editor.Select.Modifier == null //<<Modifier가 null이면 안된다.
        //		|| deltaAngleW == 0.0f
        //		)
        //	{
        //		return;
        //	}

        //	apBone bone = Editor.Select.Bone;
        //	apMeshGroup meshGroup = Editor.Select.MeshGroup;
        //	apMeshGroup boneParentMeshGroup = bone._meshGroup;//Bone이 속한 MeshGroup. 다를 수 있다.
        //	apModifierBase modifier = Editor.Select.Modifier;//선택한 Modifier

        //	if(modifier.ModifierType != apModifierBase.MODIFIER_TYPE.Rigging)
        //	{
        //		//리깅 Modifier가 아니라면 패스
        //		return;
        //	}

        //	//Editing 상태가 아니면 패스 + ModMesh가 없다면 패스
        //	if (Editor.Select.ExEditingMode == apSelection.EX_EDIT.None || Editor.Select.ExValue_ModMesh == null || Editor.Select.ExKey_ModParamSet == null)
        //	{
        //		return;
        //	}

        //	apModifiedMesh targetModMesh = Editor.Select.ExValue_ModMesh;

        //	//TODO..
        //}


        ///// <summary>
        ///// AnimClip 수정 중에 현재 AnimKeyFrame의 ModMesh값을 수정한다.
        ///// 회전값을 수정한다.
        ///// IK의 영향을 받지 않는다.
        ///// </summary>
        ///// <param name="deltaAngleW"></param>
        //public void Rotate__Bone_Animation(float deltaAngleW)
        //{
        //	if (Editor.Select.AnimClip == null
        //		|| Editor.Select.AnimClip._targetMeshGroup == null
        //		|| deltaAngleW == 0.0f)
        //	{
        //		return;
        //	}

        //	apModifierBase linkedModifier = Editor.Select.AnimTimeline._linkedModifier;
        //	apAnimKeyframe workKeyframe = Editor.Select.AnimWorkKeyframe;
        //	apModifiedMesh targetModMesh = Editor.Select.ModMeshOfAnim;
        //	apRenderUnit targetRenderUnit = Editor.Select.RenderUnitOfAnim;

        //	if (linkedModifier == null || workKeyframe == null || targetModMesh == null || targetRenderUnit == null)
        //	{
        //		//수정할 타겟이 없다.
        //		return;
        //	}

        //	if (targetModMesh._transform_Mesh == null && targetModMesh._transform_MeshGroup == null)
        //	{
        //		//대상이 되는 Mesh/MeshGroup이 없다?
        //		return;
        //	}

        //	if (!Editor.Select.IsAnimEditing || Editor.Select.IsAnimPlaying)
        //	{
        //		//에디팅 중이 아니다.
        //		return;
        //	}

        //	//보이는게 없는데 수정하려고 한다;
        //	if(!Editor._isBoneGUIVisible || Editor.Select.Bone == null)
        //	{
        //		return;
        //	}

        //	apBone bone = Editor.Select.Bone;
        //	apMeshGroup meshGroup = Editor.Select.MeshGroup;
        //	apMeshGroup boneParentMeshGroup = bone._meshGroup;//Bone이 속한 MeshGroup. 다를 수 있다.
        //	apModifierBase modifier = Editor.Select.Modifier;//선택한 Modifier

        //	//TODO..
        //}
        #endregion


        //------------------------------------------------------------------------------------------------------------
        // Bone - Scale (Default / Rigging Test / Modifier / AnimClip Modifier)
        // Scale은 IK와 관계가 없다. 값을 수정하자!
        // Scale은 옵션을 On으로 둔 Bone만 가능하다. 옵션 확인할 것
        //------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// MeshGroup 메뉴에서 Bone의 Default 편집 중의 스케일
        /// Edit Mode가 Select로 활성화되어있어야 한다.
        /// 선택한 Bone이 현재 선택한 MeshGroup에 속해있어야 한다.
        /// IK의 영향을 받지 않는다.
        /// </summary>
        /// <param name="deltaScaleW"></param>
        public void Scale__Bone_Default(Vector2 deltaScaleW)
        {
            if (Editor.Select.MeshGroup == null ||
                Editor.Select.Bone == null ||
                Editor._boneGUIRenderMode != apEditor.BONE_RENDER_MODE.Render ||
                Editor.Select.BoneEditMode != apSelection.BONE_EDIT_MODE.SelectAndTRS ||
                deltaScaleW.sqrMagnitude == 0.0f
                )
            {
                return;
            }

            apBone      bone      = Editor.Select.Bone;
            apMeshGroup meshGroup = Editor.Select.MeshGroup;

            if (bone._meshGroup != meshGroup)
            {
                //직접 속하지 않고 자식 MeshGroup의 Transform인 경우 제어할 수 없다.
                return;
            }

            apEditorUtil.SetRecord(apUndoGroupData.ACTION.MeshGroup_BoneDefaultEdit, bone._meshGroup, null, false, Editor);

            Vector3 prevScale = bone._defaultMatrix._scale;
            Vector2 nextScale = new Vector2(prevScale.x + deltaScaleW.x, prevScale.y + deltaScaleW.y);

            bone._defaultMatrix.SetScale(nextScale);
            bone.MakeWorldMatrix(true);
            bone.GUIUpdate(true);
        }
Esempio n. 8
0
        private apBone CheckBoneClick(apBone targetBone, Vector2 mousePosW, Vector2 mousePosGL, bool isDrawBoneOutline)
        {
            apBone resultBone = null;
            apBone bone       = null;

            //Child가 먼저 렌더링되므로, 여기가 우선순위
            for (int i = 0; i < targetBone._childBones.Count; i++)
            {
                bone = CheckBoneClick(targetBone._childBones[i], mousePosW, mousePosGL, isDrawBoneOutline);
                if (bone != null)
                {
                    resultBone = bone;
                }
            }
            if (resultBone != null)
            {
                return(resultBone);
            }
            if (resultBone == null)
            {
                if (IsBoneClick(targetBone, mousePosW, mousePosGL, isDrawBoneOutline))
                {
                    return(targetBone);
                }
            }
            return(null);
        }
        public void SetGUIVisibleWithExceptBone(bool isVisible, bool isRecursive, apBone exceptBone)
        {
            if (exceptBone == this)
            {
                _isBoneGUIVisible = !isVisible;                //<<반대로 적용
            }
            else
            {
                _isBoneGUIVisible = isVisible;
            }

            //if(_parentBone != null)
            //{
            //	_isBoneGUIVisible_Parent = _parentBone.IsGUIVisible;
            //}
            //else
            //{
            //	_isBoneGUIVisible_Parent = true;
            //}

            if (isRecursive)
            {
                if (_childBones.Count > 0)
                {
                    for (int i = 0; i < _childBones.Count; i++)
                    {
                        _childBones[i].SetGUIVisibleWithExceptBone(isVisible, isRecursive, exceptBone);
                    }
                }
            }
        }
Esempio n. 10
0
        private apBone CheckBoneClick(apBone targetBone, Vector2 mousePosW, Vector2 mousePosGL, apEditor.BONE_RENDER_MODE boneRenderMode, int curBoneDepth)
        {
            apBone resultBone = null;
            apBone bone       = null;

            //Child가 먼저 렌더링되므로, 여기가 우선순위
            for (int i = 0; i < targetBone._childBones.Count; i++)
            {
                bone = CheckBoneClick(targetBone._childBones[i], mousePosW, mousePosGL, boneRenderMode, curBoneDepth);
                if (bone != null)
                {
                    if (bone._depth > curBoneDepth)                    //Depth 처리를 해야한다.
                    {
                        resultBone   = bone;
                        curBoneDepth = bone._depth;                        //처리된 Depth 갱신
                    }
                }
            }
            if (resultBone != null)
            {
                return(resultBone);
            }
            if (resultBone == null)
            {
                if (IsBoneClick(targetBone, mousePosW, mousePosGL, boneRenderMode))
                {
                    return(targetBone);
                }
            }
            return(null);
        }
Esempio n. 11
0
        private void AddBoneUnitRecursive(apBone bone, List <apBone> exclusiveBones, apBone targetBone, BoneUnit parentBoneUnit)
        {
            int nextLevel = 0;

            if (parentBoneUnit != null)
            {
                nextLevel = parentBoneUnit._level + 1;
            }
            BoneUnit boneUnit = new BoneUnit(bone, !exclusiveBones.Contains(bone), bone == targetBone, parentBoneUnit, nextLevel);

            _boneUnits.Add(boneUnit);
            if (parentBoneUnit != null)
            {
                parentBoneUnit.AddBoneUnit(boneUnit);
            }

            if (parentBoneUnit == null)
            {
                _boneUnits_Root.Add(boneUnit);
            }

            for (int i = 0; i < bone._childBones.Count; i++)
            {
                AddBoneUnitRecursive(bone._childBones[i], exclusiveBones, targetBone, boneUnit);
            }

            //다 넣었으면 _boneUnit별로 Sort를 하자
            if (boneUnit._childUnits.Count > 0)
            {
                boneUnit._childUnits.Sort(delegate(BoneUnit a, BoneUnit b)
                {
                    return(string.Compare(a._bone._name, b._bone._name));
                });
            }
        }
Esempio n. 12
0
        /// <summary>
        /// 자식 Bone 중에서 특정 Target Bone을 재귀적인 자식으로 가지는 시작 Bone을 찾는다.
        /// </summary>
        /// <param name="targetBoneID"></param>
        /// <returns></returns>
        public apBone FindNextChainedBone(int targetBoneID)
        {
            //바로 아래의 자식 노드를 검색
            for (int i = 0; i < _childBones.Count; i++)
            {
                if (_childBones[i]._uniqueID == targetBoneID)
                {
                    return(_childBones[i]);
                }
            }

            //못찾았다면..
            //재귀적으로 검색해서, 그 중에 실제로 Target Bone을 포함하는 Child Bone을 리턴하자

            for (int i = 0; i < _childBones.Count; i++)
            {
                apBone result = _childBones[i].GetChildBoneRecursive(targetBoneID);
                if (result != null)
                {
                    //return result;
                    return(_childBones[i]);                   //<<Result가 아니라, ChildBone을 리턴
                }
            }
            return(null);
        }
Esempio n. 13
0
        //TODO Link 등등
        //에디터에서 제대로 Link를 해야한다.
        public void Link(apMeshGroup meshGroup_Modifier, apMeshGroup meshGroup_Bone, apBone bone, apRenderUnit renderUnit, apTransform_MeshGroup meshGroupTransform)
        {
            _meshGroup_Modifier = meshGroup_Modifier;
            _meshGroup_Bone     = meshGroup_Bone;
            _bone       = bone;
            _renderUnit = renderUnit;


            _meshGroupTransform = meshGroupTransform;


            //if (_meshGroup_Bone != meshGroup_Modifier)
            //{
            //	//Debug.Log(" ------------Sub Bone의 Link ------------");
            //	if (_renderUnit == null)
            //	{
            //		//Debug.LogError("<<< Render Unit이 Null이다. >>> ");
            //	}
            //	Debug.Log("meshGroup_Modifier : " + (meshGroup_Modifier == null ? "NULL" : meshGroup_Modifier._name));
            //	Debug.Log("_meshGroup_Bone : " + (_meshGroup_Bone == null ? "NULL" : _meshGroup_Bone._name));
            //	Debug.Log("_bone : " + (_bone == null ? "NULL" : _bone._name));
            //	Debug.Log("_meshGroupTransform : " + (_meshGroupTransform == null ? "NULL" : _meshGroupTransform._nickName));
            //	Debug.Log("_transformUniqueID : " + _transformUniqueID);
            //}
        }
Esempio n. 14
0
        private static int MakeSubUnitsFromBonesRecursive(
            apBone targetBone,
            int startUnitID,
            List <apRetargetSubUnit> bones_All,
            List <apRetargetSubUnit> bones_Root,
            apRetargetSubUnit parentSubUnit
            )
        {
            apRetargetSubUnit newUnit = new apRetargetSubUnit();

            newUnit.SetSubData(startUnitID, null, null, targetBone, parentSubUnit);

            startUnitID++;
            bones_All.Add(newUnit);
            if (parentSubUnit == null)
            {
                bones_Root.Add(newUnit);
            }

            if (targetBone._childBones.Count > 0)
            {
                for (int i = 0; i < targetBone._childBones.Count; i++)
                {
                    startUnitID = MakeSubUnitsFromBonesRecursive(
                        targetBone._childBones[i],
                        startUnitID,
                        bones_All,
                        bones_Root,
                        newUnit
                        );
                }
            }

            return(startUnitID);
        }
Esempio n. 15
0
        // Get / Set
        //--------------------------------------------
        /// <summary>
        /// boneID를 가지는 Bone을 자식 노드로 두고 있는가.
        /// 재귀적으로 찾는다.
        /// </summary>
        /// <param name="boneID"></param>
        /// <returns></returns>
        public apBone GetChildBoneRecursive(int boneID)
        {
            //바로 아래의 자식 노드를 검색
            for (int i = 0; i < _childBones.Count; i++)
            {
                if (_childBones[i]._uniqueID == boneID)
                {
                    return(_childBones[i]);
                }
            }

            //못찾았다면..
            //재귀적으로 검색해보자

            for (int i = 0; i < _childBones.Count; i++)
            {
                apBone result = _childBones[i].GetChildBoneRecursive(boneID);
                if (result != null)
                {
                    return(result);
                }
            }

            return(null);
        }
Esempio n. 16
0
        // Matrix 연산
        //----------------------------------------------------------------
        //public Vector3 LocalToWorld(Vector3 pos, bool isModified)
        //{

        //}

        // Functions
        //--------------------------------------------
        /// <summary>
        /// 다른 Bone을 Child로 둔다.
        /// Child->Parent 연결도 자동으로 수행한다.
        /// </summary>
        /// <param name="bone"></param>
        public bool AddChildBone(apBone bone)
        {
            if (bone == null)
            {
                return(false);
            }
            if (bone._meshGroup != _meshGroup)
            {
                //다른 MeshGroup에 속해있다면 실패
                return(false);
            }

            int boneID = bone._uniqueID;

            if (!_childBoneIDs.Contains(boneID))
            {
                _childBoneIDs.Add(boneID);
            }

            if (!_childBones.Contains(bone))
            {
                _childBones.Add(bone);
            }

            bone._parentBone   = this;
            bone._parentBoneID = _uniqueID;

            return(true);
        }
Esempio n. 17
0
        private void AddExclusiveBoneRecursive(List <apBone> exclusiveBones, apBone bone, bool toChild)
        {
            if (!exclusiveBones.Contains(bone))
            {
                exclusiveBones.Add(bone);
            }

            if (toChild)
            {
                if (bone._childBones.Count > 0)
                {
                    for (int i = 0; i < bone._childBones.Count; i++)
                    {
                        AddExclusiveBoneRecursive(exclusiveBones, bone._childBones[i], true);
                    }
                }
            }
            else
            {
                if (bone._parentBone != null)
                {
                    AddExclusiveBoneRecursive(exclusiveBones, bone._parentBone, false);
                }
            }
        }
Esempio n. 18
0
        //------------------------------------------------------------------------------------------
        // Bone - TransformChanged (Default / Rigging Test / Modifier / AnimClip Modifier)
        // Scale 값 직접 수정 (Scale Lock 체크)
        //------------------------------------------------------------------------------------------
        public void TransformChanged_Scale__Modifier_Rigging(Vector2 scale)
        {
            if (Editor.Select.MeshGroup == null ||
                Editor.Select.Bone == null ||
                Editor._boneGUIRenderMode != apEditor.BONE_RENDER_MODE.Render ||
                Editor.Select.Modifier == null                    //<<Modifier가 null이면 안된다.
                )
            {
                return;
            }

            if (!Editor.Select.IsRigEditTestPosing)
            {
                //TestPosing이 허용되지 않았다면 패스
                return;
            }

            apBone         bone                = Editor.Select.Bone;
            apMeshGroup    meshGroup           = Editor.Select.MeshGroup;
            apMeshGroup    boneParentMeshGroup = bone._meshGroup;        //Bone이 속한 MeshGroup. 다를 수 있다.
            apModifierBase modifier            = Editor.Select.Modifier; //선택한 Modifier

            if (modifier.ModifierType != apModifierBase.MODIFIER_TYPE.Rigging)
            {
                //리깅 Modifier가 아니라면 패스
                return;
            }

            //직접 대입한다.
            bone._rigTestMatrix.SetScale(scale);
            bone.MakeWorldMatrix(true);
            bone.GUIUpdate(true);

            //apMatrix dummyWorldMatrix = new apMatrix(bone._worldMatrix);
            //dummyWorldMatrix.SetScale(scale);

            ////Parent - (Local) - (RigTest) 순으로 matrix 역 연산 후 남는 Scale 값으로 대입
            //apMatrix parentMatrix = null;
            //if(bone._parentBone != null)
            //{
            //	parentMatrix = bone._parentBone._worldMatrix;
            //}
            //else if(bone._renderUnit != null)
            //{
            //	parentMatrix = bone._renderUnit.WorldMatrixWrap;
            //}

            //if (parentMatrix != null)
            //{
            //	dummyWorldMatrix.RInverse(parentMatrix);
            //}
            //dummyWorldMatrix.Subtract(bone._localMatrix);
            //dummyWorldMatrix.Subtract(bone._defaultMatrix);//<<Default를 빼자
            //dummyWorldMatrix.MakeMatrix();

            //bone._rigTestMatrix.SetScale(dummyWorldMatrix.Scale2);
            //bone.MakeWorldMatrix(true);
            //bone.GUIUpdate(true);
        }
Esempio n. 19
0
        //------------------------------------------------------------------------------------------
        // Bone - TransformChanged (Default / Rigging Test / Modifier / AnimClip Modifier)
        // Rotate 값 직접 수정 (IK Range 확인)
        //------------------------------------------------------------------------------------------
        public void TransformChanged_Rotate__Modifier_Rigging(float angle)
        {
            if (Editor.Select.MeshGroup == null ||
                Editor.Select.Bone == null ||
                Editor._boneGUIRenderMode != apEditor.BONE_RENDER_MODE.Render ||
                Editor.Select.Modifier == null                    //<<Modifier가 null이면 안된다.
                )
            {
                return;
            }

            if (!Editor.Select.IsRigEditTestPosing)
            {
                //TestPosing이 허용되지 않았다면 패스
                return;
            }

            apBone      bone      = Editor.Select.Bone;
            apMeshGroup meshGroup = Editor.Select.MeshGroup;
            //apMeshGroup boneParentMeshGroup = bone._meshGroup;//Bone이 속한 MeshGroup. 다를 수 있다.
            apModifierBase modifier = Editor.Select.Modifier;            //선택한 Modifier

            if (modifier.ModifierType != apModifierBase.MODIFIER_TYPE.Rigging)
            {
                //리깅 Modifier가 아니라면 패스
                return;
            }

            if (bone._isIKAngleRange)
            {
                if (angle < bone._defaultMatrix._angleDeg + bone._IKAngleRange_Lower)
                {
                    angle = bone._defaultMatrix._angleDeg + bone._IKAngleRange_Lower;
                }
                else if (angle > bone._defaultMatrix._angleDeg + bone._IKAngleRange_Upper)
                {
                    angle = bone._defaultMatrix._angleDeg + bone._IKAngleRange_Upper;
                }
            }

            //직접 대입한다.
            bone._rigTestMatrix.SetRotate(angle);
            //bone.MakeWorldMatrix(true);//<<이전

            //<BONE_EDIT>
            //if(bone._meshGroup != null)
            //{
            //	bone._meshGroup.UpdateBonesWorldMatrix();//<<변경 : 모든 본 동시에 갱신
            //}

            //>Root MeshGroup에서 변경
            if (meshGroup != null)
            {
                meshGroup.UpdateBonesWorldMatrix();
            }

            bone.GUIUpdate(true);
        }
Esempio n. 20
0
        // Show Window / Close Dialog
        //------------------------------------------------------------------------
        public static object ShowDialog(apEditor editor, apBone targetBone, apMeshGroup targetMeshGroup, REQUEST_TYPE requestType, FUNC_SELECT_LINKED_BONE funcResult)
        {
            CloseDialog();

            if (editor == null || editor._portrait == null || editor._portrait._controller == null)
            {
                return(null);
            }

            string windowName = "";

            switch (requestType)
            {
            case REQUEST_TYPE.AttachChild:
                windowName = "Select a Bone as Child";
                break;

            case REQUEST_TYPE.ChangeParent:
                windowName = "Select a Bone as Parent";
                break;

            case REQUEST_TYPE.SelectIKTarget:
                windowName = "Select a Bone as IK Target";
                break;

            case REQUEST_TYPE.SelectIKPositionControllerEffector:
            case REQUEST_TYPE.SelectIKLookAtControllerEffector:
            case REQUEST_TYPE.SelectIKLookAtControllerStartBone:
                windowName = "Select a Bone as IK Effector";
                break;

            case REQUEST_TYPE.Mirror:
                windowName = "Select a Mirror Bone";
                break;
            }
            EditorWindow curWindow            = EditorWindow.GetWindow(typeof(apDialog_SelectLinkedBone), true, windowName, true);
            apDialog_SelectLinkedBone curTool = curWindow as apDialog_SelectLinkedBone;

            object loadKey = new object();

            if (curTool != null && curTool != s_window)
            {
                //기본 Dialog보다 조금 더 크다. Hierarchy 방식으로 가로 스크롤이 포함되기 때문
                int width  = 350;
                int height = 600;
                s_window          = curTool;
                s_window.position = new Rect((editor.position.xMin + editor.position.xMax) / 2 - (width / 2),
                                             (editor.position.yMin + editor.position.yMax) / 2 - (height / 2),
                                             width, height);
                s_window.Init(editor, loadKey, targetBone, targetMeshGroup, requestType, funcResult);

                return(loadKey);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 21
0
        /// <summary>
        /// MeshGroup 메뉴 + Modifier 중 Rigging Modifier에서만 제어할 수 있다.
        /// Rigging 테스트를 위해 임시 WorldMatrix를 만들어서 움직인다.
        /// Rigging Modifier 활성할때마다 변수가 초기화됨.
        /// 자식 MeshGroup의 Bone도 제어 가능하다 (!)
        /// IK의 영향을 받지 않는다.
        /// </summary>
        /// <param name="deltaAngleW"></param>
        public void Rotate__Modifier_Rigging(float deltaAngleW, bool isFirstRotate)
        {
            if (Editor.Select.MeshGroup == null ||
                Editor.Select.Bone == null ||
                Editor._boneGUIRenderMode != apEditor.BONE_RENDER_MODE.Render ||
                Editor.Select.Modifier == null ||                 //<<Modifier가 null이면 안된다.
                deltaAngleW == 0.0f
                )
            {
                return;
            }

            if (!Editor.Select.IsRigEditTestPosing)
            {
                //TestPosing이 허용되지 않았다면 패스
                return;
            }

            apBone      bone      = Editor.Select.Bone;
            apMeshGroup meshGroup = Editor.Select.MeshGroup;
            //apMeshGroup boneParentMeshGroup = bone._meshGroup;//Bone이 속한 MeshGroup. 다를 수 있다.
            apModifierBase modifier = Editor.Select.Modifier;            //선택한 Modifier

            if (modifier.ModifierType != apModifierBase.MODIFIER_TYPE.Rigging)
            {
                //리깅 Modifier가 아니라면 패스
                return;
            }

            //Default Angle은 -180 ~ 180 범위 안에 들어간다.
            float nextAngle = bone._rigTestMatrix._angleDeg + deltaAngleW;

            if (nextAngle < -180.0f)
            {
                nextAngle += 360.0f;
            }
            if (nextAngle > 180.0f)
            {
                nextAngle -= 360.0f;
            }

            bone._rigTestMatrix.SetRotate(nextAngle);
            //bone.MakeWorldMatrix(true);//<<이전 : 단일 본 수정

            //<BONE_EDIT>
            //if(bone._meshGroup != null)
            //{
            //	bone._meshGroup.UpdateBonesWorldMatrix();//변경 : 전체 본 수정
            //}

            //>Root MeshGroup에서 변경
            if (meshGroup != null)
            {
                meshGroup.UpdateBonesWorldMatrix();
            }
            bone.GUIUpdate(true);
        }
        public void Init(int meshGroupID_Modifier, int meshGroupID_Bone, int meshGroupTransformID, apBone bone)
        {
            _meshGroupUniqueID_Modifier = meshGroupID_Modifier;
            _meshGropuUniqueID_Bone     = meshGroupID_Bone;
            _transformUniqueID          = meshGroupTransformID;

            _bone   = bone;
            _boneID = bone._uniqueID;
        }
        //TODO Link 등등
        //에디터에서 제대로 Link를 해야한다.
        public void Link(apMeshGroup meshGroup_Modifier, apMeshGroup meshGroup_Bone, apBone bone, apRenderUnit renderUnit, apTransform_MeshGroup meshGroupTransform)
        {
            _meshGroup_Modifier = meshGroup_Modifier;
            _meshGroup_Bone     = meshGroup_Bone;
            _bone       = bone;
            _renderUnit = renderUnit;

            _meshGroupTransform = meshGroupTransform;
        }
Esempio n. 24
0
            public WeightPair(apBone bone)
            {
                _bone   = bone;
                _boneID = _bone._uniqueID;

                _meshGroup   = _bone._meshGroup;
                _meshGroupID = _meshGroup._uniqueID;

                _weight = 0.0f;
            }
 // Init
 //------------------------------------------------------------------
 public void Init(apEditor editor, apBone targetBone, object loadKey, FUNC_DUPLICATE_BONE_RESULT funcResult)
 {
     _editor              = editor;
     _loadKey             = loadKey;
     _targetBone          = targetBone;
     _offsetX             = 0.0f;
     _offsetY             = 0.0f;
     _isDuplicateChildren = true;
     _funcResult          = funcResult;
 }
Esempio n. 26
0
        //---------------------------------------------------------
        // 3. 단일 포즈의 저장과 로드
        //---------------------------------------------------------
        public void SetSinglePose(apMeshGroup meshGroup, apBone selectedBone, string sceneName)
        {
            if (_singlePose == null)
            {
                _singlePose = new apRetargetBonePose();
            }

            _singlePose.Clear();
            _singlePose.SetPose(meshGroup, selectedBone, sceneName);
        }
Esempio n. 27
0
        // Functions
        //-------------------------------------------------
        public apBoneIKChainUnit(apBone baseBone, apBone targetBone, apBone parentBone)
        {
            _baseBone   = baseBone;
            _targetBone = targetBone;
            _parentBone = parentBone;

            _parentChainUnit = null;
            _childChainUnit  = null;

            _isPreferredAngleAdapted = false;
        }
Esempio n. 28
0
 public bool IsContainBone(apBone bone)
 {
     if (bone == null)
     {
         return(false);
     }
     return(_boneData.Exists(delegate(apModifiedBone a)
     {
         return a._bone == bone;
     }));
 }
Esempio n. 29
0
 private apMeshGroup GetParentMeshGroupOfBone(apBone bone)
 {
     for (int i = 0; i < _portrait._meshGroups.Count; i++)
     {
         if (_portrait._meshGroups[i]._boneList_All.Contains(bone))
         {
             //찾았다!
             return(_portrait._meshGroups[i]);
         }
     }
     return(null);
 }
Esempio n. 30
0
        // Functions
        //------------------------------------------------------
        // Bone -> File
        //------------------------------------------------------
        public void SetBone(int unitID, apBone bone)
        {
            _unitID   = unitID;
            _uniqueID = bone._uniqueID;

            _name = bone._name;

            _defaultMatrix.SetMatrix(bone._defaultMatrix);
            _localMatrix.SetMatrix(bone._localMatrix);
            _worldMatrix.SetMatrix(bone._worldMatrix);

            _targetBone = bone;            //<<Export할때도 연결해주자
        }