// Calculate Update
        //----------------------------------------------------------------------
        public void ReadyToCalculate()
        {
            //TODO : 여기서부터 작성

            if (_targetOptMesh == null)
            {
                if (_isAnyVertLocal)
                {
                    Debug.LogError("Vert인데 Mesh가 없다");
                }
                return;
            }

            if (_isAnyVertLocal || _isAnyVertWorld || _isAnyRigging)
            {
                if (_result_VertLocal == null || _result_VertLocal.Length != _targetOptMesh.RenderVertices.Length)
                {
                    //RenderUnit의 RenderVertex 개수 만큼 결과를 만들자
                    _result_VertLocal = new Vector2[_targetOptMesh.RenderVertices.Length];
                    _result_VertWorld = new Vector2[_targetOptMesh.RenderVertices.Length];
                    _result_Rigging   = new Vector2[_targetOptMesh.RenderVertices.Length];
                    int nRenderVerts = _targetOptMesh.RenderVertices.Length;

                    for (int i = 0; i < nRenderVerts; i++)
                    {
                        _result_VertLocal[i] = Vector2.zero;
                        _result_VertWorld[i] = Vector2.zero;
                        _result_Rigging[i]   = Vector2.zero;
                    }
                }
                else
                {
                    for (int i = 0; i < _result_VertLocal.Length; i++)
                    {
                        _result_VertLocal[i] = Vector2.zero;
                        _result_VertWorld[i] = Vector2.zero;
                        _result_Rigging[i]   = Vector2.zero;
                    }
                }
            }

            _result_BoneTransform.SetIdentity();
            _result_MeshTransform.SetIdentity();
            _result_MeshTransform.MakeMatrix();
            //_result_Color = _color_Default;
            _result_Color = _parentOptTransform._meshColor2X_Default;
            if (!_parentOptTransform._isVisible_Default)
            {
                _result_Color.a = 0.0f;
            }
            _result_IsVisible       = true;
            _result_CalculatedColor = false;
        }
Esempio n. 2
0
        //Link 함수의 내용은 Bake 시에 진행해야한다.
        public void Bake(apBone bone)
        {
            _uniqueID    = bone._uniqueID;
            _meshGroupID = bone._meshGroupID;
            _defaultMatrix.SetMatrix(bone._defaultMatrix);


            _deltaPos   = Vector2.zero;
            _deltaAngle = 0.0f;
            _deltaScale = Vector2.one;

            _localMatrix.SetIdentity();

            _worldMatrix.SetIdentity();

            _color       = bone._color;
            _shapeWidth  = bone._shapeWidth;
            _shapeLength = bone._shapeLength;
            _shapeTaper  = bone._shapeTaper;

            _optionLocalMove = bone._optionLocalMove;
            _optionIK        = bone._optionIK;

            _isIKTail = bone._isIKTail;

            _IKTargetBoneID = bone._IKTargetBoneID;
            _IKTargetBone   = null;          //<<나중에 링크

            _IKNextChainedBoneID = bone._IKNextChainedBoneID;
            _IKNextChainedBone   = null;          //<<나중에 링크


            _IKHeaderBoneID = bone._IKHeaderBoneID;
            _IKHeaderBone   = null;          //<<나중에 링크


            _isIKAngleRange     = bone._isIKAngleRange;
            _IKAngleRange_Lower = bone._IKAngleRange_Lower;
            _IKAngleRange_Upper = bone._IKAngleRange_Upper;
            _IKAnglePreferred   = bone._IKAnglePreferred;


            _isIKCalculated       = false;
            _IKRequestAngleResult = 0.0f;



            _transformLocalMatrix.SetIdentity();
        }
        // Functions
        //--------------------------------------------
        public void ReadyToCalculate()
        {
            _matrix.MakeMatrix();

            //변경
            //[Parent World x To Parent x Local TF] 조합으로 변경

            if (_matrix_TF_ParentWorld == null)
            {
                _matrix_TF_ParentWorld = new apMatrix();
            }
            if (_matrix_TF_ParentWorldWithoutMod == null)
            {
                _matrix_TF_ParentWorldWithoutMod = new apMatrix();
            }
            if (_matrix_TF_ToParent == null)
            {
                _matrix_TF_ToParent = new apMatrix();
            }
            if (_matrix_TF_LocalModified == null)
            {
                _matrix_TF_LocalModified = new apMatrix();
            }
            if (_matrix_TFResult_World == null)
            {
                _matrix_TFResult_World = new apMatrix();
            }
            if (_matrix_TFResult_WorldWithoutMod == null)
            {
                _matrix_TFResult_WorldWithoutMod = new apMatrix();
            }
            if (_invMatrix_TFResult_World == null)
            {
                _invMatrix_TFResult_World = new apMatrix();
            }
            if (_invMatrix_TFResult_WorldWithoutMod == null)
            {
                _invMatrix_TFResult_WorldWithoutMod = new apMatrix();
            }


            _matrix_TF_ParentWorld.SetIdentity();
            _matrix_TF_ParentWorldWithoutMod.SetIdentity();
            _matrix_TF_ToParent.SetIdentity();
            _matrix_TF_LocalModified.SetIdentity();

            //ToParent는 Pivot이므로 고정
            _matrix_TF_ToParent.SetMatrix(_matrix);

            _matrix_TFResult_World.SetIdentity();
            _matrix_TFResult_WorldWithoutMod.SetIdentity();
            _invMatrix_TFResult_World.SetIdentity();
            _invMatrix_TFResult_WorldWithoutMod.SetIdentity();

            CalculatedLog.ReadyToRecord();
        }
