private void Matrix2Floats(apMatrix3x3 srcMatrix, ref float[] targetFloats)
        {
            //이거 Row/Column 순서가 바뀔 수도 있을 것 같다.;;
            targetFloats[0] = srcMatrix._m00;
            targetFloats[1] = srcMatrix._m01;
            targetFloats[2] = srcMatrix._m02;

            targetFloats[3] = srcMatrix._m10;
            targetFloats[4] = srcMatrix._m11;
            targetFloats[5] = srcMatrix._m12;

            targetFloats[6] = srcMatrix._m20;
            targetFloats[7] = srcMatrix._m21;
            targetFloats[8] = srcMatrix._m22;

            //targetFloats[0] = srcMatrix[0, 0];
            //targetFloats[1] = srcMatrix[1, 0];
            //targetFloats[2] = srcMatrix[2, 0];
            //targetFloats[3] = srcMatrix[3, 0];

            //targetFloats[4] = srcMatrix[0, 1];
            //targetFloats[5] = srcMatrix[1, 1];
            //targetFloats[6] = srcMatrix[2, 1];
            //targetFloats[7] = srcMatrix[3, 1];

            //targetFloats[8] = srcMatrix[0, 2];
            //targetFloats[9] = srcMatrix[1, 2];
            //targetFloats[10] = srcMatrix[2, 2];
            //targetFloats[11] = srcMatrix[3, 2];

            //targetFloats[12] = srcMatrix[0, 3];
            //targetFloats[13] = srcMatrix[1, 3];
            //targetFloats[14] = srcMatrix[2, 3];
            //targetFloats[15] = srcMatrix[3, 3];
        }
示例#2
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;
        }
            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;
            }
        public void CalculateByComputeShader_New(           //Vector3 posWorld3,
            Vector2 posWorld2,
            Vector2 posLocalOnMesh,
            apMatrix3x3 mtxWorld,

            apMatrix3x3 mtxMeshWorldMatrix,
            Vector2 calLocalPos,
            Vector2 calWorldPos,
            float rigWeight,
            Vector2 rigPos)
        {
            _matrix_ToWorld = mtxWorld;

            //_pos_World3 = posWorld3;
            _pos_World = posWorld2;


            _pos_LocalOnMesh = posLocalOnMesh;


            _pos_Rigging          = rigPos;
            _weight_Rigging       = rigWeight;
            _matrix_Cal_VertLocal = apMatrix3x3.TRS(calLocalPos, 0, Vector2.one);
            _matrix_MeshTransform = mtxMeshWorldMatrix;
            _matrix_Cal_VertWorld = apMatrix3x3.TRS(calWorldPos, 0, Vector2.one);

            _isCalculated = true;
        }
示例#5
0
        //public void SetRigging_0_LocalPosWeight(Vector2 posRiggingResult, float weight)
        public void SetRigging_0_LocalPosWeight(apMatrix3x3 matrix_Rigging, float weight)
        {
            //_pos_Rigging = posRiggingResult;
            //_weight_Rigging = weight;

            _matrix_Rigging.SetMatrixWithWeight(matrix_Rigging, weight);
        }
        // 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);
        }
        // Calculate
        //---------------------------------------------------------
        public void Calculate()
        {
            //역순으로 World Matrix를 계산하자
            _matrix_ToWorld = _matrix_Cal_VertWorld
                              //* _matrix_TF_Cal_Parent
                              //* _matrix_Cal_Mesh
                              //* _matrix_TF_Mesh
                              * _matrix_MeshTransform
                              * _matrix_Cal_VertLocal
                              * _matrix_Static_Vert2Mesh;

            //_matrix_ToVert = _matrix_ToWorld.inverse;

            //이전 식
            //_vertPos3_World = _matrix_ToWorld.MultiplyPoint3x4(_pos3_Local);

            //리깅 포함한 식으로 변경
            //_weight_Rigging = Mathf.Clamp(_weight_Rigging, 0.0f, 0.5f);

            _vertPos_World = _matrix_ToWorld.MultiplyPoint(_pos_Local * (1.0f - _weight_Rigging) + _pos_Rigging * _weight_Rigging);

            //_vertPos_World.x = _vertPos3_World.x;
            //_vertPos_World.y = _vertPos3_World.y;

            Vector2 posLocalUpdated = (_matrix_Static_Vert2Mesh_Inverse).MultiplyPoint(_vertPos_World);

            _vertPos3_LocalUpdated.x = posLocalUpdated.x;
            _vertPos3_LocalUpdated.y = posLocalUpdated.y;
            _vertPos3_LocalUpdated.z = 0;

            _isCalculated = true;
        }
