Ejemplo n.º 1
0
        public void Rotate__MeshGroup_Setting(float deltaAngleW)
        {
            if (Editor.Select.MeshGroup == null || !Editor.Select.IsMeshGroupSettingChangePivot)
            {
                return;
            }

            if (deltaAngleW == 0.0f)
            {
                return;
            }

            apMatrix targetMatrix      = null;
            object   targetObj         = null;
            apMatrix worldMatrix       = null;
            apMatrix parentWorldMatrix = null;

            if (Editor.Select.SubMeshInGroup != null)
            {
                targetMatrix      = Editor.Select.SubMeshInGroup._matrix;
                targetObj         = Editor.Select.SubMeshInGroup;
                worldMatrix       = new apMatrix(Editor.Select.SubMeshInGroup._matrix_TFResult_World);
                parentWorldMatrix = Editor.Select.SubMeshInGroup._matrix_TF_ParentWorld;
            }
            else if (Editor.Select.SubMeshGroupInGroup != null)
            {
                targetMatrix      = Editor.Select.SubMeshGroupInGroup._matrix;
                targetObj         = Editor.Select.SubMeshGroupInGroup;
                worldMatrix       = new apMatrix(Editor.Select.SubMeshGroupInGroup._matrix_TFResult_World);
                parentWorldMatrix = Editor.Select.SubMeshGroupInGroup._matrix_TF_ParentWorld;
            }
            else
            {
                return;
            }

            float nextAngle = worldMatrix._angleDeg + deltaAngleW;

            while (nextAngle < -180.0f)
            {
                nextAngle += 360.0f;
            }
            while (nextAngle > 180.0f)
            {
                nextAngle -= 360.0f;
            }
            worldMatrix._angleDeg = nextAngle;
            worldMatrix.MakeMatrix();
            worldMatrix.RInverse(parentWorldMatrix);            //ParentWorld-1 x World = ToParent


            //Undo
            apEditorUtil.SetRecord(apUndoGroupData.ACTION.MeshGroup_Gizmo_RotateTransform, Editor.Select.MeshGroup, targetObj, false, Editor);

            //targetMatrix.SetRotate(deltaAngleW + targetMatrix._angleDeg);
            targetMatrix.SetRotate(worldMatrix._angleDeg);
            targetMatrix.MakeMatrix();
        }
