Exemplo n.º 1
0
        public bool Bake(apModifiedBone srcModBone, apPortrait portrait)
        {
            _portrait         = portrait;
            _meshGroupID_Bone = srcModBone._meshGropuUniqueID_Bone;
            apOptTransform meshGroupTransform = portrait.GetOptTransformAsMeshGroup(_meshGroupID_Bone);

            if (meshGroupTransform == null)
            {
                Debug.LogError("[ModBone] Bake 실패 : 찾을 수 없는 OptTransform [" + _meshGroupID_Bone + "]");
                return(false);
            }

            _transformUniqueID = meshGroupTransform._transformID;
            _meshGroup_Bone    = meshGroupTransform;

            _boneID = srcModBone._boneID;

            _bone = meshGroupTransform.GetBone(_boneID);
            if (_bone == null)
            {
                Debug.LogError("[ModBone] Bake 실패 : 찾을 수 없는 Bone [" + _boneID + "]");
                return(false);
            }
            _transformMatrix = new apMatrix(srcModBone._transformMatrix);
            return(true);
        }
Exemplo n.º 2
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.º 3
0
        public void Init(int uniqueID, int frameIndex, bool isIntControlParamLayer)
        {
            _uniqueID   = uniqueID;
            _frameIndex = frameIndex;

            _isLoopAsStart  = false;
            _isLoopAsEnd    = false;
            _loopFrameIndex = -1;

            //_conSyncValue_Bool = false;
            _conSyncValue_Int     = 0;
            _conSyncValue_Float   = 0.0f;
            _conSyncValue_Vector2 = Vector2.zero;
            //_conSyncValue_Vector3 = Vector3.zero;
            //_conSyncValue_Color = Color.black;

            _linkedParamSet_Editor = null;
            _linkedModMesh_Editor  = null;
            _linkedModBone_Editor  = null;

            if (isIntControlParamLayer)
            {
                _curveKey.SetTangentType(apAnimCurve.TANGENT_TYPE.Constant, apAnimCurve.KEY_POS.NEXT);
                _curveKey.SetTangentType(apAnimCurve.TANGENT_TYPE.Constant, apAnimCurve.KEY_POS.PREV);
            }

            _prevRotationBiasMode  = ROTATION_BIAS.None;
            _nextRotationBiasMode  = ROTATION_BIAS.None;
            _prevRotationBiasCount = 0;
            _nextRotationBiasCount = 0;
        }
Exemplo n.º 4
0
 public ParamKeyValueSet(apModifierParamSetGroup keyParamSetGroup, apModifierParamSet paramSet, apModifiedBone modifiedValue)
 {
     _keyParamSetGroup = keyParamSetGroup;
     _paramSet         = paramSet;
     _modifiedMesh     = null;
     _modifiedBone     = modifiedValue;
     _layerIndx        = _paramSet._parentParamSetGroup._layerIndex;
 }
