예제 #1
0
 // Functions
 //-------------------------------------------
 /// <summary>
 /// 해당 Preset을 "그대로 사용 중"인지 "일부 변경했는지" 체크
 /// </summary>
 /// <param name="srcMeshParam"></param>
 /// <returns></returns>
 public bool IsSameProperties(apPhysicsMeshParam srcMeshParam)
 {
     if (srcMeshParam == null)
     {
         return(false);
     }
     //TODO
     if (
         //!IsSameFloat(_stretchRange_Min, srcMeshParam._stretchRangeRatio_Min)
         !IsSameFloat(_stretchRange_Max, srcMeshParam._stretchRangeRatio_Max) ||
         !IsSameFloat(_moveRange, srcMeshParam._moveRange) ||
         !IsSameFloat(_stretchK, srcMeshParam._stretchK) ||
         !IsSameFloat(_inertiaK, srcMeshParam._inertiaK) ||
         !IsSameFloat(_damping, srcMeshParam._damping) ||
         !IsSameFloat(_mass, srcMeshParam._mass) ||
         (_gravityParamType != srcMeshParam._gravityParamType) ||
         !IsSameVector2(_gravityConstValue, srcMeshParam._gravityConstValue) ||
         (_windParamType != srcMeshParam._windParamType) ||
         !IsSameVector2(_windConstValue, srcMeshParam._windConstValue) ||
         !IsSameVector2(_windRandomRange, srcMeshParam._windRandomRange) ||
         !IsSameFloat(_airDrag, srcMeshParam._airDrag) ||
         !IsSameFloat(_viscosity, srcMeshParam._viscosity) ||
         !IsSameFloat(_restoring, srcMeshParam._restoring) ||
         _isRestrictMoveRange != srcMeshParam._isRestrictMoveRange ||
         _isRestrictStretchRange != srcMeshParam._isRestrictStretchRange
         )
     {
         //하나라도 다르면 false
         return(false);
     }
     return(true);
 }
예제 #2
0
        public void SetPhysicsMeshParam(apPhysicsMeshParam srcMeshParam)
        {
            _isRestrictStretchRange = srcMeshParam._isRestrictStretchRange;
            _isRestrictMoveRange    = srcMeshParam._isRestrictMoveRange;

            _moveRange = srcMeshParam._moveRange;
            //_stretchRange_Min = srcMeshParam._stretchRangeRatio_Min;
            _stretchRange_Max = srcMeshParam._stretchRangeRatio_Max;
            _stretchK         = srcMeshParam._stretchK;
            _inertiaK         = srcMeshParam._inertiaK;
            _damping          = srcMeshParam._damping;
            _mass             = srcMeshParam._mass;

            //Gravity와 Wind는 Constant로 저장된다.
            //ControlParam인 경우는 ID를 제외하고 저장 (ID는 저장하지 않는다. 링크는 직접 해야함)
            _gravityParamType  = srcMeshParam._gravityParamType;
            _gravityConstValue = srcMeshParam._gravityConstValue;
            _windParamType     = srcMeshParam._windParamType;
            _windConstValue    = srcMeshParam._windConstValue;
            _windRandomRange   = srcMeshParam._windRandomRange;

            _airDrag   = srcMeshParam._airDrag;
            _viscosity = srcMeshParam._viscosity;
            _restoring = srcMeshParam._restoring;
        }
예제 #3
0
        public void Bake(apPhysicsMeshParam srcPhysicsParam)
        {
            _isRestrictMoveRange    = srcPhysicsParam._isRestrictMoveRange;
            _isRestrictStretchRange = srcPhysicsParam._isRestrictStretchRange;

            _stretchRangeRatio_Max = srcPhysicsParam._stretchRangeRatio_Max;            //<<MinMax+ MoveRange

            _moveRange = srcPhysicsParam._moveRange;

            _stretchK = srcPhysicsParam._stretchK;

            _inertiaK = srcPhysicsParam._inertiaK;
            _damping  = srcPhysicsParam._damping;


            _mass = srcPhysicsParam._mass;

            switch (srcPhysicsParam._gravityParamType)
            {
            case apPhysicsMeshParam.ExternalParamType.Constant:
                _gravityParamType = ExternalParamType.Constant;
                break;

            case apPhysicsMeshParam.ExternalParamType.ControlParam:
                _gravityParamType = ExternalParamType.ControlParam;
                break;
            }
            //_optPhysicScale = physicScale;
            _gravityConstValue = srcPhysicsParam._gravityConstValue;

            _gravityControlParamID = srcPhysicsParam._gravityControlParamID;
            _gravityControlParam   = null;

            switch (srcPhysicsParam._windParamType)
            {
            case apPhysicsMeshParam.ExternalParamType.Constant:
                _windParamType = ExternalParamType.Constant;
                break;

            case apPhysicsMeshParam.ExternalParamType.ControlParam:
                _windParamType = ExternalParamType.ControlParam;
                break;
            }

            _windConstValue     = srcPhysicsParam._windConstValue;
            _windControlParamID = srcPhysicsParam._windControlParamID;

            _windControlParam = null;            //<<Link해야한다.

            _windRandomRange   = srcPhysicsParam._windRandomRange;
            _airDrag           = srcPhysicsParam._airDrag;
            _windRandItp       = Vector2.zero;
            _windRandItpLength = new Vector2(2.7f, 3.1f);

            _viscosity = srcPhysicsParam._viscosity;
            _restoring = srcPhysicsParam._restoring;
        }
예제 #4
0
        public void Bake_Physics(apPhysicsMeshParam srcPhysicParam, List <apModifiedVertexWeight> modVertWeights, apPortrait portrait)
        {
            _dataType |= DATA_TYPE.Physics;

            _subModMesh_Physics    = new apOptModifiedMesh_Physics[1];
            _subModMesh_Physics[0] = new apOptModifiedMesh_Physics();
            apOptModifiedMesh_Physics subMod_Physics = _subModMesh_Physics[0];

            subMod_Physics.Bake(srcPhysicParam, modVertWeights, portrait);
        }
        // Init - Bake
        //--------------------------------------------
        public void Bake(apPhysicsMeshParam srcPhysicParam, List <apModifiedVertexWeight> modVertWeights, apPortrait portrait)
        {
            _nVertWeights = modVertWeights.Count;
            _vertWeights  = new apOptModifiedPhysicsVertex[_nVertWeights];

            _physicMeshParam = new apOptPhysicsMeshParam();
            _physicMeshParam.Bake(srcPhysicParam);
            _physicMeshParam.Link(portrait);

            for (int i = 0; i < _nVertWeights; i++)
            {
                apOptModifiedPhysicsVertex optModPhysicVert = new apOptModifiedPhysicsVertex();
                apModifiedVertexWeight     srcModVertWeight = modVertWeights[i];
                optModPhysicVert.Bake(srcModVertWeight);

                _vertWeights[i] = optModPhysicVert;
            }
        }
예제 #6
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);
        }
예제 #7
0
        public bool AddNewPreset(apPhysicsMeshParam srcMeshParam, string name, apPhysicsPresetUnit.ICON icon)
        {
            int newID = GetNewCustomID();

            if (newID < 0)
            {
                return(false);
            }

            if (string.IsNullOrEmpty(name))
            {
                name = "<No Name>";
            }
            apPhysicsPresetUnit newUnit = new apPhysicsPresetUnit(newID, name, icon);

            newUnit.SetPhysicsMeshParam(srcMeshParam);

            _units.Add(newUnit);

            Save();
            return(true);
        }