Ejemplo n.º 2
0
        public void TransformChanged_Rotate__MeshGroup_Setting(float angle)
        {
            if (Editor.Select.MeshGroup == null || !Editor.Select.IsMeshGroupSettingChangePivot)
            {
                return;
            }
            if (Editor.Select.SubMeshInGroup == null && Editor.Select.SubMeshGroupInGroup == null)
            {
                return;
            }

            apRenderUnit curRenderUnit  = null;
            apMatrix     curMatrixParam = null;

            object targetObj = null;

            if (Editor.Select.SubMeshInGroup != null)
            {
                curRenderUnit  = Editor.Select.MeshGroup.GetRenderUnit(Editor.Select.SubMeshInGroup);
                curMatrixParam = Editor.Select.SubMeshInGroup._matrix;
                targetObj      = Editor.Select.SubMeshInGroup;
            }
            else if (Editor.Select.SubMeshGroupInGroup != null)
            {
                curRenderUnit  = Editor.Select.MeshGroup.GetRenderUnit(Editor.Select.SubMeshGroupInGroup);
                curMatrixParam = Editor.Select.SubMeshGroupInGroup._matrix;
                targetObj      = Editor.Select.SubMeshGroupInGroup;
            }

            if (curRenderUnit == null)
            {
                return;
            }

            //Undo
            apEditorUtil.SetRecord_MeshGroup(apUndoGroupData.ACTION.MeshGroup_Gizmo_RotateTransform, Editor, Editor.Select.MeshGroup, targetObj, false, true);

            curMatrixParam.SetRotate(angle);
            curMatrixParam.MakeMatrix();
            Editor.SetRepaint();
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        public InverseResult World2ModLocalPos_TransformRotationScaling(float deltaRotateAngle, Vector2 deltaScale)
        {
            if (_modMesh == null)
            {
                Debug.LogError("World2ModLocalPos_Transform 실패 : ModMesh에서 호출하지 않았다.");
                return(null);
            }
            if (_modMesh._transform_Mesh == null)
            {
                Debug.LogError("World2ModLocalPos_Transform 실패 : ModMesh의 MeshTransform이 Null이다.");
                return(null);
            }
            //현재 위치를 받자


            //이제 위로 하나씩 계산하면서 어떤 CalculateLog가 기록되었는지 확인하자
            //StatckLResultLayer까지 올라가면 된다. (거기는 값이 고정이므로)
            apCalculatedLog modified                 = this;
            apCalculatedLog layer_ParamSetGroup      = modified._parentLayerLog;
            apCalculatedLog layer_CalParamResult     = layer_ParamSetGroup._parentLayerLog;
            apCalculatedLog stackLayer_MeshTransform = layer_CalParamResult._parentCalResultStackLayer;
            apCalculatedLog transform_Modified       = stackLayer_MeshTransform._parentTF_Modified;

            //현재 posW 를 저장하자
            Vector2 posW_prev = _modMesh._transform_Mesh._matrix_TFResult_World._pos;

            //일단 회전값/스케일을 추가하자
            apMatrix RSModMatrix = new apMatrix(_modMesh._transform_Mesh._matrix_TF_LocalModified);

            RSModMatrix.SetRotate(RSModMatrix._angleDeg + deltaRotateAngle);
            RSModMatrix.SetScale(RSModMatrix._scale + deltaScale);
            apMatrix RSWorldMatrix = new apMatrix(_modMesh._transform_Mesh._matrix_TF_ToParent);

            RSWorldMatrix.RMultiply(RSModMatrix);
            RSWorldMatrix.RMultiply(_modMesh._transform_Mesh._matrix_TF_ParentWorld);

            //이 WorldMatrix의 계산 후 Position을 확인하자
            Vector2 posW_rs = RSWorldMatrix._pos;

            //posW_rotated가 아닌 posW_prev로 돌려야 한다. 고치자.
            Vector2 deltaPosW = posW_prev - posW_rs;

            _inverseResult.Request(posW_rs, deltaPosW);


            //이제 역으로 내려오자
            // ParentWorld <- Modified <- ToParent = World
            // [Modified <- ToParent] = [ParentWorld-1 <- World]
            // Modified = [ParentWorld-1 <- World <- ToParent-1]


            apMatrix worldMatrix_next = new apMatrix(RSWorldMatrix);

            worldMatrix_next.SetPos(worldMatrix_next._pos + deltaPosW);


            apMatrix modMatrix_next = transform_Modified._meshTransform._matrix_TF_ToParent.RInverseMatrix;

            modMatrix_next.RMultiply(worldMatrix_next);
            modMatrix_next.RInverse(transform_Modified._meshTransform._matrix_TF_ParentWorld);

            //위 수식은 "StackLayer-MeshTF" 레벨에서 계산된 것이다.
            //StackLayer -> CalParam -> ParamSetGroup으로 이동하자.
            apMatrix modMatrix_paramSet = GetInverseInterpolatedMatrix(layer_ParamSetGroup, layer_CalParamResult, stackLayer_MeshTransform, modMatrix_next);

            if (modMatrix_paramSet == null)
            {
                Debug.LogError("StackLayer -> CalParam -> ParamSetGroup 전환에 실패했다.");
                return(null);
            }
            //_inverseResult.SetResult(transform_Modified._meshTransform._matrix_TF_LocalModified._pos,
            //	modMatrix_next._pos);

            _inverseResult.SetResult(transform_Modified._meshTransform._matrix_TF_LocalModified._pos,
                                     modMatrix_paramSet._pos);


            return(_inverseResult);
        }