Exemple #1
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
        }
        public void Link(apPortrait portrait, apAnimPlayManager animPlayManager, apAnimPlayMecanim animPlayMecanim)
        {
            ClearTracks();
#if UNITY_2017_1_OR_NEWER
            _portrait = portrait;
#endif
            _animPlayManager = animPlayManager;
#if UNITY_2017_1_OR_NEWER
            //_animPlayMecanim = animPlayMecanim;
#endif

            //Inspector에서 지정된 트랙 정보가 있다면 먼저 등록한다.
#if UNITY_2017_1_OR_NEWER
            if (portrait._timelineTrackSets != null && portrait._timelineTrackSets.Length > 0)
            {
                apPortrait.TimelineTrackPreset trackSetData = null;
                for (int i = 0; i < portrait._timelineTrackSets.Length; i++)
                {
                    trackSetData = portrait._timelineTrackSets[i];

                    AddTrack(trackSetData._playableDirector, trackSetData._trackName, trackSetData._layer, trackSetData._blendMethod);
                }
            }
#endif
        }
Exemple #3
0
 public void BakeModifier(apPortrait portrait, apMeshGroup srcMeshGroup)
 {
     if (srcMeshGroup != null)
     {
         _modifierStack.Bake(srcMeshGroup._modifierStack, portrait);
     }
 }
Exemple #4
0
        // Show Window
        //------------------------------------------------------------------
        public static object ShowDialog(apEditor editor, apPortrait portrait, FUNC_FFD_SIZE_RESULT funcResult, int curX, int curY)
        {
            CloseDialog();

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

            EditorWindow     curWindow = EditorWindow.GetWindow(typeof(apDialog_FFDSize), true, "Custom FFD Size", true);
            apDialog_FFDSize curTool   = curWindow as apDialog_FFDSize;

            object loadKey = new object();

            if (curTool != null && curTool != s_window)
            {
                int width  = 300;
                int height = 130;
                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, portrait, loadKey, funcResult, curX, curY);

                return(loadKey);
            }
            else
            {
                return(null);
            }
        }
        // Bake
        //----------------------------------------------------------
        //Render Buffer는 Bake가 3단계로 이루어진다.
        //데이터가 절차적으로 생성되는 바람에.. 어쩔 수 없이... 힁
        public void Bake_Init(apPortrait portrait, apOptRootUnit rootUnit, apRootUnit srcRootUnit)
        {
            Clear();

            _bakedBuffers.Clear();
            _ZPerDepth = portrait._bakeZSize;
        }
        public void LinkOpt(apPortrait portrait)
        {
            _portrait = portrait;


            if (_targetMeshGroupID < 0)
            {
                //연결되지 않았네요.
                UnityEngine.Debug.LogError("No MeshGroup Linked");
                return;
            }


            _targetOptTranform = _portrait.GetOptTransformAsMeshGroup(_targetMeshGroupID);


            if (_targetOptTranform == null)
            {
                //UnityEngine.Debug.LogError("AnimClip이 적용되는 Target Opt Transform이 Null이다. [" + _targetMeshGroupID + "] (" + _name + ")");
                //이 AnimClip을 사용하지 맙시다.
                return;
            }


            for (int i = 0; i < _timelines.Count; i++)
            {
                _timelines[i].LinkOpt(this);
            }
        }
Exemple #7
0
        private IEnumerator Crt_RequestEditor()
        {
            yield return(new WaitForEndOfFrame());

            Selection.activeObject = null;

            yield return(new WaitForEndOfFrame());

            if (_requestPortrait != null)
            {
                try
                {
                    apEditor anyPortraitEditor = apEditor.ShowWindow();
                    if (_requestType == REQUEST_TYPE.OpenAndSet)
                    {
                        anyPortraitEditor.SetPortraitByInspector(_requestPortrait, false);
                    }
                    else if (_requestType == REQUEST_TYPE.QuickBake)
                    {
                        anyPortraitEditor.SetPortraitByInspector(_requestPortrait, true);
                        Selection.activeObject = _requestPortrait.gameObject;
                    }
                }
                catch (Exception ex)
                {
                    Debug.LogError("Open Editor Error : " + ex);
                }
            }
            _requestType     = REQUEST_TYPE.None;
            _requestPortrait = null;
        }
