Esempio n. 1
0
        public void SetMesh(apMeshGroup meshGroup, apTransform_Mesh meshTransform, apRenderUnit parentRenderUnit)
        {
            _unitType = UNIT_TYPE.Mesh;

            _meshGroup = meshGroup;

            _meshGroupTransform = null;
            _meshTransform      = meshTransform;

            _meshTransform._linkedRenderUnit = this;

            _depth = 0;
            if (parentRenderUnit != null)
            {
                _depth += parentRenderUnit._depth;
            }
            if (_meshGroupTransform != null)
            {
                _depth += _meshGroupTransform._depth;
            }
            _depth += meshTransform._depth;


            if (parentRenderUnit != null)
            {
                parentRenderUnit._childRenderUnits.Add(this);
                _parentRenderUnit = parentRenderUnit;
            }
        }
        // Functions
        //------------------------------------------------

        #region [미사용 코드 : Batch없이 각각 렌더링. 느렸다..]
        //public bool Compute_Editor(List<apRenderVertex> renderVerts, apMatrix3x3 matrix_Static_Vert2Mesh, apMatrix3x3 matrix_MeshTransform)
        //{
        //	if(!IsSupport)
        //	{
        //		return false;
        //	}

        //	Matrix2Floats(matrix_Static_Vert2Mesh, ref _matrix_Static_Vert2Mesh);
        //	Matrix2Floats(matrix_MeshTransform, ref _matrix_MeshTransform);
        //	Matrix2Floats(matrix_MeshTransform.inverse, ref _matrix_MeshTransformInverse);

        //	//Matrix2Floats(apMatrix3x3.identity, _matrix_Static_Vert2Mesh);
        //	//Matrix2Floats(apMatrix3x3.identity, _matrix_MeshTransform);
        //	//Matrix2Floats(apMatrix3x3.identity, _matrix_MeshTransformInverse);


        //	_cShader_Editor.SetFloats("_mtx_Static_Vert2Mesh", _matrix_Static_Vert2Mesh);
        //	_cShader_Editor.SetFloats("_mtx_MeshTransform", _matrix_MeshTransform);
        //	_cShader_Editor.SetFloats("_mtx_MeshTransformInverse", _matrix_MeshTransformInverse);

        //	_inputVerts_Editor = new InputVertexStruct_Editor[renderVerts.Count];
        //	_outputVerts_Editor = new OutputVertexStruct_Editor[renderVerts.Count];

        //	int nRenderVerts = renderVerts.Count;
        //	apRenderVertex renderVert = null;
        //	for (int i = 0; i < nRenderVerts; i++)
        //	{
        //		renderVert = renderVerts[i];
        //		_inputVerts_Editor[i]._posL = renderVert._vertex._pos;
        //		_inputVerts_Editor[i]._posRigging = renderVert._pos_Rigging;

        //		_inputVerts_Editor[i]._riggingWeight = renderVert._weight_Rigging;

        //		_inputVerts_Editor[i]._mtx_Cal_VertLocal = renderVert._matrix_Cal_VertLocal;
        //		_inputVerts_Editor[i]._mtx_Cal_VertWorld = renderVert._matrix_Cal_VertWorld;
        //		_inputVerts_Editor[i]._mtx_World =		renderVert._matrix_Cal_VertWorld *
        //										matrix_MeshTransform *
        //										renderVert._matrix_Cal_VertLocal *
        //										matrix_Static_Vert2Mesh;
        //	}
        //	_inputBuffer = new ComputeBuffer(nRenderVerts, 220);//원래는 156
        //	_outputBuffer = new ComputeBuffer(nRenderVerts, 96);

        //	_inputBuffer.SetData(_inputVerts_Editor);
        //	//_outputBuffer_Editor.SetData(_outputVerts);

        //	_cShader_Editor.SetBuffer(_kernel_Editor, "_inputBuffer", _inputBuffer);
        //	_cShader_Editor.SetBuffer(_kernel_Editor, "_outputBuffer", _outputBuffer);

        //	_cShader_Editor.Dispatch(_kernel_Editor, 32, 32, 1);

        //	_outputBuffer.GetData(_outputVerts_Editor);

        //	for (int i = 0; i < nRenderVerts; i++)
        //	{
        //		renderVert = renderVerts[i];
        //		renderVert.CalculateByComputeShader(
        //			//_outputVerts_Editor[i]._posWorld3,
        //			_outputVerts_Editor[i]._posWorld2,
        //			_outputVerts_Editor[i]._posLocalOnMesh,//<<Vec2로 바꿀 것
        //			_outputVerts_Editor[i]._mtxWorld);

        //		//if (i == 5)
        //		//{
        //		//	//Debug.Log("Compute\n" + matrix_MeshTransform + "\n>>\n" + _outputVerts[i]._mtxWorld);
        //		//	Debug.Log("Compute\n" + _inputVerts[i]._mtx_World + "\n>>\n" + _outputVerts[i]._mtxWorld);
        //		//	//Debug.Log("Compute\n" + _inputVerts[i]._mtx_Cal_VertWorld + "\n>>\n" + _outputVerts[i]._mtxWorld);
        //		//}

        //	}

        //	_inputBuffer.Release();
        //	_outputBuffer.Release();

        //	_inputBuffer = null;
        //	_outputBuffer = null;

        //	return true;
        //}
        #endregion


        public bool AddRenderRequest(apRenderUnit renderUnit,
                                     apRenderUnit.ComputedVert_Input[] inputVerts,
                                     List <apRenderVertex> renderVerts,
                                     apMatrix3x3 matrix_Static_Vert2Mesh,
                                     apMatrix3x3 matrix_MeshTransform,
                                     float riggingWeight)
        {
            if (!IsSupport)
            {
                return(false);
            }

            apMatrix3x3 invMeshTransform = matrix_MeshTransform.inverse;
            int         nVert            = renderVerts.Count;

            for (int i = 0; i < nVert; i++)
            {
                _renderRequest.Add(new RenderRequest(renderUnit,
                                                     renderVerts[i],
                                                     matrix_Static_Vert2Mesh,
                                                     matrix_MeshTransform,
                                                     invMeshTransform,
                                                     i,
                                                     inputVerts[i]._posL,
                                                     riggingWeight,
                                                     inputVerts[i]._posRigging,
                                                     inputVerts[i]._calVertLocal,
                                                     inputVerts[i]._calVertWorld
                                                     ));
            }

            return(true);
        }
