コード例 #1
0
        public override void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer)
        {
            if (Application.isPlaying)
            {
                base.OnDrawRuntimeGizmos(drawer);
            }
            else
            {
                var provider = leapProvider;
                if (provider == null)
                {
                    provider = Hands.Provider;
                }

                if (_testHand == null && provider != null)
                {
                    _testHand = provider.MakeTestHand(this.isLeft);
                }

                // Hover Point
                _unwarpedHandData = _testHand; // hoverPoint is driven by this backing variable
                drawHoverPoint(drawer, hoverPoint);

                // Primary Hover Points
                for (int i = 0; i < NUM_FINGERS; i++)
                {
                    if (enabledPrimaryHoverFingertips[i])
                    {
                        drawPrimaryHoverPoint(drawer, _testHand.Fingers[i].TipPosition.ToVector3());
                    }
                }
            }
        }
コード例 #2
0
ファイル: MeshGridRepeater.cs プロジェクト: ccdump/Paint-1
    public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer)
    {
        if (!drawDebug || !this.enabled || !this.gameObject.activeInHierarchy)
        {
            return;
        }

        drawer.PushMatrix();

        drawer.matrix = Matrix4x4.TRS(this.transform.position, this.transform.rotation, this.transform.lossyScale);

        foreach (var gridPoint in new GridPointEnumerator(gridSize, numRows, numCols))
        {
            drawer.DrawPosition(gridPoint.centerPos);
        }

        drawer.matrix = Matrix4x4.TRS(
            this.transform.position,
            this.transform.rotation,
            this.transform.lossyScale.CompMul(new Vector3(1f, 1f, 0.005f)));

        drawer.color = Color.red;
        drawer.DrawWireCube(Vector3.zero, gridSize);
        drawer.color = Color.green;
        drawer.DrawWireCube(Vector3.zero, gridSize - Vector2.one * 0.001f);
        drawer.color = Color.blue;
        drawer.DrawWireCube(Vector3.zero, gridSize - Vector2.one * 0.002f);

        drawer.PopMatrix();
    }
コード例 #3
0
 public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer)
 {
     if (!enabled || !gameObject.activeInHierarchy || !drawGizmos)
     {
         return;
     }
     DrawEllipse(drawer, Foci1.position, Foci2.position, MinorAxis);
 }
コード例 #4
0
        public void drawCorrespondence(Vector3 canonicalPos, Vector3 measuredPos, RuntimeGizmoDrawer drawer)
        {
            Vector3 canonicalViewport = raytracer.eyePerspective.WorldToViewportPoint(canonicalPos);
            Vector2 canonicalUV       = raytracer.RenderUVToDisplayUV(canonicalViewport);
            Vector3 measuredViewport  = raytracer.eyePerspective.WorldToViewportPoint(measuredPos);

            drawRayDisparity(new Vector2(canonicalUV.x, canonicalUV.y), new Vector2(measuredViewport.x, measuredViewport.y), drawer);
        }
コード例 #5
0
ファイル: GizmoHands.cs プロジェクト: masterchop/Galaxies
        private void drawCircle(Vector3 pos, float radius,
                                RuntimeGizmoDrawer drawer, int resolution = 27)
        {
            var dirToCam       = (facingCamera.transform.position - pos).normalized;
            var radialStartDir = dirToCam.Perpendicular();

            drawer.DrawWireArc(pos, dirToCam, radialStartDir, radius, 1f, resolution);
        }
コード例 #6
0
ファイル: AnchoredBehaviour.cs プロジェクト: ccdump/Paint-1
 public virtual void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer)
 {
     if (_gizmosEnabled)
     {
         drawer.color = Color.red;
         drawer.DrawSphere(_anchorTransform.transform.position, 0.005F);
     }
 }