Exemple #8
0
        private void ExecuteCoroutine()
        {
            if (_coroutine == null)
            {
                _requestType     = REQUEST_TYPE.None;
                _requestPortrait = null;

                //Debug.Log("ExecuteCoroutine => End");
                EditorApplication.update -= ExecuteCoroutine;
                return;
            }

            //Debug.Log("Update Coroutine");
            bool isResult = _coroutine.MoveNext();

            if (!isResult)
            {
                _coroutine       = null;
                _requestType     = REQUEST_TYPE.None;
                _requestPortrait = null;
                //Debug.Log("ExecuteCoroutine => End");
                EditorApplication.update -= ExecuteCoroutine;
                return;
            }
        }
        public void Link(apPortrait portrait)
        {
            //Portrait를 기준으로 Link를 해야한다.
            _portrait = portrait;

            //필요한 경우 Link 추가

            if (_physicMeshParam != null && _isUsePhysicParam)
            {
                _physicMeshParam.Link(_portrait);
            }

            if (_nVertWeights > 0)
            {
                for (int i = 0; i < _nVertWeights; i++)
                {
                    _vertWeights[i].Link(this,
                                         _targetTransform,
                                         _targetMesh,
                                                                       //_targetMesh.RenderVertices[_vertWeights[i]._vertIndex]//이전
                                         _targetMesh.RenderVertices[i] //<<변경 (이미 정렬되어 있으므로 i=vertIndex 이다.)
                                         );
                }
            }

            //추가 : Extra Option
            if (_isExtraValueEnabled)
            {
                _extraValue.Link(portrait);
            }
        }
Exemple #10
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);
        }
                public bool Link(apPortrait portrait, apCache <apOptTransform> cache)
                {
                    _bone = null;

                    //Cache를 통해서 일단 MeshGroup에 해당하는 optTransform을 찾자
                    apOptTransform meshGroup = null;

                    if (cache.IsContain(_meshGroupID))
                    {
                        meshGroup = cache.Get(_meshGroupID);
                    }
                    else
                    {
                        meshGroup = portrait.GetOptTransformAsMeshGroup(_meshGroupID);
                        if (meshGroup == null)
                        {
                            Debug.LogError("VertRig Bake 실패 : MeshGroup을 찾을 수 없다. [" + _meshGroupID + "]");
                            return(false);
                        }

                        //캐시에 담고
                        cache.Add(_meshGroupID, meshGroup);
                    }

                    //본을 찾자
                    _bone = meshGroup.GetBone(_boneID);
                    if (_bone == null)
                    {
                        Debug.LogError("VertRig Bake 실패 : Bone을 찾을 수 없다. [" + _boneID + "]");
                        return(false);
                    }

                    return(true);
                }
        // Show Window
        //------------------------------------------------------------------
        public static object ShowDialog(apEditor editor, apPortrait portrait)
        {
            CloseDialog();

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

            EditorWindow  curWindow = EditorWindow.GetWindow(typeof(apDialog_Bake), true, "Bake", true);
            apDialog_Bake curTool   = curWindow as apDialog_Bake;

            object loadKey = new object();

            if (curTool != null && curTool != s_window)
            {
                int width  = 350;
                int height = 170;
                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, portrait, loadKey);

                return(loadKey);
            }
            else
            {
                return(null);
            }
        }
Exemple #13
0
        //public void Clear()
        //{
        //	_stretchRange = 0.0f;
        //	_stretchK = 0.0f;
        //	//_bendRange = 0.0f;
        //	//_bendK = 0.0f;

        //	_damping = 0.0f;
        //	_mass = 100.0f;

        //	_gravityParamType = ExternalParamType.Constant;
        //	_gravityConstValue = Vector2.zero;
        //	_gravityControlParamID = -1;
        //	_gravityControlParam = null;

        //	_windParamType = ExternalParamType.Constant;
        //	_windConstValue = Vector2.zero;
        //	_windControlParamID = -1;
        //	_windControlParam = null;//<<Link해야한다.
        //	_windRandomRange = Vector2.zero;

        //	_airDrag = 0.0f;

        //	_viscosity = 0.0f;
        //	_restoring = 1.0f;
        //}

        public void Link(apPortrait portrait)
        {
            //ControlParam을 연결하자
            //1. Gravity
            if (_gravityControlParamID > 0)
            {
                _gravityControlParam = portrait._controller.FindParam(_gravityControlParamID);
                if (_gravityControlParam == null)
                {
                    _gravityControlParamID = -1;
                }
            }
            else
            {
                _gravityControlParam = null;
            }

            //2. Wind
            if (_windControlParamID > 0)
            {
                _windControlParam = portrait._controller.FindParam(_windControlParamID);
                if (_windControlParam == null)
                {
                    _windControlParamID = -1;
                }
            }
            else
            {
                _windControlParam = null;
            }
        }
