Exemplo n.º 1
0
        public void SetGroup(apMeshGroup meshGroup, apTransform_MeshGroup meshGroupTransform, apRenderUnit parentRenderUnit)
        {
            _unitType = UNIT_TYPE.GroupNode;

            _meshGroup = meshGroup;

            _meshGroupTransform = meshGroupTransform;
            _meshTransform      = null;

            //역으로 Link를 하자
            _meshGroupTransform._linkedRenderUnit = this;



            _depth = 0;
            if (_meshTransform != null)
            {
                _depth += _meshTransform._depth;
            }
            if (parentRenderUnit != null)
            {
                _depth += parentRenderUnit._depth;
            }
            if (meshGroupTransform != null)
            {
                //루트가 아니라면 Mesh Group Transform도 있다.
                _depth += _meshGroupTransform._depth;
            }

            if (parentRenderUnit != null)
            {
                parentRenderUnit._childRenderUnits.Add(this);
                _parentRenderUnit = parentRenderUnit;
            }
        }
        // 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;
            //});
        }
Exemplo n.º 3
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);
        }
        // Init
        //------------------------------------------------------------------------
        public void Init(FUNC_RETARGET_SINGLE_POSE_IMPORT_ANIM funcResult_Anim, FUNC_RETARGET_SINGLE_POSE_IMPORT_MOD funcResult_Mod,
                         apEditor editor, object loadKey, apMeshGroup targetMeshGroup,
                         apModifierBase targetModifier, apModifierParamSet targetParamSet,                                //<<일반 Modifier에서 작업하는 경우
                         apAnimClip targetAnimClip, apAnimTimeline targetAnimTimeline, int targetFrame)
        {
            _editor          = editor;
            _loadKey         = loadKey;
            _targetMeshGroup = targetMeshGroup;

            _funcResult_Anim = funcResult_Anim;
            _funcResult_Mod  = funcResult_Mod;

            _targetModifier     = targetModifier;
            _targetParamSet     = targetParamSet;
            _targetAnimClip     = targetAnimClip;
            _targetAnimTimeline = targetAnimTimeline;
            _targetFrame        = targetFrame;

            //_imgIcon_Bone = _editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Bone);

            _category = CATEGORY.SameMeshGroup;

            _retarget.LoadSinglePoseFileList(editor);
            _selectedBonePoseFile = null;
            _isValidPose          = false;

            _meshGroupUniqueID = _targetMeshGroup._uniqueID;
            _portraitName      = _targetMeshGroup._parentPortrait.name;
        }