示例#8
0
        //TODO : 물리 관련 지연 변수 추가 필요


        // Init
        //----------------------------------------------
        public apOptRenderVertex(apOptTransform parentTransform, apOptMesh parentMesh,
                                 int vertUniqueID, int vertIndex, Vector2 vertPosLocal,
                                 Vector2 vertUV, float zDepth)
        {
            _parentTransform = parentTransform;
            _parentMesh      = parentMesh;
            _uniqueID        = vertUniqueID;
            _index           = vertIndex;
            _pos_Local       = vertPosLocal;
            _uv     = vertUV;
            _zDepth = zDepth;


            //_pos3_Local = new Vector3(_pos_Local.x, _pos_Local.y, 0);
            //_pos3_Local.x = _pos_Local.x;
            //_pos3_Local.y = _pos_Local.y;
            //_pos3_Local.z = 0;

            _vertPos3_LocalUpdated.x = _pos_Local.x;
            _vertPos3_LocalUpdated.y = _pos_Local.y;
            _vertPos3_LocalUpdated.z = 0;

            _isCalculated = false;

            //_pos_Rigging = Vector2.zero;
            //_weight_Rigging = 0.0f;
            _matrix_Rigging = apMatrix3x3.identity;

            _matrix_MeshOrthoCorrection = apMatrix3x3.identity;
            _isMeshOrthoCorrection      = false;
        }
示例#9
0
        // Functions
        //----------------------------------------------
        // 준비 + Matrix/Delta Pos 입력
        //---------------------------------------------------------
        public void ReadyToCalculate()
        {
            _matrix_Static_Vert2Mesh         = apMatrix3x3.identity;
            _matrix_Static_Vert2Mesh_Inverse = apMatrix3x3.identity;

            _matrix_Cal_VertLocal = apMatrix3x3.identity;
            _matrix_MeshTransform = apMatrix3x3.identity;

            _matrix_Cal_VertWorld = apMatrix3x3.identity;
            _matrix_ToWorld       = apMatrix3x3.identity;
            //_matrix_ToVert = apMatrix3x3.identity;
            _vertPos_World = Vector2.zero;

            //_cal_VertWorld = Vector2.zero;

            _vertPos3_LocalUpdated.x = _pos_Local.x;
            _vertPos3_LocalUpdated.y = _pos_Local.y;
            _vertPos3_LocalUpdated.z = 0;

            //_pos_Rigging = Vector2.zero;
            //_weight_Rigging = 0.0f;

            _matrix_Rigging        = apMatrix3x3.identity;
            _isMeshOrthoCorrection = false;            //<<추가
        }
示例#10
0
        // Scale
        public void Scale__MeshTRS(Vector2 deltaScaleW, bool isFirstScale)
        {
            if (Editor.Select.SelectionType != apSelection.SELECTION_TYPE.Mesh ||
                Editor.Select.Mesh == null ||
                Editor.Select.Mesh.LinkedTextureData == null ||
                Editor.Select.Mesh.LinkedTextureData._image == null ||
                Editor._meshEditMode != apEditor.MESH_EDIT_MODE.MakeMesh ||
                Editor._meshEditeMode_MakeMesh != apEditor.MESH_EDIT_MODE_MAKEMESH.TRS)
            {
                return;
            }

            apMesh mesh = Editor.Select.Mesh;
            //Vector2 imageHalfOffset = new Vector2(mesh.LinkedTextureData._width * 0.5f, mesh.LinkedTextureData._height * 0.5f);
            List <apVertex> vertices         = mesh._vertexData;
            List <apVertex> selectedVertices = Editor.VertController.Vertices;

            if (vertices.Count == 0 || selectedVertices.Count == 0)
            {
                return;
            }

            if (isFirstScale)
            {
                apEditorUtil.SetRecord_Mesh(apUndoGroupData.ACTION.MeshEdit_EditVertex, Editor, mesh, mesh, true);
            }

            apVertex curVert   = null;
            Vector2  centerPos = Vector2.zero;

            for (int i = 0; i < selectedVertices.Count; i++)
            {
                curVert    = selectedVertices[i];
                centerPos += curVert._pos - mesh._offsetPos;
            }
            centerPos /= selectedVertices.Count;

            Vector2 scale = new Vector2(1.0f + deltaScaleW.x, 1.0f + deltaScaleW.y);

            apMatrix3x3 matrix_Rotate = apMatrix3x3.TRS(centerPos, 0, Vector2.one)
                                        * apMatrix3x3.TRS(Vector2.zero, 0.0f, scale)
                                        * apMatrix3x3.TRS(-centerPos, 0, Vector2.one);

            Vector2 posW = Vector2.zero;

            for (int i = 0; i < selectedVertices.Count; i++)
            {
                curVert      = selectedVertices[i];
                posW         = curVert._pos - (mesh._offsetPos);
                posW         = matrix_Rotate.MultiplyPoint(posW);
                curVert._pos = posW + (mesh._offsetPos);
            }

            for (int i = 0; i < selectedVertices.Count; i++)
            {
                mesh.RefreshVertexAutoUV(selectedVertices[i]);
            }

            Editor.SetRepaint();
        }