コード例 #7
0
        private void drawButtonSurface(RuntimeGizmoDrawer drawer)
        {
            drawer.color = LeapColor.cerulean;
            buttonSurface.DrawRuntimeGizmos(drawer);

            //drawer.color = LeapColor.white;
            //hingedSurface.DrawRuntimeGizmos(drawer);
        }
コード例 #8
0
ファイル: HandAttachments.cs プロジェクト: ccdump/Paint-1
 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);
 }
コード例 #9
0
        public override bool IsGesturePoseHeld(Hand leftHand, Hand rightHand,
                                               out Vector3 positionOfInterest)
        {
            var leftHandStraightAmount  = 1f - leftHand.GetFistStrength();
            var rightHandStraightAmount = 1f - rightHand.GetFistStrength();

            var isLeftHandStraight  = leftHandStraightAmount > 0.80f;
            var isRightHandStraight = rightHandStraightAmount > 0.80f;

            if (drawHeldPoseDebug)
            {
                RuntimeGizmoDrawer drawer = null;
                if (RuntimeGizmoManager.TryGetGizmoDrawer(out drawer))
                {
                    drawer.DrawBar(leftHandStraightAmount,
                                   Vector3.down * 0.2f + Vector3.left * 0.20f,
                                   Vector3.up,
                                   isLeftHandStraight ?
                                   LeapColor.white
                        : LeapColor.amber,
                                   scale: 0.2f);
                    drawer.DrawBar(rightHandStraightAmount,
                                   Vector3.down * 0.2f + Vector3.left * 0.10f,
                                   Vector3.up,
                                   isRightHandStraight ?
                                   LeapColor.white
                         : LeapColor.brown,
                                   scale: 0.2f);
                }
            }

            var areThumbsParallel = Vector3.Angle(leftHand.RadialAxis(),
                                                  rightHand.RadialAxis()) < MAX_ALIGNED_ANGLE;

            var leftMiddleTip            = leftHand.Fingers[2].TipPosition.ToVector3();
            var rightMiddleTip           = rightHand.Fingers[2].TipPosition.ToVector3();
            var areMiddleFingersTouching = (leftMiddleTip - rightMiddleTip)
                                           .sqrMagnitude < MAX_TOUCHING_DISTANCE_SQR;

            var handsAngle = Vector3.SignedAngle(rightHand.DistalAxis(),
                                                 leftHand.DistalAxis(),
                                                 rightHand.RadialAxis());
            var areHandsInUpwardTriangle = handsAngle.IsBetween(30f, 135f);

            positionOfInterest = Vector3.zero;
            bool isGesturePoseHeld = isLeftHandStraight &&
                                     isRightHandStraight &&
                                     areThumbsParallel &&
                                     areMiddleFingersTouching &&
                                     areHandsInUpwardTriangle;

            if (isGesturePoseHeld)
            {
                positionOfInterest = (leftMiddleTip + rightMiddleTip) / 2f;
            }

            return(isGesturePoseHeld);
        }
コード例 #10
0
 public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer)
 {
     if (this.enabled && this.gameObject.activeInHierarchy && drawDebug &&
         _lastRay.HasValue)
     {
         drawer.color = LeapColor.lime;
         drawer.DrawRay(_lastRay.Value.origin, _lastRay.Value.direction);
     }
 }
