예제 #1
0
 public void AddCalculatedResultParam(apCalculatedResultParam calculatedResultParam)
 {
     if (!_resultParams.Contains(calculatedResultParam))
     {
         _resultParams.Add(calculatedResultParam);
     }
 }
예제 #2
0
            public bool Remove(apCalculatedResultParam calculatedResultParam)
            {
                bool isAnyClearedParam = false;

                for (int i = 0; i < _modParamPairs.Count; i++)
                {
                    _modParamPairs[i].Remove(calculatedResultParam);
                    if (_modParamPairs[i]._resultParams.Count == 0)
                    {
                        isAnyClearedParam = true;
                    }
                }
                if (isAnyClearedParam)
                {
                    //Param이 없는 Pair는 삭제하고, Dictionary를 다시 만들어주자
                    _modParamPairs_ModKey.Clear();
                    _modParamPairs.RemoveAll(delegate(ModifierAndResultParamListPair a)
                    {
                        return(a._resultParams.Count == 0);
                    });

                    for (int i = 0; i < _modParamPairs.Count; i++)
                    {
                        ModifierAndResultParamListPair modPair = _modParamPairs[i];

                        //빠른 참조를 위해 Dictionary도 세팅해주자
                        if (!_modParamPairs_ModKey.ContainsKey(modPair._keyModifier))
                        {
                            _modParamPairs_ModKey.Add(modPair._keyModifier, modPair);
                        }
                    }
                }

                return(isAnyClearedParam);
            }
예제 #3
0
        //[NonSerialized]
        //private bool _isPrevSelectedMatched = false;

        // Functions
        //----------------------------------------------
        public override void InitCalculate(float tDelta)
        {
            base.InitCalculate(tDelta);

            if (_calculatedResultParams.Count == 0)
            {
                return;
            }

            apCalculatedResultParam calParam = null;

            for (int iCalParam = 0; iCalParam < _calculatedResultParams.Count; iCalParam++)
            {
                calParam = _calculatedResultParams[iCalParam];
                calParam.InitCalculate();
                calParam._isAvailable = false;

                //calParam._isAvailable = true;

                //List<Vector2> posList = calParam._result_Positions;
                //int nParamKeys = calParam._paramKeyValues.Count;
                //for (int iPos = 0; iPos < posList.Count; iPos++)
                //{
                //	posList[iPos] = Vector2.zero;


                //}
            }
        }
예제 #4
0
        // Init
        //----------------------------------------------
        //public apModifier_Rigging() : base()
        //{
        //}

        //public override void Init()
        //{

        //}

        //----------------------------------------------
        public override void InitCalculate(float tDelta)
        {
            base.InitCalculate(tDelta);

            if (_calculatedResultParams.Count == 0)
            {
                return;
            }

            apCalculatedResultParam calParam = null;

            for (int iCalParam = 0; iCalParam < _calculatedResultParams.Count; iCalParam++)
            {
                calParam = _calculatedResultParams[iCalParam];
                calParam.InitCalculate();
                calParam._isAvailable = false;
            }
        }
예제 #5
0
            public void AddCalculatedResultParam(apCalculatedResultParam calculatedResultParam)
            {
                apModifierBase modifier = calculatedResultParam._linkedModifier;

                if (modifier == null)
                {
                    return;
                }

                ModifierAndResultParamListPair modParamPair = null;

                if (!_modParamPairs_ModKey.ContainsKey(modifier))
                {
                    modParamPair = new ModifierAndResultParamListPair(modifier);
                    _modParamPairs_ModKey.Add(modifier, modParamPair);
                    _modParamPairs.Add(modParamPair);
                }
                else
                {
                    modParamPair = _modParamPairs_ModKey[modifier];
                }
                modParamPair.AddCalculatedResultParam(calculatedResultParam);
            }