Esempio n. 4
0
 // Functions
 //------------------------------------------
 public void ResetValues()
 {
     for (int i = 0; i < _vertices.Count; i++)
     {
         _vertices[i]._deltaPos = Vector2.zero;
     }
     _transformMatrix.SetIdentity();
     _meshColor = new Color(0.5f, 0.5f, 0.5f, 1.0f);
     _isVisible = true;
 }
Esempio n. 5
0
        // Functions
        //--------------------------------------------
        public void ReadyToCalculate()
        {
            _matrix.MakeMatrix();

            //_matrix_TF_Cal_Parent = apMatrix3x3.identity;
            //_matrix_TF_Cal_Local = _matrix.MtrxToSpace;

            //if(_calculateTmpMatrix == null)
            //{
            //	_calculateTmpMatrix = new apMatrix();
            //}
            //_calculateTmpMatrix.SetIdentity();
            //_calculateTmpMatrix.SetMatrix(_matrix);

            //if(_calculateTmpMatrix_Local == null)
            //{
            //	_calculateTmpMatrix_Local = new apMatrix();
            //}
            //_calculateTmpMatrix_Local.SetIdentity();
            //_calculateTmpMatrix_Local.SetMatrix(_matrix);

            //변경
            //[Parent World x To Parent x Local TF] 조합으로 변경

            if (_matrix_TF_ParentWorld == null)
            {
                _matrix_TF_ParentWorld = new apMatrix();
            }
            if (_matrix_TF_ToParent == null)
            {
                _matrix_TF_ToParent = new apMatrix();
            }
            if (_matrix_TF_LocalModified == null)
            {
                _matrix_TF_LocalModified = new apMatrix();
            }
            if (_matrix_TFResult_World == null)
            {
                _matrix_TFResult_World = new apMatrix();
            }
            if (_matrix_TFResult_WorldWithoutMod == null)
            {
                _matrix_TFResult_WorldWithoutMod = new apMatrix();
            }

            _matrix_TF_ParentWorld.SetIdentity();
            _matrix_TF_ToParent.SetIdentity();
            _matrix_TF_LocalModified.SetIdentity();

            //ToParent는 Pivot이므로 고정
            _matrix_TF_ToParent.SetMatrix(_matrix);

            _matrix_TFResult_World.SetIdentity();
            _matrix_TFResult_WorldWithoutMod.SetIdentity();
        }
Esempio n. 6
0
            /// <summary>
            /// Keyframe에 Rotation Bias 설정이 있는 경우 관련 변수를 갱신한다.
            /// </summary>
            /// <param name="rotationBias"></param>
            /// <param name="rotationCount"></param>
            public void SetAnimRotationBias(apAnimKeyframe.ROTATION_BIAS rotationBias, int rotationCount)
            {
                if (rotationBias == apAnimKeyframe.ROTATION_BIAS.CW)
                {
                    _isAnimRotationBias    = true;
                    _animRotationBiasAngle = -360 * rotationCount;
                }
                else if (rotationBias == apAnimKeyframe.ROTATION_BIAS.CCW)
                {
                    _isAnimRotationBias    = true;
                    _animRotationBiasAngle = 360 * rotationCount;
                }
                else
                {
                    _isAnimRotationBias    = false;
                    _animRotationBiasAngle = 0;
                }
                //에디터에서는 최적화가 아니라 언제 바뀔지 모르므로 항상 갱신
                //if(_animRotationBiasAngle_Prev != _animRotationBiasAngle && _isAnimRotationBias)
                if (_isAnimRotationBias)
                {
                    if (_animRotationBiasedMatrix == null)
                    {
                        _animRotationBiasedMatrix = new apMatrix();
                    }

                    if (_modifiedMesh != null)
                    {
                        _animRotationBiasedMatrix.SetTRS(
                            _modifiedMesh._transformMatrix._pos,
                            _modifiedMesh._transformMatrix._angleDeg + _animRotationBiasAngle,
                            _modifiedMesh._transformMatrix._scale
                            );
                    }
                    else if (_modifiedBone != null)
                    {
                        _animRotationBiasedMatrix.SetTRS(
                            _modifiedBone._transformMatrix._pos,
                            _modifiedBone._transformMatrix._angleDeg + _animRotationBiasAngle,
                            _modifiedBone._transformMatrix._scale
                            );
                    }
                    else
                    {
                        _animRotationBiasedMatrix.SetIdentity();
                    }

                    _animRotationBiasAngle_Prev = _animRotationBiasAngle;
                }
            }