Exemple #14
0
 public void Link(apPortrait portrait)
 {
     if (_textureDataID >= 0)
     {
         _linkedTextureData = portrait.GetTexture(_textureDataID);
     }
 }
Exemple #15
0
 public void LinkPortrait(apPortrait portrait)
 {
     if (_linkedPortraits.Contains(portrait))
     {
         return;
     }
     _linkedPortraits.Add(portrait);
 }
Exemple #16
0
        public void Ready(apPortrait portrait)
        {
            _portrait = portrait;
            //_portrait.RegistUniqueID_ControlParam(_uniqueID);
            _portrait.RegistUniqueID(apIDManager.TARGET.ControlParam, _uniqueID);

            MakeInterpolationRange();
        }
Exemple #17
0
 public void Link(apPortrait portrait)
 {
     _parentPortrait = portrait;
     for (int i = 0; i < _matUnits.Count; i++)
     {
         _matUnits[i]._linkedMeshes.Clear();
     }
 }
Exemple #18
0
        // Init
        //-------------------------------------------------
        public apModifierParamSetGroup(apPortrait portrait, apModifierBase parentModifier, int layerIndex)
        {
            LinkPortrait(portrait, parentModifier);

            _layerIndex  = layerIndex;
            _layerWeight = 1.0f;
            _blendMethod = BLEND_METHOD.Interpolation;
        }
Exemple #19
0
        void OnEnable()
        {
            _targetPortrait = null;

            _isFold_RootPortraits    = true;
            _isFold_AnimationClips   = true;
            _isFold_ConrolParameters = true;
        }
Exemple #20
0
 //추가 12.6
 //Sorted Render Buffer에 대한 Bake
 public void BakeSortedRenderBuffer(apPortrait portrait, apRootUnit srcRootUnit)
 {
     if (_sortedRenderBuffer == null)
     {
         _sortedRenderBuffer = new apOptSortedRenderBuffer();
     }
     _sortedRenderBuffer.Bake_Init(portrait, this, srcRootUnit);
 }
Exemple #21
0
        // Link
        //---------------------------------------------------------------------------------
        public void Link(apPortrait portrait)
        {
            _portrait = portrait;

            if (IsVertex)
            {
                apOptModifiedMesh_Vertex sub_Vertex = SubModMesh_Vertex;
                if (sub_Vertex != null)
                {
                    sub_Vertex.Link(this);
                }
            }

            if (IsTransform)
            {
                apOptModifiedMesh_Transform sub_Transform = SubModMesh_Transform;
                if (sub_Transform != null)
                {
                    sub_Transform.Link(this);
                }
            }

            if (IsRigging)
            {
                apOptModifiedMesh_VertexRig sub_Rigging = SubModMesh_Rigging;
                if (sub_Rigging != null)
                {
                    sub_Rigging.Link(portrait, this);
                }
            }

            if (IsPhysics)
            {
                apOptModifiedMesh_Physics sub_Physics = SubModMesh_Physics;
                if (sub_Physics != null)
                {
                    sub_Physics.Link(portrait, this);
                }
            }

            if (IsColor)
            {
                apOptModifiedMesh_Color sub_Color = SubModMesh_Color;
                if (sub_Color != null)
                {
                    sub_Color.Link(this);
                }
            }

            if (IsExtra)
            {
                apOptModifiedMesh_Extra sub_Extra = SubModMesh_Extra;
                if (sub_Extra != null)
                {
                    sub_Extra.Link(portrait, this);
                }
            }
        }
        // Functions
        //-----------------------------------------------------------------------------
        //Material Info를 사용하지 않는 이전 방식
        public Material GetSharedMaterial_Prev(Texture texture, Shader shader, apPortrait portrait)
        {
#if UNITY_EDITOR
            if (UnityEditor.BuildPipeline.isBuildingPlayer)
            {
                return(null);
            }
#endif
            MaterialUnit matUnit = null;

            //Debug.LogWarning("Shared Material - Get Shared Material [ " + texture.name + " / " + shader.name + " / " + portrait.name + " ]");
            if (_matUnits_Prev.ContainsKey(texture))
            {
                if (_matUnits_Prev[texture].ContainsKey(shader))
                {
                    matUnit = _matUnits_Prev[texture][shader];
                }
                else
                {
                    //새로운 Material Set 생성
                    matUnit = new MaterialUnit(texture, shader);

                    //Shader 키와 함께 등록
                    _matUnits_Prev[texture].Add(shader, matUnit);

                    //Debug.Log(">> (!) 새로운 Material 리턴");
                }
            }
            else
            {
                //새로운 Material Set 생성
                matUnit = new MaterialUnit(texture, shader);

                //Texture 키와 리스트 생성
                _matUnits_Prev.Add(texture, new Dictionary <Shader, MaterialUnit>());

                //Shader 키와 함께 등록
                _matUnits_Prev[texture].Add(shader, matUnit);

                //Debug.Log(">> (!) 새로운 Material 리턴");
            }

            //Portrait 등록
            matUnit.LinkPortrait(portrait);
            List <MaterialUnit> matUnitList = null;
            if (!_portrait2MatUnits_Prev.ContainsKey(portrait))
            {
                _portrait2MatUnits_Prev.Add(portrait, new List <MaterialUnit>());
            }
            matUnitList = _portrait2MatUnits_Prev[portrait];
            if (!matUnitList.Contains(matUnit))
            {
                matUnitList.Add(matUnit);
            }

            //Shader Material 반환
            return(matUnit._material);
        }