예제 #6
0
        public void RemoveCalculatedResultParam(apCalculatedResultParam resultParam)
        {
            _resultParams_Rigging.Remove(resultParam);
            _resultParams_VertLocal.Remove(resultParam);
            _resultParams_Transform.Remove(resultParam);
            _resultParams_MeshColor.Remove(resultParam);
            _resultParams_VertWorld.Remove(resultParam);

            //Bone Transform은 Pair된 SubList로 관리되므로, 해당 Pair를 먼저 찾고 거기서 체크를 해야한다.
            bool isAnyClearedBoneParam = false;

            for (int i = 0; i < _resultParams_BoneTransform.Count; i++)
            {
                if (_resultParams_BoneTransform[i].Remove(resultParam))
                {
                    isAnyClearedBoneParam = true;
                }
            }

            if (isAnyClearedBoneParam)
            {
                //전체에서 Param 개수가 0인 것들을 빼자
                _resultParams_BoneTransform.RemoveAll(delegate(BoneAndModParamPair a)
                {
                    return(a._modParamPairs.Count == 0);
                });
            }

            _isAnyRigging        = (_resultParams_Rigging.Count != 0);
            _isAnyVertLocal      = (_resultParams_VertLocal.Count != 0);
            _isAnyTransformation = (_resultParams_Transform.Count != 0);
            _isAnyMeshColor      = (_resultParams_MeshColor.Count != 0);
            _isAnyVertWorld      = (_resultParams_VertWorld.Count != 0);
            _isAnyBoneTransform  = (_resultParams_BoneTransform.Count != 0);
            //Debug.LogError("[" + _tmpID + "] <<Remove Result Params>>");
        }