Exemplo n.º 5
0
        public void SetMesh(apMeshGroup meshGroup, apTransform_Mesh meshTransform, apRenderUnit parentRenderUnit)
        {
            _unitType = UNIT_TYPE.Mesh;

            _meshGroup = meshGroup;

            _meshGroupTransform = null;
            _meshTransform      = meshTransform;

            _meshTransform._linkedRenderUnit = this;

            _depth = 0;
            if (parentRenderUnit != null)
            {
                _depth += parentRenderUnit._depth;
            }
            if (_meshGroupTransform != null)
            {
                _depth += _meshGroupTransform._depth;
            }
            _depth += meshTransform._depth;


            if (parentRenderUnit != null)
            {
                parentRenderUnit._childRenderUnits.Add(this);
                _parentRenderUnit = parentRenderUnit;
            }
        }
        // Show Window / Close Dialog
        //------------------------------------------------------------------------
        public static object ShowDialog(apEditor editor, apMeshGroup targetMeshGroup, apBone selectedBone)
        {
            CloseDialog();

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



            EditorWindow curWindow = EditorWindow.GetWindow(typeof(apDialog_RetargetSinglePoseExport), true, "Export Pose", true);
            apDialog_RetargetSinglePoseExport curTool = curWindow as apDialog_RetargetSinglePoseExport;

            object loadKey = new object();

            if (curTool != null && curTool != s_window)
            {
                int width  = 400;
                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, targetMeshGroup, selectedBone);

                return(loadKey);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 7
0
        private bool AddBoneToParamSet(apModifierParamSet paramSet, apTransform_MeshGroup meshGroupTransform, apBone bone)
        {
            if (!_parentModifier.IsTarget_Bone)
            {
                return(false);
            }

            bool isExist = paramSet._boneData.Exists(delegate(apModifiedBone a)
            {
                return(a._bone == bone);
            });

            if (!isExist)
            {
                apMeshGroup parentMeshGroupOfBone = GetParentMeshGroupOfBone(bone);
                if (parentMeshGroupOfBone == null)
                {
                    return(false);
                }

                apRenderUnit targetRenderUnit = _parentModifier._meshGroup.GetRenderUnit(meshGroupTransform);

                apModifiedBone modBone = new apModifiedBone();
                modBone.Init(_parentModifier._meshGroup._uniqueID, parentMeshGroupOfBone._uniqueID, meshGroupTransform._transformUniqueID, bone);
                modBone.Link(_parentModifier._meshGroup, parentMeshGroupOfBone, bone, targetRenderUnit, meshGroupTransform);


                paramSet._boneData.Add(modBone);
            }

            return(!isExist);
        }
Exemplo n.º 8
0
        // Init
        //--------------------------------------------------------------------
        public void Init(apEditor editor, object loadKey, apMeshGroup srcMeshGroup, FUNC_SELECT_TRANSFORM_RESULT funcResult)
        {
            _editor  = editor;
            _loadKey = loadKey;
            //_srcMeshGroup = srcMeshGroup;
            _funcResult = funcResult;

            //타겟을 검색하자
            _meshes.Clear();
            _meshGroups.Clear();

            for (int i = 0; i < _editor._portrait._meshes.Count; i++)
            {
                _meshes.Add(_editor._portrait._meshes[i]);
            }


            for (int i = 0; i < _editor._portrait._meshGroups.Count; i++)
            {
                apMeshGroup meshGroup = _editor._portrait._meshGroups[i];
                if (meshGroup == srcMeshGroup)
                {
                    continue;
                }
                //재귀적으로 이미 포함된 MeshGroup인지 판단한다.
                //추가 12.03 : 그 반대도 포함해야 한다.
                apTransform_MeshGroup childMeshGroupTransform     = srcMeshGroup.FindChildMeshGroupTransform(meshGroup);
                apTransform_MeshGroup childMeshGroupTransform_Rev = meshGroup.FindChildMeshGroupTransform(srcMeshGroup);
                if (childMeshGroupTransform == null && childMeshGroupTransform_Rev == null)
                {
                    //child가 아닐때
                    _meshGroups.Add(meshGroup);
                }
            }
        }
Exemplo n.º 9
0
 public void BakeModifier(apPortrait portrait, apMeshGroup srcMeshGroup)
 {
     if (srcMeshGroup != null)
     {
         _modifierStack.Bake(srcMeshGroup._modifierStack, portrait);
     }
 }
Exemplo n.º 10
0
        private static int MakeSubUnitsFromMeshGroupTransformRecursive(
            apMeshGroup rootMeshGroup,
            apTransform_MeshGroup meshGroupTransform,
            int startUnitID,
            List <apRetargetSubUnit> transforms_All,
            List <apRetargetSubUnit> transforms_Root,
            apRetargetSubUnit parentSubUnit
            )
        {
            //MeshGroup Transform을 추가한다.
            apRetargetSubUnit newGroupSubUnit = new apRetargetSubUnit();

            newGroupSubUnit.SetSubData(startUnitID, null, meshGroupTransform, null, parentSubUnit);

            transforms_All.Add(newGroupSubUnit);
            if (parentSubUnit == null)
            {
                transforms_Root.Add(newGroupSubUnit);
            }

            startUnitID++;

            if (meshGroupTransform._meshGroup != null && meshGroupTransform._meshGroup != rootMeshGroup)
            {
                if (meshGroupTransform._meshGroup._childMeshTransforms != null)
                {
                    for (int i = 0; i < meshGroupTransform._meshGroup._childMeshTransforms.Count; i++)
                    {
                        //MeshTransform을 추가한다.
                        apTransform_Mesh meshTransform = meshGroupTransform._meshGroup._childMeshTransforms[i];

                        apRetargetSubUnit newSubUnit = new apRetargetSubUnit();
                        newSubUnit.SetSubData(startUnitID, meshTransform, null, null, newGroupSubUnit);
                        startUnitID++;

                        transforms_All.Add(newSubUnit);
                    }
                }

                //하위에 다른 MeshGroup Transform이 있는 경우
                if (meshGroupTransform._meshGroup._childMeshGroupTransforms != null)
                {
                    //재귀 호출을 한다
                    for (int i = 0; i < meshGroupTransform._meshGroup._childMeshGroupTransforms.Count; i++)
                    {
                        apTransform_MeshGroup childMeshGroup = meshGroupTransform._meshGroup._childMeshGroupTransforms[i];

                        startUnitID = MakeSubUnitsFromMeshGroupTransformRecursive(
                            rootMeshGroup,
                            childMeshGroup,
                            startUnitID,
                            transforms_All,
                            transforms_Root,
                            newGroupSubUnit
                            );
                    }
                }
            }
            return(startUnitID);
        }
 // Init
 //------------------------------------------------------------------------
 public void Init(apEditor editor, object loadKey, apMeshGroup targetMeshGroup, FUNC_LOAD_RETARGET funcResult)
 {
     _editor          = editor;
     _loadKey         = loadKey;
     _funcResult      = funcResult;
     _targetMeshGroup = targetMeshGroup;
 }
        // Show Window / Close Dialog
        //------------------------------------------------------------------------
        public static object ShowDialog(apEditor editor, apMeshGroup targetMeshGroup, FUNC_LOAD_RETARGET funcResult)
        {
            CloseDialog();

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



            EditorWindow          curWindow = EditorWindow.GetWindow(typeof(apDialog_RetargetBase), true, "Export/Import Bones", true);
            apDialog_RetargetBase curTool   = curWindow as apDialog_RetargetBase;

            object loadKey = new object();

            if (curTool != null && curTool != s_window)
            {
                int width  = 500;
                int height = 800;
                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, targetMeshGroup, funcResult);

                return(loadKey);
            }
            else
            {
                return(null);
            }
        }
        // Show Window
        //--------------------------------------------------------------
        public static object ShowDialog(apEditor editor, apMeshGroup targetMeshGroup, FUNC_ADD_MODIFIER_RESULT funcResult)
        {
            CloseDialog();

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

            EditorWindow         curWindow = EditorWindow.GetWindow(typeof(apDialog_AddModifier), true, "Select Modifier", true);
            apDialog_AddModifier curTool   = curWindow as apDialog_AddModifier;

            object loadKey = new object();

            if (curTool != null && curTool != s_window)
            {
                int width  = 250;
                int height = 400;
                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, targetMeshGroup, funcResult);

                return(loadKey);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 14
0
        // Init
        //------------------------------------
        public apRenderVertex(apRenderUnit parentRenderUnit, apMeshGroup parentMeshGroup, apMesh parentMesh, apVertex vertex)
        {
            _parentRenderUnit = parentRenderUnit;
            _parentMeshGroup  = parentMeshGroup;
            _parentMesh       = parentMesh;
            _vertex           = vertex;

            //_isStaticRefreshed = false;
            _isCalculated = false;

            //_matrixStack.Clear();

            //
            _matrix_Static_Vert2Mesh = apMatrix3x3.identity;
            _matrix_Cal_VertLocal    = apMatrix3x3.identity;
            _matrix_MeshTransform    = apMatrix3x3.identity;

            _matrix_Cal_VertWorld = apMatrix3x3.identity;
            _matrix_ToWorld       = apMatrix3x3.identity;
            _pos_World            = Vector2.zero;

            //_cal_VertWorld = Vector2.zero;

            //_matrixHashCode_Static_Vert2Mesh = -1;
            //_matrixHashCode_Calculate = -1;

            //_isMatrixChanged = true;
            //_isUpdateMatrixForce = true;

            _pos_Rigging    = Vector2.zero;
            _weight_Rigging = 0.0f;

            _matrix_Rigging = apMatrix3x3.identity;
        }
Exemplo n.º 15
0
        public void UpdateBeforeBake(apPortrait portrait, apMeshGroup mainMeshGroup, apTransform_MeshGroup mainMeshGroupTransform)
        {
            //Bake 전에 업데이트할게 있으면 여기서 업데이트하자

            //1. VertRig의 LocalPos 갱신을 여기서 하자
            #region [미사용 코드]
            //if(_vertRigs != null && _vertRigs.Count > 0)
            //{
            //	apModifiedVertexRig vertRig = null;
            //	//기존 링크 말고, Bake 직전의 Transform 등을 검색하여 값을 넣어주자
            //	apTransform_Mesh meshTransform = mainMeshGroup.GetMeshTransformRecursive(_transformUniqueID);
            //	if (meshTransform != null)
            //	{
            //		apMesh mesh = meshTransform._mesh;
            //		if (mesh != null)
            //		{
            //			for (int iVR = 0; iVR < _vertRigs.Count; iVR++)
            //			{
            //				vertRig = _vertRigs[iVR];
            //				apVertex vert = vertRig._vertex;

            //				for (int iW = 0; iW < vertRig._weightPairs.Count; iW++)
            //				{
            //					apModifiedVertexRig.WeightPair weightPair = vertRig._weightPairs[iW];
            //					weightPair.CalculateLocalPos(vert._pos, mesh.Matrix_VertToLocal, meshTransform._matrix_TFResult_WorldWithoutMod, weightPair._bone._defaultMatrix);
            //				}

            //			}
            //		}
            //	}
            //}
            #endregion
        }
Exemplo n.º 16
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);
            //}
        }
        public bool Paste_MultipleVertRig(apMeshGroup keyMeshGroup, List <apSelection.ModRenderVert> modRenderVerts)
        {
            bool isPastable = IsRiggingPosPastable(keyMeshGroup, modRenderVerts);

            if (!isPastable)
            {
                return(false);
            }

            List <apModifiedVertexRig> vertRigs = new List <apModifiedVertexRig>();

            apSelection.ModRenderVert curModRenderVert = null;
            for (int i = 0; i < modRenderVerts.Count; i++)
            {
                curModRenderVert = modRenderVerts[i];
                if (curModRenderVert != null && curModRenderVert._modVertRig != null)
                {
                    vertRigs.Add(curModRenderVert._modVertRig);
                }
            }
            if (vertRigs.Count == 0)
            {
                return(false);
            }

            return(_clipboard_MultipleVertRig.Paste(keyMeshGroup, vertRigs));
        }
