private void AttachLimbMarker() { var chara = FkCharaMgr.FindSelectChara(); if (chara == null) { return; } chara.Limbs().Foreach(b => { var marker = BoneMarker.Create(b.Transform); _limbMarkers.Add(marker); marker.OnDrag = (m) => { var screenVec = m.MouseEndPos - m.MouseStartPos; var pos = Kit.MapScreenVecToWorld(screenVec, b.Transform.position); FkJointAssist.MoveEnd(b.GuideObject, pos); }; marker.OnMidClick = (m) => { // ClearLimbMarker(); DisableLimbMarker(); _follower = b; AttachSelectorMarker(); }; marker.OnRightClick = (m) => { ToggleLockBone(b, m); }; marker.OnLeftDown = (m) => { UndoRedoHelper.Record(); }; marker.OnLeftUp = (m) => { UndoRedoHelper.Finish(); }; }); }
private void InnerUpdate() { if (Input.GetKeyDown(KeyCode.T) && Input.GetKey(KeyCode.LeftControl)) { if (_isLockerEnable) { AttachHangMarker(); } } else if (Input.GetKeyDown(KeyCode.T)) { if (_isLockerEnable) { _isLockerEnable = false; ClearLimbMarker(); ClearSelectorMarker(); ClearHangMarker(); _attachRecords.Clear(); _hangRecords.Clear(); CameraMgr.Unlock(); } else { _isLockerEnable = true; AttachLimbMarker(); } Tracer.Log(_isLockerEnable); } else if (Input.GetKeyDown(KeyCode.P)) { CameraMgr.Toggle(); } // 移动到Lock的位置 foreach (var pair in _dicLockRecords) { var b = pair.Key; var r = pair.Value; if (b.Transform.position != r.LockedPos && b.GuideObject.IsLimb()) { FkJointAssist.FkJointRotater(b.GuideObject).MoveTo(r.LockedPos); } if (b.Transform.rotation != r.LockedRot) { b.GuideObject.TurnTo(r.LockedRot); } } _hangRecords.ForEach(r => { var vec = r.Pos - r.Bone.Transform.position; if (vec != Vector3.zero) { r.Bone.Chara.Root.GuideObject.Move(vec); } if (r.Rot != r.Bone.Transform.rotation) { r.Bone.GuideObject.TurnTo(r.Rot); } }); _attachRecords.ForEach(r => { // if (r.Leader.Transform == r.Follower.Transform) // { // var vec = r.Pos - r.Leader.Transform.position; // r.Leader.Chara.Root.GuideObject.Move(vec); // } // else // { var target = r.Leader.Transform.position + r.Pos; r.Follower.GuideObject.MoveEnd(target); // } }); }
private void InnerUpdate() { var go = Context.GuideObjectManager().selectObject; if (go == null) { return; } float angle = 0.5f; float dist = 0.002f; if (Input.anyKeyDown) { UndoRedoHelper.Record(); } if (Input.GetKey(KeyCode.LeftShift)) { angle /= 4; dist /= 4; } _counter++; if (Input.GetKey(KeyCode.LeftShift) && Input.GetKeyDown(KeyCode.R)) { go.Reset(); } // else if (Input.GetKey(KeyCode.E) && Input.GetMouseButton(0)) { go.Rotate(angle, 0, 0); } else if (Input.GetKey(KeyCode.E) && Input.GetMouseButton(1)) { go.Rotate(-angle, 0, 0); } // else if (Input.GetKey(KeyCode.S) && Input.GetMouseButton(0)) { go.Rotate(0, angle, 0); } else if (Input.GetKey(KeyCode.S) && Input.GetMouseButton(1)) { go.Rotate(0, -angle, 0); } // else if (Input.GetKey(KeyCode.D) && Input.GetMouseButton(0)) { go.Rotate(0, 0, angle); } else if (Input.GetKey(KeyCode.D) && Input.GetMouseButton(1)) { go.Rotate(0, 0, -angle); } // else if (Input.GetKey(KeyCode.X) && Input.GetMouseButton(0)) { FkJointAssist.Forward(go, dist); } else if (Input.GetKey(KeyCode.X) && Input.GetMouseButton(1)) { FkJointAssist.Forward(go, -dist); } // else if (Input.GetKey(KeyCode.C) && Input.GetMouseButton(0)) { FkJointAssist.Tangent(go, angle); } else if (Input.GetKey(KeyCode.C) && Input.GetMouseButton(1)) { FkJointAssist.Tangent(go, -angle); } // else if (Input.GetKey(KeyCode.V) && Input.GetMouseButton(0)) { FkJointAssist.Normals(go, angle); } else if (Input.GetKey(KeyCode.V) && Input.GetMouseButton(1)) { FkJointAssist.Normals(go, -angle); } // else if (Input.GetKey(KeyCode.B) && Input.GetMouseButton(0)) { FkJointAssist.Revolution(go, angle); } else if (Input.GetKey(KeyCode.B) && Input.GetMouseButton(1)) { FkJointAssist.Revolution(go, -angle); } // else if (Input.GetKey(KeyCode.G) && Input.GetMouseButton(0)) { FkJointAssist.MoveEndX(go, dist); } else if (Input.GetKey(KeyCode.G) && Input.GetMouseButton(1)) { FkJointAssist.MoveEndX(go, -dist); } // else if (Input.GetKey(KeyCode.Y) && Input.GetMouseButton(0)) { FkJointAssist.MoveEndY(go, dist); } else if (Input.GetKey(KeyCode.Y) && Input.GetMouseButton(1)) { FkJointAssist.MoveEndY(go, -dist); } // else if (Input.GetKey(KeyCode.H) && Input.GetMouseButton(0)) { FkJointAssist.MoveEndZ(go, dist); } else if (Input.GetKey(KeyCode.H) && Input.GetMouseButton(1)) { FkJointAssist.MoveEndZ(go, -dist); } // else { if (_counter > 1) { UndoRedoHelper.Finish(); // FinishRotate(); } _counter = 0; // _oldRot = CollectOldRot(); } }