コード例 #1
0
        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);
        }
コード例 #2
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));
        }
コード例 #3
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);
        }
 public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer)
 {
     if (time > 0f)
     {
         drawer.DrawSphere(transform.TransformPoint(pos), 0.05f);
     }
 }
コード例 #5
0
        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);
                    }
                }
            }
        }
コード例 #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
        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;
        }
コード例 #8
0
        public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer)
        {
            if (!Application.isEditor || !drawRuntimeGizmos || !enabled)
            {
                return;
            }
            if (!Input.GetMouseButton(0))
            {
                Ray     cameraRay = mainCamera.ScreenPointToRay(curMousePosition);
                Vector3 start     = filter.transform.InverseTransformPoint(cameraRay.origin);
                drawer.DrawSphere(filter.transform.TransformPoint(new Vector3(start.x, start.y, 0f)), 0.0075f);
            }

            drawer.color = Color.green;
            if (closestVertex != -1)
            {
                drawer.DrawSphere(filter.transform.TransformPoint(calibrationMesh.distortedMeshVertices[closestVertex]), 0.01f);
            }
            for (int i = 0; i < vertexIndices.Count; i++)
            {
                drawer.DrawSphere(filter.transform.TransformPoint(calibrationMesh.distortedMeshVertices[vertexIndices[i]]), 0.005f);
            }
        }
コード例 #9
0
 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]);
             }
         }
     }
 }
コード例 #10
0
ファイル: InteractionManager.cs プロジェクト: tuita520/handUI
        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));
                }
            }
        }
コード例 #11
0
        public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer)
        {
            if (stroke == null)
            {
                return;
            }
            bool colorSet = false;
            IEnumerator <StrokePoint> pointsEnum = stroke.GetPointsEnumerator();

            for (; pointsEnum.MoveNext();)
            {
                StrokePoint point = pointsEnum.Current;
                if (!colorSet)
                {
                    drawer.color = point.color;
                }
                drawer.DrawSphere(point.position, 0.01F * point.pressure);
            }
        }
コード例 #12
0
        public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer)
        {
            for (int i = 0; i < _heat.Length; i++)
            {
                _colors[i] = Color.Lerp(Color.cyan, Color.red, _heat[i]);
            }

            for (int i = 0; i < _indexPosBuffer.Count; i++)
            {
                drawer.color = _colors[i];
                float radius = 0.005F;
                if (_heat[i] > 0.8F)
                {
                    radius = 0.01F;
                }
                drawer.DrawSphere(_indexPosBuffer.Get(i), radius);
            }

            drawer.color = Color.green;
            drawer.DrawWireSphere(_lastTapPosition, 0.008F);
        }
コード例 #13
0
ファイル: GizmoHands.cs プロジェクト: masterchop/Galaxies
        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);
                }
            }
        }
コード例 #14
0
        public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer)
        {
            Quaternion beginningRot = transform.rotation;

            if (curFocalPoint.ContainsNaN())
            {
                curFocalPoint = Vector3.zero;
            }

            averagedInterSectionPoints = new List <Vector3>();

            ARRaytracer.OpticalSystem optics = raytracer.optics;

            curDrawing = 0;
            for (float yRot = -30f; yRot < 30f; yRot += 5f)
            {
                for (float xRot = -20f; xRot < 70f; xRot += 5f)
                {
                    //for (float yRot = -0f; yRot < 25f; yRot += 5f) {
                    //  for (float xRot = 5f; xRot < 35f; xRot += 5f) {
                    List <Ray> intersectRayList = new List <Ray>();

                    for (float i = 0f; i < 91; i += 90)
                    {
                        transform.rotation = Quaternion.Euler(0, 0, i);// Quaternion.Euler(xRot, yRot, i);
                        Vector3 convergencePoint = transform.position + ((Vector3.forward) +
                                                                         (Vector3.up * -xRot * 0.01f) + (Vector3.right * yRot * 0.01f)) * focalDistance;

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

                        transform.rotation = Quaternion.Euler(0, 0, i + 180f); //Quaternion.Euler(xRot, yRot, i+180f);
                        optics.eyePosition = transform.position + (transform.right * 0.001f);
                        firstBounceRay     = traceRay((convergencePoint - optics.eyePosition).normalized, optics, whichToDraw == curDrawing ? drawer : null);
                        intersectRayList.Add(firstBounceRay);
                    }

                    Vector3 intersectSum = Vector3.zero;
                    int     numPoints    = 0;

                    for (int i = 0; i < (intersectRayList.Count - 1); i += 2)
                    {
                        Vector3 tmp = Fit.ClosestPointOnRayToRay(intersectRayList[i], intersectRayList[i + 1]);
                        drawer.color = i == 0 ? LeapColor.coral : LeapColor.forest;
                        drawer.DrawSphere(tmp, 0.0005f);
                        intersectSum += tmp;

                        numPoints++;
                    }

                    Vector3 ptAverage = intersectSum / numPoints;
                    averagedInterSectionPoints.Add(ptAverage);

                    /*for (int i = 0; i < (intersectRayList.Count - 1); i += 2) {
                     * Vector3 tmp = ClosestPointOnRayToRay(intersectRayList[i], intersectRayList[i + 1]);
                     * drawer.color = LeapColor.red;
                     * drawer.DrawLine(tmp, ptAverage);
                     * }*/

                    //Debug.Log("Average: " + ptAverage);
                    curDrawing++;
                }
            }

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

            //drawer.color = LeapColor.periwinkle;
            //for (int i = 0; i < averagedInterSectionPoints.Count; i++) drawer.DrawSphere(averagedInterSectionPoints[i], .0005f);

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

            Fit.Plane(averagedInterSectionPoints, out position, out normal, 200, drawer);
            newScreen.position = Vector3.ProjectOnPlane(newScreen.position - position, normal) + position;
            newScreen.rotation = Quaternion.FromToRotation(newScreen.forward, normal) * newScreen.rotation;

            //log the continous fit to the console
            ///Debug.Log("Position is " + position + "  normal is " + normal);
            transform.rotation = beginningRot;

            Vector2 CornerOneUV   = ARRaytracer.DisplayUVToRenderUV(new Vector2(0f, 0f), optics, 80);
            Vector2 CornerTwoUV   = ARRaytracer.DisplayUVToRenderUV(new Vector2(1f, 0f), optics, 80);
            Vector2 CornerThreeUV = ARRaytracer.DisplayUVToRenderUV(new Vector2(0f, 1f), optics, 80);
            Vector2 CornerFourUV  = ARRaytracer.DisplayUVToRenderUV(new Vector2(1f, 1f), optics, 80);

            drawer.matrix = Matrix4x4.identity;
            traceRay(ARRaytracer.ViewportPointToRayDirection(new Vector3(CornerOneUV.x, CornerOneUV.y, 1f),
                                                             raytracer.eyePerspective.transform.position, optics.clipToWorld), optics, drawer);
            traceRay(ARRaytracer.ViewportPointToRayDirection(new Vector3(CornerTwoUV.x, CornerTwoUV.y, 1f),
                                                             raytracer.eyePerspective.transform.position, optics.clipToWorld), optics, drawer);
            traceRay(ARRaytracer.ViewportPointToRayDirection(new Vector3(CornerThreeUV.x, CornerThreeUV.y, 1f),
                                                             raytracer.eyePerspective.transform.position, optics.clipToWorld), optics, drawer);
            traceRay(ARRaytracer.ViewportPointToRayDirection(new Vector3(CornerFourUV.x, CornerFourUV.y, 1f),
                                                             raytracer.eyePerspective.transform.position, optics.clipToWorld), optics, drawer);
        }