Exemplo n.º 18
0
        // Show Window
        //--------------------------------------------------------------
        public static object ShowDialog(apEditor editor, apMeshGroup srcMeshGroup, FUNC_SELECT_TRANSFORM_RESULT funcResult)
        {
            CloseDialog();

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

            EditorWindow curWindow             = EditorWindow.GetWindow(typeof(apDialog_AddChildTransform), true, "Add Mesh/MeshGroup", true);
            apDialog_AddChildTransform curTool = curWindow as apDialog_AddChildTransform;

            object loadKey = new object();

            if (curTool != null && curTool != s_window)
            {
                s_window          = curTool;
                s_window.position = new Rect(100, 100, 250, 400);
                s_window.Init(editor, loadKey, srcMeshGroup, funcResult);

                return(loadKey);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 19
0
        public bool Copy(apMeshGroup meshGroup, List <apModifiedVertexRig> srcModVertRigs)
        {
            if (meshGroup == null ||
                srcModVertRigs == null ||
                srcModVertRigs.Count == 0)
            {
                return(false);
            }

            Clear();

            _keyMeshGroup = meshGroup;

            //Debug.LogWarning("Pos-Copy Start");
            for (int i = 0; i < srcModVertRigs.Count; i++)
            {
                PosWeightPair newPosWeightPair = new PosWeightPair();
                newPosWeightPair.SetModVertRig(srcModVertRigs[i]);

                _posWeightPairs.Add(newPosWeightPair);
            }
            //Debug.LogWarning("Result : " + _posWeightPairs.Count);

            return(true);
        }
Exemplo n.º 20
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);
        }