Exemple #23
0
            /// <summary>
            /// Portrait의 등록을 해제한다.
            /// 등록된 모든 Portrait가 삭제되었다면, True를 리턴한다. (삭제하도록)
            /// </summary>
            /// <param name="portrait"></param>
            /// <returns></returns>
            public bool RemovePortrait(apPortrait portrait)
            {
                if (_linkedPortraits.Contains(portrait))
                {
                    _linkedPortraits.Remove(portrait);
                }

                return(_linkedPortraits.Count == 0);
            }
        // Editor Functions
        //------------------------------------------------
        public void Bake(apPortrait portrait,         //apMeshGroup srcMeshGroup,
                         apOptTransform parentTransform,
                         apOptRootUnit rootUnit,
                         string name,
                         int transformID, int meshGroupUniqueID, apMatrix defaultMatrix,
                         bool isMesh, int level, int depth,
                         bool isVisible_Default,
                         Color meshColor2X_Default,
                         float zScale
                         )
        {
            _portrait          = portrait;
            _rootUnit          = rootUnit;
            _transformID       = transformID;
            _name              = name;
            _meshGroupUniqueID = meshGroupUniqueID;

            _parentTransform = parentTransform;

            _defaultMatrix = new apMatrix(defaultMatrix);
            _transform     = transform;

            _level = level;
            _depth = depth;

            _isVisible_Default   = isVisible_Default;
            _meshColor2X_Default = meshColor2X_Default;

            if (parentTransform != null)
            {
                _depth -= parentTransform._depth;
            }

            //이부분 실험 중
            //1. Default Matrix를 Transform에 적용하고, Modifier 계산에서는 제외하는 경우
            //결과 : Bake시에는 "Preview"를 위해서 DefaultMatrix 위치로 이동을 시키지만, 실행시에는 원점으로 이동시킨다.
            //_transform.localPosition = _defaultMatrix.Pos3 - new Vector3(0.0f, 0.0f, (float)_depth);
            //_transform.localRotation = Quaternion.Euler(0.0f, 0.0f, _defaultMatrix._angleDeg);
            //_transform.localScale = _defaultMatrix._scale;

            //2. Default Matrix를 Modifier에 포함시키고 Transform은 원점인 경우 (Editor와 동일)
            _transform.localPosition = -new Vector3(0.0f, 0.0f, (float)_depth * zScale);
            _transform.localRotation = Quaternion.identity;
            _transform.localScale    = Vector3.one;

            if (isMesh)
            {
                _unitType = UNIT_TYPE.Mesh;
            }
            else
            {
                _unitType = UNIT_TYPE.Group;
            }

            _childTransforms = null;
            _childMesh       = null;
        }
Exemple #25
0
 // Init
 //------------------------------------------------------------------
 public void Init(apEditor editor, apPortrait portrait, object loadKey, FUNC_FFD_SIZE_RESULT funcResult, int curX, int curY)
 {
     _editor         = editor;
     _loadKey        = loadKey;
     _targetPortrait = portrait;
     _funcResult     = funcResult;
     _nX             = curX;
     _nY             = curY;
 }