コード例 #11
0
        public float evaluateFocalPlane(RuntimeGizmoDrawer drawer = null)
        {
            intersectionPoints = new List <Vector3>();

            raytracer.manager.UpdateCalibrationFromObjects(true, true);
            ARRaytracer.OpticalSystem optics = raytracer.optics;

            int curDrawing = 0;

            for (float v = 0f; v < 1.1f; v += 0.1f)
            {
                for (float u = 0f; u < 1.1f; u += 0.1f)
                {
                    List <Ray> intersectRayList = new List <Ray>();

                    Vector3 convergencePoint = raytracer.eyePerspective.ViewportToWorldPoint(new Vector3(u, v, focalDistance));
                    if (drawer != null)
                    {
                        drawer.color = LeapColor.electricBlue; drawer.DrawSphere(convergencePoint, 0.005f);
                    }

                    optics.eyePosition = transform.position + (transform.right * (pupilDiameter * 0.5f));
                    Ray firstBounceRay = PointSpreadTracer.traceRay((convergencePoint - optics.eyePosition).normalized, optics, whichToDraw == curDrawing ? drawer : null);
                    intersectRayList.Add(firstBounceRay);

                    optics.eyePosition = transform.position + (transform.right * -(pupilDiameter * 0.5f));
                    firstBounceRay     = PointSpreadTracer.traceRay((convergencePoint - optics.eyePosition).normalized, optics, whichToDraw == curDrawing ? drawer : null);
                    intersectRayList.Add(firstBounceRay);

                    optics.eyePosition = transform.position + (transform.up * (pupilDiameter * 0.5f));
                    firstBounceRay     = PointSpreadTracer.traceRay((convergencePoint - optics.eyePosition).normalized, optics, whichToDraw == curDrawing ? drawer : null);
                    intersectRayList.Add(firstBounceRay);

                    optics.eyePosition = transform.position + (transform.up * -(pupilDiameter * 0.5f));
                    firstBounceRay     = PointSpreadTracer.traceRay((convergencePoint - optics.eyePosition).normalized, optics, whichToDraw == curDrawing ? drawer : null);
                    intersectRayList.Add(firstBounceRay);

                    Vector3 leftRight = PointSpreadTracer.Fit.ClosestPointOnRayToRay(intersectRayList[0], intersectRayList[1]);
                    Vector3 topBottom = PointSpreadTracer.Fit.ClosestPointOnRayToRay(intersectRayList[2], intersectRayList[3]);
                    if (drawer != null)
                    {
                        drawer.color = LeapColor.coral; drawer.DrawSphere(leftRight, 0.0005f);
                        drawer.color = LeapColor.forest; drawer.DrawSphere(topBottom, 0.0005f);
                    }

                    intersectionPoints.Add(leftRight); intersectionPoints.Add(topBottom);
                    curDrawing++;
                }
            }

            optics.eyePosition = raytracer.eyePerspective.transform.position;

            Vector3 position = Vector3.zero; Vector3 normal = Vector3.zero;

            return(PointSpreadTracer.Fit.Plane(intersectionPoints, out planePos, out planeNormal, 200, drawer));
        }
コード例 #12
0
        public void CreateDistortionMesh(RuntimeGizmoDrawer drawer = null)
        {
            if (eyePerspective == null)
            {
                eyePerspective = GetComponent <Camera>();
            }                                                                 /// 1.12f; }
            eyePerspective.aspect = aspectRatio;

            ellipse.UpdateEllipsoid();

            meshVertices.Clear();
            meshUVs.Clear();
            meshTriangles.Clear();

            //Full range = 0f - 1f
            for (float i = 0; i <= meshResolution.x; i++)
            {
                for (float j = 0; j <= meshResolution.y; j++)
                {
                    Vector2 RenderUV = new Vector2(i / meshResolution.x, j / meshResolution.y);
                    meshUVs.Add(RenderUV);
                    meshVertices.Add(RenderUVToDisplayUV(RenderUV, (i % 5 == 0 && j % 5 == 0), drawer) - (Vector2.one * 0.5f));

                    //drawer.DrawSphere(filter.transform.TransformPoint(meshVertices[meshVertices.Count - 1]), 0.005f);
                }
            }

            for (int x = 1; x <= meshResolution.x; x++)
            {
                for (int y = 1; y <= meshResolution.y; y++)
                {
                    //Adds the index of the three vertices in order to make up each of the two tris
                    meshTriangles.Add((int)meshResolution.x * x + y);           //Top right
                    meshTriangles.Add((int)meshResolution.x * x + y - 1);       //Bottom right
                    meshTriangles.Add((int)meshResolution.x * (x - 1) + y - 1); //Bottom left - First triangle
                    meshTriangles.Add((int)meshResolution.x * (x - 1) + y - 1); //Bottom left
                    meshTriangles.Add((int)meshResolution.x * (x - 1) + y);     //Top left
                    meshTriangles.Add((int)meshResolution.x * x + y);           //Top right - Second triangle
                }
            }

            _distortionMesh.SetVertices(meshVertices);
            _distortionMesh.SetUVs(0, meshUVs);
            _distortionMesh.SetTriangles(meshTriangles, 0);
            _distortionMesh.RecalculateNormals();

            if (filter != null)
            {
                filter.sharedMesh = _distortionMesh;
            }

            if (deformer != null)
            {
                deformer.InitializeMeshDeformations();
            }
        }