Exemplo n.º 21
0
 // Functions
 //-------------------------------------------------------------
 public bool IsPastable(apMeshGroup meshGroup)
 {
     if (_keyMeshGroup == null || _keyMeshGroup != meshGroup || _posWeightPairs.Count == 0)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 22
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);
            }
        }
Exemplo n.º 23
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);
        }
Exemplo n.º 24
0
 public void Clear()
 {
     _keyMeshGroup = null;
     if (_posWeightPairs == null)
     {
         _posWeightPairs = new List <PosWeightPair>();
     }
     _posWeightPairs.Clear();
 }
        //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;
        }
Exemplo n.º 26
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);
        }
Exemplo n.º 27
0
        //---------------------------------------------------------
        // 3. 단일 포즈의 저장과 로드
        //---------------------------------------------------------
        public void SetSinglePose(apMeshGroup meshGroup, apBone selectedBone, string sceneName)
        {
            if (_singlePose == null)
            {
                _singlePose = new apRetargetBonePose();
            }

            _singlePose.Clear();
            _singlePose.SetPose(meshGroup, selectedBone, sceneName);
        }
Exemplo n.º 28
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,
                         object loadKey,
                         apMeshGroup srcMeshGroup,
                         apTransform_Mesh srcMeshTransform,
                         FUNC_SELECT_MESH_TF_COPY funcResult)
        {
            _editor     = editor;
            _loadKey    = loadKey;
            _meshGroup  = srcMeshGroup;
            _funcResult = funcResult;

            _srcMeshTransform = srcMeshTransform;

            //타겟을 검색하자
            _meshTransforms.Clear();



            _img_Mesh     = _editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Mesh);
            _img_FoldDown = _editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_FoldDown);

            //대상이 되는 데이터를 가져온다.
            for (int i = 0; i < _meshGroup._renderUnits_All.Count; i++)
            {
                apRenderUnit renderUnit = _meshGroup._renderUnits_All[i];
                if (renderUnit._meshTransform == null || renderUnit._meshTransform == _srcMeshTransform)
                {
                    continue;
                }

                if (!_meshTransforms.Contains(renderUnit._meshTransform))
                {
                    _meshTransforms.Add(renderUnit._meshTransform);
                }
            }

            _meshTransforms.Reverse();


            if (_copiedProperties == null)
            {
                _copiedProperties = new Dictionary <COPIED_PROPERTIES, bool>();
            }

            _copiedProperties.Clear();

            _copiedProperties.Add(COPIED_PROPERTIES.DefaultColor, false);
            _copiedProperties.Add(COPIED_PROPERTIES.ShaderType, false);
            _copiedProperties.Add(COPIED_PROPERTIES.CustomShader, false);
            _copiedProperties.Add(COPIED_PROPERTIES.RenderTextureSize, false);
            _copiedProperties.Add(COPIED_PROPERTIES.TwoSides, false);
            _copiedProperties.Add(COPIED_PROPERTIES.ShadowSettings, false);
            _copiedProperties.Add(COPIED_PROPERTIES.MaterialSet, false);
            _copiedProperties.Add(COPIED_PROPERTIES.MaterialProperties, false);
        }
Exemplo n.º 30
0
 public bool IsContains_MeshGroupTransform(apMeshGroup meshGroup, apTransform_MeshGroup meshGroupTransform)
 {
     if (_meshGroupUniqueID_Modifier == meshGroup._uniqueID &&
         _transformUniqueID == meshGroupTransform._transformUniqueID &&
         _transformUniqueID >= 0 &&
         !_isMeshTransform)
     {
         return(true);
     }
     return(false);
 }