Esempio n. 7
0
        /// <summary>
        /// Transform을 모두 초기화한다. Default 포함 (업데이트때는 호출하지 말것)
        /// </summary>
        public void InitTransform()
        {
            _defaultMatrix.SetIdentity();

            if (_localMatrix == null)
            {
                _localMatrix = new apMatrix();
            }
            _localMatrix.SetIdentity();

            _deltaPos   = Vector2.zero;
            _deltaAngle = 0.0f;
            _deltaScale = Vector2.one;
            if (_worldMatrix == null)
            {
                _worldMatrix = new apMatrix();
            }
            if (_worldMatrix_NonModified == null)
            {
                _worldMatrix_NonModified = new apMatrix();
            }

            //if(_invWorldMatrix == null)
            //{
            //	_invWorldMatrix = new apMatrix();
            //}

            //if(_invWorldMatrix_NonModified == null)
            //{
            //	_invWorldMatrix_NonModified = new apMatrix();
            //}

            _worldMatrix.SetIdentity();
            _worldMatrix_NonModified.SetIdentity();
            //_invWorldMatrix.SetIdentity();
            //_invWorldMatrix_NonModified.SetIdentity();
        }
Esempio n. 8
0
        public bool DecodeData(string strSrc)
        {
            try
            {
                int nameLength = int.Parse(strSrc.Substring(0, 3));
                _name = strSrc.Substring(3, nameLength);

                strSrc = strSrc.Substring(3 + nameLength);

                string[] strParse = strSrc.Split(new string[] { "/" }, StringSplitOptions.None);

                _unitID   = int.Parse(strParse[0]);
                _uniqueID = int.Parse(strParse[1]);

                _defaultMatrix.SetIdentity();
                _localMatrix.SetIdentity();
                _worldMatrix.SetIdentity();

                _defaultMatrix._pos.x    = float.Parse(strParse[2]);
                _defaultMatrix._pos.y    = float.Parse(strParse[3]);
                _defaultMatrix._angleDeg = float.Parse(strParse[4]);
                _defaultMatrix._scale.x  = float.Parse(strParse[5]);
                _defaultMatrix._scale.y  = float.Parse(strParse[6]);
                _defaultMatrix.MakeMatrix();

                _localMatrix._pos.x    = float.Parse(strParse[7]);
                _localMatrix._pos.y    = float.Parse(strParse[8]);
                _localMatrix._angleDeg = float.Parse(strParse[9]);
                _localMatrix._scale.x  = float.Parse(strParse[10]);
                _localMatrix._scale.y  = float.Parse(strParse[11]);
                _localMatrix.MakeMatrix();

                _worldMatrix._pos.x    = float.Parse(strParse[12]);
                _worldMatrix._pos.y    = float.Parse(strParse[13]);
                _worldMatrix._angleDeg = float.Parse(strParse[14]);
                _worldMatrix._scale.x  = float.Parse(strParse[15]);
                _worldMatrix._scale.y  = float.Parse(strParse[16]);
                _worldMatrix.MakeMatrix();
            }
            catch (Exception ex)
            {
                Debug.LogError("DecodeData Exception : " + ex);
                return(false);
            }
            return(true);
        }
Esempio n. 9
0
        /// <summary>
        /// BlendMatrix_ITP의 역연산. [ (curMatrix - (subtractedLayer * weight)) / (1-weight) ]
        /// weight가 1이면 Identity로 만든다.
        /// </summary>
        /// <param name="curMatrix"></param>
        /// <param name="subtractedLayer"></param>
        /// <param name="weight"></param>
        public void InverseBlendMatrix_ITP(apMatrix curMatrix, apMatrix subtractedLayer, float weight)
        {
            if (weight >= 1.0f)
            {
                curMatrix.SetIdentity();
                return;
            }
            if (weight <= 0.0f)
            {
                //처리하지 않는다.
                return;
            }

            curMatrix._pos.x = (curMatrix._pos.x - subtractedLayer._pos.x * weight) / (1.0f - weight);
            curMatrix._pos.y = (curMatrix._pos.y - subtractedLayer._pos.y * weight) / (1.0f - weight);

            curMatrix._angleDeg = (curMatrix._angleDeg - subtractedLayer._angleDeg * weight) / (1.0f - weight);

            curMatrix._scale.x = (curMatrix._scale.x - subtractedLayer._scale.x * weight) / (1.0f - weight);
            curMatrix._scale.y = (curMatrix._scale.y - subtractedLayer._scale.y * weight) / (1.0f - weight);
            //curMatrix._scale.z = (curMatrix._scale.z - subtractedLayer._scale.z * weight) / (1.0f - weight);

            curMatrix.MakeMatrix();
        }