Esempio n. 3
0
        public void SetGroup(apMeshGroup meshGroup, apTransform_MeshGroup meshGroupTransform, apRenderUnit parentRenderUnit)
        {
            _unitType = UNIT_TYPE.GroupNode;

            _meshGroup = meshGroup;

            _meshGroupTransform = meshGroupTransform;
            _meshTransform      = null;

            //역으로 Link를 하자
            _meshGroupTransform._linkedRenderUnit = this;



            _depth = 0;
            if (_meshTransform != null)
            {
                _depth += _meshTransform._depth;
            }
            if (parentRenderUnit != null)
            {
                _depth += parentRenderUnit._depth;
            }
            if (meshGroupTransform != null)
            {
                //루트가 아니라면 Mesh Group Transform도 있다.
                _depth += _meshGroupTransform._depth;
            }

            if (parentRenderUnit != null)
            {
                parentRenderUnit._childRenderUnits.Add(this);
                _parentRenderUnit = parentRenderUnit;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 현재 상태에 대한 Matrix 들을 계산하고 렌더링 준비를 한다.
        /// 1차 업데이트 이후에 처리하는 Post 업데이트이다.
        /// Rigging, VertWorld 타입만 처리된다.
        /// </summary>
        /// <param name="isMatrixCalculateForce">Matrix를 강제로 넣어야 한다. 초기화에 가까운 Force 옵션일때만 true 값을 넣자</param>
        //public void Update_Post(float tDelta, bool isMatrixCalculateForce, apMeshGroup.FUNC_IS_FORCE_UPDATE funcForceUpdate)
        public void Update_Post(float tDelta)
        {
            if (_calculatedStack != null)
            {
                //강제로 CalculateStack의 Hash를 업데이트해야하는지 결정한다.
                //bool isForceUpdateHash = isMatrixCalculateForce;
                //if(!isForceUpdateHash && funcForceUpdate != null)
                //{
                //	isForceUpdateHash = funcForceUpdate(this);
                //}

                //_calculatedStack.Calculate_Post(tDelta, isForceUpdateHash);
                _calculatedStack.Calculate_Post(tDelta);
            }


            apRenderUnit childRenderUnit = null;


            for (int i = 0; i < _childRenderUnits.Count; i++)
            {
                childRenderUnit = _childRenderUnits[i];

                //childRenderUnit.Update_Post(tDelta, isMatrixCalculateForce, funcForceUpdate);
                childRenderUnit.Update_Post(tDelta);
            }
        }
Esempio n. 5
0
        // Init
        //------------------------------------
        public apRenderVertex(apRenderUnit parentRenderUnit, apMeshGroup parentMeshGroup, apMesh parentMesh, apVertex vertex)
        {
            _parentRenderUnit = parentRenderUnit;
            _parentMeshGroup  = parentMeshGroup;
            _parentMesh       = parentMesh;
            _vertex           = vertex;

            //_isStaticRefreshed = false;
            _isCalculated = false;

            //_matrixStack.Clear();

            //
            _matrix_Static_Vert2Mesh = apMatrix3x3.identity;
            _matrix_Cal_VertLocal    = apMatrix3x3.identity;
            _matrix_MeshTransform    = apMatrix3x3.identity;

            _matrix_Cal_VertWorld = apMatrix3x3.identity;
            _matrix_ToWorld       = apMatrix3x3.identity;
            _pos_World            = Vector2.zero;

            //_cal_VertWorld = Vector2.zero;

            //_matrixHashCode_Static_Vert2Mesh = -1;
            //_matrixHashCode_Calculate = -1;

            //_isMatrixChanged = true;
            //_isUpdateMatrixForce = true;

            _pos_Rigging    = Vector2.zero;
            _weight_Rigging = 0.0f;

            _matrix_Rigging = apMatrix3x3.identity;
        }
Esempio n. 6
0
        private bool AddBoneToParamSet(apModifierParamSet paramSet, apTransform_MeshGroup meshGroupTransform, apBone bone)
        {
            if (!_parentModifier.IsTarget_Bone)
            {
                return(false);
            }

            bool isExist = paramSet._boneData.Exists(delegate(apModifiedBone a)
            {
                return(a._bone == bone);
            });

            if (!isExist)
            {
                apMeshGroup parentMeshGroupOfBone = GetParentMeshGroupOfBone(bone);
                if (parentMeshGroupOfBone == null)
                {
                    return(false);
                }

                apRenderUnit targetRenderUnit = _parentModifier._meshGroup.GetRenderUnit(meshGroupTransform);

                apModifiedBone modBone = new apModifiedBone();
                modBone.Init(_parentModifier._meshGroup._uniqueID, parentMeshGroupOfBone._uniqueID, meshGroupTransform._transformUniqueID, bone);
                modBone.Link(_parentModifier._meshGroup, parentMeshGroupOfBone, bone, targetRenderUnit, meshGroupTransform);


                paramSet._boneData.Add(modBone);
            }

            return(!isExist);
        }
Esempio n. 7
0
        //TODO Link 등등
        //에디터에서 제대로 Link를 해야한다.
        public void Link(apMeshGroup meshGroup_Modifier, apMeshGroup meshGroup_Bone, apBone bone, apRenderUnit renderUnit, apTransform_MeshGroup meshGroupTransform)
        {
            _meshGroup_Modifier = meshGroup_Modifier;
            _meshGroup_Bone     = meshGroup_Bone;
            _bone       = bone;
            _renderUnit = renderUnit;


            _meshGroupTransform = meshGroupTransform;


            //if (_meshGroup_Bone != meshGroup_Modifier)
            //{
            //	//Debug.Log(" ------------Sub Bone의 Link ------------");
            //	if (_renderUnit == null)
            //	{
            //		//Debug.LogError("<<< Render Unit이 Null이다. >>> ");
            //	}
            //	Debug.Log("meshGroup_Modifier : " + (meshGroup_Modifier == null ? "NULL" : meshGroup_Modifier._name));
            //	Debug.Log("_meshGroup_Bone : " + (_meshGroup_Bone == null ? "NULL" : _meshGroup_Bone._name));
            //	Debug.Log("_bone : " + (_bone == null ? "NULL" : _bone._name));
            //	Debug.Log("_meshGroupTransform : " + (_meshGroupTransform == null ? "NULL" : _meshGroupTransform._nickName));
            //	Debug.Log("_transformUniqueID : " + _transformUniqueID);
            //}
        }
            public Vector2 _cal_VertWorld;              //64

            public RenderRequest(apRenderUnit renderUnit,
                                 apRenderVertex renderVert,
                                 apMatrix3x3 matrix_Static_Vert2Mesh,
                                 apMatrix3x3 matrix_MeshTransform,
                                 apMatrix3x3 matrix_MeshTransformInverse,
                                 int iVert,
                                 Vector2 posL,
                                 float riggingWeight,
                                 Vector2 posRigging,
                                 Vector2 cal_VertLocal,
                                 Vector2 cal_VertWorld
                                 )
            {
                _renderUnit = renderUnit;
                _renderVert = renderVert;
                _matrix_Static_Vert2Mesh     = matrix_Static_Vert2Mesh;
                _matrix_MeshTransform        = matrix_MeshTransform;
                _matrix_MeshTransformInverse = matrix_MeshTransformInverse;
                _iVert         = iVert;
                _posL          = posL;
                _riggingWeight = riggingWeight;
                _posRigging    = posRigging;
                _cal_VertLocal = cal_VertLocal;
                _cal_VertWorld = cal_VertWorld;
            }
Esempio n. 9
0
        // Init
        //---------------------------------------------------
        public apCalculatedResultStack(apRenderUnit parentRenderUnit)
        {
            //_tmpID = UnityEngine.Random.Range(0, 1000);

            _parentRenderUnit = parentRenderUnit;
            //Debug.Log("[" + _tmpID + "] Init [R " + _parentRenderUnit._tmpName + "]");
            ClearResultParams();
        }
        //TODO Link 등등
        //에디터에서 제대로 Link를 해야한다.
        public void Link(apMeshGroup meshGroup_Modifier, apMeshGroup meshGroup_Bone, apBone bone, apRenderUnit renderUnit, apTransform_MeshGroup meshGroupTransform)
        {
            _meshGroup_Modifier = meshGroup_Modifier;
            _meshGroup_Bone     = meshGroup_Bone;
            _bone       = bone;
            _renderUnit = renderUnit;

            _meshGroupTransform = meshGroupTransform;
        }
        // Init
        //--------------------------------------------------------------------
        public void Init(apEditor editor,
                         object loadKey,
                         apMeshGroup srcMeshGroup,
                         apTransform_Mesh srcMeshTransform,
                         FUNC_SELECT_MESH_TF_COPY funcResult)
        {
            _editor     = editor;
            _loadKey    = loadKey;
            _meshGroup  = srcMeshGroup;
            _funcResult = funcResult;

            _srcMeshTransform = srcMeshTransform;

            //타겟을 검색하자
            _meshTransforms.Clear();



            _img_Mesh     = _editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Mesh);
            _img_FoldDown = _editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_FoldDown);

            //대상이 되는 데이터를 가져온다.
            for (int i = 0; i < _meshGroup._renderUnits_All.Count; i++)
            {
                apRenderUnit renderUnit = _meshGroup._renderUnits_All[i];
                if (renderUnit._meshTransform == null || renderUnit._meshTransform == _srcMeshTransform)
                {
                    continue;
                }

                if (!_meshTransforms.Contains(renderUnit._meshTransform))
                {
                    _meshTransforms.Add(renderUnit._meshTransform);
                }
            }

            _meshTransforms.Reverse();


            if (_copiedProperties == null)
            {
                _copiedProperties = new Dictionary <COPIED_PROPERTIES, bool>();
            }

            _copiedProperties.Clear();

            _copiedProperties.Add(COPIED_PROPERTIES.DefaultColor, false);
            _copiedProperties.Add(COPIED_PROPERTIES.ShaderType, false);
            _copiedProperties.Add(COPIED_PROPERTIES.CustomShader, false);
            _copiedProperties.Add(COPIED_PROPERTIES.RenderTextureSize, false);
            _copiedProperties.Add(COPIED_PROPERTIES.TwoSides, false);
            _copiedProperties.Add(COPIED_PROPERTIES.ShadowSettings, false);
            _copiedProperties.Add(COPIED_PROPERTIES.MaterialSet, false);
            _copiedProperties.Add(COPIED_PROPERTIES.MaterialProperties, false);
        }