Exemple #26
0
        // Link
        //------------------------------------------------
        public void Link(apPortrait portrait)
        {
            _sortedRenderBuffer.Link(portrait, this);

            for (int i = 0; i < _optTransforms.Count; i++)
            {
                _optTransforms[i].SetExtraDepthChangedEvent(OnExtraDepthChanged);
            }
        }
Exemple #27
0
        // Init
        //--------------------------------------------------------------
        public void Init(apEditor editor, apPortrait portrait, apAnimClip animClip)
        {
            _editor   = editor;
            _portrait = portrait;
            _animClip = animClip;

            _curSelectedEvent = null;
            _defaultFrame     = animClip.CurFrame;
        }
Exemple #28
0
        //TODO : Undo 스택 관리
        /// <summary>
        /// 현재 작업을 취소하고, 이전 작업으로 넘어간다.
        /// </summary>
        /// <returns></returns>
        public apUndoUnitBase Undo(apPortrait portrait, apEditor editor)
        {
            if (_curPortrait != portrait || _curPortrait == null)
            {
                //Portrait가 다르면 자동으로 Undo는 리셋
                Clear();

                _curPortrait = portrait;
                //Debug.LogError("Portrait가 맞지 않는다.");
                return(null);
            }

            if (_units.Count == 0)
            {
                //Debug.LogError("Unit 카운트가 0");
                return(null);
            }

            if (_curUnit == null)
            {
                //더이상 Undo를 할 수 없다.
                //Debug.LogError("Cur Unit이 없다.");
                return(null);
            }

            //Debug.Log("Units : " + _units.Count);

            //Undo Execute 수행을 먼저하고,
            //인덱스를 이전으로 옮기자
            apUndoUnitBase executedUnit = _curUnit;

            _curUnit.ExecuteNext2Prev(editor);


            _iCurUnit = GetIndex(_curUnit);
            if (_iCurUnit < 0)
            {
                _curUnit = null;
            }
            else
            {
                int iPrevUnit = _iCurUnit - 1;
                if (iPrevUnit < 0)
                {
                    _curUnit  = null;
                    _iCurUnit = -1;
                }
                else
                {
                    //이전 유닛으로 이동한다.
                    _curUnit  = _units[iPrevUnit];
                    _iCurUnit = iPrevUnit;
                }
            }

            return(executedUnit);
        }
        public void Ready(apPortrait portrait)
        {
            _portrait = portrait;

            for (int i = 0; i < _controlParams.Count; i++)
            {
                _controlParams[i].Ready(portrait);
            }
        }
Exemple #30
0
        // Update
        //------------------------------------------------------
        /// <summary>
        /// Update를 한다.
        /// return이 True인 경우에 백업 시간을 체크할 타이밍이다.
        /// </summary>
        /// <param name="deltaTime"></param>
        /// <returns></returns>
        public bool Update(float deltaTime, string fileFolder, apPortrait portrait, string sceneName)
        {
            if (!_isInitLoaded)
            {
                Load(fileFolder);

                _isInitLoaded = true;
            }

            if (portrait == null || string.IsNullOrEmpty(portrait.name) || string.IsNullOrEmpty(sceneName))
            {
                return(false);
            }

            //Debug.Log("BackupTimer Update : Delta Time : " + deltaTime);

            bool isUpdatable = false;

            _refreshTimerSec  += deltaTime;
            _fileSaveTimerSec += deltaTime;

            if (_refreshTimerSec > 60.0f)
            {
                _refreshTimerSec -= 60.0f;
                isUpdatable       = true;


                PortraitUnit workUnit = _units.Find(delegate(PortraitUnit a)
                {
                    return(string.Equals(a._sceneName, sceneName) && string.Equals(a._portraitName, portrait.name));
                });

                if (workUnit == null)
                {
                    //현재 등록 안된 Portrait이다. 추가해주자
                    workUnit = new PortraitUnit(sceneName, portrait.name, 0, DateTime.Now);
                    _units.Add(workUnit);
                }

                //유닛의 타이머를 1 올리고, 갱신 날짜를 오늘로 한다.
                workUnit._timer_Min++;
                workUnit._lastWorkDateTime = DateTime.Now;

                //Debug.Log("BackupTimer Update : Timer Refresh : " + sceneName + "-" + portrait.name + " / " + workUnit._timer_Min);
            }


            //일정 시간(5분)이 지나면 타이머 시간도 저장을 하자
            if (_fileSaveTimerSec > 300.0f)
            {
                Save(fileFolder);
                _fileSaveTimerSec = 0.0f;
            }

            return(isUpdatable);
        }