Esempio n. 1
0
        public override void RenderWire()
        {
            Vector3 coneTip = Tip;

            if (_wireRenderDesc.WireMode == WireRenderMode.Basic)
            {
                Graphics.DrawMeshNow(MeshPool.Get.UnitWireCircleXY, Matrix4x4.TRS(_baseCenter,
                                                                                  _rotation * Quaternion.AngleAxis(90.0f, Vector3.right), new Vector3(_baseRadius, _baseRadius, 1.0f)));

                List <Vector3> baseExtents = GetBaseExtents();
                GLRenderer.DrawLines3D(new List <Vector3>()
                {
                    baseExtents[0], coneTip, baseExtents[1], coneTip, baseExtents[2], coneTip, baseExtents[3], coneTip
                });
            }
            else
            {
                // Axial rings
                Vector3    centralAxis    = CentralAxis;
                Quaternion circleRotation = Quaternion.AngleAxis(90.0f, Vector3.right);
                float      upStep         = _height / (_wireRenderDesc.NumDetailAxialRings - 1);
                float      tan            = _height / Mathf.Max(_baseRadius, 1e-5f);

                for (int ringIndex = 0; ringIndex < _wireRenderDesc.NumDetailAxialRings; ++ringIndex)
                {
                    float   upOffset        = upStep * (float)ringIndex;
                    Vector3 ringCenter      = _baseCenter + centralAxis * upStep * (float)ringIndex;
                    float   ringRadius      = (_height - upOffset) / tan;
                    Vector3 circleMeshScale = new Vector3(ringRadius, ringRadius, 1.0f);
                    Graphics.DrawMeshNow(MeshPool.Get.UnitWireCircleXY, Matrix4x4.TRS(ringCenter, circleRotation, circleMeshScale));
                }

                // Axial segments
                var   axialSegmentPts = new List <Vector3>(_wireRenderDesc.NumDetailAxialSegments * 2);
                float angleStep       = 360.0f / (float)_wireRenderDesc.NumDetailAxialSegments;
                for (int segIndex = 0; segIndex < _wireRenderDesc.NumDetailAxialSegments; ++segIndex)
                {
                    Vector3 pivotAxis  = (Quaternion.AngleAxis(segIndex * angleStep, centralAxis) * Vector3.right).normalized;
                    Vector3 ptOnBorder = _baseCenter + pivotAxis * _baseRadius;
                    axialSegmentPts.Add(ptOnBorder);
                    axialSegmentPts.Add(coneTip);
                }
                GLRenderer.DrawLines3D(axialSegmentPts);
            }
        }
Esempio n. 2
0
        public override void RenderWire()
        {
            if (_areBorderPointsDirty)
            {
                OnBorderPointsFoundDirty();
            }

            if ((_wireRenderDesc.WireFlags & WireRenderFlags.ArcBorder) != 0)
            {
                GLRenderer.DrawLines3D(_borderPoints);
            }
            if ((_wireRenderDesc.WireFlags & WireRenderFlags.ExtremitiesBorder) != 0)
            {
                GLRenderer.DrawLines3D(new List <Vector3>()
                {
                    _origin, StartPoint, _origin, EndPoint
                });
            }
        }
        public void Render()
        {
            if (SharedLookAndFeel == null)
            {
                return;
            }

            if (IsActive && _grabSurfaceInfo.SurfaceType != GrabSurfaceType.Invalid)
            {
                Material material = MaterialPool.Get.SimpleColor;
                if (SharedLookAndFeel.DrawAnchorLines)
                {
                    List <Vector3> linePoints = new List <Vector3>(_grabTargets.Count * 2);
                    foreach (GrabTarget grabTarget in _grabTargets)
                    {
                        linePoints.Add(grabTarget.Transform.position);
                        linePoints.Add(_grabSurfaceInfo.AnchorPoint);
                    }

                    material.SetZTestAlways();
                    material.SetColor(_sharedLookAndFeel.AnchorLineColor);
                    material.SetPass(0);
                    GLRenderer.DrawLines3D(linePoints);
                }

                if (SharedLookAndFeel.DrawObjectBoxes)
                {
                    material.SetZTestLess();
                    material.SetColor(SharedLookAndFeel.ObjectBoxWireColor);
                    material.SetPass(0);

                    ObjectBounds.QueryConfig boundsQConfig = GetObjectBoundsQConfig();
                    foreach (GrabTarget grabTarget in _grabTargets)
                    {
                        OBB obb = ObjectBounds.CalcHierarchyWorldOBB(grabTarget.GameObject, boundsQConfig);
                        if (obb.IsValid)
                        {
                            GraphicsEx.DrawWireBox(obb);
                        }
                    }
                }

                if (SharedLookAndFeel.DrawObjectPosTicks)
                {
                    material.SetColor(SharedLookAndFeel.ObjectPosTickColor);
                    material.SetPass(0);

                    foreach (GrabTarget grabTarget in _grabTargets)
                    {
                        Vector2 screenPos = Camera.current.WorldToScreenPoint(grabTarget.Transform.position);
                        GLRenderer.DrawRect2D(RectEx.FromCenterAndSize(screenPos, Vector2Ex.FromValue(SharedLookAndFeel.ObjectPosTickSize)), Camera.current);
                    }
                }

                if (SharedLookAndFeel.DrawAnchorPosTick)
                {
                    material.SetColor(SharedLookAndFeel.AnchorPosTickColor);
                    material.SetPass(0);

                    Vector2 anchorScreenPos = Camera.current.WorldToScreenPoint(_grabSurfaceInfo.AnchorPoint);
                    GLRenderer.DrawRect2D(RectEx.FromCenterAndSize(anchorScreenPos, Vector2Ex.FromValue(SharedLookAndFeel.AnchorPosTickSize)), Camera.current);
                }
            }
        }