Esempio n. 12
0
        public void TransformChanged_Position__MeshGroup_Setting(Vector2 pos, int depth)
        {
            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(apUndoGroupData.ACTION.MeshGroup_Gizmo_MoveTransform, Editor.Select.MeshGroup, targetObj, false, Editor);

            bool bSort = false;

            if (curRenderUnit.GetDepth() != depth)
            {
                //curRenderUnit.SetDepth(depth);
                Editor.Select.MeshGroup.ChangeRenderUnitDetph(curRenderUnit, depth);

                bSort = true;
            }
            curMatrixParam.SetPos(pos);
            curMatrixParam.MakeMatrix();
            if (bSort)
            {
                Editor.Select.MeshGroup.SortRenderUnits(true);
            }
            Editor.SetRepaint();
        }
Esempio n. 13
0
        public void TransformChanged_Depth__MeshGroup_Setting(int depth)
        {
            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_MoveTransform, Editor, Editor.Select.MeshGroup, targetObj, false, true);

            bool bSort = false;

            if (curRenderUnit.GetDepth() != depth)
            {
                //curRenderUnit.SetDepth(depth);
                Editor.Select.MeshGroup.ChangeRenderUnitDepth(curRenderUnit, depth);

                bSort = true;
                apEditorUtil.ReleaseGUIFocus();
            }
            if (bSort)
            {
                Editor.Select.MeshGroup.SortRenderUnits(true);
            }
            Editor.RefreshControllerAndHierarchy();
            Editor.SetRepaint();
        }