Esempio n. 10
0
        // Functions
        //---------------------------------------------------
        public void ReadyToCalculate()
        {
            if (_isAnyVertLocal || _isAnyVertWorld || _isAnyRigging)
            {
                if (_result_VertLocal == null || _result_VertLocal.Length != _parentRenderUnit._renderVerts.Count)
                {
                    //RenderUnit의 RenderVertex 개수 만큼 결과를 만들자
                    //_result_VertLocal = new List<Vector2>();
                    //_result_VertWorld = new List<Vector2>();

                    _result_VertLocal     = new Vector2[_parentRenderUnit._renderVerts.Count];
                    _result_VertWorld     = new Vector2[_parentRenderUnit._renderVerts.Count];
                    _result_Rigging       = new Vector2[_parentRenderUnit._renderVerts.Count];
                    _result_RiggingWeight = 0.0f;


                    //_result_VertLocal.Initialize();
                    //_result_VertWorld.Initialize();
                    for (int i = 0; i < _parentRenderUnit._renderVerts.Count; i++)
                    {
                        _result_VertLocal[i] = Vector2.zero;
                        _result_VertWorld[i] = Vector2.zero;
                        _result_Rigging[i]   = Vector2.zero;
                    }
                }
                else
                {
                    //_result_VertLocal.Initialize();
                    //_result_VertWorld.Initialize();
                    //for (int i = 0; i < _result_VertLocal.Count; i++)
                    //{
                    //	_result_VertLocal[i] = Vector2.zero;
                    //	_result_VertWorld[i] = Vector2.zero;
                    //}

                    for (int i = 0; i < _result_VertLocal.Length; i++)
                    {
                        _result_VertLocal[i] = Vector2.zero;
                        _result_VertWorld[i] = Vector2.zero;
                        _result_Rigging[i]   = Vector2.zero;
                    }
                    _result_RiggingWeight = 0.0f;
                }
            }

            _result_BoneTransform.SetIdentity();
            _result_MeshTransform.SetIdentity();
            _result_MeshTransform.MakeMatrix();
            _result_Color           = _color_Default;
            _result_IsVisible       = true;
            _result_CalculatedColor = false;

            //>>> CalculateLog 초기화
            CalculateLog_0_Rigging.ReadyToRecord();
            CalculateLog_1_StaticMesh.ReadyToRecord();
            CalculateLog_2_VertLocal.ReadyToRecord();
            CalculateLog_3_MeshTransform.ReadyToRecord();
            CalculateLog_4_VertWorld.ReadyToRecord();

            CalculateLog_0_Rigging.LinkLog_CalResultStackLayer(CalculateLog_0_Rigging, CalculateLog_1_StaticMesh, CalculateLog_2_VertLocal, CalculateLog_3_MeshTransform, CalculateLog_4_VertWorld);
            CalculateLog_1_StaticMesh.LinkLog_CalResultStackLayer(CalculateLog_0_Rigging, CalculateLog_1_StaticMesh, CalculateLog_2_VertLocal, CalculateLog_3_MeshTransform, CalculateLog_4_VertWorld);
            CalculateLog_2_VertLocal.LinkLog_CalResultStackLayer(CalculateLog_0_Rigging, CalculateLog_1_StaticMesh, CalculateLog_2_VertLocal, CalculateLog_3_MeshTransform, CalculateLog_4_VertWorld);
            CalculateLog_3_MeshTransform.LinkLog_CalResultStackLayer(CalculateLog_0_Rigging, CalculateLog_1_StaticMesh, CalculateLog_2_VertLocal, CalculateLog_3_MeshTransform, CalculateLog_4_VertWorld);
            CalculateLog_4_VertWorld.LinkLog_CalResultStackLayer(CalculateLog_0_Rigging, CalculateLog_1_StaticMesh, CalculateLog_2_VertLocal, CalculateLog_3_MeshTransform, CalculateLog_4_VertWorld);
        }
        public void ReadyToCalculate()
        {
            //TODO : 여기서부터 작성

            if (_targetOptMesh == null)
            {
                if (_isAnyVertLocal)
                {
                    Debug.LogError("AnyPortrait : Error No Mesh");
                }
                return;
            }

            int nRenderVerts = _targetOptMesh.RenderVertices.Length;

            //수정 3.22
            //따로 리셋하자.
            if (_isAnyVertLocal)
            {
                if (_result_VertLocal == null || _result_VertLocal.Length != nRenderVerts)
                {
                    _result_VertLocal = new Vector2[nRenderVerts];
                }

                for (int i = 0; i < nRenderVerts; i++)
                {
                    _result_VertLocal[i] = Vector2.zero;
                }
            }


            if (_isAnyVertWorld)
            {
                if (_result_VertWorld == null || _result_VertWorld.Length != nRenderVerts)
                {
                    _result_VertWorld = new Vector2[nRenderVerts];
                }

                for (int i = 0; i < nRenderVerts; i++)
                {
                    _result_VertWorld[i] = Vector2.zero;
                }
            }

            if (_isAnyRigging)
            {
                if (_result_RiggingMatrices == null || _result_RiggingMatrices.Length != nRenderVerts)
                {
                    _result_RiggingMatrices = new apMatrix3x3[nRenderVerts];
                }

                for (int i = 0; i < nRenderVerts; i++)
                {
                    _result_RiggingMatrices[i].SetIdentity();
                }

                _result_RiggingWeight = 0.0f;
            }



            #region [미사용 코드 : 모디파이어에 따라 다 분리시켰다]
            //if (_isAnyVertLocal || _isAnyVertWorld || _isAnyRigging)
            //{

            //	if (_result_VertLocal == null || _result_VertLocal.Length != _targetOptMesh.RenderVertices.Length)
            //	{
            //		//RenderUnit의 RenderVertex 개수 만큼 결과를 만들자
            //		_result_VertLocal = new Vector2[_targetOptMesh.RenderVertices.Length];
            //		_result_VertWorld = new Vector2[_targetOptMesh.RenderVertices.Length];
            //		//_result_Rigging = new Vector2[_targetOptMesh.RenderVertices.Length];
            //		_result_RiggingMatrices = new apMatrix3x3[_targetOptMesh.RenderVertices.Length];
            //		_result_RiggingWeight = 0.0f;


            //		for (int i = 0; i < nRenderVerts; i++)
            //		{
            //			_result_VertLocal[i] = Vector2.zero;
            //			_result_VertWorld[i] = Vector2.zero;
            //			//_result_Rigging[i] = Vector2.zero;
            //			_result_RiggingMatrices[i].SetIdentity();
            //		}
            //	}
            //	else
            //	{
            //		_result_RiggingWeight = 0.0f;

            //		for (int i = 0; i < _result_VertLocal.Length; i++)
            //		{
            //			_result_VertLocal[i] = Vector2.zero;
            //			_result_VertWorld[i] = Vector2.zero;
            //			//_result_Rigging[i] = Vector2.zero;
            //			_result_RiggingMatrices[i].SetIdentity();
            //		}
            //	}
            //}

            //_result_BoneTransform.SetIdentity();
            //_result_MeshTransform.SetIdentity();
            //_result_MeshTransform.MakeMatrix();
            ////_result_Color = _color_Default;
            //_result_Color = _parentOptTransform._meshColor2X_Default;
            //if (!_parentOptTransform._isVisible_Default)
            //{
            //	_result_Color.a = 0.0f;
            //}
            #endregion

            _result_MeshTransform.SetIdentity();
            _result_MeshTransform.MakeMatrix();
            _result_Color = _parentOptTransform._meshColor2X_Default;
            if (!_parentOptTransform._isVisible_Default)
            {
                _result_Color.a = 0.0f;
            }
            _result_BoneTransform.SetIdentity();

            _result_IsVisible       = true;
            _result_CalculatedColor = false;
        }
        //Link 함수의 내용은 Bake 시에 진행해야한다.
        /// <summary>
        /// [Please do not use it]
        /// </summary>
        /// <param name="bone"></param>
        public void Bake(apBone bone)
        {
            _name        = bone._name;
            _uniqueID    = bone._uniqueID;
            _meshGroupID = bone._meshGroupID;
            _defaultMatrix.SetMatrix(bone._defaultMatrix);


            _deltaPos   = Vector2.zero;
            _deltaAngle = 0.0f;
            _deltaScale = Vector2.one;

            _localMatrix.SetIdentity();

            _worldMatrix.SetIdentity();

            _worldMatrix_NonModified.SetIdentity();
            _vertWorld2BoneModWorldMatrix.SetIdentity();

            _color       = bone._color;
            _shapeWidth  = bone._shapeWidth;
            _shapeLength = bone._shapeLength;
            _shapeTaper  = bone._shapeTaper;

            _optionLocalMove = bone._optionLocalMove;
            _optionIK        = bone._optionIK;

            _isIKTail = bone._isIKTail;

            _IKTargetBoneID = bone._IKTargetBoneID;
            _IKTargetBone   = null;          //<<나중에 링크

            _IKNextChainedBoneID = bone._IKNextChainedBoneID;
            _IKNextChainedBone   = null;          //<<나중에 링크


            _IKHeaderBoneID = bone._IKHeaderBoneID;
            _IKHeaderBone   = null;          //<<나중에 링크


            _isIKAngleRange = bone._isIKAngleRange;
            //이게 기존 코드
            //_IKAngleRange_Lower = bone._IKAngleRange_Lower;
            //_IKAngleRange_Upper = bone._IKAngleRange_Upper;
            //_IKAnglePreferred = bone._IKAnglePreferred;

            //이게 변경된 IK 코드
            _IKAngleRange_Lower = bone._defaultMatrix._angleDeg + bone._IKAngleRange_Lower;
            _IKAngleRange_Upper = bone._defaultMatrix._angleDeg + bone._IKAngleRange_Upper;
            _IKAnglePreferred   = bone._defaultMatrix._angleDeg + bone._IKAnglePreferred;


            _isIKCalculated       = false;
            _IKRequestAngleResult = 0.0f;
            _IKRequestWeight      = 0.0f;

            _socketTransform = null;

            _transformLocalMatrix.SetIdentity();

            _childBones = null;

            _isIKChainInit = false;
        }