コード例 #13
0
        public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer)
        {
            if (!drawDebug || !this.enabled || !gameObject.activeInHierarchy)
            {
                return;
            }

            drawer.color = LeapColor.cerulean.WithAlpha(0.5f);
            drawer.DrawColliders(this.gameObject, useWireframe: false, drawTriggers: true);
        }
コード例 #14
0
 public static void DrawPoseSplineSequence(this RuntimeGizmoDrawer drawer,
                                           PoseSplineSequence poseSplines,
                                           bool drawPoses = true,
                                           bool drawSegments = true) {
   for (int i = 0; i < poseSplines.Count; i++) {
     drawer.DrawPoseSpline(poseSplines[i],
                           drawPoses: drawPoses,
                           drawSegments: drawSegments);
   }
 }
コード例 #15
0
        public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer)
        {
            Color pinchOriginColor = Color.blue;

            if (_isTipHandTracked && !brush.IsBrushing())
            {
                drawer.color = pinchOriginColor;
                drawer.DrawWireSphere(_pointBeginPosition, tipRadius);
            }
        }
コード例 #16
0
        public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer)
        {
            if (!gameObject.activeInHierarchy)
            {
                return;
            }

            drawer.color = color;
            drawer.DrawWireSphere(this.transform.position, radius);
        }
コード例 #17
0
        public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer)
        {
            this.transform.position = _leftPinchDetector.transform.position;
            this.transform.rotation = _leftPinchDetector.transform.rotation * Quaternion.Euler(_leftHandEulerRotation);
            DrawPinchDetectorAlignmentGizmo(_leftPinchDetector, drawer);

            this.transform.position = _rightPinchDetector.transform.position;
            this.transform.rotation = _rightPinchDetector.transform.rotation * Quaternion.Euler(_rightHandEulerRotation);
            DrawPinchDetectorAlignmentGizmo(_rightPinchDetector, drawer);
        }
コード例 #18
0
        public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer)
        {
            if (Application.isPlaying)
            {
                return;
            }

            drawer.color = LeapColor.turquoise;

            drawer.DrawLine(beginPosition, endPosition);
        }
コード例 #19
0
 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]);
         }
     }
 }
コード例 #20
0
 public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer)
 {
     if (eyePerspective == null)
     {
         eyePerspective = GetComponent <Camera>(); eyePerspective.aspect = 1.111f;
     }
     if (!Application.isPlaying)
     {
         CreateDistortionMesh(drawer);
     }
 }
コード例 #21
0
ファイル: UIActivator.cs プロジェクト: ccdump/Paint-1
 public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer)
 {
     if (_drawGizmos)
     {
         drawer.PushMatrix();
         drawer.matrix = this.transform.localToWorldMatrix;
         drawer.color  = Color.blue;
         drawer.DrawWireSphere(Vector3.zero, _radius);
         drawer.PopMatrix();
     }
 }