Esempio n. 14
0
        /// <summary>
        /// MeshGroupTransform과 ModMesh를 연결한다.
        /// </summary>
        /// <param name="meshGroupOfMod">Modifier가 속한 MeshGroup</param>
        /// <param name="meshGroupOfTransform">Transform이 속한 MeshGroup</param>
        public void Link_MeshGroupTransform(apMeshGroup meshGroupOfMod, apMeshGroup meshGroupOfTransform, apTransform_MeshGroup meshGroupTransform, apRenderUnit renderUnit)
        {
            _meshGroupOfModifier  = meshGroupOfMod;
            _meshGroupOfTransform = meshGroupOfTransform;

            _transform_MeshGroup = meshGroupTransform;
            _renderUnit          = renderUnit;


            RefreshModifiedValues(meshGroupOfMod._parentPortrait);
        }
 public BufferData GetBufferData(apRenderUnit renderUnit)
 {
     for (int i = 0; i < _buffers.Length; i++)
     {
         if (_buffers[i]._renderUnit == renderUnit)
         {
             return(_buffers[i]);
         }
     }
     return(null);
 }
Esempio n. 16
0
        public override bool Save(object target, string strParam)
        {
            base.Save(target, strParam);

            apModifiedMesh modMesh = target as apModifiedMesh;

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

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

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

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

            _vertices.Clear();
            int nVert = modMesh._vertices.Count;

            for (int i = 0; i < nVert; i++)
            {
                apModifiedVertex modVert = modMesh._vertices[i];
                _vertices.Add(new VertData(modVert._vertex, modVert._deltaPos));
            }

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


            _isExtraValueEnabled = false;
            _extraValue          = null;

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

            return(true);
        }