예제 #7
0
        /// <summary>
        /// RenderUnit의 CalculateStack을 업데이트한다.
        /// 1차 업데이트 이후에 실행되며, Rigging, VertWorld를 처리한다.
        /// </summary>
        /// <param name="tDelta"></param>
        /// <param name="isMakeHashCode"></param>
        //public void Calculate_Post(float tDelta, bool isMakeHashCode)
        public void Calculate_Post(float tDelta)
        {
            float prevWeight = 0.0f;
            float curWeight  = 0.0f;
            apCalculatedResultParam resultParam = null;

            //추가) 처음 실행되는 CalParam은 Additive로 작동하지 않도록 한다.
            int iCalculatedParam = 0;


            //--------------------------------------------------------------------
            // 0. Rigging
            if (_isAnyRigging)
            {
                prevWeight  = 0.0f;
                curWeight   = 0.0f;
                resultParam = null;
                List <Vector2> posVerts = null;

                iCalculatedParam = 0;

                _result_RiggingWeight = 0.0f;

                for (int iParam = 0; iParam < _resultParams_Rigging.Count; iParam++)
                {
                    resultParam = _resultParams_Rigging[iParam];
                    curWeight   = resultParam.ModifierWeight;

                    if (!resultParam.IsModifierAvailable || curWeight <= 0.001f)
                    {
                        continue;
                    }


                    posVerts = resultParam._result_Positions;
                    if (posVerts.Count != _result_Rigging.Length)
                    {
                        //결과가 잘못 들어왔다 갱신 필요
                        Debug.LogError("Wrong Vert Local Result (Cal : " + posVerts.Count + " / Verts : " + _result_Rigging.Length + ")");
                        continue;
                    }

                    _result_RiggingWeight += curWeight;

                    // Blend 방식에 맞게 Pos를 만들자
                    if (resultParam.ModifierBlendMethod == apModifierBase.BLEND_METHOD.Interpolation || iCalculatedParam == 0)
                    {
                        for (int i = 0; i < posVerts.Count; i++)
                        {
                            _result_Rigging[i] = BlendPosition_ITP(_result_Rigging[i], posVerts[i], curWeight);
                        }

                        prevWeight += curWeight;

                        //>>>> Calculated Log - Rigging
                        resultParam.CalculatedLog.Calculate_CalParamResult(curWeight,
                                                                           iCalculatedParam,
                                                                           apModifierBase.BLEND_METHOD.Interpolation,
                                                                           CalculateLog_0_Rigging);
                    }
                    else
                    {
                        for (int i = 0; i < posVerts.Count; i++)
                        {
                            _result_Rigging[i] = BlendPosition_Add(_result_Rigging[i], posVerts[i], curWeight);
                        }

                        //>>>> Calculated Log - Rigging
                        resultParam.CalculatedLog.Calculate_CalParamResult(curWeight,
                                                                           iCalculatedParam,
                                                                           apModifierBase.BLEND_METHOD.Additive,
                                                                           CalculateLog_0_Rigging);
                    }

                    //Debug.Log("[" + resultParam._targetRenderUnit.Name + "] : " + resultParam._linkedModifier.DisplayName + " / " + resultParam._paramKeyValues.Count);
                    iCalculatedParam++;
                }

                //HashCode를 만들자.
                //if (isMakeHashCode)
                //{
                //	if (_result_Rigging.Length > 0)
                //	{
                //		_hashCode_Rigging = _result_Rigging[(_result_Rigging.Length - 1) / 2].GetHashCode();
                //	}
                //}

                if (_result_RiggingWeight > 1.0f)
                {
                    _result_RiggingWeight = 1.0f;
                }
            }

            //--------------------------------------------------------------------
            // 4. World Morph
            if (_isAnyVertWorld)
            {
                prevWeight  = 0.0f;
                curWeight   = 0.0f;
                resultParam = null;
                List <Vector2> posVerts = null;

                iCalculatedParam = 0;

                for (int iParam = 0; iParam < _resultParams_VertWorld.Count; iParam++)
                {
                    resultParam = _resultParams_VertWorld[iParam];
                    curWeight   = resultParam.ModifierWeight;

                    if (!resultParam.IsModifierAvailable || curWeight <= 0.001f)
                    {
                        continue;
                    }

                    posVerts = resultParam._result_Positions;
                    if (posVerts.Count != _result_VertWorld.Length)
                    {
                        //결과가 잘못 들어왔다 갱신 필요
                        Debug.LogError("Wrong Vert World Result (Cal : " + posVerts.Count + " / Verts : " + _result_VertWorld.Length + ")");
                        continue;
                    }

                    // Blend 방식에 맞게 Pos를 만들자
                    if (resultParam.ModifierBlendMethod == apModifierBase.BLEND_METHOD.Interpolation || iCalculatedParam == 0)
                    {
                        for (int i = 0; i < posVerts.Count; i++)
                        {
                            _result_VertWorld[i] = BlendPosition_ITP(_result_VertWorld[i], posVerts[i], curWeight);
                        }

                        prevWeight += curWeight;

                        //>>>> Calculated Log - VertWorld
                        resultParam.CalculatedLog.Calculate_CalParamResult(curWeight,
                                                                           iCalculatedParam,
                                                                           apModifierBase.BLEND_METHOD.Interpolation,
                                                                           CalculateLog_4_VertWorld);
                    }
                    else
                    {
                        for (int i = 0; i < posVerts.Count; i++)
                        {
                            _result_VertWorld[i] = BlendPosition_Add(_result_VertWorld[i], posVerts[i], curWeight);
                        }

                        //>>>> Calculated Log - VertWorld
                        resultParam.CalculatedLog.Calculate_CalParamResult(curWeight,
                                                                           iCalculatedParam,
                                                                           apModifierBase.BLEND_METHOD.Additive,
                                                                           CalculateLog_4_VertWorld);
                    }

                    iCalculatedParam++;
                }

                //HashCode를 만들자.
                //if (isMakeHashCode)
                //{
                //	if (_result_VertWorld.Length > 0)
                //	{
                //		_hashCode_VertWorld = _result_VertWorld[(_result_VertWorld.Length - 1) / 2].GetHashCode();
                //	}
                //}
            }
            //--------------------------------------------------------------------
        }