Esempio n. 13
0
 public void ResetRiggingTestPose()
 {
     _rigTestMatrix.SetIdentity();
 }
Esempio n. 14
0
            /// <summary>
            /// Keyframe에 Rotation Bias 설정이 있는 경우 관련 변수를 갱신한다.
            /// </summary>
            /// <param name="rotationBias"></param>
            /// <param name="rotationCount"></param>
            public void SetAnimRotationBias(apAnimKeyframe.ROTATION_BIAS rotationBias, int rotationCount)
            {
                if (rotationBias == apAnimKeyframe.ROTATION_BIAS.CW)
                {
                    _isAnimRotationBias    = true;
                    _animRotationBiasAngle = -360 * rotationCount;
                }
                else if (rotationBias == apAnimKeyframe.ROTATION_BIAS.CCW)
                {
                    _isAnimRotationBias    = true;
                    _animRotationBiasAngle = 360 * rotationCount;
                }
                else
                {
                    _isAnimRotationBias    = false;
                    _animRotationBiasAngle = 0;
                }
                if (_animRotationBiasAngle_Prev != _animRotationBiasAngle && _isAnimRotationBias)
                {
                    if (_animRotationBiasedMatrix == null)
                    {
                        _animRotationBiasedMatrix = new apMatrix();
                    }

                    if (_modifiedMesh != null)
                    {
                        _animRotationBiasedMatrix.SetTRS(
                            _modifiedMesh._transformMatrix._pos,
                            _modifiedMesh._transformMatrix._angleDeg + _animRotationBiasAngle,
                            _modifiedMesh._transformMatrix._scale
                            );
                    }
                    else if (_modifiedMeshSet != null)
                    {
                        //추가됨 19.5.24 : ModMeshSet으로 계산하기
                        _subModMesh_Transform = _modifiedMeshSet.SubModMesh_Transform;
                        if (_subModMesh_Transform != null)
                        {
                            _animRotationBiasedMatrix.SetTRS(
                                _subModMesh_Transform._transformMatrix._pos,
                                _subModMesh_Transform._transformMatrix._angleDeg + _animRotationBiasAngle,
                                _subModMesh_Transform._transformMatrix._scale
                                );
                        }
                        else
                        {
                            Debug.LogError("TODO : 에러 : 애니메이션에 SubModMeshSet_Transform이 없다.");
                            _animRotationBiasedMatrix.SetIdentity();
                        }
                    }
                    else if (_modifiedBone != null)
                    {
                        _animRotationBiasedMatrix.SetTRS(
                            _modifiedBone._transformMatrix._pos,
                            _modifiedBone._transformMatrix._angleDeg + _animRotationBiasAngle,
                            _modifiedBone._transformMatrix._scale
                            );
                    }
                    else
                    {
                        _animRotationBiasedMatrix.SetIdentity();
                    }

                    _animRotationBiasAngle_Prev = _animRotationBiasAngle;
                }
            }
