Example #1
0
        //public void Init(int vertUniqueID, int vertIndex, apOptMesh mesh, Vector2 deltaPos)
        //{
        //	_vertUniqueID = vertUniqueID;
        //	_vertIndex = vertIndex;
        //	_mesh = mesh;
        //	_deltaPos = deltaPos;
        //}

        public void Bake(apModifiedVertex srcModVert, apOptMesh mesh)
        {
            _vertUniqueID = srcModVert._vertexUniqueID;
            _vertIndex    = srcModVert._vertIndex;
            _mesh         = mesh;
            _deltaPos     = srcModVert._deltaPos;
        }
        // Init - 값 넣기 (값복사)
        //--------------------------------------------
        //연동을 해주자 (apModifiedMesh에서 Init/Link 계열 함수)
        public void Bake_VertexMorph(apOptTransform rootTransform, apOptTransform targetTransform,
                                     apOptMesh targetMesh, List <apModifiedVertex> modVerts, Color meshColor, bool isVisible)
        {
            //_targetType = apModifiedMesh.TARGET_TYPE.VertexWithMeshTransform;

            _rootTransform   = rootTransform;
            _targetTransform = targetTransform;
            _targetMesh      = targetMesh;

            if (_targetMesh == null)
            {
                Debug.LogError("Vert Morph인데 Target Mesh가 Null");
                Debug.LogError("Target Transform [" + _targetTransform.transform.name + "]");
            }

            _nVerts   = modVerts.Count;
            _vertices = new apOptModifiedVertex[_nVerts];
            for (int i = 0; i < _nVerts; i++)
            {
                apOptModifiedVertex optModVert = new apOptModifiedVertex();
                apModifiedVertex    srcModVert = modVerts[i];
                optModVert.Bake(srcModVert, _targetMesh);

                _vertices[i] = optModVert;
            }

            _meshColor = meshColor;
            _isVisible = isVisible;
        }
Example #3
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);
        }
Example #4
0
        public override bool Save(object target, string strParam)
        {
            base.Save(target, strParam);

            apModifiedMesh modMesh = target as apModifiedMesh;

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

            _key_MeshGroupOfMod       = modMesh._meshGroupOfModifier;
            _key_MeshGroupOfTransform = modMesh._meshGroupOfTransform;

            _key_MeshTransform      = null;
            _key_MeshGroupTransform = null;
            _key_RenderUnit         = null;

            if (modMesh._transform_Mesh != null)
            {
                _key_MeshTransform = modMesh._transform_Mesh;
            }
            if (modMesh._transform_MeshGroup != null)
            {
                _key_MeshGroupTransform = modMesh._transform_MeshGroup;
            }
            _key_RenderUnit = modMesh._renderUnit;

            _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;


            _isExtraValueEnabled = false;
            _extraValue          = null;

            //추가 3.29 : ExtraValue도 복사
            if (modMesh._isExtraValueEnabled)
            {
                _isExtraValueEnabled = true;
                _extraValue          = new ExtraDummyValue(modMesh._extraValue);
            }

            return(true);
        }
Example #5
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);
        }
