/** * Draws lines from elbow to wrist, wrist to palm, and normal to the palm. * Also draws the orthogonal basis vectors for the pinch and grab points. */ public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer gizmoDrawer) { if (DrawHand) { Hand hand = GetLeapHand(); gizmoDrawer.color = Color.red; gizmoDrawer.DrawLine(hand.Arm.ElbowPosition.ToVector3(), hand.Arm.WristPosition.ToVector3()); gizmoDrawer.color = Color.white; gizmoDrawer.DrawLine(hand.WristPosition.ToVector3(), hand.PalmPosition.ToVector3()); //Wrist to palm line gizmoDrawer.color = Color.black; gizmoDrawer.DrawLine(hand.PalmPosition.ToVector3(), (hand.PalmPosition + hand.PalmNormal * hand.PalmWidth / 2).ToVector3()); //Hand Normal if (PinchPoint != null) { DrawBasis(gizmoDrawer, PinchPoint.position, PinchPoint.GetLeapMatrix(), .01f); //Pinch basis } if (GrabPoint != null) { DrawBasis(gizmoDrawer, GrabPoint.position, GrabPoint.GetLeapMatrix(), .01f); //Grab basis } for (int f = 0; f < 5; f++) //Fingers { Finger finger = hand.Fingers[f]; for (int i = 0; i < 4; ++i) { Bone bone = finger.Bone((Bone.BoneType)i); gizmoDrawer.color = colors[i]; gizmoDrawer.DrawLine(bone.PrevJoint.ToVector3(), bone.PrevJoint.ToVector3() + bone.Direction.ToVector3() * bone.Length); } } } }
public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer) { if (_drawGizmos) { drawer.color = Color.blue; for (int i = 0; i < _ribbon.Points.Count - 1; i++) { drawer.DrawLine(_ribbon.Points[i].Position, _ribbon.Points[i + 1].Position); } drawer.color = Color.green; for (int i = 0; i < _ribbon.Points.Count; i++) { drawer.DrawLine(_ribbon.Points[i].Position, _ribbon.Points[i].Position + _ribbon.Points[i].Normal * 0.02F); } drawer.color = Color.red; for (int i = 0; i < _ribbon.Points.Count - 1; i++) { Vector3 binormal = Vector3.Cross(_ribbon.Points[i + 1].Position - _ribbon.Points[i].Position, _ribbon.Points[i + 1].Normal).normalized * 0.04F; drawer.DrawLine(_ribbon.Points[i + 1].Position - binormal, _ribbon.Points[i + 1].Position + binormal); drawer.DrawCube(_ribbon.Points[i + 1].Position + binormal, Vector3.one * 0.005F); } } }
public void DrawBasis(RuntimeGizmoDrawer gizmoDrawer, Vector3 origin, LeapTransform basis, float scale) { gizmoDrawer.color = Color.red; gizmoDrawer.DrawLine(origin, origin + basis.xBasis.ToVector3() * scale); gizmoDrawer.color = Color.green; gizmoDrawer.DrawLine(origin, origin + basis.yBasis.ToVector3() * scale); gizmoDrawer.color = Color.blue; gizmoDrawer.DrawLine(origin, origin + basis.zBasis.ToVector3() * scale); }
public Vector2 RenderUVToDisplayUV(Vector2 UV, bool drawLine = false, RuntimeGizmoDrawer drawer = null) { Ray eyeRay = eyePerspective.ViewportPointToRay(new Vector3(UV.x, UV.y, 1f)); eyeRay.origin = eyePerspective.transform.position; Vector3 sphereSpaceRayOrigin = ellipse.worldToSphereSpace.MultiplyPoint(eyeRay.origin); Vector3 sphereSpaceRayDirection = (ellipse.worldToSphereSpace.MultiplyPoint(eyeRay.origin + eyeRay.direction) - sphereSpaceRayOrigin).normalized; float intersectionTime = intersectLineSphere(sphereSpaceRayOrigin, sphereSpaceRayDirection, Vector3.zero, 0.5f * 0.5f, false); if (intersectionTime < 0f) { return(Vector2.zero); } Vector3 sphereSpaceIntersection = sphereSpaceRayOrigin + (intersectionTime * sphereSpaceRayDirection); //Ellipsoid Normals Vector3 sphereSpaceNormal = -sphereSpaceIntersection.normalized; sphereSpaceNormal = new Vector3(sphereSpaceNormal.x / Mathf.Pow(ellipse.MinorAxis / 2f, 2f), sphereSpaceNormal.y / Mathf.Pow(ellipse.MinorAxis / 2f, 2f), sphereSpaceNormal.z / Mathf.Pow(ellipse.MajorAxis / 2f, 2f)).normalized; Vector3 worldSpaceIntersection = ellipse.sphereToWorldSpace.MultiplyPoint(sphereSpaceIntersection); Vector3 worldSpaceNormal = ellipse.sphereToWorldSpace.MultiplyVector(sphereSpaceNormal).normalized; Ray firstBounce = new Ray(worldSpaceIntersection, Vector3.Reflect(eyeRay.direction, worldSpaceNormal)); intersectionTime = intersectPlane(Screen.forward, Screen.position, firstBounce.origin, firstBounce.direction); if (intersectionTime < 0f) { return(Vector2.zero); } Vector3 planeIntersection = firstBounce.GetPoint(intersectionTime); Vector2 ScreenUV = Screen.InverseTransformPoint(planeIntersection); if (drawer != null) { if (drawLine) { drawer.DrawLine(eyeRay.origin, worldSpaceIntersection); drawer.DrawLine(firstBounce.origin, planeIntersection); } //drawer.DrawSphere(firstBounce.origin, 0.0005f); //drawer.DrawSphere(((firstBounce.origin - eyeRay.origin) * 1f) + eyeRay.origin, 0.0005f); //drawer.DrawSphere(planeIntersection, 0.0005f); } //ScreenUV = new Vector2(Mathf.Clamp01(ScreenUV.x + 0.5f), Mathf.Clamp01(ScreenUV.y + 0.5f)); ScreenUV = new Vector2((ScreenUV.x + 0.5f), /*Mathf.Clamp01*/ (ScreenUV.y + 0.5f)); return(ScreenUV); }
public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer) { drawer.color = color; if (!_spline.HasValue || (fullPoseSpline && !_qSpline.HasValue)) { return; } int resolution = 16; float incr = 1f / resolution; Vector3?lastPos = null; for (float t = 0; t <= 1f; t += incr) { var pos = _spline.Value.PositionAt(t); if (fullPoseSpline) { var rot = _qSpline.Value.RotationAt(t); drawer.DrawPose(new Pose(pos, rot), 0.01f); } if (lastPos.HasValue) { drawer.DrawLine(lastPos.Value, pos); } lastPos = pos; } }
public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer) { if (!this.enabled || !gameObject.activeInHierarchy) { return; } drawer.color = gizmoColor; foreach (var prevPair in strokePoses.Query().WithPrevious()) { var pose = prevPair.value; var prevPose = prevPair.prev; drawer.DrawLine(prevPose.position, pose.position); } if (drawPoseGizmos) { foreach (var pose in strokePoses.GetEnumerator()) { drawer.DrawPose(pose, 0.006f); } } }
public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer) { if (!_drawStrokeGizmos) { return; // TODO REMOVE, also this function is expecting two registered pinch detectors } if (_liveStrokeMeshGenerators == null || _liveStrokeMeshGenerators[1] == null) { return; } List <MeshPoint> meshPoints = _liveStrokeMeshGenerators[1].GetSmoothMeshPoints(); List <bool> flipRegisterStates = _liveStrokeMeshGenerators[1].GetFlipRegisters(); if (_drawStrokeGizmos) { for (int i = 0; i < meshPoints.Count - 1; i++) { if (_drawStrokeLine) { drawer.color = Color.blue; drawer.DrawLine(meshPoints[i].Position, meshPoints[i + 1].Position); if (flipRegisterStates[i]) { drawer.color = Color.yellow; } drawer.DrawSphere(meshPoints[i].Position, 0.002F); } if (_drawRibbonNormals) { Vector3 normalDirection = meshPoints[i].Normal; drawer.color = new Color(1.0F, 0.4F, 0.2F); drawer.DrawLine(meshPoints[i].Position, meshPoints[i].Position + normalDirection * 0.01F); } if (_drawRibbonBinormals) { Vector3 binormalDirection = Vector3.Cross(meshPoints[i].Normal, (meshPoints[i + 1].Position - meshPoints[i].Position)).normalized; drawer.color = Color.red; drawer.DrawLine(meshPoints[i].Position - binormalDirection * 0.02F, meshPoints[i].Position + binormalDirection * 0.02F); drawer.DrawSphere(meshPoints[i].Position + binormalDirection * 0.02F, 0.001F); } } } }
public static void DrawCone(this RuntimeGizmoDrawer drawer, Vector3 pos0, Vector3 pos1, float radius, int resolution = 24) { var dir = pos1 - pos0; var R = dir.Perpendicular().normalized *radius; Quaternion rot = Quaternion.AngleAxis(360f / 24, dir); for (int i = 0; i < resolution; i++) { drawer.DrawLine(pos0 + R, pos1); var nextR = rot * R; drawer.DrawLine(pos0 + R, pos0 + nextR); R = nextR; } }
private void DrawPinchDetectorAlignmentGizmo(PinchDetector pinchDetector, RuntimeGizmoDrawer drawer) { if (_alignmentGizmoEnabled) { drawer.PushMatrix(); drawer.matrix = pinchDetector.transform.localToWorldMatrix; drawer.color = Color.red; drawer.DrawLine(Vector3.zero, Vector3.right * 0.01F); drawer.color = Color.green; drawer.DrawLine(Vector3.zero, Vector3.up * 0.01F); drawer.color = Color.blue; drawer.DrawLine(Vector3.zero, Vector3.forward * 0.01F); drawer.PopMatrix(); } }
public static float Plane(List <Vector3> points, out Vector3 position, out Vector3 normal, int iters = 200, RuntimeGizmoDrawer drawer = null) { //Find the primary principal axis Vector3 primaryDirection = Vector3.right; Line(points, out position, ref primaryDirection, iters / 2); //Flatten the points along that axis List <Vector3> flattenedPoints = new List <Vector3>(points); for (int i = 0; i < flattenedPoints.Count; i++) { flattenedPoints[i] = Vector3.ProjectOnPlane(points[i] - position, primaryDirection) + position; } //Find the secondary principal axis Vector3 secondaryDirection = Vector3.right; Line(flattenedPoints, out position, ref secondaryDirection, iters / 2); normal = Vector3.Cross(primaryDirection, secondaryDirection).normalized; float residualSum = 0f; foreach (Vector3 point in points) { residualSum += Vector3.Distance(point, Vector3.ProjectOnPlane(point - position, normal) + position); } if (drawer != null) { drawer.color = Color.red; //foreach (Vector3 point in points) drawer.DrawLine(point, Vector3.ProjectOnPlane(point - position, normal) + position); drawer.color = Color.blue; drawer.DrawLine(position, position + (normal * 0.02f)); drawer.DrawLine(position, position - (normal * 0.02f)); drawer.matrix = Matrix4x4.TRS(position, Quaternion.LookRotation(normal, primaryDirection), new Vector3(0.025f, 0.025f, 0.001f)); drawer.DrawWireSphere(Vector3.zero, 1f); drawer.matrix = Matrix4x4.identity; } return(residualSum); }
public static Ray traceRay(Vector3 rayDirection, ARRaytracer.OpticalSystem optics, RuntimeGizmoDrawer drawer = null) { //Debug.Log(optics.eyePosition.ToString("G3")); Vector3 sphereSpaceRayOrigin = optics.worldToSphereSpace.MultiplyPoint(optics.eyePosition); Vector3 sphereSpaceRayDirection = (optics.worldToSphereSpace.MultiplyPoint(optics.eyePosition + rayDirection) - sphereSpaceRayOrigin); sphereSpaceRayDirection = sphereSpaceRayDirection / sphereSpaceRayDirection.magnitude; float intersectionTime = ARRaytracer.intersectLineSphere(sphereSpaceRayOrigin, sphereSpaceRayDirection, Vector3.zero, 0.5f * 0.5f, false); if (intersectionTime < 0f) { Debug.Log("bad ray...."); return(new Ray()); } Vector3 sphereSpaceIntersection = sphereSpaceRayOrigin + (intersectionTime * sphereSpaceRayDirection); //Ellipsoid Normals Vector3 sphereSpaceNormal = -sphereSpaceIntersection / sphereSpaceIntersection.magnitude; sphereSpaceNormal = new Vector3( sphereSpaceNormal.x / Mathf.Pow(optics.ellipseMinorAxis / 2f, 2f), sphereSpaceNormal.y / Mathf.Pow(optics.ellipseMinorAxis / 2f, 2f), sphereSpaceNormal.z / Mathf.Pow(optics.ellipseMajorAxis / 2f, 2f)); sphereSpaceNormal /= sphereSpaceNormal.magnitude; Vector3 worldSpaceIntersection = optics.sphereToWorldSpace.MultiplyPoint(sphereSpaceIntersection); Vector3 worldSpaceNormal = optics.sphereToWorldSpace.MultiplyVector(sphereSpaceNormal); worldSpaceNormal /= worldSpaceNormal.magnitude; Ray firstBounce = new Ray(worldSpaceIntersection, Vector3.Reflect(rayDirection, worldSpaceNormal)); if (drawer != null) { //float halfDistance = constantDistance - Vector3.Distance(optics.eyePosition, firstBounce.origin); drawer.DrawLine(optics.eyePosition, firstBounce.origin); drawer.DrawLine(firstBounce.origin, firstBounce.origin + (firstBounce.direction * 0.5f)); //drawer.DrawSphere(firstBounce.origin + (firstBounce.direction * halfDistance), 0.001f); } // we just need the first bounce return(firstBounce); }
public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer) { if (drawDebugIKArm) { drawer.color = Color.red; for (int i = 0; i + 1 < armPointsIK.Length; i++) { drawer.DrawLine(armPointsIK[i], armPointsIK[i + 1]); } } }
public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer) { if (Application.isPlaying) { return; } drawer.color = LeapColor.turquoise; drawer.DrawLine(beginPosition, endPosition); }
public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer) { if (_isSimulating && _drawRuntimeGizmos) { drawer.color = Color.red; drawer.PushMatrix(); drawer.matrix = Matrix4x4.TRS(_position, _rotation, Vector3.one); drawer.DrawWireCube(Vector3.zero, Vector3.one * 0.05f); drawer.color = Color.red; drawer.DrawLine(Vector3.zero, Vector3.right * 0.10f); drawer.color = Color.green; drawer.DrawLine(Vector3.zero, Vector3.up * 0.10f); drawer.color = Color.blue; drawer.DrawLine(Vector3.zero, Vector3.forward * 0.10f); drawer.PopMatrix(); } }
void drawRayDisparity(Vector2 canonicalUV, Vector2 measuredRay, RuntimeGizmoDrawer drawer) { Vector3 refPoint1 = screenToWorld(canonicalUV); Vector3 testPoint1 = screenToWorld(raytracer.RenderUVToDisplayUV(measuredRay)); drawer.color = Color.blue; drawer.DrawLine(refPoint1, testPoint1); drawer.color = Color.green; drawer.DrawSphere(refPoint1, 0.0009f); drawer.color = Color.red; drawer.DrawSphere(testPoint1, 0.0009f); }
public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer) { if (!_drawGizmos) { return; } Vector3 basePos = this.transform.position + Vector3.up * 0.1F; drawer.color = Color.red; drawer.DrawSphere(basePos, 0.001F); drawer.color = Color.red; drawer.DrawLine(basePos, basePos + Vector3.right * _objSpacePullVectors[0].x * 0.01F); drawer.DrawLine(basePos, basePos + Vector3.right * _objSpacePullVectors[1].x * 0.01F); drawer.color = Color.green; drawer.DrawLine(basePos, basePos + Vector3.up * _objSpacePullVectors[0].y * 0.01F); drawer.DrawLine(basePos, basePos + Vector3.up * _objSpacePullVectors[1].y * 0.01F); drawer.color = Color.blue; drawer.DrawLine(basePos, basePos + Vector3.forward * _objSpacePullVectors[0].z * 0.01F); drawer.DrawLine(basePos, basePos + Vector3.forward * _objSpacePullVectors[1].z * 0.01F); drawer.color = Color.red; drawer.DrawSphere(this.transform.TransformPoint(_objSpaceHandOffsets[0]), 0.011F); drawer.DrawSphere(this.transform.TransformPoint(_objSpaceHandOffsets[1]), 0.011F); drawer.color = Color.black; drawer.DrawSphere(this.transform.TransformPoint(_objSpacePullVectors[0]), 0.013F); drawer.DrawSphere(this.transform.TransformPoint(_objSpacePullVectors[1]), 0.013F); }
public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer) { if (!this.enabled || !this.gameObject.activeInHierarchy || !drawDebug) { return; } drawer.color = LeapColor.white; for (int i = 0; i < thumbPoints.Count; i++) { drawer.DrawLine(thumbPoints[i], indexPoints[i]); } }
public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer) { if (!this._drawGizmos) { return; } drawer.color = Color.blue; drawer.RelativeTo(base.transform); for (int i = 0; i < 16; i++) { float f = (float)i / 16f * 3.14159274f * 2f; Vector3 a = new Vector3(Mathf.Cos(f) * this._tableRadius, this._tableHeight, Mathf.Sin(f) * this._tableRadius); Vector3 b = new Vector3(Mathf.Cos(f) * this._lowerLevelRadius, this._lowerLevelHeight, Mathf.Sin(f) * this._lowerLevelRadius); drawer.DrawLine(a, b); } }
public static void DrawCircle(this RuntimeGizmoDrawer drawer, Vector3 position, float radius, Vector3 planeDirection) { Vector3 perpDirection = Vector3.Cross(planeDirection, Vector3.up).normalized; if (perpDirection.magnitude < 0.99F) { perpDirection = Vector3.Cross(planeDirection, Vector3.right).normalized; } int numSegments = 64; for (int i = 0; i < numSegments; i++) { drawer.DrawLine(position + Quaternion.AngleAxis(360F * (i / (float)numSegments), planeDirection) * perpDirection * radius, position + Quaternion.AngleAxis(360F * ((i + 1) / (float)numSegments), planeDirection) * perpDirection * radius); } }
public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer) { drawer.color = Color.green; Vector3 aRay = a.position - transform.position; Vector3 bRay = b.position - transform.position; Debug.Log(gameObject.name + ": " + Vector3.Angle(aRay, bRay) + "°"); float distance = aRay.magnitude; b.position = ((b.position - transform.position).normalized * distance) + transform.position; for (float i = 0f; i < 1f; i += 0.01f) { drawer.DrawLine(((Vector3.Lerp(a.position, b.position, i) - transform.position).normalized * distance) + transform.position, ((Vector3.Lerp(a.position, b.position, i + 0.01f) - transform.position).normalized * distance) + transform.position); } }
public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer) { if (maybePoseSpline.HasValue) { var spline = maybePoseSpline.Value; drawer.color = LeapColor.brown.WithAlpha(0.4f); Vector3?prevPos = null; int numSteps = 32; int drawPosePer = 8, counter = 0; float tStep = 1f / numSteps; for (float t = 0f; t <= 1f; t += tStep) { var pose = spline.PoseAt(t); if (counter % drawPosePer == 0) { drawer.DrawPose(pose, 0.02f); } if (prevPos.HasValue) { drawer.DrawLine(prevPos.Value, pose.position); } prevPos = pose.position; counter++; } var renderPose = spline.PoseAt(renderPoseAtT); var len = 0.06f; var thick = 0.01f; drawer.PushMatrix(); drawer.matrix = Matrix4x4.TRS(renderPose.position, renderPose.rotation, Vector3.one); drawer.color = Color.red; drawer.DrawCube(Vector3.right * ((len / 2f) + (thick / 2f)), new Vector3(len, thick, thick)); drawer.color = Color.green; drawer.DrawCube(Vector3.up * ((len / 2f) + (thick / 2f)), new Vector3(thick, len, thick)); drawer.color = Color.blue; drawer.DrawCube(Vector3.forward * ((len / 2f) + (thick / 2f)), new Vector3(thick, thick, len)); } }
public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer) { if (_drawControllerRuntimeGizmos) { foreach (var controller in _interactionControllers) { if (controller != null) { controller.OnDrawRuntimeGizmos(drawer); } } foreach (PhysicsUtility.SoftContact contact in _softContactsToDraw) { drawer.DrawSphere(contact.position, 0.01f); drawer.DrawLine(contact.position, contact.position + (contact.normal * 0.02f)); } } }
public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer) { if (!_drawGizmos) { return; } drawer.color = Color.blue; drawer.RelativeTo(transform); // drawer.DrawWireCircle(new Vector3(0, _tableHeight, 0), Vector3.up, _tableRadius); // drawer.DrawWireCircle(new Vector3(0, _lowerLevelHeight, 0), Vector3.up, _lowerLevelRadius); for (int i = 0; i < 16; i++) { float angle = i / 16.0f * Mathf.PI * 2; Vector3 tablePoint = new Vector3(Mathf.Cos(angle) * _tableRadius, _tableHeight, Mathf.Sin(angle) * _tableRadius); Vector3 lowerPoint = new Vector3(Mathf.Cos(angle) * _lowerLevelRadius, _lowerLevelHeight, Mathf.Sin(angle) * _lowerLevelRadius); drawer.DrawLine(tablePoint, lowerPoint); } }
private void drawSweepGizmos(RuntimeGizmoDrawer drawer) { for (int i = 0; i < _interactorMotionsBuffer.Count; i++) { var sweep = _interactorMotionsBuffer[i]; var wasSweepIntersecting = _wasMotionIntersectingBuffer[i]; if (sweep.HasValue) { if (wasSweepIntersecting) { drawer.color = LeapColor.red; } else { drawer.color = LeapColor.amber; } drawer.DrawLine(sweep.Value.a, sweep.Value.b); } } }
public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer) { if (!enabled || !gameObject.activeInHierarchy) { return; } drawer.color = Rect.DEFAULT_GIZMO_COLOR; rect.DrawRuntimeGizmos(drawer); if (_maybeSegment.HasValue) { drawer.color = Color.white; _maybeSegment.Value.DrawRuntimeGizmos(drawer); } drawer.color = LeapColor.red; if (_maybePointOnRect.HasValue && _maybePointOnSegment.HasValue) { drawer.DrawLine(_maybePointOnRect.Value, _maybePointOnSegment.Value); } }
public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer) { //DRAW SPHERES IN EDITOR AT THE INTERSECTIONS OF THE MATCHED RAYS for (int j = 0; j < calibrationDevices.Length; j++) { if (!calibrationDevices[j].isConnected) { continue; } for (int i = 0; i < _realDots.Count; i++) { drawer.color = Color.red; _realDots[i] = calibrationDotsParent.GetChild(i).position; drawer.DrawSphere(_realDots[i], 0.01f); if (calibrationDevices[j].triangulatedDots[i] != Vector3.zero) { drawer.color = j == 1 ? Color.green : Color.blue; drawer.DrawSphere(calibrationDevices[j].triangulatedDots[i], 0.01f); drawer.color = Color.white; drawer.DrawLine(_realDots[i], calibrationDevices[j].triangulatedDots[i]); } } } }
public void DrawRuntimeGizmos(RuntimeGizmoDrawer drawer) { drawer.PushMatrix(); drawer.matrix = this.matrix; Vector3 b = localCorner01, c = localCorner11, a = localCorner00, d = localCorner10; Vector2 shrink; var invRadii = Vector3.one.CompDiv(radii.Abs()).NaNOrInfTo(0f); if (radii == Vector2.zero) { shrink = Vector2.zero; } else { shrink = Vector2.one * (radii * 0.02f).Abs().CompMin(); } int numRectLines = 8; for (int i = 0; i < numRectLines; i++) { var shrinkMul = (Vector2.one - shrink.CompMul(invRadii) * i); drawer.DrawLine(a * shrinkMul, b * shrinkMul); drawer.DrawLine(b * shrinkMul, c * shrinkMul); drawer.DrawLine(c * shrinkMul, d * shrinkMul); drawer.DrawLine(d * shrinkMul, a * shrinkMul); } drawer.DrawLine(a, c); drawer.DrawLine(b, d); //drawer.matrix = Matrix4x4.Scale(new Vector3(1f, 1f, 0f)) * this.matrix; //drawer.DrawCube(Vector3.zero, new Vector3(radii.x, radii.y, 1f)); drawer.PopMatrix(); }
public override void Draw(RuntimeGizmoDrawer drawer) { var p0 = getP0(); var p1 = getP1(); drawer.DrawLine(p0, p1); }
private void renderGizmoHand(Hand hand, PinchGesture pinchGesture, ref Color currentGizmoColor, ref float pinchOrbRadius, RuntimeGizmoDrawer drawer) { drawer.color = handColor; // Wrist. var wristPos = hand.WristPosition.ToVector3(); var wristRadius = hand.GetPinky().Length * 0.5f; var wristNormal = hand.Arm.Basis.yBasis.ToVector3(); var wristOffsetAlongNormal = hand.GetIndex().bones[3].Length; wristPos += wristNormal * wristOffsetAlongNormal; drawCircle(wristPos, wristRadius, wristNormal, drawer); // Palm. var palmPos = hand.PalmPosition.ToVector3(); var palmRadius = hand.GetMiddle().Length * 0.5f; var palmNormal = hand.PalmarAxis() * -1f; var palmOffsetAlongNormal = hand.GetIndex().bones[3].Length * 2f; palmPos += palmNormal * palmOffsetAlongNormal; drawCircle(palmPos, palmRadius, palmNormal, drawer); // Fingers. for (int fIdx = 0; fIdx < hand.Fingers.Count; fIdx++) { var finger = hand.Fingers[fIdx]; var radius = finger.bones[3].Length * 0.5f; for (int bId = 1; bId < finger.bones.Length; bId++) { var bone = finger.bones[bId]; var boneNormal = bone.Basis.yBasis.ToVector3(); var offsetAlongNormal = radius; var bonePos = bone.NextJoint.ToVector3() + boneNormal * offsetAlongNormal; drawCircle(bonePos, radius, boneNormal, drawer, 16); } } // TRS gizmos. if (leapTRS2 != null && leapTRS2.isEnabledAndConfigured) { // Wrist gizmo color. Color targetGizmoColor; if (!pinchGesture.isEligible) { targetGizmoColor = ineligibleGizmoColor; } else if (pinchGesture.isActive) { targetGizmoColor = activeGizmoColor; } else { targetGizmoColor = eligibleGizmoColor; } currentGizmoColor = currentGizmoColor.Lerp(targetGizmoColor, gizmoColorLerpSpeed * Time.deltaTime); drawer.color = currentGizmoColor; // Wrist gizmo. var wristRot = hand.Arm.Basis.rotation.ToQuaternion(); var stemLength = wristRadius * 0.55f; var stemVector = stemLength * Vector3.forward; for (int i = 0; i < 4; i++) { var stemEnd = wristPos + wristRot * stemVector; drawer.DrawLine(wristPos, stemEnd); var arrowLength = stemLength * 0.33f; var arrowPoint = stemEnd + wristRot * Vector3.right * arrowLength + wristRot * Vector3.back * arrowLength; drawer.DrawLine(arrowPoint, stemEnd); arrowPoint = stemEnd + wristRot * Vector3.left * arrowLength + wristRot * Vector3.back * arrowLength; drawer.DrawLine(arrowPoint, stemEnd); wristRot = wristRot * _trsGizmoRotator; } float targetPinchOrbRadius = 0f; if (pinchGesture != null && pinchGesture.isActive) { targetPinchOrbRadius = maxPinchOrbRadius; } pinchOrbRadius = Mathf.Lerp(pinchOrbRadius, targetPinchOrbRadius, pinchOrbLerpSpeed * Time.deltaTime); var pinchOrbColor = Color.Lerp(inactivePinchOrbColor, activePinchOrbcolor, pinchOrbRadius.Map(0f, maxPinchOrbRadius, 0f, 1f)); if (pinchOrbRadius > 0.0001f) { drawer.color = pinchOrbColor; drawer.DrawSphere(hand.GetPinchPosition(), pinchOrbRadius); } } }
public void DrawRuntimeGizmos(RuntimeGizmoDrawer drawer) { drawer.DrawLine(a, b); }