Esempio n. 15
0
        // File To Bone
        //---------------------------------------------------
        public bool DecodeData(string strSrc)
        {
            try
            {
                if (strSrc.Length < 3)
                {
                    return(false);
                }
                int nName = int.Parse(strSrc.Substring(0, 3));
                _name = strSrc.Substring(3, nName);

                strSrc = strSrc.Substring(3 + nName);

                //나머지는 델리미터를 이용한다.
                string[] strUnits = strSrc.Split(new string[] { "/" }, StringSplitOptions.None);
                int      iStr     = 0;
                _unitID = int.Parse(strUnits[iStr]);
                iStr++;

                _parentUnitID = int.Parse(strUnits[iStr]);
                iStr++;

                _level = int.Parse(strUnits[iStr]);
                iStr++;

                _depth = int.Parse(strUnits[iStr]);
                iStr++;

                _childUnitID.Clear();
                int nChild = int.Parse(strUnits[iStr]);
                iStr++;

                for (int i = 0; i < nChild; i++)
                {
                    _childUnitID.Add(int.Parse(strUnits[iStr]));
                    iStr++;
                }

                _defaultMatrix.SetIdentity();
                _defaultMatrix.SetTRS(
                    new Vector2(float.Parse(strUnits[iStr]), float.Parse(strUnits[iStr + 1])),
                    float.Parse(strUnits[iStr + 2]),
                    new Vector2(float.Parse(strUnits[iStr + 3]), float.Parse(strUnits[iStr + 4]))
                    );

                iStr += 5;

                _color.r = float.Parse(strUnits[iStr]);
                _color.g = float.Parse(strUnits[iStr + 1]);
                _color.b = float.Parse(strUnits[iStr + 2]);
                _color.a = float.Parse(strUnits[iStr + 3]);
                iStr    += 4;

                _shapeWidth  = int.Parse(strUnits[iStr]);
                _shapeLength = int.Parse(strUnits[iStr + 1]);
                _shapeTaper  = int.Parse(strUnits[iStr + 2]);
                iStr        += 3;

                _optionIK = (apBone.OPTION_IK) int.Parse(strUnits[iStr]);
                _isIKTail = (int.Parse(strUnits[iStr + 1]) == 1) ? true : false;
                iStr     += 2;

                _IKTargetBoneUnitID      = int.Parse(strUnits[iStr]);
                _IKNextChainedBoneUnitID = int.Parse(strUnits[iStr + 1]);
                _IKHeaderBoneUnitID      = int.Parse(strUnits[iStr + 2]);
                iStr += 3;

                _isIKAngleRange     = (int.Parse(strUnits[iStr]) == 1) ? true : false;
                _IKAngleRange_Lower = float.Parse(strUnits[iStr + 1]);
                _IKAngleRange_Upper = float.Parse(strUnits[iStr + 2]);
                _IKAnglePreferred   = float.Parse(strUnits[iStr + 3]);
                iStr += 4;

                _isSocketEnabled = (int.Parse(strUnits[iStr]) == 1) ? true : false;

                _isImportEnabled = true;
                _isIKEnabled     = true;
                _isShapeEnabled  = true;
            }
            catch (Exception ex)
            {
                Debug.LogError("Decode Exception : " + ex);
                return(false);
            }


            return(true);
        }
