public void SetTangent(apAnimCurve.TANGENT_TYPE tangentType) { if (_curveKeyA == null || _curveKeyB == null) { return; } _curveKeyA._nextTangentType = tangentType; _curveKeyB._prevTangentType = tangentType; _curveKeyA.Refresh(); _curveKeyB.Refresh(); MakeCurve(); }
public void Clear() { _syncStatus = SYNC_STATUS.NoKeyframes; if (_keyframes == null) { _keyframes = new List <apAnimKeyframe>(); } _keyframes.Clear(); if (_curveSets == null) { _curveSets = new List <CurveSet>(); } _curveSets.Clear(); if (_prevKey2CurveSet == null) { _prevKey2CurveSet = new Dictionary <apAnimKeyframe, CurveSet>(); } if (_nextKey2CurveSet == null) { _nextKey2CurveSet = new Dictionary <apAnimKeyframe, CurveSet>(); } _prevKey2CurveSet.Clear(); _nextKey2CurveSet.Clear(); _isAnyChangedRequest = false; _syncCurve_Prev.Init(); _syncCurve_Next.Init(); _syncCurve_Prev._keyIndex = 0; _syncCurve_Next._keyIndex = 1; _syncCurve_Prev._nextIndex = 1; _syncCurve_Next._prevIndex = 0; //이전 //_syncCurve_Prev._nextCurveResult.Link(_syncCurve_Prev, _syncCurve_Next, true, true); //_syncCurve_Next._prevCurveResult.Link(_syncCurve_Prev, _syncCurve_Next, false, true); //변경 19.5.20 : MakeCurve를 항상 하는 걸로 변경 _syncCurve_Prev._nextCurveResult.Link(_syncCurve_Prev, _syncCurve_Next, true); _syncCurve_Next._prevCurveResult.Link(_syncCurve_Prev, _syncCurve_Next, false); _syncCurve_Prev.Refresh(); _syncCurve_Next.Refresh(); }
public void ApplySync(bool isApplyForce, bool isMousePressed) { if (_syncStatus != SYNC_STATUS.Sync || !_isAnyChangedRequest) { return; } if (_curveSets == null || _curveSets.Count == 0) { return; } //isApplyForce = true이거나 //isMousePressed = false일때 Apply를 한다. if (!isApplyForce && isMousePressed) { return; } apEditorUtil.SetEditorDirty(); _syncCurve_Prev._nextCurveResult.MakeCurve(); _syncCurve_Next._prevCurveResult.MakeCurve(); //동기화를 적용하자 CurveSet curSet = null; apAnimCurve prevCurve = null; apAnimCurve nextCurve = null; for (int i = 0; i < _curveSets.Count; i++) { curSet = _curveSets[i]; if (curSet._prevKeyframe == null || curSet._nextKeyframe == null) { continue; } prevCurve = curSet._prevKeyframe._curveKey; nextCurve = curSet._nextKeyframe._curveKey; //공통 커브와 동일하게 만들자. //Prev의 Next와 Next의 Prev.. 아 헷갈려;; prevCurve._nextTangentType = _syncCurve_Prev._nextTangentType; prevCurve._nextSmoothX = _syncCurve_Prev._nextSmoothX; prevCurve._nextSmoothY = _syncCurve_Prev._nextSmoothY; nextCurve._prevTangentType = _syncCurve_Next._prevTangentType; nextCurve._prevSmoothX = _syncCurve_Next._prevSmoothX; nextCurve._prevSmoothY = _syncCurve_Next._prevSmoothY; prevCurve.Refresh(); nextCurve.Refresh(); } _isAnyChangedRequest = false; }
private static void DrawSmoothLineControlPoints(apAnimCurve curveA, apAnimCurve curveB, Vector2 posA, Vector2 posB) { Vector2 smoothA_Ratio = new Vector2(Mathf.Clamp01(curveA._nextSmoothX), Mathf.Clamp01(curveA._nextSmoothY)); Vector2 smoothB_Ratio = new Vector2(Mathf.Clamp01(curveB._prevSmoothX), Mathf.Clamp01(curveB._prevSmoothY)); Vector2 smoothA_Pos = new Vector2( posA.x * (1.0f - smoothA_Ratio.x) + posB.x * smoothA_Ratio.x, posA.y * (1.0f - smoothA_Ratio.y) + posB.y * smoothA_Ratio.y); Vector2 smoothB_Pos = new Vector2( posB.x * (1.0f - smoothB_Ratio.x) + posA.x * smoothB_Ratio.x, posB.y * (1.0f - smoothB_Ratio.y) + posA.y * smoothB_Ratio.y); int pointSize = 16; DrawBoldLine(posA, smoothA_Pos, 2, Color.red, true); DrawBoldLine(posB, smoothB_Pos, 2, Color.red, true); DrawTexture(_img_ControlPoint, smoothA_Pos, pointSize, pointSize, _color_Gray, true); DrawTexture(_img_ControlPoint, smoothB_Pos, pointSize, pointSize, _color_Gray, true); AddCursorRect(smoothA_Pos, pointSize, pointSize, MouseCursor.MoveArrow); AddCursorRect(smoothB_Pos, pointSize, pointSize, MouseCursor.MoveArrow); if (_isMouseEvent && !_isMouseEventUsed) { switch (_leftBtnStatus) { case apMouse.MouseBtnStatus.Down: case apMouse.MouseBtnStatus.Pressed: if (_leftBtnStatus == apMouse.MouseBtnStatus.Down) { if (IsMouseInLayout(_mousePos)) { apEditorUtil.SetEditorDirty(); if (IsMouseInButton(_mousePos, smoothA_Pos, pointSize, pointSize)) { //Debug.Log("Select A"); _selectedCurveKey = curveA; _isLockMouse = false; _prevMousePos = _mousePos; } else if (IsMouseInButton(_mousePos, smoothB_Pos, pointSize, pointSize)) { //Debug.Log("Select B"); _selectedCurveKey = curveB; _isLockMouse = false; _prevMousePos = _mousePos; } else { _selectedCurveKey = null; _isLockMouse = true; } } else { _selectedCurveKey = null; _isLockMouse = true; } } if (!_isLockMouse) { apEditorUtil.SetEditorDirty(); if (_selectedCurveKey == curveA) { Vector2 nextPos_Ratio = new Vector2( (_mousePos.x - posA.x) / (posB.x - posA.x), (_mousePos.y - posA.y) / (posB.y - posA.y)); curveA._nextSmoothX = Mathf.Clamp01(nextPos_Ratio.x); curveA._nextSmoothY = Mathf.Clamp01(nextPos_Ratio.y); } else if (_selectedCurveKey == curveB) { Vector2 nextPos_Ratio = new Vector2( (_mousePos.x - posA.x) / (posB.x - posA.x), (_mousePos.y - posA.y) / (posB.y - posA.y)); curveB._prevSmoothX = 1.0f - Mathf.Clamp01(nextPos_Ratio.x); curveB._prevSmoothY = 1.0f - Mathf.Clamp01(nextPos_Ratio.y); } if (Vector2.Distance(_prevMousePos, _mousePos) > 0.001f) { curveA.Refresh(); curveB.Refresh(); //Debug.LogError("Make Curve"); _prevMousePos = _mousePos; } } break; case apMouse.MouseBtnStatus.Released: case apMouse.MouseBtnStatus.Up: break; } } }