Esempio n. 17
0
            public SubUnit(apRenderUnit renderUnit, int level, bool isTarget, bool isRoot)
            {
                _isRoot   = isRoot;
                _level    = level;
                _isTarget = isTarget;
                _name     = renderUnit.Name;
                _depth    = renderUnit.GetDepth();

                _isMeshTransform = (renderUnit._meshTransform != null);

                _childUnits.Clear();
            }
Esempio n. 18
0
 // Link
 //----------------------------------------------------
 public void ClearAllCalculateParams()
 {
     for (int i = 0; i < _modifiers.Count; i++)
     {
         _modifiers[i]._calculatedResultParams.Clear();
     }
     //렌더 유닛들의 Stack도 리셋한다.
     for (int i = 0; i < _parentMeshGroup._renderUnits_All.Count; i++)
     {
         apRenderUnit renderUnit = _parentMeshGroup._renderUnits_All[i];
         renderUnit._calculatedStack.ClearResultParams();
     }
 }
        // Init
        //--------------------------------------------------
        public apCalculatedResultParam(CALCULATED_VALUE_TYPE calculatedValueType,
                                       CALCULATED_SPACE calculatedSpace,
                                       apModifierBase linkedModifier,
                                       apRenderUnit targetRenderUnit,
                                       apRenderUnit ownerRenderUnit, //<<추가 10.2 : Modifier를 가지고 있었던 RenderUnit
                                       apBone targetBone
                                                                     //apModifierParamSetGroupVertWeight weightedVertData//삭제 19.5.20
                                       )
        {
            _calculatedValueType = calculatedValueType;
            _calculatedSpace     = calculatedSpace;

            _linkedModifier   = linkedModifier;
            _targetRenderUnit = targetRenderUnit;
            _ownerRenderUnit  = ownerRenderUnit;

            _targetBone = targetBone;

            //삭제 19.5.20 : _weightedVertexData 변수 삭제됨
            //_weightedVertexData = weightedVertData;

            //처리 타입이 Vertex 계열이면 Vertex List를 준비해야한다.
            if ((int)(_calculatedValueType & CALCULATED_VALUE_TYPE.VertexPos) != 0)
            {
                int nPos = 0;
                if (_targetRenderUnit._meshTransform != null && _targetRenderUnit._meshTransform._mesh != null)
                {
                    nPos = _targetRenderUnit._meshTransform._mesh._vertexData.Count;
                }

                _result_Positions = new Vector2[nPos];
                //_tmp_Positions = new List<Vector2>();
                for (int i = 0; i < nPos; i++)
                {
                    _result_Positions[i] = Vector2.zero;
                    //_tmp_Positions.Add(Vector2.zero);
                }

                //추가 : 만약 리깅타입이면 Vertex 개수만큼의 Matrix를 만들어야 한다.
                if (_linkedModifier.ModifierType == apModifierBase.MODIFIER_TYPE.Rigging)
                {
                    _result_VertMatrices = new apMatrix3x3[nPos];
                    for (int i = 0; i < nPos; i++)
                    {
                        _result_VertMatrices[i] = apMatrix3x3.zero;
                    }
                }
            }

            _debugID = UnityEngine.Random.Range(0, 10000);
        }