Esempio n. 16
0
        public void ReadyToUpdate()
        {
            //1. Child Mesh와 기본 Reday
            if (_childMesh != null)
            {
                _childMesh.ReadyToUpdate();
            }

            //2. Calculate Stack Ready
            if (_calculatedStack != null)
            {
                _calculatedStack.ReadyToCalculate();
            }

            //3. 몇가지 변수 초기화
            _meshColor2X = new Color(0.5f, 0.5f, 0.5f, 1.0f);

            _isVisible = true;

            //Editor에서는 기본 matrix가 들어가지만, 여기서는 아예 Transform(Mono)에 들어가기 때문에 Identity가 된다.
            //_matrix_TF_Cal_ToWorld = apMatrix3x3.identity;
            //_calculateTmpMatrix.SetIdentity();


            //변경
            //[Parent World x To Parent x Local TF] 조합으로 변경

            if (_matrix_TF_ParentWorld == null)
            {
                _matrix_TF_ParentWorld = new apMatrix();
            }
            if (_matrix_TF_ParentWorld_NonModified == null)
            {
                _matrix_TF_ParentWorld_NonModified = new apMatrix();
            }
            if (_matrix_TF_ToParent == null)
            {
                _matrix_TF_ToParent = new apMatrix();
            }
            if (_matrix_TF_LocalModified == null)
            {
                _matrix_TF_LocalModified = new apMatrix();
            }
            if (_matrix_TFResult_World == null)
            {
                _matrix_TFResult_World = new apMatrix();
            }
            if (_matrix_TFResult_WorldWithoutMod == null)
            {
                _matrix_TFResult_WorldWithoutMod = new apMatrix();
            }


            _matrix_TF_ParentWorld.SetIdentity();
            _matrix_TF_ParentWorld_NonModified.SetIdentity();
            //_matrix_TF_ToParent.SetIdentity();
            _matrix_TF_LocalModified.SetIdentity();

            //Editor에서는 기본 matrix가 들어가지만, 여기서는 아예 Transform(Mono)에 들어가기 때문에 Identity가 된다.
            _matrix_TF_ToParent.SetMatrix(_defaultMatrix);

            _matrix_TFResult_World.SetIdentity();
            _matrix_TFResult_WorldWithoutMod.SetIdentity();


            //3. 자식 호출
            //자식 객체도 업데이트를 한다.
            if (_childTransforms != null)
            {
                for (int i = 0; i < _childTransforms.Length; i++)
                {
                    _childTransforms[i].ReadyToUpdate();
                }
            }
        }