示例#11
0
 public void SetMatrix3x3(apMatrix3x3 matrix4x4, CalculateType calculateType, bool isWeighted, float weight)
 {
     _valueType     = UnitValueType.Matrix3x3;
     _val_Matrix3x3 = matrix4x4;
     _calculateType = calculateType;
     _isWeighted    = isWeighted;
     _weight        = weight;
 }
        /// <summary>
        /// Modifier가 적용되지 않은 World Position을 직접 계산한다.
        /// _pos_World_NoMod로 저장된다.
        /// </summary>
        /// <param name="matrix_Vert2Local"></param>
        /// <param name="matrix_meshTransformNoMod"></param>
        public void CalculateNotModified(apMatrix3x3 matrix_Vert2Local, apMatrix3x3 matrix_meshTransformNoMod)
        {
            apMatrix3x3 matrix_ToWorld = matrix_meshTransformNoMod * matrix_Vert2Local;
            Vector2     posW           = matrix_ToWorld.MultiplyPoint(_vertex._pos);

            _pos_World_NoMod = posW;
            //_pos_World_NoMod.x = posW.x;
            //_pos_World_NoMod.y = posW.y;
        }
示例#13
0
        public void Scale__MeshAutoGen(Vector2 deltaScaleW, bool isFirstScale)
        {
            if (Editor.Select.SelectionType != apSelection.SELECTION_TYPE.Mesh ||
                Editor.Select.Mesh == null ||
                Editor.Select.Mesh.LinkedTextureData == null ||
                Editor.Select.Mesh.LinkedTextureData._image == null ||
                Editor._meshEditMode != apEditor.MESH_EDIT_MODE.MakeMesh ||
                Editor._meshEditeMode_MakeMesh != apEditor.MESH_EDIT_MODE_MAKEMESH.AutoGenerate ||
                !Editor.MeshGenerator.IsScanned)
            {
                return;
            }

            apMesh  mesh            = Editor.Select.Mesh;
            Vector2 imageHalfOffset = new Vector2(mesh.LinkedTextureData._width * 0.5f, mesh.LinkedTextureData._height * 0.5f);

            //List<apMeshGenMapper.ControlPoint> controlPoints = Editor.MeshGenerator.Mapper.ControlPoints;
            List <apMeshGenMapper.ControlPoint> selectedControlPoints = Editor.MeshGenerator._selectedControlPoints;

            if (selectedControlPoints.Count <= 1)
            {
                return;
            }

            apMeshGenMapper.ControlPoint curPoint = null;

            Vector2 posW      = Vector2.zero;
            Vector2 centerPos = Vector2.zero;

            for (int i = 0; i < selectedControlPoints.Count; i++)
            {
                curPoint   = selectedControlPoints[i];
                posW       = curPoint._pos_Cur - (mesh._offsetPos + imageHalfOffset);
                centerPos += posW;
            }
            centerPos /= selectedControlPoints.Count;

            Vector2 scale = new Vector2(1.0f + deltaScaleW.x, 1.0f + deltaScaleW.y);

            apMatrix3x3 matrix_Scale = apMatrix3x3.TRS(centerPos, 0, Vector2.one)
                                       * apMatrix3x3.TRS(Vector2.zero, 0, scale)
                                       * apMatrix3x3.TRS(-centerPos, 0, Vector2.one);


            for (int i = 0; i < selectedControlPoints.Count; i++)
            {
                curPoint          = selectedControlPoints[i];
                posW              = curPoint._pos_Cur - (mesh._offsetPos + imageHalfOffset);
                posW              = matrix_Scale.MultiplyPoint(posW);
                curPoint._pos_Cur = posW + (mesh._offsetPos + imageHalfOffset);
            }

            Editor.SetRepaint();
        }
        public void Calculate(float tDelta)        //<<tDelta가 추가되었다.
        {
            #region [미사용 코드] 해시코드 체크 부분을 없앴다. 퍼포먼스 잘나온다 =3=b
            //if (_isMatrixChanged)
            //{
            //	//테스트
            //	//상대값이 아니라 절대값을 World로 사용하자
            //	//_matrix_ToWorld = _matrix_MeshTransform * _matrix_Cal_VertLocal * _matrix_Static_Vert2Mesh;
            //	//_pos_World3 = _matrix_ToWorld.MultiplyPoint3x4(Vector3.zero);
            //	//_pos_World3 = _matrix_ToWorld.MultiplyPoint3x4(_vertex._pos);

            //	//역순으로 World Matrix를 계산하자
            //	_matrix_ToWorld = _matrix_Cal_VertWorld
            //					//* _matrix_TF_Cal_Parent
            //					//* _matrix_Cal_Mesh
            //					//* _matrix_TF_Mesh
            //					* _matrix_MeshTransform
            //					* _matrix_Cal_VertLocal
            //					* _matrix_Static_Vert2Mesh;

            //	//_matrix_ToVert = _matrix_ToWorld.inverse;


            //}
            #endregion


            //역순으로 World Matrix를 계산하자
            //1. 기존 식
            //(Vert -> Rigging : ITP) -> (V2Mesh -> Local Morph -> Mesh TF -> World Morph : WorldMTX) 방식
            //_matrix_ToWorld = _matrix_Cal_VertWorld
            //				* _matrix_MeshTransform
            //				* _matrix_Cal_VertLocal
            //				* _matrix_Static_Vert2Mesh;

            //_pos_World = _matrix_ToWorld.MultiplyPoint(_vertex._pos * (1.0f - _weight_Rigging) + _pos_Rigging * _weight_Rigging);

            //2. 변경된 식
            //Vert -> (V2Mesh -> Local Morph -> RiggingMTX -> MeshTF -> World Morph : WorldMTX) 방식
            _matrix_ToWorld = _matrix_Cal_VertWorld
                              * _matrix_MeshTransform
                              * _matrix_Rigging                          //<<이게 추가
                              * _matrix_Cal_VertLocal
                              * _matrix_Static_Vert2Mesh;

            _pos_World = _matrix_ToWorld.MultiplyPoint(_vertex._pos);


            //World -> Local
            _pos_LocalOnMesh = (_matrix_MeshTransform.inverse).MultiplyPoint(_pos_World);


            _isCalculated = true;
        }