Example #6
0
        // 버텍스 Refresh
        //---------------------------------------------------
        public void RefreshVertices()
        {
            if (_transform_Mesh._mesh != null)
            {
                bool isSameVerts = true;
                if (_vertices.Count == 0 || _vertices.Count != _transform_Mesh._mesh._vertexData.Count)
                {
                    isSameVerts = false;
                }
                else
                {
                    //전부 비교해볼까나..
                    //빠르게 단순 링크를 시도해보고, 한번이라도 실패하면 다시 리스트를 만들어야한다.
                    List <apVertex>  meshVertList = _transform_Mesh._mesh._vertexData;
                    apVertex         meshVert     = null;
                    apModifiedVertex modVert      = null;
                    for (int i = 0; i < meshVertList.Count; i++)
                    {
                        meshVert = meshVertList[i];
                        modVert  = _vertices[i];

                        if (modVert._vertexUniqueID != meshVert._uniqueID)
                        {
                            //버텍스 리스트 갱신이 필요하다
                            isSameVerts = false;
                            break;
                        }

                        modVert.Link(this, _transform_Mesh._mesh, meshVert);
                    }
                }

                if (!isSameVerts)
                {
                    //유효한 Vertex만 찾아서 넣어준다.
                    //유효하면 - Link
                    //유효하지 않다면 - Pass (Link 안된거 삭제)
                    //없는건 - Add
                    //순서는.. Index를 넣어서



                    //1. 일단 기존 데이터 복사 - 없어진 Vertex를 빼자
                    if (_vertices.Count != 0)
                    {
                        apModifiedVertex modVert = null;
                        for (int i = 0; i < _vertices.Count; i++)
                        {
                            modVert = _vertices[i];
                            apVertex existVert = _transform_Mesh._mesh._vertexData.Find(delegate(apVertex a)
                            {
                                return(a._uniqueID == modVert._vertexUniqueID);
                            });

                            if (existVert != null)
                            {
                                //유효하다면 Link
                                modVert.Link(this, _transform_Mesh._mesh, existVert);
                            }
                            else
                            {
                                //유효하지 않다면.. Unlink -> 나중에 삭제됨
                                modVert._vertex = null;
                            }
                        }

                        //이제 존재하지 않는 Vertex에 대해서는 삭제
                        _vertices.RemoveAll(delegate(apModifiedVertex a)
                        {
                            return(a._vertex == null);
                        });

                        List <apVertex> meshVertList = _transform_Mesh._mesh._vertexData;
                        apVertex        meshVert     = null;

                        for (int i = 0; i < meshVertList.Count; i++)
                        {
                            meshVert = meshVertList[i];
                            //해당 Vertex가 있었는가
                            bool isLinked = _vertices.Exists(delegate(apModifiedVertex a)
                            {
                                return(a._vertex == meshVert);
                            });

                            //없으면 추가
                            if (!isLinked)
                            {
                                apModifiedVertex newVert = new apModifiedVertex();
                                newVert.Init(meshVert._uniqueID, meshVert);
                                newVert.Link(this, _transform_Mesh._mesh, meshVert);

                                _vertices.Add(newVert);                                //<<새로 추가할 리스트에 넣어준다.
                            }
                        }

                        //Vertex Index에 맞게 정렬
                        _vertices.Sort(delegate(apModifiedVertex a, apModifiedVertex b)
                        {
                            return(a._vertIndex - b._vertIndex);
                        });
                    }
                    else
                    {
                        //2. 아예 리스트가 없을 때
                        _vertices.Clear();

                        List <apVertex> meshVertList = _transform_Mesh._mesh._vertexData;
                        apVertex        meshVert     = null;

                        for (int i = 0; i < meshVertList.Count; i++)
                        {
                            meshVert = meshVertList[i];

                            apModifiedVertex newVert = new apModifiedVertex();
                            newVert.Init(meshVert._uniqueID, meshVert);
                            newVert.Link(this, _transform_Mesh._mesh, meshVert);

                            _vertices.Add(newVert);                            //<<새로 추가할 리스트에 넣어준다.
                        }
                    }
                }
            }
        }
Example #7
0
        public override bool Load(object targetObj)
        {
            apModifiedMesh modMesh = targetObj as apModifiedMesh;

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

            int  nVert           = _vertices.Count;
            bool isDifferentVert = false;

            //만약 하나라도 Vert가 변경된게 있으면 좀 오래 걸리는 로직으로 바뀌어야 한다.
            //미리 체크해주자
            if (modMesh._vertices.Count != nVert)
            {
                isDifferentVert = true;
            }
            else
            {
                for (int i = 0; i < nVert; i++)
                {
                    if (_vertices[i]._key_Vert != modMesh._vertices[i]._vertex)
                    {
                        isDifferentVert = true;
                        break;
                    }
                }
            }

            if (isDifferentVert)
            {
                //1. 만약 Vertex 구성이 다르면
                //매번 Find로 찾아서 매칭해야한다.
                VertData         vertData = null;
                apModifiedVertex modVert  = null;
                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;
                    }
                }
            }
            else
            {
                //2. Vertex 구성이 같으면
                // 그냥 For 돌면서 넣어주자
                VertData         vertData = null;
                apModifiedVertex modVert  = null;
                for (int i = 0; i < nVert; i++)
                {
                    vertData = _vertices[i];
                    modVert  = modMesh._vertices[i];

                    modVert._deltaPos = vertData._deltaPos;
                }
            }

            modMesh._transformMatrix = new apMatrix(_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();
            }


            return(true);
        }
Example #8
0
        public override bool Load(object targetObj)
        {
            apModifiedMesh modMesh = targetObj as apModifiedMesh;

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

            int  nVert           = _vertices.Count;
            bool isDifferentVert = false;

            //만약 하나라도 Vert가 변경된게 있으면 좀 오래 걸리는 로직으로 바뀌어야 한다.
            //미리 체크해주자
            if (modMesh._vertices.Count != nVert)
            {
                isDifferentVert = true;
            }
            else
            {
                for (int i = 0; i < nVert; i++)
                {
                    if (_vertices[i]._key_Vert != modMesh._vertices[i]._vertex)
                    {
                        isDifferentVert = true;
                        break;
                    }
                }
            }

            if (isDifferentVert)
            {
                //1. 만약 Vertex 구성이 다르면
                //매번 Find로 찾아서 매칭해야한다.
                VertData         vertData = null;
                apModifiedVertex modVert  = null;
                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;
                    }
                }
            }
            else
            {
                //2. Vertex 구성이 같으면
                // 그냥 For 돌면서 넣어주자
                VertData         vertData = null;
                apModifiedVertex modVert  = null;
                for (int i = 0; i < nVert; i++)
                {
                    vertData = _vertices[i];
                    modVert  = modMesh._vertices[i];

                    modVert._deltaPos = vertData._deltaPos;
                }
            }

            modMesh._transformMatrix = new apMatrix(_transformMatrix);
            modMesh._meshColor       = _meshColor;
            modMesh._isVisible       = _isVisible;

            return(true);
        }
Example #9
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);
        }