예제 #8
0
        /// <summary>
        /// RenderUnit의 CalculateStack을 업데이트한다.
        /// 기본 단계의 업데이트이며, Rigging, VertWorld는 Post Update에서 처리한다.
        /// </summary>
        /// <param name="tDelta"></param>
        /// <param name="isMakeHashCode"></param>
        //public void Calculate_Pre(float tDelta, bool isMakeHashCode)
        public void Calculate_Pre(float tDelta)
        {
            float prevWeight = 0.0f;
            float curWeight  = 0.0f;
            apCalculatedResultParam resultParam = null;

            //추가) 처음 실행되는 CalParam은 Additive로 작동하지 않도록 한다.
            int iCalculatedParam = 0;


            //--------------------------------------------------------------------
            // 1. Local Morph
            if (_isAnyVertLocal)
            {
                prevWeight  = 0.0f;
                curWeight   = 0.0f;
                resultParam = null;
                List <Vector2> posVerts = null;

                iCalculatedParam = 0;

                for (int iParam = 0; iParam < _resultParams_VertLocal.Count; iParam++)
                {
                    resultParam = _resultParams_VertLocal[iParam];
                    curWeight   = resultParam.ModifierWeight;

                    if (!resultParam.IsModifierAvailable || curWeight <= 0.001f)
                    {
                        continue;
                    }

                    posVerts = resultParam._result_Positions;
                    if (posVerts.Count != _result_VertLocal.Length)
                    {
                        //결과가 잘못 들어왔다 갱신 필요
                        Debug.LogError("Wrong Vert Local Result (Cal : " + posVerts.Count + " / Verts : " + _result_VertLocal.Length + ")");
                        continue;
                    }

                    // Blend 방식에 맞게 Pos를 만들자
                    if (resultParam.ModifierBlendMethod == apModifierBase.BLEND_METHOD.Interpolation || iCalculatedParam == 0)
                    {
                        for (int i = 0; i < posVerts.Count; i++)
                        {
                            _result_VertLocal[i] = BlendPosition_ITP(_result_VertLocal[i], posVerts[i], curWeight);
                        }

                        prevWeight += curWeight;

                        //>>>> Calculated Log - VertLog
                        resultParam.CalculatedLog.Calculate_CalParamResult(curWeight,
                                                                           iCalculatedParam,
                                                                           apModifierBase.BLEND_METHOD.Interpolation,
                                                                           CalculateLog_2_VertLocal);
                    }
                    else
                    {
                        for (int i = 0; i < posVerts.Count; i++)
                        {
                            _result_VertLocal[i] = BlendPosition_Add(_result_VertLocal[i], posVerts[i], curWeight);
                        }

                        //>>>> Calculated Log - VertLog
                        resultParam.CalculatedLog.Calculate_CalParamResult(curWeight,
                                                                           iCalculatedParam,
                                                                           apModifierBase.BLEND_METHOD.Additive,
                                                                           CalculateLog_2_VertLocal);
                    }

                    //Debug.Log("[" + resultParam._targetRenderUnit.Name + "] : " + resultParam._linkedModifier.DisplayName + " / " + resultParam._paramKeyValues.Count);
                    iCalculatedParam++;
                }

                ////HashCode를 만들자.
                //if (isMakeHashCode)
                //{
                //	if (_result_VertLocal.Length > 0)
                //	{
                //		_hashCode_VertLocal = _result_VertLocal[(_result_VertLocal.Length - 1) / 2].GetHashCode();
                //	}
                //}
            }

            //--------------------------------------------------------------------

            // 2. Mesh / MeshGroup Transformation
            if (_isAnyTransformation)
            {
                prevWeight  = 0.0f;
                curWeight   = 0.0f;
                resultParam = null;

                iCalculatedParam = 0;

                for (int iParam = 0; iParam < _resultParams_Transform.Count; iParam++)
                {
                    resultParam = _resultParams_Transform[iParam];
                    curWeight   = resultParam.ModifierWeight;

                    if (!resultParam.IsModifierAvailable || curWeight <= 0.001f)
                    {
                        continue;
                    }


                    // Blend 방식에 맞게 Matrix를 만들자 하자
                    if (resultParam.ModifierBlendMethod == apModifierBase.BLEND_METHOD.Interpolation || iCalculatedParam == 0)
                    {
                        BlendMatrix_ITP(_result_MeshTransform, resultParam._result_Matrix, curWeight);
                        prevWeight += curWeight;

                        //>>>> Calculated Log - VertLog
                        resultParam.CalculatedLog.Calculate_CalParamResult(curWeight,
                                                                           iCalculatedParam,
                                                                           apModifierBase.BLEND_METHOD.Interpolation,
                                                                           CalculateLog_3_MeshTransform);
                    }
                    else
                    {
                        BlendMatrix_Add(_result_MeshTransform, resultParam._result_Matrix, curWeight);

                        //>>>> Calculated Log - VertLog
                        resultParam.CalculatedLog.Calculate_CalParamResult(curWeight,
                                                                           iCalculatedParam,
                                                                           apModifierBase.BLEND_METHOD.Additive,
                                                                           CalculateLog_3_MeshTransform);
                    }

                    iCalculatedParam++;
                }

                _result_MeshTransform.MakeMatrix();

                ////HashCode를 만들자.
                //if (isMakeHashCode)
                //{
                //	_hashCode_MeshTransform = _result_MeshTransform.GetHashCode();
                //}
            }

            //--------------------------------------------------------------------

            // 3. Mesh Color
            if (_isAnyMeshColor)
            {
                prevWeight  = 0.0f;
                curWeight   = 0.0f;
                resultParam = null;

                iCalculatedParam = 0;

                _result_IsVisible       = false;
                _result_CalculatedColor = false;

                int nMeshColorCalculated = 0;

                for (int iParam = 0; iParam < _resultParams_MeshColor.Count; iParam++)
                {
                    resultParam = _resultParams_MeshColor[iParam];
                    curWeight   = resultParam.ModifierWeight;

                    if (!resultParam.IsModifierAvailable ||
                        curWeight <= 0.001f ||
                        !resultParam.IsColorValueEnabled ||
                        !resultParam._isColorCalculated                           //<<추가 : Color로 등록했지만 아예 계산이 안되었을 수도 있다.
                        )
                    {
                        continue;
                    }


                    // Blend 방식에 맞게 Matrix를 만들자 하자
                    if (resultParam.ModifierBlendMethod == apModifierBase.BLEND_METHOD.Interpolation || iCalculatedParam == 0)
                    {
                        //_result_Color = BlendColor_ITP(_result_Color, resultParam._result_Color, prevWeight, curWeight);
                        _result_Color = apUtil.BlendColor_ITP(_result_Color, resultParam._result_Color, Mathf.Clamp01(curWeight));
                        prevWeight   += curWeight;
                    }
                    else
                    {
                        _result_Color = apUtil.BlendColor_Add(_result_Color, resultParam._result_Color, curWeight);
                    }



                    //Visible 여부도 결정
                    _result_IsVisible |= resultParam._result_IsVisible;
                    nMeshColorCalculated++;
                    _result_CalculatedColor = true;                    //<<"계산된 MeshColor" Result가 있음을 알린다.

                    //Debug.Log("MeshColor Update < " + resultParam._result_Color + " [" + resultParam._linkedModifier.DisplayName + "] (" + curWeight + ") >> " + _result_Color);

                    iCalculatedParam++;
                }

                if (nMeshColorCalculated == 0)
                {
                    //색상 처리값이 없다면 자동으로 True
                    _result_IsVisible = true;
                }
            }
            else
            {
                //색상 처리값이 없다면 자동으로 True
                _result_IsVisible = true;
            }

            //--------------------------------------------------------------------

            //5. Bone을 업데이트 하자
            //Bone은 값 저장만 할게 아니라 직접 업데이트를 해야한다.
            if (_isAnyBoneTransform)
            //if(false)
            {
                prevWeight  = 0.0f;
                curWeight   = 0.0f;
                resultParam = null;



                for (int iBonePair = 0; iBonePair < _resultParams_BoneTransform.Count; iBonePair++)
                {
                    BoneAndModParamPair boneModPair = _resultParams_BoneTransform[iBonePair];
                    apBone targetBone = boneModPair._keyBone;
                    List <ModifierAndResultParamListPair> modParamPairs = boneModPair._modParamPairs;
                    if (targetBone == null || modParamPairs.Count == 0)
                    {
                        continue;
                    }

                    iCalculatedParam = 0;
                    _result_BoneTransform.SetIdentity();

                    for (int iModParamPair = 0; iModParamPair < modParamPairs.Count; iModParamPair++)
                    {
                        ModifierAndResultParamListPair modParamPair = modParamPairs[iModParamPair];

                        for (int iParam = 0; iParam < modParamPair._resultParams.Count; iParam++)
                        {
                            resultParam = modParamPair._resultParams[iParam];
                            curWeight   = resultParam.ModifierWeight;

                            if (!resultParam.IsModifierAvailable || curWeight <= 0.001f)
                            {
                                continue;
                            }



                            // Blend 방식에 맞게 Matrix를 만들자 하자
                            if (resultParam.ModifierBlendMethod == apModifierBase.BLEND_METHOD.Interpolation || iCalculatedParam == 0)
                            {
                                BlendMatrix_ITP(_result_BoneTransform, resultParam._result_Matrix, curWeight);
                                prevWeight += curWeight;
                            }
                            else
                            {
                                BlendMatrix_Add(_result_BoneTransform, resultParam._result_Matrix, curWeight);
                            }

                            iCalculatedParam++;
                        }
                    }

                    //참조된 본에 직접 값을 넣어주자
                    targetBone.UpdateModifiedValue(_result_BoneTransform._pos, _result_BoneTransform._angleDeg, _result_BoneTransform._scale);
                }
            }
        }
