public apLinkedMatrix SetMatrixWrap(apMatrix matrixWrap, CALCULATE_TYPE calculateType, float lerpIfInterpolation = 1.0f) { _valueType = VALUE_TYPE.MatrixWrap; if (_matrixWrap == null) { _matrixWrap = new apMatrix(matrixWrap); } else { _matrixWrap.SetMatrix(matrixWrap); } _calculateType = calculateType; if (_calculateType == CALCULATE_TYPE.Interpolation) { _lerp = lerpIfInterpolation; } _weight = 1.0f; _isWeight = false; _weightCalAdded = 1.0f; _isWeightCalAdded = false; return(this); }
public bool Bake(apModifiedBone srcModBone, apPortrait portrait) { _portrait = portrait; _meshGroupID_Bone = srcModBone._meshGropuUniqueID_Bone; apOptTransform meshGroupTransform = portrait.GetOptTransformAsMeshGroup(_meshGroupID_Bone); if (meshGroupTransform == null) { Debug.LogError("[ModBone] Bake 실패 : 찾을 수 없는 OptTransform [" + _meshGroupID_Bone + "]"); return(false); } _transformUniqueID = meshGroupTransform._transformID; _meshGroup_Bone = meshGroupTransform; _boneID = srcModBone._boneID; _bone = meshGroupTransform.GetBone(_boneID); if (_bone == null) { Debug.LogError("[ModBone] Bake 실패 : 찾을 수 없는 Bone [" + _boneID + "]"); return(false); } _transformMatrix = new apMatrix(srcModBone._transformMatrix); return(true); }
public void Scale__MeshGroup_Setting(Vector2 deltaScaleW, bool isFirstScale) { if (Editor.Select.MeshGroup == null || !Editor.Select.IsMeshGroupSettingChangePivot) { return; } if (deltaScaleW.sqrMagnitude == 0.0f && !isFirstScale) { return; } apMatrix targetMatrix = null; object targetObj = null; apMatrix worldMatrix = null; apMatrix parentWorldMatrix = null; //Modifier가 적용이 안된 상태이므로 //World Matrix = ParentWorld x ToParent(Default) 가 성립한다. bool isRootMeshGroup = false; 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; isRootMeshGroup = Editor.Select.MeshGroup._childMeshTransforms.Contains(Editor.Select.SubMeshInGroup); } 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; isRootMeshGroup = false; } else { return; } worldMatrix._scale += deltaScaleW; worldMatrix.MakeMatrix(); worldMatrix.RInverse(parentWorldMatrix); //ParentWorld-1 x World = ToParent //Undo if (isFirstScale) { apEditorUtil.SetRecord_MeshGroup(apUndoGroupData.ACTION.MeshGroup_Gizmo_ScaleTransform, Editor, Editor.Select.MeshGroup, targetObj, false, !isRootMeshGroup); } //Vector2 scale2 = new Vector2(targetMatrix._scale.x, targetMatrix._scale.y); //targetMatrix.SetScale(deltaScaleW + scale2); targetMatrix.SetScale(worldMatrix._scale); targetMatrix.MakeMatrix(); }
/// <summary> /// Parent의 Matrix를 추가한다. (Parent x This) /// </summary> /// <param name="matrix_parentTransform"></param> //public void AddWorldMatrix_Parent(apMatrix3x3 matrix_parentTransform) public void AddWorldMatrix_Parent(apMatrix matrix_parentTransform) { //_matrix_TF_Cal_Parent = matrix_parentTransform.MtrxToSpace * _matrix_TF_Cal_Parent; ////_calculateTmpMatrix.SRMultiply(matrix_parentTransform, true); ////_matrix_TF_Cal_ToWorld = _calculateTmpMatrix.MtrxToSpace; _matrix_TF_ParentWorld.SetMatrix(matrix_parentTransform); }
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(); }
public void SetModifiedTransform(apMatrix matrix_modified) { ////_calculateTmpMatrix_Local.SRMultiply(matrix_modified, true);//Parent //_calculateTmpMatrix_Local.SRMultiply(matrix_modified, false);//Child //_matrix_TF_Cal_Local = _calculateTmpMatrix_Local.MtrxToSpace; _matrix_TF_LocalModified.SetMatrix(matrix_modified); }
// Functions //--------------------------------------------------------- // Keyframe -> File public void SetAnimKeyframe(int unitID, apAnimKeyframe animKeyframe) { _unitID = unitID; _keyframeUniqueID = animKeyframe._uniqueID; _linkedKeyframe = animKeyframe; _frameIndex = animKeyframe._frameIndex; _isKeyValueSet = animKeyframe._isKeyValueSet; _isActive = animKeyframe._isActive; _isLoopAsStart = animKeyframe._isLoopAsStart; _isLoopAsEnd = animKeyframe._isLoopAsEnd; _loopFrameIndex = animKeyframe._loopFrameIndex; _activeFrameIndexMin = animKeyframe._activeFrameIndexMin; _activeFrameIndexMax = animKeyframe._activeFrameIndexMax; _activeFrameIndexMin_Dummy = animKeyframe._activeFrameIndexMin_Dummy; _activeFrameIndexMax_Dummy = animKeyframe._activeFrameIndexMax_Dummy; //Curve 정보 _curve_PrevTangentType = animKeyframe._curveKey._prevTangentType; _curve_PrevSmoothX = animKeyframe._curveKey._prevSmoothX; _curve_PrevSmoothY = animKeyframe._curveKey._prevSmoothY; _curve_NextTangentType = animKeyframe._curveKey._nextTangentType; _curve_NextSmoothX = animKeyframe._curveKey._nextSmoothX; _curve_NextSmoothY = animKeyframe._curveKey._nextSmoothY; //Control Param 타입이면 //Control Param의 어떤 값에 동기화되는가 _conSyncValue_Int = animKeyframe._conSyncValue_Int; _conSyncValue_Float = animKeyframe._conSyncValue_Float; _conSyncValue_Vector2 = animKeyframe._conSyncValue_Vector2; //Modifier Mesh 타입일때 _isModMeshType = animKeyframe._linkedModMesh_Editor != null; _isModBoneType = animKeyframe._linkedModBone_Editor != null; //>> Transform만 저장한다. _modTransformMatrix = new apMatrix(); _modMeshColor = Color.black; _modVisible = true; if (_isModMeshType) { _modTransformMatrix.SetMatrix(animKeyframe._linkedModMesh_Editor._transformMatrix); _modMeshColor = animKeyframe._linkedModMesh_Editor._meshColor; _modVisible = animKeyframe._linkedModMesh_Editor._isVisible; } else if (_isModBoneType) { _modTransformMatrix.SetMatrix(animKeyframe._linkedModBone_Editor._transformMatrix); } }
// Editor Functions //------------------------------------------------ public void Bake(apPortrait portrait, //apMeshGroup srcMeshGroup, apOptTransform parentTransform, apOptRootUnit rootUnit, string name, int transformID, int meshGroupUniqueID, apMatrix defaultMatrix, bool isMesh, int level, int depth, bool isVisible_Default, Color meshColor2X_Default, float zScale ) { _portrait = portrait; _rootUnit = rootUnit; _transformID = transformID; _name = name; _meshGroupUniqueID = meshGroupUniqueID; _parentTransform = parentTransform; _defaultMatrix = new apMatrix(defaultMatrix); _transform = transform; _level = level; _depth = depth; _isVisible_Default = isVisible_Default; _meshColor2X_Default = meshColor2X_Default; if (parentTransform != null) { _depth -= parentTransform._depth; } //이부분 실험 중 //1. Default Matrix를 Transform에 적용하고, Modifier 계산에서는 제외하는 경우 //결과 : Bake시에는 "Preview"를 위해서 DefaultMatrix 위치로 이동을 시키지만, 실행시에는 원점으로 이동시킨다. //_transform.localPosition = _defaultMatrix.Pos3 - new Vector3(0.0f, 0.0f, (float)_depth); //_transform.localRotation = Quaternion.Euler(0.0f, 0.0f, _defaultMatrix._angleDeg); //_transform.localScale = _defaultMatrix._scale; //2. Default Matrix를 Modifier에 포함시키고 Transform은 원점인 경우 (Editor와 동일) _transform.localPosition = -new Vector3(0.0f, 0.0f, (float)_depth * zScale); _transform.localRotation = Quaternion.identity; _transform.localScale = Vector3.one; if (isMesh) { _unitType = UNIT_TYPE.Mesh; } else { _unitType = UNIT_TYPE.Group; } _childTransforms = null; _childMesh = null; }
// Functions //-------------------------------------------- public void ReadyToCalculate() { _matrix.MakeMatrix(); //변경 //[Parent World x To Parent x Local TF] 조합으로 변경 if (_matrix_TF_ParentWorld == null) { _matrix_TF_ParentWorld = new apMatrix(); } if (_matrix_TF_ParentWorldWithoutMod == null) { _matrix_TF_ParentWorldWithoutMod = new apMatrix(); } if (_matrix_TF_ToParent == null) { _matrix_TF_ToParent = new apMatrix(); } if (_matrix_TF_LocalModified == null) { _matrix_TF_LocalModified = new apMatrix(); } if (_matrix_TFResult_World == null) { _matrix_TFResult_World = new apMatrix(); } if (_matrix_TFResult_WorldWithoutMod == null) { _matrix_TFResult_WorldWithoutMod = new apMatrix(); } if (_invMatrix_TFResult_World == null) { _invMatrix_TFResult_World = new apMatrix(); } if (_invMatrix_TFResult_WorldWithoutMod == null) { _invMatrix_TFResult_WorldWithoutMod = new apMatrix(); } _matrix_TF_ParentWorld.SetIdentity(); _matrix_TF_ParentWorldWithoutMod.SetIdentity(); _matrix_TF_ToParent.SetIdentity(); _matrix_TF_LocalModified.SetIdentity(); //ToParent는 Pivot이므로 고정 _matrix_TF_ToParent.SetMatrix(_matrix); _matrix_TFResult_World.SetIdentity(); _matrix_TFResult_WorldWithoutMod.SetIdentity(); _invMatrix_TFResult_World.SetIdentity(); _invMatrix_TFResult_WorldWithoutMod.SetIdentity(); CalculatedLog.ReadyToRecord(); }
public override bool Save(object target, string strParam) { base.Save(target, strParam); apAnimKeyframe keyframe = target as apAnimKeyframe; if (keyframe == null) { return(false); } _key_TimelineLayer = keyframe._parentTimelineLayer; if (_key_TimelineLayer == null) { return(false); } _animCurve = new apAnimCurve(keyframe._curveKey, keyframe._frameIndex); _isKeyValueSet = keyframe._isKeyValueSet; //_conSyncValue_Bool = keyframe._conSyncValue_Bool; _conSyncValue_Int = keyframe._conSyncValue_Int; _conSyncValue_Float = keyframe._conSyncValue_Float; _conSyncValue_Vector2 = keyframe._conSyncValue_Vector2; //_conSyncValue_Vector3 = keyframe._conSyncValue_Vector3; //_conSyncValue_Color = keyframe._conSyncValue_Color; _vertices.Clear(); _transformMatrix = new apMatrix(); _meshColor = new Color(0.5f, 0.5f, 0.5f, 1.0f); _isVisible = true; if (keyframe._linkedModMesh_Editor != null) { apModifiedMesh modMesh = keyframe._linkedModMesh_Editor; _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; } else if (keyframe._linkedModBone_Editor != null) { apModifiedBone modBone = keyframe._linkedModBone_Editor; _transformMatrix = new apMatrix(modBone._transformMatrix); } return(true); }
public void BlendMatrix_Add(apMatrix curMatrix, apMatrix itpLayer, float itpWeight) { curMatrix._pos += itpLayer._pos * itpWeight; curMatrix._angleDeg += itpLayer._angleDeg * itpWeight; //Scale은 Multiply의 보간 방식 curMatrix._scale.x = (curMatrix._scale.x * (1.0f - itpWeight)) + (curMatrix._scale.x * itpLayer._scale.x * itpWeight); curMatrix._scale.y = (curMatrix._scale.y * (1.0f - itpWeight)) + (curMatrix._scale.y * itpLayer._scale.y * itpWeight); //curMatrix._scale.z = (curMatrix._scale.z * (1.0f - itpWeight)) + (curMatrix._scale.z * itpLayer._scale.z * itpWeight); }
private void BlendMatrix_Add(apMatrix prevResult, apMatrix nextResult, float nextWeight) { prevResult._pos += nextResult._pos * nextWeight; prevResult._angleDeg += nextResult._angleDeg * nextWeight; //prevResult._scale += nextResult._scale * nextWeight; prevResult._scale.x = (prevResult._scale.x * (1.0f - nextWeight)) + (prevResult._scale.x * nextResult._scale.x * nextWeight); prevResult._scale.y = (prevResult._scale.y * (1.0f - nextWeight)) + (prevResult._scale.y * nextResult._scale.y * nextWeight); //prevResult._scale.z = (prevResult._scale.z * (1.0f - nextWeight)) + (prevResult._scale.z * nextResult._scale.z * nextWeight); }
public void Bake_Transform(apMatrix transformMatrix) { _dataType |= DATA_TYPE.Transform; _subModMesh_Transform = new apOptModifiedMesh_Transform[1]; _subModMesh_Transform[0] = new apOptModifiedMesh_Transform(); apOptModifiedMesh_Transform subMod_Transform = _subModMesh_Transform[0]; subMod_Transform.Bake(transformMatrix); }
public void Move__MeshGroup_Setting(Vector2 curMouseGL, Vector2 curMousePosW, Vector2 deltaMoveW, int btnIndex, bool isFirstMove) { if (Editor.Select.MeshGroup == null || !Editor.Select.IsMeshGroupSettingChangePivot) { return; } if (deltaMoveW.sqrMagnitude == 0.0f) { return; } apMatrix targetMatrix = null; object targetObj = null; apMatrix worldMatrix = null; apMatrix parentWorldMatrix = null; //Modifier가 적용이 안된 상태이므로 //World Matrix = ParentWorld x ToParent(Default) 가 성립한다. if (Editor.Select.SubMeshInGroup != null) { targetMatrix = Editor.Select.SubMeshInGroup._matrix; //=ToParent 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; //=ToParent targetObj = Editor.Select.SubMeshGroupInGroup; worldMatrix = new apMatrix(Editor.Select.SubMeshGroupInGroup._matrix_TFResult_World); parentWorldMatrix = Editor.Select.SubMeshGroupInGroup._matrix_TF_ParentWorld; } else { return; } worldMatrix._pos += deltaMoveW; worldMatrix.MakeMatrix(); worldMatrix.RInverse(parentWorldMatrix); //ParentWorld-1 x World = ToParent Vector2 newLocalPos = worldMatrix._pos; //Undo apEditorUtil.SetRecord(apUndoGroupData.ACTION.MeshGroup_Gizmo_MoveTransform, Editor.Select.MeshGroup, targetObj, false, Editor); //targetMatrix.SetPos(targetMatrix._pos.x + deltaMoveW.x, targetMatrix._pos.y + deltaMoveW.y); targetMatrix.SetPos(newLocalPos.x, newLocalPos.y); targetMatrix.MakeMatrix(); //Editor.RefreshControllerAndHierarchy(); }
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(); }
// Functions //-------------------------------------------- public void ReadyToCalculate() { _matrix.MakeMatrix(); //_matrix_TF_Cal_Parent = apMatrix3x3.identity; //_matrix_TF_Cal_Local = _matrix.MtrxToSpace; //if(_calculateTmpMatrix == null) //{ // _calculateTmpMatrix = new apMatrix(); //} //_calculateTmpMatrix.SetIdentity(); //_calculateTmpMatrix.SetMatrix(_matrix); //if(_calculateTmpMatrix_Local == null) //{ // _calculateTmpMatrix_Local = new apMatrix(); //} //_calculateTmpMatrix_Local.SetIdentity(); //_calculateTmpMatrix_Local.SetMatrix(_matrix); //변경 //[Parent World x To Parent x Local TF] 조합으로 변경 if (_matrix_TF_ParentWorld == null) { _matrix_TF_ParentWorld = new apMatrix(); } if (_matrix_TF_ToParent == null) { _matrix_TF_ToParent = new apMatrix(); } if (_matrix_TF_LocalModified == null) { _matrix_TF_LocalModified = new apMatrix(); } if (_matrix_TFResult_World == null) { _matrix_TFResult_World = new apMatrix(); } if (_matrix_TFResult_WorldWithoutMod == null) { _matrix_TFResult_WorldWithoutMod = new apMatrix(); } _matrix_TF_ParentWorld.SetIdentity(); _matrix_TF_ToParent.SetIdentity(); _matrix_TF_LocalModified.SetIdentity(); //ToParent는 Pivot이므로 고정 _matrix_TF_ToParent.SetMatrix(_matrix); _matrix_TFResult_World.SetIdentity(); _matrix_TFResult_WorldWithoutMod.SetIdentity(); }
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); }
/// <summary> /// 변형된 modMatrix에 대해서 StackLayer, CalParamResult, ParamSet 상에서 레이어 보간된 연산을 역으로 수행하여 /// 요청된 Target Modified Matrix 레벨에서 어떤 값을 가져야 하는지 리턴한다. /// [Matrix에 대한 역 보간처리 함수] /// </summary> /// <param name="targetModifiedLog"></param> /// <param name="layer_ParamSetGroupLog"></param> /// <param name="layer_CalParamResultLog"></param> /// <param name="stackLayer_MeshTransformLog"></param> /// <param name="modMatrix_next"></param> /// <returns></returns> private apMatrix GetInverseInterpolatedMatrix(apCalculatedLog layer_ParamSetGroupLog, apCalculatedLog layer_CalParamResultLog, apCalculatedLog stackLayer_MeshTransformLog, apMatrix modMatrix_next ) { //1. StackLayer -> CalParamResultLog if (!stackLayer_MeshTransformLog._childCalParamResultLogs.Contains(layer_CalParamResultLog)) { return(null); } //Debug.Log("GetInvMatrix"); //for (int i = 0; i < stackLayer_MeshTransformLog._childCalParamResultLogs.Count; i++) //{ // Debug.Log("Cal Param [" + i + "] : " + stackLayer_MeshTransformLog._childCalParamResultLogs[i]._calResultParam._linkedModifier.DisplayName + " / " // + stackLayer_MeshTransformLog._childCalParamResultLogs[i]._layerBlendType + " (" + stackLayer_MeshTransformLog._childCalParamResultLogs[i]._weight + ")"); //} //for (int i = 0; i < layer_CalParamResultLog._childLayerLogs.Count; i++) //{ // Debug.Log("ParamSetGroup [" + i + "] : " + layer_CalParamResultLog._childLayerLogs[i]._paramSetGroup._keyControlParam._keyName + " / " // + layer_CalParamResultLog._childLayerLogs[i]._layerBlendType + " ( " + layer_CalParamResultLog._childLayerLogs[i]._weight + ")" // + "\r\n" + layer_CalParamResultLog._childLayerLogs[i]._paramSetGroup._tmpMatrix); //} //1. StackLayer -> CalParamResultLog apMatrix modMatrix_CalParamResultLog = GetSubInverseLayeredMatrix(layer_CalParamResultLog, stackLayer_MeshTransformLog, modMatrix_next); if (modMatrix_CalParamResultLog == null) { Debug.LogError("GetInverseInterpolatedMatrix 실패 : StackLayer -> CalParamResultLog를 처리할 수 없다."); return(null); } //Debug.Log("Calculate : 1. StackLayer -> CalParamResultLog\r\n" + modMatrix_next + "\r\n >>>> \r\n" + modMatrix_CalParamResultLog); //2. CalParamResultLog -> ParamSetGroupLog (ParamSet은 하나만 선택했으니 ParamSet 레벨과 동일하다) apMatrix modMatrix_ParamSetGroupLog = GetSubInverseLayeredMatrix(layer_ParamSetGroupLog, layer_CalParamResultLog, modMatrix_CalParamResultLog); if (modMatrix_ParamSetGroupLog == null) { Debug.LogError("GetInverseInterpolatedMatrix 실패 : StackLayer -> CalParamResultLog를 처리할 수 없다."); return(null); } //Debug.Log("Calculate : 2. CalParamResultLog -> ParamSetGroupLog\r\n" + modMatrix_CalParamResultLog + "\r\n >>>> \r\n" + modMatrix_ParamSetGroupLog); return(modMatrix_ParamSetGroupLog); }
public void Bake_MeshGroupTransform(apOptTransform rootTransform, apOptTransform targetTransform, apMatrix transformMatrix, Color meshColor, bool isVisible) { //_targetType = apModifiedMesh.TARGET_TYPE.MeshGroupTransformOnly; _rootTransform = rootTransform; _targetTransform = targetTransform; _transformMatrix = new apMatrix(transformMatrix); _meshColor = meshColor; _isVisible = isVisible; }
public ParamKeyValueSet(apModifierParamSetGroup keyParamSetGroup, apModifierParamSet paramSet, apModifiedBone modifiedValue) { _keyParamSetGroup = keyParamSetGroup; _paramSet = paramSet; _modifiedMesh = null; _modifiedBone = modifiedValue; _layerIndx = _paramSet._parentParamSetGroup._layerIndex; //추가 : RotationBias _isAnimRotationBias = false; _animRotationBiasAngle = 0; _animRotationBiasAngle_Prev = -1; _animRotationBiasedMatrix = new apMatrix(); }
/// <summary> /// Keyframe에 Rotation Bias 설정이 있는 경우 관련 변수를 갱신한다. /// </summary> /// <param name="rotationBias"></param> /// <param name="rotationCount"></param> public void SetAnimRotationBias(apAnimKeyframe.ROTATION_BIAS rotationBias, int rotationCount) { if (rotationBias == apAnimKeyframe.ROTATION_BIAS.CW) { _isAnimRotationBias = true; _animRotationBiasAngle = -360 * rotationCount; } else if (rotationBias == apAnimKeyframe.ROTATION_BIAS.CCW) { _isAnimRotationBias = true; _animRotationBiasAngle = 360 * rotationCount; } else { _isAnimRotationBias = false; _animRotationBiasAngle = 0; } //에디터에서는 최적화가 아니라 언제 바뀔지 모르므로 항상 갱신 //if(_animRotationBiasAngle_Prev != _animRotationBiasAngle && _isAnimRotationBias) if (_isAnimRotationBias) { if (_animRotationBiasedMatrix == null) { _animRotationBiasedMatrix = new apMatrix(); } if (_modifiedMesh != null) { _animRotationBiasedMatrix.SetTRS( _modifiedMesh._transformMatrix._pos, _modifiedMesh._transformMatrix._angleDeg + _animRotationBiasAngle, _modifiedMesh._transformMatrix._scale ); } else if (_modifiedBone != null) { _animRotationBiasedMatrix.SetTRS( _modifiedBone._transformMatrix._pos, _modifiedBone._transformMatrix._angleDeg + _animRotationBiasAngle, _modifiedBone._transformMatrix._scale ); } else { _animRotationBiasedMatrix.SetIdentity(); } _animRotationBiasAngle_Prev = _animRotationBiasAngle; } }
/// <summary> /// ModMesh와 연동되는 ParamKeyValue 생성 /// </summary> public OptParamKeyValueSet(apOptParamSetGroup keyParamSetGroup, apOptParamSet paramSet, apOptModifiedMesh modifiedMesh) { _keyParamSetGroup = keyParamSetGroup; _paramSet = paramSet; _modifiedMesh = modifiedMesh; _layerIndex = _keyParamSetGroup._layerIndex; _modifiedBone = null; //추가 : RotationBias _isAnimRotationBias = false; _animRotationBiasAngle = 0; _animRotationBiasAngle_Prev = -1; _animRotationBiasedMatrix = new apMatrix(); }
public void SetMatrixWrap(apMatrix matrixWrap, CalculateType calculateType, bool isWeighted, float weight) { _valueType = UnitValueType.MatrixWrap; if (_val_MatrixWrap == null) { _val_MatrixWrap = new apMatrix(matrixWrap); //<<복사를 하자 } else { _val_MatrixWrap.SetMatrix(matrixWrap); } _calculateType = calculateType; _isWeighted = isWeighted; _weight = weight; }
public void LinkPortrait(apPortrait portrait, apModifierBase parentModifier) { _portrait = portrait; _parentModifier = parentModifier; if (_tmpMatrix == null) { _tmpMatrix = new apMatrix(); } if (_tmpPositions == null) { _tmpPositions = new List <Vector2>(); } }
//private void BlendMatrix_ITP(apMatrix prevResult, apMatrix nextResult, float prevWeight, float nextWeight) private void BlendMatrix_ITP(apMatrix prevResult, apMatrix nextResult, float nextWeight) { //prevResult._pos = ((prevResult._pos * prevWeight) + (nextResult._pos * nextWeight)) / (prevWeight + nextWeight); //prevResult._angleDeg = ((prevResult._angleDeg * prevWeight) + (nextResult._angleDeg * nextWeight)) / (prevWeight + nextWeight); //prevResult._scale = ((prevResult._scale * prevWeight) + (nextResult._scale * nextWeight)) / (prevWeight + nextWeight); //float totalWeight = prevWeight + nextWeight; //if(totalWeight <= 0.0f) //{ // return; //} //float totalWeight = 1.0f; //prevResult.LerpMartix(nextResult, nextWeight / totalWeight); prevResult.LerpMartix(nextResult, nextWeight); }
/// <summary> /// BlendMatrix_Add의 역연산 [ (curMatrix - subtractedLayer * weight) ] /// </summary> /// <param name="curMatrix"></param> /// <param name="subtractedLayer"></param> /// <param name="weight"></param> public void InverseBlendMatrix_Add(apMatrix curMatrix, apMatrix subtractedLayer, float weight) { if (weight <= 0.0f) { //처리하지 않는다. return; } //curMatrix._pos = curMatrix._pos + itpLayer._pos * itpWeight; //Result = Prev + Next * Weight //Prev = Result - (Next * Weight) curMatrix._pos = curMatrix._pos - subtractedLayer._pos * weight; curMatrix._angleDeg = curMatrix._angleDeg - subtractedLayer._angleDeg * weight; //curMatrix._scale.x = (curMatrix._scale.x * (1.0f - itpWeight)) + (curMatrix._scale.x * itpLayer._scale.x * itpWeight); //Result = Prev * (1 - Weight) + (Prev * Next * Weight) //Result = Prev * (1 - Weight + Next * Weight) //Prev = Result / ((1 - Weight) + Next * Weight) float divScaleX = (1.0f - weight) + subtractedLayer._scale.x * weight; float divScaleY = (1.0f - weight) + subtractedLayer._scale.y * weight; //float divScaleZ = (1.0f - weight) + subtractedLayer._scale.z * weight; if (divScaleX == 0.0f) { curMatrix._scale.x = 0.0f; } else { curMatrix._scale.x = curMatrix._scale.x / divScaleX; } if (divScaleY == 0.0f) { curMatrix._scale.y = 0.0f; } else { curMatrix._scale.y = curMatrix._scale.y / divScaleY; } //if(divScaleZ == 0.0f) { curMatrix._scale.z = 0.0f; } //else { curMatrix._scale.z = curMatrix._scale.z / divScaleZ; } }
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(); }
public void LinkPortrait(apPortrait portrait, apModifierBase parentModifier) { _portrait = portrait; _parentModifier = parentModifier; if (_tmpMatrix == null) { _tmpMatrix = new apMatrix(); } //if (_tmpPositions == null) //{ // _tmpPositions = new List<Vector2>(); //} //if(_tmpVertMatrices == null) //{ // _tmpVertMatrices = new List<apMatrix3x3>(); //} }
/// <summary> /// BlendMatrix_Add의 역연산 중 TargetLayer에서 최종 결과값을 만드는 과정. /// Pos/Angle : [ X = (inverseUpperLayer - lowerLayer) / weight ] /// Scale : [ X = ( (inverseUpperLayer / lowerLayer) - 1 + weight ) / weight ] /// weight가 0이면 Null리턴 /// </summary> /// <param name="curMatrix"></param> /// <param name="subtractedLayer"></param> /// <param name="weight"></param> public apMatrix InverseBlendMatrixTarget_Add(apMatrix invUpperLayerResult, apMatrix lowerLayerResult, apMatrix targetLayer, float weight) { if (weight <= 0.0f) { //처리하지 않는다. return(null); } apMatrix result = new apMatrix(); result._pos.x = (invUpperLayerResult._pos.x - lowerLayerResult._pos.x) / weight; result._pos.y = (invUpperLayerResult._pos.y - lowerLayerResult._pos.y) / weight; result._angleDeg = (invUpperLayerResult._angleDeg - lowerLayerResult._angleDeg) / weight; result._scale.x = ((invUpperLayerResult._scale.x / lowerLayerResult._scale.x) - (1.0f - weight)) / weight; result._scale.y = ((invUpperLayerResult._scale.y / lowerLayerResult._scale.y) - (1.0f - weight)) / weight; //result._scale.z = ((invUpperLayerResult._scale.z / lowerLayerResult._scale.z) - (1.0f - weight)) / weight; return(result); }
/// <summary> /// BlendMatrix_ITP의 역연산 중 TargetLayer에서 최종 결과값을 만드는 과정. /// [ X = (inverseUpperLayer - (lowerLayer * (1 - weight))) / (weight) ] /// weight가 0이면 Null 리턴 /// </summary> /// <param name="curMatrix"></param> /// <param name="subtractedLayer"></param> /// <param name="weight"></param> public apMatrix InverseBlendMatrixTarget_ITP(apMatrix invUpperLayerResult, apMatrix lowerLayerResult, apMatrix targetLayer, float weight) { if (weight <= 0.0f) { return(null); } // ( InvUpperLayer - (lowerLayer * (1-weight)) ) / weight apMatrix result = new apMatrix(); result._pos.x = (invUpperLayerResult._pos.x - lowerLayerResult._pos.x * (1.0f - weight)) / weight; result._pos.y = (invUpperLayerResult._pos.y - lowerLayerResult._pos.y * (1.0f - weight)) / weight; result._angleDeg = (invUpperLayerResult._angleDeg - lowerLayerResult._angleDeg * (1.0f - weight)) / weight; result._scale.x = (invUpperLayerResult._scale.x - lowerLayerResult._scale.x * (1.0f - weight)) / weight; result._scale.y = (invUpperLayerResult._scale.y - lowerLayerResult._scale.y * (1.0f - weight)) / weight; //result._scale.z = (invUpperLayerResult._scale.z - lowerLayerResult._scale.z * (1.0f - weight)) / weight; result.MakeMatrix(); return(result); }