示例#15
0
        public void DrawMeshEdgeOnly(apMesh mesh, apMatrix3x3 matrix)
        {
            try
            {
                //0. 메시, 텍스쳐가 없을 때
                //if (mesh == null || mesh._textureData == null || mesh._textureData._image == null)//이전 코드
                if (mesh == null || mesh.LinkedTextureData == null || mesh.LinkedTextureData._image == null)                //변경 코드
                {
                    return;
                }

                //1. 모든 메시를 보여줄때 (또는 클리핑된 메시가 없을 때) =>
                Color meshEdgeColor       = new Color(1.0f, 0.5f, 0.0f, 0.9f);
                Color meshHiddenEdgeColor = new Color(1.0f, 1.0f, 0.0f, 0.7f);

                matrix *= mesh.Matrix_VertToLocal;


                Vector2 pos0 = Vector2.zero, pos1 = Vector2.zero;
                if (mesh._edges.Count > 0)
                {
                    _matBatch.SetPass_Color();
                    _matBatch.SetClippingSize(_glScreenClippingSize);
                    GL.Begin(GL.LINES);
                    for (int i = 0; i < mesh._edges.Count; i++)
                    {
                        pos0 = matrix.MultiplyPoint(mesh._edges[i]._vert1._pos);
                        pos1 = matrix.MultiplyPoint(mesh._edges[i]._vert2._pos);

                        DrawLine(pos0, pos1, meshEdgeColor, false);
                    }

                    for (int iPoly = 0; iPoly < mesh._polygons.Count; iPoly++)
                    {
                        for (int iHE = 0; iHE < mesh._polygons[iPoly]._hidddenEdges.Count; iHE++)
                        {
                            apMeshEdge hiddenEdge = mesh._polygons[iPoly]._hidddenEdges[iHE];

                            pos0 = matrix.MultiplyPoint(hiddenEdge._vert1._pos);
                            pos1 = matrix.MultiplyPoint(hiddenEdge._vert2._pos);

                            DrawLine(pos0, pos1, meshHiddenEdgeColor, false);
                        }
                    }

                    GL.End();
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }
        }
示例#16
0
        public void Calculate(float tDelta)        //<<tDelta가 추가되었다.
        {
            #region [미사용 코드] 해시코드 체크 부분을 없앴다. 퍼포먼스 잘나온다 =3=b
            //if (_isMatrixChanged)
            //{
            //	//테스트
            //	//상대값이 아니라 절대값을 World로 사용하자
            //	//_matrix_ToWorld = _matrix_MeshTransform * _matrix_Cal_VertLocal * _matrix_Static_Vert2Mesh;
            //	//_pos_World3 = _matrix_ToWorld.MultiplyPoint3x4(Vector3.zero);
            //	//_pos_World3 = _matrix_ToWorld.MultiplyPoint3x4(_vertex._pos);

            //	//역순으로 World Matrix를 계산하자
            //	_matrix_ToWorld = _matrix_Cal_VertWorld
            //					//* _matrix_TF_Cal_Parent
            //					//* _matrix_Cal_Mesh
            //					//* _matrix_TF_Mesh
            //					* _matrix_MeshTransform
            //					* _matrix_Cal_VertLocal
            //					* _matrix_Static_Vert2Mesh;

            //	//_matrix_ToVert = _matrix_ToWorld.inverse;


            //}
            #endregion


            //역순으로 World Matrix를 계산하자
            _matrix_ToWorld = _matrix_Cal_VertWorld
                              * _matrix_MeshTransform
                              * _matrix_Cal_VertLocal
                              * _matrix_Static_Vert2Mesh;



            //_pos_World3 = _matrix_ToWorld.MultiplyPoint3x4(_vertex._pos * (1.0f - _weight_Rigging) + _pos_Rigging * _weight_Rigging);

            //_pos_World.x = _pos_World3.x;
            //_pos_World.y = _pos_World3.y;

            _pos_World = _matrix_ToWorld.MultiplyPoint(_vertex._pos * (1.0f - _weight_Rigging) + _pos_Rigging * _weight_Rigging);

            _pos_LocalOnMesh = (_matrix_MeshTransform.inverse).MultiplyPoint(_pos_World);
            //_pos_LocalOnMesh.z = 0;


            _isCalculated = true;

            //_isUpdateMatrixForce = false;
            //_isMatrixChanged = false;
        }
示例#17
0
        // Functions
        //------------------------------------
        //해시코드 계열 계산 중복 처리를 제외한다.
        //퍼포먼스가 잘 나와서 그냥 해도 되겠다.
        //public void ResetMatrixHashCode()
        //{
        //	_matrixHashCode_Static_Vert2Mesh = -1;
        //	_matrixHashCode_Calculate = -1;

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

        public void ResetData()
        {
            _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;

            _pos_Rigging    = Vector2.zero;
            _weight_Rigging = 0.0f;

            _renderWeightByTool = 0.0f;
            _renderColorByTool  = Color.gray;
        }
示例#18
0
        //스텝별로 하나씩 세팅하자
        //public void SetMatrix_1_Static_Vert2Mesh(apMatrix3x3 matrix_Vert2Local, int hashCode)
        public void SetMatrix_1_Static_Vert2Mesh(apMatrix3x3 matrix_Vert2Local)
        {
            _matrix_Static_Vert2Mesh = matrix_Vert2Local;

            //해시코드 비교후 업데이트를 한다.
            //if(_matrixHashCode_Static_Vert2Mesh != hashCode || _isUpdateMatrixForce)
            //{
            //	_matrix_Static_Vert2Mesh = matrix_Vert2Local;
            //	_matrixHashCode_Static_Vert2Mesh = hashCode;
            //	_isMatrixChanged = true;
            //}



            //_isStaticRefreshed = true;
        }
示例#19
0
        public apLinkedMatrix SetMatrix3x3(apMatrix3x3 matrix4x4, CALCULATE_TYPE calculateType, float lerpIfInterpolation = 1.0f)
        {
            _valueType     = VALUE_TYPE.Matrix3x3;
            _matrix4x4     = matrix4x4;
            _calculateType = calculateType;
            if (_calculateType == CALCULATE_TYPE.Interpolation)
            {
                _lerp = lerpIfInterpolation;
            }

            _weight   = 1.0f;
            _isWeight = false;

            _weightCalAdded   = 1.0f;
            _isWeightCalAdded = false;

            return(this);
        }
        public void CalculateByComputeShader(Vector2 posWorld2, Vector2 posLocalOnMesh, apMatrix3x3 mtxWorld)
        {
            _matrix_ToWorld = mtxWorld;

            //_pos_World3 = posWorld3;
            _pos_World = posWorld2;


            _pos_LocalOnMesh = posLocalOnMesh;

            _isCalculated = true;

            //_isUpdateMatrixForce = false;
            //_isMatrixChanged = false;

            //if(_cal_VertWorld.magnitude > 0.5f && _vertex._index == 4)
            //{
            //	Debug.Log("Editor Cal World : " + _cal_VertWorld + " >> VertWorld : " + _pos_World + " >> Mesh Transform : \r\n" + _matrix_MeshTransform.ToString());
            //}
        }
示例#21
0
        public void Clear()
        {
            _isMeshTransformCalculated = false;
            _meshTransformMatrix       = apMatrix3x3.identity;

            //Mesh의 Visible 변경 정보가 있는가
            _isMeshVisibleCalculated = false;
            _isMeshVisible           = true;  //키애니메이션/컨트롤러에 따라 Visible 여부가 결정된다.

            //Mesh의 Color 정보가 있다
            _isColorCalculated = false;
            _color2X           = Color.black;  //칼라도 결정된다.

            //Vert -> Mesh Space
            _isVertLocalMatrixCalculated = false;
            //_localMatrixPerVertex.Clear();

            //Mesh Space -> WorldSpace (이건 MeshTransfrom 이후)
            _isVertWorldMatrixCalculated = false;
            //_worldMatrixPerVertex.Clear();
        }
示例#22
0
        //12.7 추가
        //Depth가 바뀔때, 그 프레임에서 다시 빌보드를 계산할 필요가 있다.
        public void CorrectBillboardMatrix()
        {
            if (_portrait._billboardType != apPortrait.BILLBOARD_TYPE.None && _childMesh != null)
            {
                Camera curCamera = _portrait.GetCamera();
                if (curCamera != null && !curCamera.orthographic)
                {
                    //Perspective 카메라라면

                    Vector3 pos_Cam = curCamera.worldToCameraMatrix.MultiplyPoint3x4(_childMesh.transform.position);
                    //Vector3 pos_Cam = (curCamera.worldToCameraMatrix * transform.localToWorldMatrix).MultiplyPoint3x4(new Vector3(_matrix_TFResult_World._pos.x, _matrix_TFResult_World._pos.y, 0));
                    float zDepth = pos_Cam.z;
                    float zRatio = zDepth / _portrait.GetZDepth();


                    //Debug.Log("pos_Cam : " + pos_Cam + " / " + zRatio);
                    //transform.tr//>>TODO
                    _isCamOrthoCorrection = true;

                    Matrix4x4 orthoConvertMatrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(zRatio, zRatio, 1));
                    _convert2TargetMatrix4x4 = _childMesh.transform.worldToLocalMatrix * curCamera.cameraToWorldMatrix * orthoConvertMatrix * curCamera.worldToCameraMatrix * _childMesh.transform.localToWorldMatrix;

                    _convert2TargetMatrix3x3      = apMatrix3x3.identity;
                    _convert2TargetMatrix3x3._m00 = _convert2TargetMatrix4x4.m00;
                    _convert2TargetMatrix3x3._m01 = _convert2TargetMatrix4x4.m01;
                    _convert2TargetMatrix3x3._m02 = _convert2TargetMatrix4x4.m03;

                    _convert2TargetMatrix3x3._m10 = _convert2TargetMatrix4x4.m10;
                    _convert2TargetMatrix3x3._m11 = _convert2TargetMatrix4x4.m11;
                    _convert2TargetMatrix3x3._m12 = _convert2TargetMatrix4x4.m13;

                    _convert2TargetMatrix3x3._m20 = _convert2TargetMatrix4x4.m30;
                    _convert2TargetMatrix3x3._m21 = _convert2TargetMatrix4x4.m31;
                    _convert2TargetMatrix3x3._m22 = _convert2TargetMatrix4x4.m23;

                    //Debug.Log("_convert2TargetMatrix4x4 : \n " + _convert2TargetMatrix4x4.ToString() + "\n" + "_convert2TargetMatrix3x3 : \n " + _convert2TargetMatrix3x3.ToString());
                }
            }
        }
