private void DrawSelectedContactPoint() { if (editedData == null || gameObject == null) { return; } if (contactPointsRL != null) { if (0 <= contactPointsRL.index && contactPointsRL.index < editedData.contactPoints.Count) { Handles.color = Color.green; MotionMatchingContact cp = editedData.contactPoints[contactPointsRL.index]; Vector3 drawPosition = gameObject.transform.TransformPoint(cp.position); Vector3 drawDirection = gameObject.transform.TransformDirection(cp.contactNormal); cp.position = gameObject.transform.TransformPoint(cp.position); // Changing contactPoint position if (drawPositionManipulator) { Vector3 cpPosBuffor = cp.position; Vector3 cpSurNorBuffor = cp.contactNormal; cp.position = Handles.PositionHandle(cp.position, Quaternion.identity); } // Changing contactPoint surface reverse normal if (drawRotationManipuator) { Vector3 contactNormal = gameObject.transform.TransformDirection(cp.contactNormal); //Quaternion rot = Quaternion.FromToRotation(Vector3.forward, dirRSN.normalized); //rot = Handles.RotationHandle(rot, cp.position); if (cp.rotation.x == 0f && cp.rotation.y == 0f && cp.rotation.z == 0f && cp.rotation.w == 0f) { cp.rotation = Quaternion.identity; } cp.rotation = Handles.RotationHandle(cp.rotation, cp.position); contactNormal = cp.rotation * Vector3.forward; cp.contactNormal = contactNormal; cp.contactNormal = gameObject.transform.InverseTransformDirection(cp.contactNormal); } Handles.DrawWireCube(drawPosition, Vector3.one * drawCubeSize); MM_Gizmos.DrawArrowHandles(drawPosition, drawDirection, arrowLength, arrowArmLength); cp.position = gameObject.transform.InverseTransformPoint(cp.position); editedData.contactPoints[contactPointsRL.index] = cp; } } }
private void DrawSceneGUI(SceneView sceneView) { if (gameObject != null && editedData != null) { if (selectedOption == 1) { DrawSelectedContactPoint(); DrawCalculatedContactPoints(); } if (_bDrawTrajectory) { Handles.color = Color.cyan; Handles.DrawWireCube(gameObject.transform.position, Vector3.one * 0.1f); Trajectory t = new Trajectory(editedData.trajectoryPointsTimes.Count); editedData.GetTrajectoryInTime(ref t, currentAnimaionTime); Handles.color = Color.green; t.TransformToWorldSpace(gameObject.transform); MM_Gizmos.DrawTrajectory_Handles( editedData.trajectoryPointsTimes.ToArray(), gameObject.transform.position, gameObject.transform.forward, t, 0.04f, 0.2f ); } if (_bDrawPose) { PoseData p = new PoseData(editedData[0].pose.Count); editedData.GetPoseInTime(ref p, currentAnimaionTime); p.TransformToWorldSpace(gameObject.transform); MM_Gizmos.DrawPose(p, Color.blue, Color.yellow); } if (selectedOption == 1) { float length = 200f; float height = 25f; Rect r = new Rect( sceneView.position.width / 2f - length / 2f, 30f, length, height ); DrawContactGizmosSelectRect(r); } } }
private void DrawSceneGUIImpacts() { FrameData frame = editedData.GetClossestFrame(currentAnimaionTime); if (frame.contactPoints.Length != 1) { return; } Vector3 cpPos = gameObject.transform.TransformPoint(frame.contactPoints[0].position); Vector3 cpRSN = gameObject.transform.TransformDirection(frame.contactPoints[0].normal); if (drawContactsPositions) { Handles.DrawWireCube(cpPos, Vector3.one * drawCubeSize); } if (drawContactsRSN) { MM_Gizmos.DrawArrowHandles(cpPos, cpRSN.normalized, arrowLength, arrowArmLength); } }
private void DrawSceneGUIContacts() { List <FrameContact> cpList = new List <FrameContact>(); editedData.GetContactPoints(ref cpList, currentAnimaionTime); Handles.color = Color.red; for (int i = 0; i < cpList.Count; i++) { Vector3 cpPos = gameObject.transform.TransformPoint(cpList[i].position); if (drawContactsPositions) { Handles.DrawWireCube(cpPos, Vector3.one * drawCubeSize); } if (drawContactsRSN) { Vector3 cpRSN = gameObject.transform.TransformDirection(cpList[i].normal); MM_Gizmos.DrawArrowHandles(cpPos, cpRSN.normalized, arrowLength, arrowArmLength); } } }