コード例 #22
0
        public void DrawRuntimeGizmos(RuntimeGizmoDrawer drawer)
        {
            Matrix4x4 m = Matrix4x4.identity;

            if (transform != null)
            {
                m = transform.localToWorldMatrix;
            }

            var origDrawerColor = drawer.color;

            Vector3 center = m.MultiplyPoint3x4(this.center);
            float   radius = m.MultiplyPoint3x4(Vector3.right).magnitude *this.radius;
            Vector3 x      = m.MultiplyVector(Vector3.right);
            Vector3 y      = m.MultiplyVector(Vector3.up);

            //Vector3 z = m.MultiplyVector(Vector3.forward); // unused

            // Sphere
            drawer.color = drawer.color.WithAlpha(origDrawerColor.a * 0.05f);
            drawer.DrawSphere(center, radius);

            // Wire lat-long sphere
            drawer.color = drawer.color.WithAlpha(origDrawerColor.a * 0.2f);
            int        latDiv = 6;
            float      latAngle = 180f / latDiv; float accumLatAngle = 0f;
            int        lonDiv    = 6;
            float      lonAngle  = 180f / lonDiv;
            Quaternion lonRot    = Quaternion.AngleAxis(lonAngle, y);
            Vector3    lonNormal = x;

            for (int i = 0; i < latDiv; i++)
            {
                accumLatAngle += latAngle;
                drawer.DrawWireArc(center: center + y * Mathf.Cos(accumLatAngle * Mathf.Deg2Rad) * radius,
                                   normal: y,
                                   radialStartDirection: x,
                                   radius: Mathf.Sin(accumLatAngle * Mathf.Deg2Rad) * radius,
                                   fractionOfCircleToDraw: 1.0f,
                                   numCircleSegments: 22);
            }
            for (int i = 0; i < latDiv; i++)
            {
                drawer.DrawWireArc(center: center,
                                   normal: lonNormal,
                                   radialStartDirection: y,
                                   radius: radius,
                                   fractionOfCircleToDraw: 1.0f,
                                   numCircleSegments: 22);
                lonNormal = lonRot * lonNormal;
            }

            drawer.color = origDrawerColor;
        }
コード例 #23
0
 public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer)
 {
     if (eyePerspective == null)
     {
         eyePerspective = GetComponent <Camera>();
     }
     if (!Application.isPlaying)
     {
         ScheduleCreateDistortionMesh(false, drawer);
     }
 }
コード例 #24
0
        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);
        }
コード例 #25
0
        public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer)
        {
            if (drawDebug)
            {
                drawer.color = LeapColor.cerulean.WithAlpha(0.5f);

                if (intersectionVolume != null)
                {
                    drawer.DrawCollider(intersectionVolume, useWireframe: false);
                }
            }
        }
コード例 #26
0
        public static void DrawWireSphere(this RuntimeGizmoDrawer drawer,
                                          Vector3 position,
                                          Quaternion rotation,
                                          float radius)
        {
            drawer.PushMatrix();

            drawer.matrix = Matrix4x4.TRS(position, rotation, Vector3.one);

            drawer.DrawWireSphere(Vector3.zero, radius);

            drawer.PopMatrix();
        }
コード例 #27
0
        private static void drawLineGizmos(RuntimeGizmoDrawer drawer)
        {
            var color = drawer.color;

            foreach (var idLinePair in _pingLines)
            {
                if (idLinePair.Value.color != color)
                {
                    color = drawer.color = idLinePair.Value.color;
                }
                idLinePair.Value.Draw(drawer);
            }
        }
コード例 #28
0
        public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer)
        {
            if (!this.enabled || !this.gameObject.activeInHierarchy)
            {
                return;
            }

            drawer.color = LeapColor.white;

            drawer.DrawPose(this.pose, radius: 0.015f);

            drawer.DrawPose(tabStubPose, radius: 0.010f);
        }
コード例 #29
0
 public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer)
 {
     if (_drawControllerRuntimeGizmos)
     {
         foreach (var controller in _interactionControllers)
         {
             if (controller != null)
             {
                 controller.OnDrawRuntimeGizmos(drawer);
             }
         }
     }
 }
コード例 #30
0
        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);
        }