Exemplo n.º 5
0
        public override bool Save(object target, string strParam)
        {
            base.Save(target, strParam);

            apAnimKeyframe keyframe = target as apAnimKeyframe;

            if (keyframe == null)
            {
                return(false);
            }

            _key_TimelineLayer = keyframe._parentTimelineLayer;
            if (_key_TimelineLayer == null)
            {
                return(false);
            }

            _animCurve     = new apAnimCurve(keyframe._curveKey, keyframe._frameIndex);
            _isKeyValueSet = keyframe._isKeyValueSet;

            //_conSyncValue_Bool = keyframe._conSyncValue_Bool;
            _conSyncValue_Int     = keyframe._conSyncValue_Int;
            _conSyncValue_Float   = keyframe._conSyncValue_Float;
            _conSyncValue_Vector2 = keyframe._conSyncValue_Vector2;
            //_conSyncValue_Vector3 = keyframe._conSyncValue_Vector3;
            //_conSyncValue_Color = keyframe._conSyncValue_Color;

            _vertices.Clear();
            _transformMatrix = new apMatrix();
            _meshColor       = new Color(0.5f, 0.5f, 0.5f, 1.0f);
            _isVisible       = true;

            if (keyframe._linkedModMesh_Editor != null)
            {
                apModifiedMesh modMesh = keyframe._linkedModMesh_Editor;
                _vertices.Clear();
                int nVert = modMesh._vertices.Count;

                for (int i = 0; i < nVert; i++)
                {
                    apModifiedVertex modVert = modMesh._vertices[i];
                    _vertices.Add(new VertData(modVert._vertex, modVert._deltaPos));
                }

                _transformMatrix = new apMatrix(modMesh._transformMatrix);
                _meshColor       = modMesh._meshColor;
                _isVisible       = modMesh._isVisible;
            }
            else if (keyframe._linkedModBone_Editor != null)
            {
                apModifiedBone modBone = keyframe._linkedModBone_Editor;

                _transformMatrix = new apMatrix(modBone._transformMatrix);
            }
            return(true);
        }
        //--------------------------------------------------------------------
        // 1-2. ModBone
        //--------------------------------------------------------------------
        public void Copy_ModBone(apModifiedBone modBone, string snapShotName)
        {
            _clipboard_ModBone = new apSnapShotStackUnit(snapShotName);
            bool result = _clipboard_ModBone.SetSnapShot_ModBone(modBone, "Clipboard");

            if (!result)
            {
                _clipboard_ModBone = null;                //<<저장 불가능하다.
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Modifier들의 계산 값들을 초기화한다.
        /// </summary>
        public void InitModifierCalculatedValues()
        {
            for (int iMod = 0; iMod < _modifiers.Count; iMod++)
            {
                //Modifier ->..
                apModifierBase modifier = _modifiers[iMod];

                List <apModifierParamSetGroup> paramSetGroups = modifier._paramSetGroup_controller;

                for (int iGroup = 0; iGroup < paramSetGroups.Count; iGroup++)
                {
                    //Modifier -> ParamSetGroup ->..
                    apModifierParamSetGroup paramSetGroup = paramSetGroups[iGroup];

                    List <apModifierParamSet> paramSets = paramSetGroup._paramSetList;

                    for (int iParam = 0; iParam < paramSets.Count; iParam++)
                    {
                        //Modifier -> ParamSetGroup -> ParamSet ->...
                        apModifierParamSet paramSet = paramSets[iParam];

                        List <apModifiedMesh> modMeshes = paramSet._meshData;
                        List <apModifiedBone> modBones  = paramSet._boneData;

                        for (int iModMesh = 0; iModMesh < modMeshes.Count; iModMesh++)
                        {
                            apModifiedMesh modMesh = modMeshes[iModMesh];
                            if (modMesh._vertices != null && modMesh._vertices.Count > 0)
                            {
                                //ModVert 초기화 => 현재는 초기화 할게 없다.
                            }
                            if (modMesh._vertRigs != null && modMesh._vertRigs.Count > 0)
                            {
                                //ModVertRig 초기화 => 현재는 초기화 할게 없다.
                            }
                            if (modMesh._vertWeights != null && modMesh._vertWeights.Count > 0)
                            {
                                apModifiedVertexWeight vertWeight = null;
                                for (int iVW = 0; iVW < modMesh._vertWeights.Count; iVW++)
                                {
                                    vertWeight = modMesh._vertWeights[iVW];
                                    vertWeight.InitCalculatedValue();                                    //<<초기화를 하자. (여기서는 물리값)
                                }
                            }
                        }

                        for (int iModBone = 0; iModBone < modBones.Count; iModBone++)
                        {
                            apModifiedBone modBone = modBones[iModBone];
                            //ModBone도 현재는 초기화 할게 없다.
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
        public override bool Load(object targetObj)
        {
            apAnimKeyframe keyframe = targetObj as apAnimKeyframe;

            if (keyframe == null)
            {
                return(false);
            }

            keyframe._curveKey      = new apAnimCurve(_animCurve, keyframe._frameIndex);
            keyframe._isKeyValueSet = _isKeyValueSet;

            //keyframe._conSyncValue_Bool = _conSyncValue_Bool;
            keyframe._conSyncValue_Int     = _conSyncValue_Int;
            keyframe._conSyncValue_Float   = _conSyncValue_Float;
            keyframe._conSyncValue_Vector2 = _conSyncValue_Vector2;
            //keyframe._conSyncValue_Vector3 = _conSyncValue_Vector3;
            //keyframe._conSyncValue_Color = _conSyncValue_Color;


            if (keyframe._linkedModMesh_Editor != null)
            {
                apModifiedMesh modMesh = keyframe._linkedModMesh_Editor;

                VertData         vertData = null;
                apModifiedVertex modVert  = null;
                int nVert = _vertices.Count;
                for (int i = 0; i < nVert; i++)
                {
                    vertData = _vertices[i];
                    modVert  = modMesh._vertices.Find(delegate(apModifiedVertex a)
                    {
                        return(a._vertex == vertData._key_Vert);
                    });

                    if (modVert != null)
                    {
                        modVert._deltaPos = vertData._deltaPos;
                    }
                }

                modMesh._transformMatrix.SetMatrix(_transformMatrix);
                modMesh._meshColor = _meshColor;
                modMesh._isVisible = _isVisible;
            }
            else if (keyframe._linkedModBone_Editor != null)
            {
                apModifiedBone modBone = keyframe._linkedModBone_Editor;
                modBone._transformMatrix.SetMatrix(_transformMatrix);
            }

            return(true);
        }
Exemplo n.º 9
0
        public override bool Load(object targetObj)
        {
            apModifiedBone modBone = targetObj as apModifiedBone;

            if (modBone == null)
            {
                return(false);
            }

            modBone._transformMatrix.SetMatrix(_transformMatrix);
            modBone._transformMatrix.MakeMatrix();

            return(true);
        }
Exemplo n.º 10
0
            public ParamKeyValueSet(apModifierParamSetGroup keyParamSetGroup, apModifierParamSet paramSet, apModifiedBone modifiedValue)
            {
                _keyParamSetGroup = keyParamSetGroup;
                _paramSet         = paramSet;
                _modifiedMesh     = null;
                _modifiedBone     = modifiedValue;
                _layerIndx        = _paramSet._parentParamSetGroup._layerIndex;

                //추가 : RotationBias
                _isAnimRotationBias         = false;
                _animRotationBiasAngle      = 0;
                _animRotationBiasAngle_Prev = -1;
                _animRotationBiasedMatrix   = new apMatrix();
            }
Exemplo n.º 11
0
        public override bool Save(object target, string strParam)
        {
            base.Save(target, strParam);

            apModifiedBone modBone = target as apModifiedBone;

            if (modBone == null)
            {
                return(false);
            }

            _key_MeshGroupOfMod  = modBone._meshGroup_Modifier;
            _key_MeshGroupOfBone = modBone._meshGroup_Bone;
            _key_Bone            = modBone._bone;

            _transformMatrix.SetMatrix(modBone._transformMatrix);
            return(true);
        }
Exemplo n.º 12
0
        public void Init(int uniqueID, int frameIndex)
        {
            _uniqueID   = uniqueID;
            _frameIndex = frameIndex;

            _isLoopAsStart  = false;
            _isLoopAsEnd    = false;
            _loopFrameIndex = -1;

            //_conSyncValue_Bool = false;
            _conSyncValue_Int     = 0;
            _conSyncValue_Float   = 0.0f;
            _conSyncValue_Vector2 = Vector2.zero;
            //_conSyncValue_Vector3 = Vector3.zero;
            //_conSyncValue_Color = Color.black;

            _linkedParamSet_Editor = null;
            _linkedModMesh_Editor  = null;
            _linkedModBone_Editor  = null;
        }
        public bool IsPastable(apModifiedBone targetModBone)
        {
            if (targetModBone == null)
            {
                return(false);
            }
            if (_clipboard_ModBone == null)
            {
                return(false);
            }

            //만약, 복사-붙여넣기 불가능한 객체이면 생략한다.
            bool isKeySync = _clipboard_ModBone.IsKeySyncable(targetModBone);

            if (!isKeySync)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 14
0
        // Functions
        //--------------------------------------------
        public override bool IsKeySyncable(object target)
        {
            if (!(target is apModifiedBone))
            {
                return(false);
            }

            apModifiedBone targetModBone = target as apModifiedBone;

            if (targetModBone == null)
            {
                return(false);
            }

            //Key 체크를 하자
            if (targetModBone._meshGroup_Modifier != _key_MeshGroupOfMod ||
                targetModBone._meshGroup_Bone != _key_MeshGroupOfBone ||
                targetModBone._bone != _key_Bone)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 15
0
 public bool SetSnapShot_ModBone(apModifiedBone modBone, string strParam)
 {
     _snapShot = new apSnapShot_ModifiedBone();
     return(_snapShot.Save(modBone, strParam));
 }
Exemplo n.º 16
0
        public bool RefreshSync()
        {
            if (_syncTransform_Mesh == null)
            {
                _syncTransform_Mesh = new List <apTransform_Mesh>();
            }
            _syncTransform_Mesh.Clear();

            if (_syncTransform_MeshGroup == null)
            {
                _syncTransform_MeshGroup = new List <apTransform_MeshGroup>();
            }
            _syncTransform_MeshGroup.Clear();

            if (_syncBone == null)
            {
                _syncBone = new List <apBone>();
            }
            _syncBone.Clear();

            //한번이라도 등장한 MeshTransform / MeshGroup Transform을 찾자
            for (int i = 0; i < _paramSetList.Count; i++)
            {
                apModifierParamSet paramSet = _paramSetList[i];

                for (int iModMesh = 0; iModMesh < paramSet._meshData.Count; iModMesh++)
                {
                    apModifiedMesh modMesh = paramSet._meshData[iModMesh];
                    if (modMesh._transform_Mesh != null)
                    {
                        if (!_syncTransform_Mesh.Contains(modMesh._transform_Mesh))
                        {
                            _syncTransform_Mesh.Add(modMesh._transform_Mesh);
                        }
                    }
                    if (modMesh._transform_MeshGroup != null)
                    {
                        if (!_syncTransform_MeshGroup.Contains(modMesh._transform_MeshGroup))
                        {
                            _syncTransform_MeshGroup.Add(modMesh._transform_MeshGroup);
                        }
                    }
                }
                for (int iModBone = 0; iModBone < paramSet._boneData.Count; iModBone++)
                {
                    apModifiedBone modBone = paramSet._boneData[iModBone];

                    if (modBone._bone != null)
                    {
                        if (modBone._meshGroup_Bone != null && modBone._meshGroup_Bone._boneList_All.Contains(modBone._bone))
                        {
                            if (!_syncBone.Contains(modBone._bone))
                            {
                                _syncBone.Add(modBone._bone);
                            }
                        }
                        else
                        {
                            //Modifier로 등록되었지만 Bone이 삭제되었다면 여기로 들어온다.
                            //Sync가 안됨
                        }
                    }
                }
            }

            //동기화 전용 Sync Transform을 모든 ParamSet에 넣자
            bool isAnyChanged = false;

            for (int iSync = 0; iSync < _syncTransform_Mesh.Count; iSync++)
            {
                apTransform_Mesh meshTransform = _syncTransform_Mesh[iSync];
                //bool isAdd = _parentModifier.AddMeshTransformToAllParamSet(_parentModifier._meshGroup, meshTransform, false);
                for (int iParamSet = 0; iParamSet < _paramSetList.Count; iParamSet++)
                {
                    bool isAdd = AddMeshTransformToParamSet(_paramSetList[iParamSet], meshTransform);
                    if (isAdd)
                    {
                        isAnyChanged = true;
                    }
                }
            }

            for (int iSync = 0; iSync < _syncTransform_MeshGroup.Count; iSync++)
            {
                apTransform_MeshGroup meshGroupTransform = _syncTransform_MeshGroup[iSync];
                for (int iParamSet = 0; iParamSet < _paramSetList.Count; iParamSet++)
                {
                    bool isAdd = AddMeshGroupTransformToParamSet(_paramSetList[iParamSet], meshGroupTransform);
                    //bool isAdd = _parentModifier.AddMeshGroupTransformToAllParamSet(_parentModifier._meshGroup, meshGroupTransform, false);
                    if (isAdd)
                    {
                        isAnyChanged = true;
                    }
                }
            }

            for (int iSync = 0; iSync < _syncBone.Count; iSync++)
            {
                apBone bone = _syncBone[iSync];

                for (int iParamSet = 0; iParamSet < _paramSetList.Count; iParamSet++)
                {
                    bool isAdd = AddBoneToParamSet(_paramSetList[iParamSet], bone._meshGroup._rootMeshGroupTransform, bone);
                    if (isAdd)
                    {
                        isAnyChanged = true;
                    }
                }
            }

            //추가 : Sync시 WeightedVertex도 같이 처리해주자
            // 동기화 안된건 자동 삭제
            for (int i = 0; i < _calculatedWeightedVertexList.Count; i++)
            {
                _calculatedWeightedVertexList[i]._isSync = false;
            }

            for (int iSync = 0; iSync < _syncTransform_Mesh.Count; iSync++)
            {
                apTransform_Mesh meshTransform            = _syncTransform_Mesh[iSync];
                apModifierParamSetGroupVertWeight existWV = _calculatedWeightedVertexList.Find(delegate(apModifierParamSetGroupVertWeight a)
                {
                    return(a._meshTransform_ID == meshTransform._transformUniqueID);
                });
                if (existWV != null)
                {
                    existWV._isSync = true;
                    existWV.LinkMeshTransform(meshTransform);
                }
                else
                {
                    //없다. 새로 만들자
                    apModifierParamSetGroupVertWeight newVW = new apModifierParamSetGroupVertWeight(meshTransform);
                    newVW._isSync = true;
                    _calculatedWeightedVertexList.Add(newVW);
                }
            }

            //동기화 되지 않은건 지운다.
            _calculatedWeightedVertexList.RemoveAll(delegate(apModifierParamSetGroupVertWeight a)
            {
                return(!a._isSync);
            });

            return(isAnyChanged);
        }
Exemplo n.º 17
0
        public bool RefreshSync()
        {
            if (_syncTransform_Mesh == null)
            {
                _syncTransform_Mesh = new List <apTransform_Mesh>();
            }
            _syncTransform_Mesh.Clear();

            if (_syncTransform_MeshGroup == null)
            {
                _syncTransform_MeshGroup = new List <apTransform_MeshGroup>();
            }
            _syncTransform_MeshGroup.Clear();

            if (_syncBone == null)
            {
                _syncBone = new List <apBone>();
            }
            _syncBone.Clear();

            //한번이라도 등장한 MeshTransform / MeshGroup Transform을 찾자
            for (int i = 0; i < _paramSetList.Count; i++)
            {
                apModifierParamSet paramSet = _paramSetList[i];

                for (int iModMesh = 0; iModMesh < paramSet._meshData.Count; iModMesh++)
                {
                    apModifiedMesh modMesh = paramSet._meshData[iModMesh];
                    if (modMesh._transform_Mesh != null)
                    {
                        //수정 4.1 : Mesh가 없는 MeshTransform
                        if (modMesh._transform_Mesh._mesh == null)
                        {
                            //Debug.Log("AnyPortrait : Mesh of [" + modMesh._transform_Mesh._nickName + "] is removed. Please check it.");
                        }
                        else
                        {
                            if (!_syncTransform_Mesh.Contains(modMesh._transform_Mesh))
                            {
                                _syncTransform_Mesh.Add(modMesh._transform_Mesh);
                            }
                        }

                        //이전 코드
                        //if (!_syncTransform_Mesh.Contains(modMesh._transform_Mesh))
                        //{
                        //	_syncTransform_Mesh.Add(modMesh._transform_Mesh);
                        //}
                    }
                    if (modMesh._transform_MeshGroup != null)
                    {
                        if (!_syncTransform_MeshGroup.Contains(modMesh._transform_MeshGroup))
                        {
                            _syncTransform_MeshGroup.Add(modMesh._transform_MeshGroup);
                        }
                    }
                }
                for (int iModBone = 0; iModBone < paramSet._boneData.Count; iModBone++)
                {
                    apModifiedBone modBone = paramSet._boneData[iModBone];

                    if (modBone._bone != null)
                    {
                        //>> 이건 Bone Set이 필요없다.
                        if (modBone._meshGroup_Bone != null &&
                            modBone._meshGroup_Bone._boneList_All.Contains(modBone._bone)                               //해당 MeshGroup에 Bone이 존재하는가.
                            )
                        {
                            if (!_syncBone.Contains(modBone._bone))
                            {
                                _syncBone.Add(modBone._bone);
                            }
                        }
                        else
                        {
                            //Modifier로 등록되었지만 Bone이 삭제되었다면 여기로 들어온다.
                            //Sync가 안됨
                        }
                    }
                }
            }

            //동기화 전용 Sync Transform을 모든 ParamSet에 넣자
            bool isAnyChanged = false;

            for (int iSync = 0; iSync < _syncTransform_Mesh.Count; iSync++)
            {
                apTransform_Mesh meshTransform = _syncTransform_Mesh[iSync];
                //bool isAdd = _parentModifier.AddMeshTransformToAllParamSet(_parentModifier._meshGroup, meshTransform, false);
                for (int iParamSet = 0; iParamSet < _paramSetList.Count; iParamSet++)
                {
                    bool isAdd = AddMeshTransformToParamSet(_paramSetList[iParamSet], meshTransform);
                    if (isAdd)
                    {
                        isAnyChanged = true;
                    }
                }
            }

            for (int iSync = 0; iSync < _syncTransform_MeshGroup.Count; iSync++)
            {
                apTransform_MeshGroup meshGroupTransform = _syncTransform_MeshGroup[iSync];
                for (int iParamSet = 0; iParamSet < _paramSetList.Count; iParamSet++)
                {
                    bool isAdd = AddMeshGroupTransformToParamSet(_paramSetList[iParamSet], meshGroupTransform);
                    //bool isAdd = _parentModifier.AddMeshGroupTransformToAllParamSet(_parentModifier._meshGroup, meshGroupTransform, false);
                    if (isAdd)
                    {
                        isAnyChanged = true;
                    }
                }
            }

            for (int iSync = 0; iSync < _syncBone.Count; iSync++)
            {
                apBone bone = _syncBone[iSync];

                apTransform_MeshGroup meshGroupTransform = null;
                if (_parentModifier._meshGroup == bone._meshGroup)
                {
                    meshGroupTransform = _parentModifier._meshGroup._rootMeshGroupTransform;
                }
                else
                {
                    meshGroupTransform = _parentModifier._meshGroup.FindChildMeshGroupTransform(bone._meshGroup);
                }

                for (int iParamSet = 0; iParamSet < _paramSetList.Count; iParamSet++)
                {
                    //이전
                    //bool isAdd = AddBoneToParamSet(_paramSetList[iParamSet], bone._meshGroup._rootMeshGroupTransform, bone);
                    //변경 : ChildMeshGroup의 Root MGTF로 설정하는 코드는 잘못되었다.
                    bool isAdd = AddBoneToParamSet(_paramSetList[iParamSet], meshGroupTransform, bone);
                    if (isAdd)
                    {
                        isAnyChanged = true;
                    }
                }
            }

            //추가 : Sync시 WeightedVertex도 같이 처리해주자
            // 동기화 안된건 자동 삭제
            for (int i = 0; i < _calculatedWeightedVertexList.Count; i++)
            {
                _calculatedWeightedVertexList[i]._isSync = false;
            }

            for (int iSync = 0; iSync < _syncTransform_Mesh.Count; iSync++)
            {
                apTransform_Mesh meshTransform            = _syncTransform_Mesh[iSync];
                apModifierParamSetGroupVertWeight existWV = _calculatedWeightedVertexList.Find(delegate(apModifierParamSetGroupVertWeight a)
                {
                    return(a._meshTransform_ID == meshTransform._transformUniqueID);
                });
                if (existWV != null)
                {
                    existWV._isSync = true;
                    existWV.LinkMeshTransform(meshTransform);
                }
                else
                {
                    //없다. 새로 만들자
                    apModifierParamSetGroupVertWeight newVW = new apModifierParamSetGroupVertWeight(meshTransform);
                    newVW._isSync = true;
                    _calculatedWeightedVertexList.Add(newVW);
                }
            }

            //동기화 되지 않은건 지운다.
            _calculatedWeightedVertexList.RemoveAll(delegate(apModifierParamSetGroupVertWeight a)
            {
                return(!a._isSync);
            });

            return(isAnyChanged);
        }
Exemplo n.º 18
0
        public void BakeModifierParamSet(apModifierParamSet srcParamSet, apPortrait portrait)
        {
            //switch (srcParamSet._syncTarget)
            //{
            //	case apModifierParamSet.SYNC_TARGET.Static:
            //		_syncTarget = SYNC_TARGET.Static;
            //		break;

            //	case apModifierParamSet.SYNC_TARGET.Controller:
            //		_syncTarget = SYNC_TARGET.Controller;
            //		break;

            //	case apModifierParamSet.SYNC_TARGET.KeyFrame:
            //		_syncTarget = SYNC_TARGET.KeyFrame;
            //		break;

            //	default:
            //		Debug.LogError("연동 에러 : ParamSet에 정의되지 않은 타입 : " + srcParamSet._syncTarget);
            //		break;
            //}

            //_controlKeyName = srcParamSet._controlKeyName;

            //_conSyncValue_Bool = srcParamSet._conSyncValue_Bool;
            _conSyncValue_Int     = srcParamSet._conSyncValue_Int;
            _conSyncValue_Float   = srcParamSet._conSyncValue_Float;
            _conSyncValue_Vector2 = srcParamSet._conSyncValue_Vector2;
            //_conSyncValue_Vector3 = srcParamSet._conSyncValue_Vector3;
            //_conSyncValue_Color = srcParamSet._conSyncValue_Color;


            _keyframeUniqueID = srcParamSet._keyframeUniqueID;
            _syncKeyframe     = null;

            _overlapWeight = srcParamSet._overlapWeight;            //OverlapWeight를 집어넣자

            _meshData.Clear();
            _boneData.Clear();


            //SrcModifier ParamSet의 ModMesh, ModBone을 Bake해주자
            //Debug.LogError("TODO : Bone 데이터 연동");
            for (int i = 0; i < srcParamSet._meshData.Count; i++)
            {
                apModifiedMesh    srcModMesh = srcParamSet._meshData[i];
                apOptModifiedMesh optModMesh = new apOptModifiedMesh();
                bool isResult = optModMesh.Bake(srcModMesh, portrait);
                if (isResult)
                {
                    _meshData.Add(optModMesh);
                }
            }

            //추가 : ModBone
            for (int i = 0; i < srcParamSet._boneData.Count; i++)
            {
                apModifiedBone    srcModBone = srcParamSet._boneData[i];
                apOptModifiedBone optModBone = new apOptModifiedBone();
                bool isResult = optModBone.Bake(srcModBone, portrait);
                if (isResult)
                {
                    _boneData.Add(optModBone);
                }
            }
        }
Exemplo n.º 19
0
        public override bool Load(object targetObj)
        {
            apAnimKeyframe keyframe = targetObj as apAnimKeyframe;

            if (keyframe == null)
            {
                return(false);
            }

            keyframe._curveKey      = new apAnimCurve(_animCurve, keyframe._frameIndex);
            keyframe._isKeyValueSet = _isKeyValueSet;

            //keyframe._conSyncValue_Bool = _conSyncValue_Bool;
            keyframe._conSyncValue_Int     = _conSyncValue_Int;
            keyframe._conSyncValue_Float   = _conSyncValue_Float;
            keyframe._conSyncValue_Vector2 = _conSyncValue_Vector2;
            //keyframe._conSyncValue_Vector3 = _conSyncValue_Vector3;
            //keyframe._conSyncValue_Color = _conSyncValue_Color;


            if (keyframe._linkedModMesh_Editor != null)
            {
                apModifiedMesh modMesh = keyframe._linkedModMesh_Editor;

                VertData         vertData = null;
                apModifiedVertex modVert  = null;
                int nVert = _vertices.Count;
                for (int i = 0; i < nVert; i++)
                {
                    vertData = _vertices[i];
                    modVert  = modMesh._vertices.Find(delegate(apModifiedVertex a)
                    {
                        return(a._vertex == vertData._key_Vert);
                    });

                    if (modVert != null)
                    {
                        modVert._deltaPos = vertData._deltaPos;
                    }
                }

                modMesh._transformMatrix.SetMatrix(_transformMatrix);
                modMesh._meshColor = _meshColor;
                modMesh._isVisible = _isVisible;

                //추가 3.29 : ExtraProperty도 복사
                modMesh._isExtraValueEnabled = _isExtraValueEnabled;
                if (modMesh._extraValue == null)
                {
                    modMesh._extraValue = new apModifiedMesh.ExtraValue();
                    modMesh._extraValue.Init();
                }

                if (_isExtraValueEnabled)
                {
                    if (_extraValue != null)
                    {
                        modMesh._extraValue._isDepthChanged        = _extraValue._isDepthChanged;
                        modMesh._extraValue._deltaDepth            = _extraValue._deltaDepth;
                        modMesh._extraValue._isTextureChanged      = _extraValue._isTextureChanged;
                        modMesh._extraValue._linkedTextureData     = _extraValue._linkedTextureData;
                        modMesh._extraValue._textureDataID         = _extraValue._textureDataID;
                        modMesh._extraValue._weightCutout          = _extraValue._weightCutout;
                        modMesh._extraValue._weightCutout_AnimPrev = _extraValue._weightCutout_AnimPrev;
                        modMesh._extraValue._weightCutout_AnimNext = _extraValue._weightCutout_AnimNext;
                    }
                }
                else
                {
                    modMesh._extraValue.Init();
                }
            }
            else if (keyframe._linkedModBone_Editor != null)
            {
                apModifiedBone modBone = keyframe._linkedModBone_Editor;
                modBone._transformMatrix.SetMatrix(_transformMatrix);
            }


            return(true);
        }
Exemplo n.º 20
0
        public void LinkModifierStackToRenderUnitCalculateStack(bool isRoot = true, apMeshGroup rootMeshGroup = null)
        {
            //전체 Modifier중에서 RenderUnit을 포함한 Modifer를 찾는다.
            //그 중, RenderUnit에 대한것만 처리할 CalculateResultParam을 만들고 연동한다.
            //ResultParam을 RenderUnit의 CalculateStack에 넣는다.

            //Debug.Log("--------------------------------------------------------------");
            //Debug.Log("LinkModifierStackToRenderUnitCalculateStack [" + _parentMeshGroup._name + "]");
            //Debug.Log("--------------------------------------------------------------");

            //수정
            //각 ModMesh에서 계층적인 Link를 할 수 있도록
            //RenderUnit을 매번 바꾸어주자
            if (isRoot)
            {
                rootMeshGroup = _parentMeshGroup;

                //Modifier-ParamSetGroup-ParamSet + ModMesh가 "실제 RenderUnit"과 링크되지 않으므로
                //Calculate Param을 만들기 전에 이 링크를 먼저 해주어야 한다.
            }



            //Modifier를 돌면서 ParamSet 데이터를 Calculated 데이터로 변환해서 옮긴다.
            for (int iMod = 0; iMod < _modifiers.Count; iMod++)
            {
                //Modifier ->..
                apModifierBase modifier = _modifiers[iMod];

                List <apModifierParamSetGroup> paramSetGroups = modifier._paramSetGroup_controller;

                for (int iGroup = 0; iGroup < paramSetGroups.Count; iGroup++)
                {
                    //Modifier -> ParamSetGroup ->..
                    apModifierParamSetGroup paramSetGroup = paramSetGroups[iGroup];

                    List <apModifierParamSet> paramSets = paramSetGroup._paramSetList;

                    for (int iParam = 0; iParam < paramSets.Count; iParam++)
                    {
                        //Modifier -> ParamSetGroup -> ParamSet ->...
                        apModifierParamSet paramSet = paramSets[iParam];

                        List <apModifiedMesh> modMeshes = paramSet._meshData;
                        List <apModifiedBone> modBones  = paramSet._boneData;

                        //1. Mod Mesh => Calculate Param으로 연결한다.
                        for (int iModMesh = 0; iModMesh < modMeshes.Count; iModMesh++)
                        {
                            //[핵심]
                            //Modifier -> ParamSetGroup -> ParamSet -> ModMeh
                            //이제 이 ModMesh와 타겟 Transform을 연결하자.
                            //연결할땐 Calculated 오브젝트를 만들어서 연결
                            apModifiedMesh modMesh = modMeshes[iModMesh];

                            #region [미사용 코드]
                            //여기서 수정
                            //Root가 아닐때 > RenderUnit을 자체적으로 세팅할게 아니라, Root MeshGroup을 기준으로 RenderUnit을 찾자
                            //if(!isRoot)
                            //{
                            //	apRenderUnit recursiveRenderUnit = null;
                            //	if(modMesh._isMeshTransform)
                            //	{
                            //		recursiveRenderUnit = rootMeshGroup.GetRenderUnit(modMesh._transform_Mesh);
                            //	}
                            //	else
                            //	{
                            //		recursiveRenderUnit = rootMeshGroup.GetRenderUnit(modMesh._transform_MeshGroup);
                            //	}
                            //	if(recursiveRenderUnit != null)
                            //	{
                            //		//Debug.Log("Link ModStack -> Child Render Unit Changed [Modifier : " + modifier.DisplayName + "] / RenderUnit Name : " + recursiveRenderUnit.Name + " / is Changed : " + (modMesh._renderUnit != recursiveRenderUnit));
                            //		//if(modMesh._renderUnit == null)
                            //		//{
                            //		//	Debug.LogError("기존 RenderUnit이 Null이다.");
                            //		//}
                            //		//else if(modMesh._renderUnit._meshGroup == null)
                            //		//{
                            //		//	Debug.LogError("기존 RenderUnit의 MeshGroup이 Null이다.");
                            //		//}
                            //		//else
                            //		//{
                            //		//	Debug.Log("[" + modMesh._renderUnit._meshGroup._name + " > " + rootMeshGroup._name + "]");
                            //		//}

                            //		modMesh._renderUnit = recursiveRenderUnit;
                            //	}
                            //	else
                            //	{
                            //		Debug.LogError("Re Link Failed");
                            //	}
                            //}

                            #endregion

                            if (modMesh._renderUnit == null)
                            {
                                continue;
                            }
                            //이미 만든 Calculate Param이 있는지 확인
                            apCalculatedResultParam existParam = modifier.GetCalculatedResultParam(modMesh._renderUnit);

                            //추가 : 만약 Calculated Param을 찾지 못했다면..
                            //Parent의 누군가가 이미 만들었을 수 있다!
                            //Root Parent MeshGroup에 요청해서 한번 더 확인하자
                            //(Calculated Result Param을 공유할 수 있기 때문)
                            if (existParam == null && rootMeshGroup != null)
                            {
                                //rootMeshGroup._modifierStack
                                //?? 이거 해야하나
                            }

                            apModifierParamSetGroupVertWeight weightedVertexData = null;
                            if (modMesh._transform_Mesh != null)
                            {
                                weightedVertexData = paramSetGroup.GetWeightVertexData(modMesh._transform_Mesh);
                            }

                            if (existParam != null)
                            {
                                //Debug.Log("> ModMesh [" + iModMesh + "] : " + modMesh._transformUniqueID + "< Add >");
                                existParam.AddParamSetAndModifiedValue(paramSetGroup, paramSet, modMesh, null);
                                existParam.LinkWeightedVertexData(weightedVertexData);

                                //if(!isRoot)
                                //{
                                //	Debug.LogWarning("Child Modifier의 CalculateParam을 찾아서 적용 : "
                                //		+ modifier.DisplayName + " / " + existParam._debugID + " / " + existParam._targetRenderUnit.Name);
                                //}
                            }
                            else
                            {
                                //Debug.Log("> ModMesh [" + iModMesh + "] : " + modMesh._transformUniqueID + "< New >");
                                //새로 Calculate Param을 만들고..
                                apCalculatedResultParam newCalParam = new apCalculatedResultParam(
                                    modifier.CalculatedValueType,
                                    modifier.CalculatedSpace,
                                    modifier,
                                    modMesh._renderUnit,
                                    null,                                    //<Bone은 없으닝께..
                                    weightedVertexData
                                    );

                                newCalParam.AddParamSetAndModifiedValue(paramSetGroup, paramSet, modMesh, null);

                                // Modifier에 등록하고
                                modifier._calculatedResultParams.Add(newCalParam);

                                //RenderUnit에도 등록을 하자
                                modMesh._renderUnit._calculatedStack.AddCalculatedResultParam(newCalParam);


                                //if(!isRoot)
                                //{
                                //	Debug.LogWarning("Child Modifier의 CalculateParam을 찾아서 적용 : "
                                //		+ modifier.DisplayName + " / " + newCalParam._debugID + " / " + newCalParam._targetRenderUnit.Name);
                                //}
                            }
                            //else
                            //{
                            //	Debug.LogError("Link Modifier Stack Error : No Render Unit (isRoot : " + isRoot + ")");
                            //}
                        }

                        //2. Mod Bone => Calculate Param으로 연결한다.
                        for (int iModBone = 0; iModBone < modBones.Count; iModBone++)
                        {
                            apModifiedBone modBone = modBones[iModBone];

                            if (modBone._bone == null || modBone._renderUnit == null)
                            {
                                Debug.LogError("ModBone -> Calculate Link 실패 : [Bone : " + (modBone._bone != null) + ", RenderUnit : " + (modBone._renderUnit != null) + "]");
                                continue;
                            }

                            //이미 만든 Calculate Param이 있는지 확인
                            apCalculatedResultParam existParam = modifier.GetCalculatedResultParam_Bone(modBone._renderUnit, modBone._bone);

                            if (existParam != null)
                            {
                                //이미 있다면 ModBone만 추가해주자
                                existParam.AddParamSetAndModifiedValue(paramSetGroup, paramSet, null, modBone);
                            }
                            else
                            {
                                //Debug.Log("Mod Bone -> Calculate Param 등록");
                                //새로 CalculateParam을 만들고
                                apCalculatedResultParam newCalParam = new apCalculatedResultParam(
                                    modifier.CalculatedValueType,
                                    modifier.CalculatedSpace,
                                    modifier,
                                    modBone._renderUnit,
                                    modBone._bone,
                                    null                                    //WeightedVertex
                                    );

                                newCalParam.AddParamSetAndModifiedValue(paramSetGroup, paramSet, null, modBone);

                                // Modifier에 등록하고
                                modifier._calculatedResultParams.Add(newCalParam);

                                //RenderUnit에도 등록을 하자
                                modBone._renderUnit._calculatedStack.AddCalculatedResultParam(newCalParam);
                            }
                        }
                    }
                }


                //SubList를 한번 정렬하자
                for (int iCal = 0; iCal < modifier._calculatedResultParams.Count; iCal++)
                {
                    modifier._calculatedResultParams[iCal].SortSubList();
                }
            }

            //추가>>
            //하위 객체에 대해서도 Link를 자동으로 수행한다.
            //다 끝나고 Sort
            List <apTransform_MeshGroup> childMeshGroupTransforms = _parentMeshGroup._childMeshGroupTransforms;

            apTransform_MeshGroup childMeshGroup = null;

            if (childMeshGroupTransforms != null && childMeshGroupTransforms.Count > 0)
            {
                for (int i = 0; i < childMeshGroupTransforms.Count; i++)
                {
                    childMeshGroup = childMeshGroupTransforms[i];
                    if (childMeshGroup._meshGroup != null && childMeshGroup._meshGroup != _parentMeshGroup)
                    {
                        childMeshGroup._meshGroup._modifierStack.LinkModifierStackToRenderUnitCalculateStack(false, rootMeshGroup);                        //<<여기서도 같이 수행
                    }
                }
            }

            if (isRoot)
            {
                //Debug.Log("Start Sort : " + _parentMeshGroup._name);
                //Root인 경우
                //RenderUnit들을 검사하면서 Calculated Stack에 대해서 Sort를 해주자
                List <apRenderUnit> renderUnits = _parentMeshGroup._renderUnits_All;
                for (int i = 0; i < renderUnits.Count; i++)
                {
                    renderUnits[i]._calculatedStack.Sort();
                }
            }
        }
Exemplo n.º 21
0
 public void LinkModBone_Editor(apModifierParamSet paramSet, apModifiedBone modBone)
 {
     _linkedParamSet_Editor = paramSet;
     _linkedModMesh_Editor  = null;
     _linkedModBone_Editor  = modBone;
 }
Exemplo n.º 22
0
        public void BakeModifierParamSet(apModifierParamSet srcParamSet, apPortrait portrait, bool isUseModMeshSet)
        {
            _conSyncValue_Int     = srcParamSet._conSyncValue_Int;
            _conSyncValue_Float   = srcParamSet._conSyncValue_Float;
            _conSyncValue_Vector2 = srcParamSet._conSyncValue_Vector2;


            _keyframeUniqueID = srcParamSet._keyframeUniqueID;
            _syncKeyframe     = null;

            _overlapWeight = srcParamSet._overlapWeight;            //OverlapWeight를 집어넣자

            _meshData.Clear();
            _boneData.Clear();

            //19.5.23 : meshSetData 추가
            if (_meshSetData == null)
            {
                _meshSetData = new List <apOptModifiedMeshSet>();
            }
            _meshSetData.Clear();
            _isUseModMeshSet = isUseModMeshSet;            //<<이 값이 1.1.7부터는 true가 된다.


            if (!_isUseModMeshSet)
            {
                //이전버전
                //SrcModifier ParamSet의 ModMesh, ModBone을 Bake해주자
                for (int i = 0; i < srcParamSet._meshData.Count; i++)
                {
                    apModifiedMesh    srcModMesh = srcParamSet._meshData[i];
                    apOptModifiedMesh optModMesh = new apOptModifiedMesh();
                    bool isResult = optModMesh.Bake(srcModMesh, portrait);
                    if (isResult)
                    {
                        _meshData.Add(optModMesh);
                    }
                }
            }
            else
            {
                //변경된 버전 : 19.5.23 (v.1.1.7)
                for (int i = 0; i < srcParamSet._meshData.Count; i++)
                {
                    apModifiedMesh       srcModMesh    = srcParamSet._meshData[i];
                    apOptModifiedMeshSet optModMeshSet = new apOptModifiedMeshSet();
                    bool isResult = optModMeshSet.Bake(
                        srcParamSet._parentParamSetGroup._parentModifier,
                        srcParamSet._parentParamSetGroup,
                        srcModMesh,
                        portrait);
                    if (isResult)
                    {
                        _meshSetData.Add(optModMeshSet);
                    }
                }
            }


            //ModBone
            for (int i = 0; i < srcParamSet._boneData.Count; i++)
            {
                apModifiedBone    srcModBone = srcParamSet._boneData[i];
                apOptModifiedBone optModBone = new apOptModifiedBone();
                bool isResult = optModBone.Bake(srcModBone, portrait);
                if (isResult)
                {
                    _boneData.Add(optModBone);
                }
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// ParamSet을 받아서 SubList와 연동한다.
        /// </summary>
        /// <param name="paramSet"></param>
        /// <param name="modifiedValue"></param>
        public void AddParamSetAndModifiedValue(apModifierParamSetGroup paramSetGroup,
                                                apModifierParamSet paramSet,
                                                apModifiedMesh modifiedMesh,
                                                apModifiedBone modifiedBone)
        {
            ParamKeyValueSet existSet = GetParamKeyValue(paramSet);

            if (existSet != null)
            {
                return;
            }


            //수정 : ModifiedBone을 넣어주자
            //새로운 KeyValueSet을 만들어서 리스트에 추가하자
            ParamKeyValueSet newKeyValueSet = null;

            if (modifiedMesh != null)
            {
                //ModMesh를 등록하는 경우
                newKeyValueSet = new ParamKeyValueSet(paramSetGroup, paramSet, modifiedMesh);
            }
            else if (modifiedBone != null)
            {
                //ModBone을 등록하는 경우
                newKeyValueSet = new ParamKeyValueSet(paramSetGroup, paramSet, modifiedBone);
            }

            _paramKeyValues.Add(newKeyValueSet);

            //Debug.LogError("Cur Param Key Value : " + _paramKeyValues.Count);

            apCalculatedResultParamSubList targetSubList = null;

            //같이 묶여서 작업할 SubList가 있는가
            apCalculatedResultParamSubList existSubList = _subParamKeyValueList.Find(delegate(apCalculatedResultParamSubList a)
            {
                //return a._controlParam == paramSetGroup._keyControlParam;
                return(a._keyParamSetGroup == paramSetGroup);
            });

            if (existSubList != null)
            {
                targetSubList = existSubList;
            }
            else
            {
                targetSubList = new apCalculatedResultParamSubList(this);
                targetSubList.SetParamSetGroup(paramSetGroup);
                //targetSubList.SetControlParam(paramSetGroup._keyControlParam);

                _subParamKeyValueList.Add(targetSubList);
                //Debug.LogError("AddParamSetAndModifiedMesh : Add New SubList");
            }


            #region [미사용 코드]
            //switch (paramSetGroup._syncTarget)
            //{
            //	case apModifierParamSetGroup.SYNC_TARGET.Controller:
            //		{
            //			if (paramSetGroup._keyControlParam != null)
            //			{
            //				//같이 묶여서 작업할 SubList가 있는가
            //				apCalculatedResultParamSubList existSubList = _subParamKeyValueList.Find(delegate (apCalculatedResultParamSubList a)
            //				{
            //					return a._controlParam == paramSetGroup._keyControlParam;
            //				});

            //				if (existSubList != null)
            //				{
            //					targetSubList = existSubList;
            //				}
            //				else
            //				{
            //					targetSubList = new apCalculatedResultParamSubList(this);
            //					targetSubList.SetParamSetGroup(paramSetGroup);
            //					//targetSubList.SetControlParam(paramSetGroup._keyControlParam);

            //					_subParamKeyValueList.Add(targetSubList);
            //				}
            //			}
            //		}
            //		break;

            //	case apModifierParamSetGroup.SYNC_TARGET.KeyFrame:
            //		{
            //			//...TODO
            //			Debug.LogError("TODO : KeyFrame 타입의 CalculateResultParam의 SubList 처리할 것");
            //			//??
            //		}
            //		break;

            //	case apModifierParamSetGroup.SYNC_TARGET.Static:
            //		{
            //			//Static은 1개만 있다.
            //			if(_subParamKeyValueList.Count == 0)
            //			{
            //				//새로 만들자.
            //				targetSubList = new apCalculatedResultParamSubList(this);
            //				targetSubList.SetStatic();

            //				_subParamKeyValueList.Add(targetSubList);
            //			}
            //			else
            //			{
            //				//있는거 사용하자
            //				targetSubList = _subParamKeyValueList[0];
            //			}
            //		}
            //		break;
            //}
            #endregion

            //해당 SubList에 위에서 만든 KeyValueSet을 추가하자
            if (targetSubList != null)
            {
                //ParamKeyValueSet을 추가하자
                targetSubList.AddParamKeyValueSet(newKeyValueSet);
            }
        }
Exemplo n.º 24
0
 /// <summary>Modified의 초기화</summary>
 public apCalculatedLog(apModifiedBone modBone)
 {
     _logType = LOG_TYPE.Modified;
     _modBone = modBone;
 }