示例#23
0
        public void ReadyToUpdate()
        {
            _isMeshTransformCalculated = false;
            _meshTransformMatrix       = apMatrix3x3.identity;

            _isMeshVisibleCalculated = false;
            _isMeshVisible           = true;  //키애니메이션/컨트롤러에 따라 Visible 여부가 결정된다.

            _isColorCalculated = false;
            _color2X           = Color.black;  //칼라도 결정된다.

            //Vert -> Mesh Space
            _isVertLocalMatrixCalculated = false;

            //Mesh Space -> WorldSpace (이건 MeshTransfrom 이후)
            _isVertWorldMatrixCalculated = false;

            for (int i = 0; i < _mesh._vertexData.Count; i++)
            {
                _localMatrixPerVertex[_mesh._vertexData[i]] = apMatrix3x3.identity;
                _worldMatrixPerVertex[_mesh._vertexData[i]] = apMatrix3x3.identity;
            }
        }
示例#24
0
        public static bool IsMouseInMesh(Vector2 mousePos, apMesh targetMesh, apMatrix3x3 matrixWorldToMeshLocal)
        {
            Vector2 mousePosW = apGL.GL2World(mousePos);

            Vector2 mousePosL = matrixWorldToMeshLocal.MultiplyPoint(mousePosW);

            //Vector2 mousePosL = mousePosW + targetMesh._offsetPos;//<<이걸 추가해줘야 Local Pos가 된다.

            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];
                    if (tri.IsPointInTri(mousePosL))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
 //스텝별로 하나씩 세팅하자
 //public void SetMatrix_1_Static_Vert2Mesh(apMatrix3x3 matrix_Vert2Local, int hashCode)
 public void SetMatrix_1_Static_Vert2Mesh(apMatrix3x3 matrix_Vert2Local)
 {
     _matrix_Static_Vert2Mesh = matrix_Vert2Local;
 }
示例#26
0
 public void Clear()
 {
     //_matrixUnit.Clear();
     _resultMatrix = apMatrix3x3.identity;
 }
 public void SetMatrix_1_Static_Vert2Mesh(apMatrix3x3 matrix_Vert2Local)
 {
     _matrix_Static_Vert2Mesh         = matrix_Vert2Local;
     _matrix_Static_Vert2Mesh_Inverse = _matrix_Static_Vert2Mesh.inverse;
 }
 public void SetMatrix_2_Calculate_VertLocal(Vector2 deltaPos)
 {
     _matrix_Cal_VertLocal = apMatrix3x3.TRS(deltaPos, 0, Vector2.one);
 }
 public void SetMatrix_4_Calculate_VertWorld(Vector2 deltaPos)
 {
     _matrix_Cal_VertWorld = apMatrix3x3.TRS(deltaPos, 0, Vector2.one);
     //_cal_VertWorld = deltaPos;
 }
 public void SetMatrix_3_Transform_Mesh(apMatrix3x3 matrix_meshTransform)
 {
     _matrix_MeshTransform = matrix_meshTransform;
 }