예제 #9
0
        // Add / Remove / Sort
        //---------------------------------------------------
        public void AddCalculatedResultParam(apCalculatedResultParam resultParam)
        {
            //Debug.Log("[" + _tmpID + "] AddCalculatedResultParam >> " + resultParam._resultType + "[R " + _parentRenderUnit._tmpName + "]");
            if ((int)(resultParam._calculatedValueType & apCalculatedResultParam.CALCULATED_VALUE_TYPE.VertexPos) != 0)
            {
                if (resultParam._targetBone == null)
                {
                    if (resultParam._calculatedSpace == apCalculatedResultParam.CALCULATED_SPACE.Object)
                    {
                        if (!_resultParams_VertLocal.Contains(resultParam))
                        {
                            _resultParams_VertLocal.Add(resultParam);
                        }
                        _isAnyVertLocal = true;
                    }
                    else if (resultParam._calculatedSpace == apCalculatedResultParam.CALCULATED_SPACE.World)
                    {
                        if (!_resultParams_VertWorld.Contains(resultParam))
                        {
                            _resultParams_VertWorld.Add(resultParam);
                        }
                        _isAnyVertWorld = true;
                    }
                    else if (resultParam._calculatedSpace == apCalculatedResultParam.CALCULATED_SPACE.Rigging)                    //<<추가되었다.
                    {
                        if (!_resultParams_Rigging.Contains(resultParam))
                        {
                            _resultParams_Rigging.Add(resultParam);
                        }
                        _isAnyRigging = true;
                    }
                    else
                    {
                        Debug.LogError("허용되지 않은 데이터 타입 [Calculate : Vertex + Loca]");
                    }
                }
            }
            if ((int)(resultParam._calculatedValueType & apCalculatedResultParam.CALCULATED_VALUE_TYPE.TransformMatrix) != 0)
            {
                //변경 : Bone타입과 일반 Transform타입으로 나뉜다.
                if (resultParam._targetBone != null)
                {
                    //Bone 타입이다.
                    //Modifier + ResultParam Pair로 저장해야한다.
                    BoneAndModParamPair modParamPair = _resultParams_BoneTransform.Find(delegate(BoneAndModParamPair a)
                    {
                        return(a._keyBone == resultParam._targetBone);
                    });
                    if (modParamPair == null)
                    {
                        modParamPair = new BoneAndModParamPair(resultParam._targetBone);
                        _resultParams_BoneTransform.Add(modParamPair);
                    }

                    modParamPair.AddCalculatedResultParam(resultParam);
                    _isAnyBoneTransform = true;

                    //이전 코드
                    //if(!_resultParams_BoneTransform.Contains(resultParam))
                    //{
                    //	_resultParams_BoneTransform.Add(resultParam);
                    //	_isAnyBoneTransform = true;
                    //}
                }
                else
                {
                    //Mesh/MeshGroup Transform 타입이다.
                    if (!_resultParams_Transform.Contains(resultParam))
                    {
                        _resultParams_Transform.Add(resultParam);
                        _isAnyTransformation = true;
                    }
                }
            }
            if ((int)(resultParam._calculatedValueType & apCalculatedResultParam.CALCULATED_VALUE_TYPE.Color) != 0)
            {
                //Bone 타입은 제외한다.
                if (resultParam._targetBone == null)
                {
                    if (!_resultParams_MeshColor.Contains(resultParam))
                    {
                        _resultParams_MeshColor.Add(resultParam);
                        _isAnyMeshColor = true;
                    }
                }
            }

            //else
            //{
            //	Debug.LogError("apCalculatedResultStack / AddCalculatedResultParam : 알수없는 Result Type : " + resultParam._calculatedValueType);
            //}
            #region [미사용 코드] 변경되기 전의 Caculated Value
            //switch (resultParam._calculatedValueType)
            //{
            //	case apCalculatedResultParam.CALCULATED_VALUE_TYPE.VertexPos:
            //		{

            //		}
            //		break;

            //	case apCalculatedResultParam.CALCULATED_VALUE_TYPE.TransformMatrix:
            //		if(!_resultParams_Transform.Contains(resultParam))
            //		{
            //			_resultParams_Transform.Add(resultParam);
            //			_isAnyTransformation = true;
            //		}
            //		break;

            //	case apCalculatedResultParam.CALCULATED_VALUE_TYPE.MeshGroup_Color:
            //		if(!_resultParams_MeshColor.Contains(resultParam))
            //		{
            //			_resultParams_MeshColor.Add(resultParam);
            //			_isAnyMeshColor = true;
            //		}
            //		break;

            //	case apCalculatedResultParam.CALCULATED_VALUE_TYPE.Vertex_World:
            //		if(!_resultParams_VertWorld.Contains(resultParam))
            //		{
            //			_resultParams_VertWorld.Add(resultParam);
            //			_isAnyVertWorld = true;
            //		}
            //		break;

            //	default:
            //		Debug.LogError("apCalculatedResultStack / AddCalculatedResultParam : 알수없는 Result Type : " + resultParam._calculatedValueType);
            //		break;
            //}
            #endregion
        }
예제 #10
0
 public void Remove(apCalculatedResultParam calculatedResultParam)
 {
     _resultParams.Remove(calculatedResultParam);
 }
예제 #11
0
        private apCalculatedLerpArea _cpLerpAreaLastSelected = null;        //빠른 처리를 위해 "이전에 참조된 Area"를 저장하자.



        // Init
        //--------------------------------------------------
        public apCalculatedResultParamSubList(apCalculatedResultParam parentResultParam)
        {
            _parentResultParam = parentResultParam;
            _subParamKeyValues.Clear();
        }
예제 #12
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();
                }
            }
        }
예제 #13
0
 /// <summary>
 /// CalResultParam의 초기화
 /// </summary>
 /// <param name="calResultParam"></param>
 public apCalculatedLog(apCalculatedResultParam calResultParam)
 {
     _logType        = LOG_TYPE.Layer_CalParamResult;
     _calResultParam = calResultParam;
 }