Esempio n. 17
0
        public apMatrix GetSubInverseLayeredMatrix(apCalculatedLog targetLog, apCalculatedLog parentLog, apMatrix parentMatrix)
        {
            apMatrix invUpperLayerMatrix = new apMatrix(parentMatrix);
            apMatrix lowerLayerMatrix    = new apMatrix();         //타겟보다 낮은 레이어는 따로 합을 구한다.

            LOG_TYPE layerLogType = targetLog._logType;

            int nLayers = 0;
            int iLayer  = -1;

            if (layerLogType == LOG_TYPE.Layer_CalParamResult)
            {
                nLayers = parentLog._childCalParamResultLogs.Count;
                iLayer  = parentLog._childCalParamResultLogs.IndexOf(targetLog);
            }
            else if (layerLogType == LOG_TYPE.Layer_ParamSetGroup)
            {
                nLayers = parentLog._childLayerLogs.Count;
                iLayer  = parentLog._childLayerLogs.IndexOf(targetLog);
            }
            else
            {
                Debug.LogError("Layer가 없는 LogType [" + layerLogType + "] 이다");
                return(null);
            }

            if (iLayer < 0)
            {
                Debug.LogError("존재하지 않는 Log [" + layerLogType + "]");
                return(null);
            }



            lowerLayerMatrix.SetIdentity();

            //Debug.LogWarning(">> Lower To Layer [0 > " + iLayer + "]");
            //낮은 레이어에서는 값을 더하자
            if (iLayer > 0)
            {
                for (int i = 0; i < iLayer; i++)
                {
                    apCalculatedLog calLog    = null;
                    apMatrix        calMatrix = null;
                    switch (layerLogType)
                    {
                    case LOG_TYPE.Layer_CalParamResult:
                        calLog    = parentLog._childCalParamResultLogs[i];
                        calMatrix = calLog._calResultParam._result_Matrix;
                        break;

                    case LOG_TYPE.Layer_ParamSetGroup:
                        calLog    = parentLog._childLayerLogs[i];
                        calMatrix = calLog._paramSetGroup._tmpMatrix;
                        break;
                    }

                    float weight = calLog._weight;
                    if (!calLog._isWeight)
                    {
                        weight = 1.0f;
                    }

                    //string prevMatrix = lowerLayerMatrix.ToString();

                    if (i == 0)
                    {
                        lowerLayerMatrix.SetPos(calMatrix._pos * weight);
                        lowerLayerMatrix.SetRotate(calMatrix._angleDeg * weight);
                        lowerLayerMatrix.SetScale(calMatrix._scale * weight + Vector2.one * (1.0f - weight));
                        lowerLayerMatrix.MakeMatrix();
                    }
                    else
                    {
                        switch (calLog._layerBlendType)
                        {
                        case BLEND_METHOD.Interpolation:
                            BlendMatrix_ITP(lowerLayerMatrix, calMatrix, weight);
                            //Debug.Log("[" + i + "] ITP/" + weight + " : " + prevMatrix + " >> " + calMatrix + " => " + lowerLayerMatrix);
                            break;

                        case BLEND_METHOD.Additive:
                            BlendMatrix_Add(lowerLayerMatrix, calMatrix, weight);
                            //Debug.Log("[" + i + "] ADD/" + weight + " : " + prevMatrix + " >> " + calMatrix + " => " + lowerLayerMatrix);
                            break;
                        }
                    }
                }
            }

            //Debug.LogWarning(">> Upper To Layer [" + (nLayers - 1) + " > " + iLayer + "]");
            //위 레이어에서는 값을 빼자
            if (iLayer < nLayers - 1)
            {
                for (int i = (nLayers - 1); i >= iLayer + 1; i--)
                {
                    apCalculatedLog calLog    = null;
                    apMatrix        calMatrix = null;
                    switch (layerLogType)
                    {
                    case LOG_TYPE.Layer_CalParamResult:
                        calLog    = parentLog._childCalParamResultLogs[i];
                        calMatrix = calLog._calResultParam._result_Matrix;
                        break;

                    case LOG_TYPE.Layer_ParamSetGroup:
                        calLog    = parentLog._childLayerLogs[i];
                        calMatrix = calLog._paramSetGroup._tmpMatrix;
                        break;
                    }


                    float weight = calLog._weight;
                    if (!calLog._isWeight)
                    {
                        weight = 1.0f;
                    }
                    switch (calLog._layerBlendType)
                    {
                    case BLEND_METHOD.Interpolation:
                        InverseBlendMatrix_ITP(invUpperLayerMatrix, calMatrix, weight);
                        break;

                    case BLEND_METHOD.Additive:
                        InverseBlendMatrix_Add(invUpperLayerMatrix, calMatrix, weight);
                        break;
                    }
                }
            }

            apMatrix result          = null;
            float    weight_calParam = targetLog._weight;

            if (!targetLog._isWeight)
            {
                weight_calParam = 1.0f;
            }

            apMatrix calTargetMatrix = null;

            switch (layerLogType)
            {
            case LOG_TYPE.Layer_CalParamResult:
                calTargetMatrix = targetLog._calResultParam._result_Matrix;
                break;

            case LOG_TYPE.Layer_ParamSetGroup:
                calTargetMatrix = targetLog._paramSetGroup._tmpMatrix;
                break;
            }

            switch (targetLog._layerBlendType)
            {
            case BLEND_METHOD.Additive:
                result = InverseBlendMatrixTarget_Add(invUpperLayerMatrix, lowerLayerMatrix, calTargetMatrix, weight_calParam);
                break;

            case BLEND_METHOD.Interpolation:
                result = InverseBlendMatrixTarget_ITP(invUpperLayerMatrix, lowerLayerMatrix, calTargetMatrix, weight_calParam);
                break;
            }
            if (result == null)
            {
                return(null);
            }

            return(result);
        }