Esempio n. 20
0
        // Show Window / Close Dialog
        //------------------------------------------------------------------------
        public static object ShowDialog(apEditor editor,
                                        apPortrait portrait,
                                        apMeshGroup meshGroup,
                                        apModifierBase modifier,
                                        apModifiedMesh modMesh,
                                        apRenderUnit renderUnit,
                                        bool isAnimEdit,
                                        apAnimClip animClip,
                                        apAnimKeyframe keyframe)
        {
            CloseDialog();

            if (editor == null ||
                editor._portrait == null ||
                meshGroup == null ||
                modifier == null ||
                modMesh == null)
            {
                return(null);
            }



            EditorWindow         curWindow = EditorWindow.GetWindow(typeof(apDialog_ExtraOption), true, "Extra Properties", true);
            apDialog_ExtraOption curTool   = curWindow as apDialog_ExtraOption;

            object loadKey = new object();

            if (curTool != null && curTool != s_window)
            {
                int width = 400;

                int height = 620;
                if (isAnimEdit)
                {
                    height = 715;
                }
                s_window          = curTool;
                s_window.position = new Rect((editor.position.xMin + editor.position.xMax) / 2 - (width / 2),
                                             (editor.position.yMin + editor.position.yMax) / 2 - (height / 2),
                                             width, height);
                s_window.Init(editor, portrait, meshGroup, modifier, modMesh, renderUnit, isAnimEdit, animClip, keyframe);

                return(loadKey);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 21
0
        public void TransformChanged_Color__MeshGroup_Setting(Color color, bool isVisible)
        {
            if (Editor.Select.MeshGroup == null
                //|| !Editor.Select.IsMeshGroupSettingChangePivot//수정 : Pivot 변경 상태가 아니어도 변경 가능
                )
            {
                return;
            }
            if (Editor.Select.SubMeshInGroup == null && Editor.Select.SubMeshGroupInGroup == null)
            {
                return;
            }

            apRenderUnit curRenderUnit = null;
            //apMatrix curMatrixParam = null;
            object targetObj = null;

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

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

            if (curRenderUnit == null)
            {
                return;
            }



            //curRenderUnit.SetColor(color);
            Editor.RefreshControllerAndHierarchy();            //Show/Hide 아이콘 갱신 땜시
            Editor.SetRepaint();
        }
            public BufferData _parent       = null;      //상위 MeshGroup

            public BufferData(int index, apRenderUnit renderUnit)
            {
                _indexOriginal = index;
                _indexChanged  = index;
                _renderUnit    = renderUnit;
                _level         = renderUnit._level;

                _isMesh           = (renderUnit._unitType == apRenderUnit.UNIT_TYPE.Mesh);
                _isClippedChild   = false;
                _isClippingParent = false;

                if (_isMesh)
                {
                    _isClippedChild   = _renderUnit._meshTransform._isClipping_Child;
                    _isClippingParent = _renderUnit._meshTransform._isClipping_Parent;
                }
                _parent = null;
            }
        /// <summary>
        /// Extra 이벤트에 의해서 Depth를 바꿔야 하는 경우 호출
        /// </summary>
        /// <param name="renderUnit"></param>
        /// <param name="deltaDepth"></param>
        public void OnExtraDepthChanged(apRenderUnit renderUnit, int deltaDepth)
        {
            if (deltaDepth == 0)
            {
                return;
            }
            if (renderUnit._meshTransform != null && renderUnit._meshTransform._isClipping_Child)
            {
                //Clipping Child의 Depth 이동은 허용하지 않는다.
                return;
            }

            //Debug.Log("OnExtraDepthChanged [" + renderUnit.Name + " - "+ deltaDepth + "]");

            //일단 DepthChanged 이벤트가 발생했음을 알리고
            _isDepthChanged = true;
            _nDepthChangedRequest++;

            //어떤 RenderUnit의 Depth가 바뀌었는지 저장한다.
            if (_depthChangedRequests.ContainsKey(renderUnit))
            {
                //키가 있을리가 없는데..
                _depthChangedRequests[renderUnit] = deltaDepth;
            }
            else
            {
                _depthChangedRequests.Add(renderUnit, deltaDepth);
            }

            //캐시 미스 여부를 찾는다.
            if (!_depthChangedCache.ContainsKey(renderUnit))
            {
                //만약 캐시에 없는 거라면 -> 정렬을 다시 해야한다.
                _isNeedToSortDepthChangedBuffers = true;
                //Debug.LogError(">> Cache Miss (New Data)");
            }
            else if (_depthChangedCache[renderUnit] != deltaDepth)
            {
                //만약 캐시와 값이 다르다면 -> 정렬을 다시 해야한다.
                _isNeedToSortDepthChangedBuffers = true;
                //Debug.LogError(">> Cache Miss (Delta Changed)");
            }
        }
Esempio n. 24
0
        public void TransformChanged_Position__MeshGroup_Setting(Vector2 pos)
        {
            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_MoveTransform, Editor, Editor.Select.MeshGroup, targetObj, false, true);

            curMatrixParam.SetPos(pos);
            curMatrixParam.MakeMatrix();
            Editor.SetRepaint();
        }
Esempio n. 25
0
        private bool AddMeshGroupTransformToParamSet(apModifierParamSet paramSet, apTransform_MeshGroup meshGroupTransform)
        {
            //if(_parentModifier.ModifiedTargetType != apModifiedMesh.TARGET_TYPE.MeshGroupTransformOnly)
            //{
            //	return false;
            //}
            if (!_parentModifier.IsTarget_MeshGroupTransform)
            {
                return(false);
            }

            bool isExist = paramSet._meshData.Exists(delegate(apModifiedMesh a)
            {
                return(a.IsContains_MeshGroupTransform(_parentModifier._meshGroup, meshGroupTransform));
            });

            if (!isExist)
            {
                apRenderUnit targetRenderUnit = _parentModifier._meshGroup.GetRenderUnit(meshGroupTransform);
                if (targetRenderUnit != null)
                {
                    apMeshGroup parentMeshGroupOfTransform = GetParentMeshGroupOfMeshGroupTransform(meshGroupTransform);
                    if (parentMeshGroupOfTransform == null)
                    {
                        //Parent MeshGroup이 없네염
                        return(false);
                    }

                    apModifiedMesh modMesh = new apModifiedMesh();
                    modMesh.Init(_parentModifier._meshGroup._uniqueID, parentMeshGroupOfTransform._uniqueID, _parentModifier.ModifiedValueType);
                    modMesh.SetTarget_MeshGroupTransform(meshGroupTransform._transformUniqueID, meshGroupTransform._meshColor2X_Default, meshGroupTransform._isVisible_Default);

                    //modMesh.Init_MeshGroupTransform(_parentModifier._meshGroup._uniqueID,
                    //		meshGroupTransform._transformUniqueID);

                    modMesh.Link_MeshGroupTransform(_parentModifier._meshGroup, parentMeshGroupOfTransform, meshGroupTransform, targetRenderUnit);
                    paramSet._meshData.Add(modMesh);
                }
            }

            return(!isExist);
        }
        // 단축키 : 버텍스 전체 선택
        private void OnHotKeyEvent__Modifier_Physics__Ctrl_A(object paramObject)
        {
            if (Editor.Select.MeshGroup == null || Editor.Select.Modifier == null)
            {
                return;
            }


            if (Editor.Select.ModRenderVertListOfMod == null)
            {
                return;
            }

            if (Editor.Select.ExEditingMode != apSelection.EX_EDIT.None && Editor.Select.ExKey_ModMesh != null && Editor.Select.MeshGroup != null)
            {
                //선택된 RenderUnit을 고르자
                apRenderUnit targetRenderUnit = Editor.Select.MeshGroup.GetRenderUnit(Editor.Select.ExKey_ModMesh._transform_Mesh);

                if (targetRenderUnit != null)
                {
                    //모든 버텍스를 선택
                    for (int iVert = 0; iVert < targetRenderUnit._renderVerts.Count; iVert++)
                    {
                        apRenderVertex renderVert = targetRenderUnit._renderVerts[iVert];

                        apModifiedVertexWeight selectedModVertWeight = Editor.Select.ExKey_ModMesh._vertWeights.Find(delegate(apModifiedVertexWeight a)
                        {
                            return(renderVert._vertex._uniqueID == a._vertexUniqueID);
                        });
                        Editor.Select.AddModVertexOfModifier(null, null, selectedModVertWeight, renderVert);
                    }

                    Editor.Gizmos.SetSelectResultForce_Multiple <apSelection.ModRenderVert>(Editor.Select.ModRenderVertListOfMod);

                    Editor.RefreshControllerAndHierarchy(false);
                    //Editor.Repaint();
                    Editor.SetRepaint();

                    Editor.Select.AutoSelectModMeshOrModBone();
                }
            }
        }
Esempio n. 27
0
        //public void SetTarget_Bone(int boneID)
        //{
        //	_boneUniqueID = boneID;
        //}

        #region [미사용 코드] 타입에 따른 초기화는 유연성이 떨어져서 패스.
        //public void Init_VertexMorph(int meshGroupID, int meshTransformID, int meshID)
        //{
        //	_targetType = TARGET_TYPE.VertexWithMeshTransform;
        //	_meshGroupUniqueID = meshGroupID;
        //	_transformUniqueID = meshTransformID;
        //	_meshUniqueID = meshID;
        //	_boneUniqueID = -1;


        //}

        //public void Init_MeshTransform(int meshGroupID, int meshTransformID, int meshID)
        //{
        //	_targetType = TARGET_TYPE.MeshTransformOnly;
        //	_meshGroupUniqueID = meshGroupID;
        //	_transformUniqueID = meshTransformID;
        //	_meshUniqueID = meshID;
        //	_boneUniqueID = -1;
        //}

        //public void Init_MeshGroupTransform(int meshGroupID, int meshGroupTransformID)
        //{
        //	_targetType = TARGET_TYPE.MeshGroupTransformOnly;
        //	_meshGroupUniqueID = meshGroupID;
        //	_transformUniqueID = meshGroupTransformID;
        //	_meshUniqueID = -1;
        //	_boneUniqueID = -1;
        //}

        //public void Init_BoneTransform(int meshGroupID, int boneID)
        //{
        //	_targetType = TARGET_TYPE.Bone;
        //	_meshGroupUniqueID = meshGroupID;
        //	_transformUniqueID = -1;
        //	_meshUniqueID = -1;
        //	_boneUniqueID = boneID;
        //}
        #endregion


        // Init - ID에 맞게 세팅
        //--------------------------------------------------------
        //이건 날립니더
        //public void Link_VertexMorph(apMeshGroup meshGroup, apTransform_Mesh meshTransform, apRenderUnit renderUnit)
        //{
        //	_meshGroup = meshGroup;
        //	_transform_Mesh = meshTransform;
        //	_renderUnit = renderUnit;

        //	//RefreshVertices();

        //}

        /// <summary>
        /// MeshTransform과 ModMesh를 연결한다.
        /// </summary>
        /// <param name="meshGroupOfMod">Modifier가 속한 MeshGroup</param>
        ///<param name="meshGroupOfTransform">Transform이 속한 MeshGroup</param>
        public void Link_MeshTransform(apMeshGroup meshGroupOfMod, apMeshGroup meshGroupOfTransform, apTransform_Mesh meshTransform, apRenderUnit renderUnit, apPortrait portrait)
        {
            _meshGroupOfModifier  = meshGroupOfMod;
            _meshGroupOfTransform = meshGroupOfTransform;

            _transform_Mesh = meshTransform;
            _renderUnit     = renderUnit;

            if (_isUsePhysicParam)
            {
                if (_physicMeshParam == null)
                {
                    _physicMeshParam = new apPhysicsMeshParam();
                }
                _physicMeshParam.Link(portrait);
            }

            //Debug.Log("ModMesh Link RenderUnit");
            RefreshModifiedValues(meshGroupOfMod._parentPortrait);
        }
Esempio n. 28
0
        /// <summary>
        /// Link시 Parent -> Child 순서로 호출하는 초기화 함수
        /// WorldMatrix의 레퍼런스를 전달해준다.
        /// </summary>
        public void LinkRecursive(int curLevel)
        {
            ReadyToUpdate(false);
            //if(_parentBone != null)
            //{
            //	SetParentMatrix(_parentBone._worldMatrix);
            //}
            if (_parentBone != null)
            {
                _renderUnit = _parentBone._renderUnit;
            }

            _level = curLevel;


            for (int i = 0; i < _childBones.Count; i++)
            {
                _childBones[i].LinkRecursive(curLevel + 1);
            }
        }
Esempio n. 29
0
        public static bool IsMouseInRenderUnitMesh(Vector2 mousePos, apRenderUnit meshRenderUnit)
        {
            if (meshRenderUnit._meshTransform == null)
            {
                return(false);
            }

            if (meshRenderUnit._meshTransform._mesh == null || meshRenderUnit._renderVerts.Count == 0)
            {
                return(false);
            }

            apMesh targetMesh            = meshRenderUnit._meshTransform._mesh;
            List <apRenderVertex> rVerts = meshRenderUnit._renderVerts;

            Vector2 mousePosW = apGL.GL2World(mousePos);

            apRenderVertex       rVert0, rVert1, rVert2;
            List <apMeshPolygon> polygons = targetMesh._polygons;

            for (int iPoly = 0; iPoly < polygons.Count; iPoly++)
            {
                List <apMeshTri> tris = polygons[iPoly]._tris;
                for (int iTri = 0; iTri < tris.Count; iTri++)
                {
                    apMeshTri tri = tris[iTri];
                    rVert0 = rVerts[tri._verts[0]._index];
                    rVert1 = rVerts[tri._verts[1]._index];
                    rVert2 = rVerts[tri._verts[2]._index];

                    if (apMeshTri.IsPointInTri(mousePosW,
                                               rVert0._pos_World,
                                               rVert1._pos_World,
                                               rVert2._pos_World))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
        public void AddClippedChildMesh(apTransform_Mesh meshTransform, apRenderUnit renderUnit)
        {
            _isClipping_Parent = true;

            if (_clipChildMeshes.Exists(delegate(ClipMeshSet a)
            {
                return(a._meshTransform == meshTransform);
            }))
            {
                //겹친다면 Pass
                SortClipMeshTransforms();
                return;
            }

            int clippIndex = _clipChildMeshes.Count;

            _clipChildMeshes.Add(new ClipMeshSet(meshTransform, renderUnit));
            meshTransform._isClipping_Child    = true;
            meshTransform._clipIndexFromParent = clippIndex;

            #region [미사용 코드]
            //_clipChildMeshTransformIDs.Add(meshTransform._transformUniqueID);
            //_clipChildMeshTransforms.Add(meshTransform);
            //_clipChildRenderUnits.Add(renderUnit);

            //이전 코드 : 3개 고정
            //for (int i = 0; i < 3; i++)
            //{
            //	if(_clipChildMeshTransforms[i] == null)
            //	{
            //		_clipChildMeshTransforms[i] = meshTransform;
            //		_clipChildMeshTransformIDs[i] = meshTransform._transformUniqueID;
            //		_clipChildRenderUnits[i] = renderUnit;
            //		break;
            //	}
            //}
            #endregion

            SortClipMeshTransforms();
        }