public override void RenderArea(Camera camera)
 {
     if (_areBorderPointsDirty)
     {
         OnBorderPointsFoundDirty();
     }
     GLRenderer.DrawTriangleFan2D(_origin, _borderPoints, camera);
 }
示例#2
0
 public override void RenderBorder(Camera camera)
 {
     if (_areModelBorderPointsDirty)
     {
         CalcModelBorderPoints();
     }
     GLRenderer.DrawLines2D(_modelBorderPoints, _center, Vector2Ex.FromValue(_radius), camera);
 }
示例#3
0
 public override void RenderArea(Camera camera)
 {
     if (_areModelBorderPointsDirty)
     {
         CalcModelBorderPoints();
     }
     GLRenderer.DrawTriangleFan2D(ModelCenter, _modelBorderPoints, _center, Vector2Ex.FromValue(_radius), camera);
 }
 public override void RenderSolid()
 {
     if (_areBorderPointsDirty)
     {
         OnBorderPointsFoundDirty();
     }
     GLRenderer.DrawTriangleFan3D(_origin, _borderPoints);
 }
        public override void RenderArea(Camera camera)
        {
            var     cornerPoints = QuadMath.Calc2DQuadCornerPoints(_center, _size, _rotationDegrees);
            Vector2 topLeft      = cornerPoints[(int)QuadCorner.TopLeft];

            cornerPoints.RemoveAt((int)QuadCorner.TopLeft);

            GLRenderer.DrawTriangleFan2D(topLeft, cornerPoints, camera);
        }
        public override void RenderArea(Camera camera)
        {
            var     points = GetPoints();
            Vector2 origin = points[0];

            points.RemoveAt(0);

            GLRenderer.DrawTriangleFan2D(origin, points, camera);
        }
        public override void RenderWire()
        {
            Vector3    circleMeshScale = new Vector3(_radius, _radius, 1.0f);
            Quaternion circleRotation  = _rotation * Quaternion.AngleAxis(90.0f, Vector3.right);

            Graphics.DrawMeshNow(MeshPool.Get.UnitWireCircleXY, Matrix4x4.TRS(_baseCenter, circleRotation, circleMeshScale));
            Graphics.DrawMeshNow(MeshPool.Get.UnitWireCircleXY, Matrix4x4.TRS(TopCenter, circleRotation, circleMeshScale));

            var bottomCapPts = GetBottomCapExtentPoints();
            var topCapPts    = GetTopCapExtentPoints();

            GLRenderer.DrawLinePairs3D(new List <Vector3>()
            {
                bottomCapPts[0], topCapPts[0], bottomCapPts[1], topCapPts[1], bottomCapPts[2], topCapPts[2], bottomCapPts[3], topCapPts[3],
            });
        }
        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);
            }
        }
        public void Render(IEnumerable <GameObject> gameObjects, Camera camera)
        {
            if (gameObjects == null)
            {
                return;
            }

            var material = GizmoLineMaterial.Get;

            material.ResetValuesToSensibleDefaults();

            foreach (var gameObj in gameObjects)
            {
                Transform transform  = gameObj.transform;
                Vector3   axesOrigin = transform.position;
                Vector3   right      = transform.right;
                Vector3   up         = transform.up;
                Vector3   look       = transform.forward;

                float zoomFactor = 1.0f;
                if (LookAndFeel.UseZoomFactor)
                {
                    zoomFactor = camera.EstimateZoomFactor(axesOrigin);
                }
                float axisLength = LookAndFeel.AxisLength * zoomFactor;

                Vector3 startPt = axesOrigin - right * axisLength;
                Vector3 endPt   = axesOrigin + right * axisLength;
                material.SetColor(LookAndFeel.XAxisColor);
                material.SetPass(0);
                GLRenderer.DrawLine3D(startPt, endPt);

                startPt = axesOrigin - up * axisLength;
                endPt   = axesOrigin + up * axisLength;
                material.SetColor(LookAndFeel.YAxisColor);
                material.SetPass(0);
                GLRenderer.DrawLine3D(startPt, endPt);

                startPt = axesOrigin - look * axisLength;
                endPt   = axesOrigin + look * axisLength;
                material.SetColor(LookAndFeel.ZAxisColor);
                material.SetPass(0);
                GLRenderer.DrawLine3D(startPt, endPt);
            }
        }
        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 override void RenderBorder(Camera camera)
        {
            if (_areBorderPointsDirty)
            {
                OnBorderPointsFoundDirty();
            }

            if ((_borderRenderDesc.BorderFlags & BorderRenderFlags.ArcBorder) != 0)
            {
                GLRenderer.DrawLines2D(_borderPoints, camera);
            }
            if ((_borderRenderDesc.BorderFlags & BorderRenderFlags.ExtremitiesBorder) != 0)
            {
                GLRenderer.DrawLines2D(new List <Vector2>()
                {
                    _origin, StartPoint, _origin, EndPoint
                }, camera);
            }
        }
        public override void RenderBorder(Camera camera)
        {
            var points = GetPoints();

            GLRenderer.DrawLineLoop2D(points, camera);
        }
 public override void RenderArea(Camera camera)
 {
     GLRenderer.DrawLine2D(_startPoint, _endPoint, camera);
 }
示例#14
0
        public void Render(GizmoRotationArc2DLookAndFeel lookAndFeel, Camera camera)
        {
            if (_type == ArcType.Standard || _projectionPoly == null)
            {
                _arc.ForceShortestArc = lookAndFeel.UseShortestRotation;
                if ((lookAndFeel.FillFlags & GizmoRotationArcFillFlags.Area) != 0)
                {
                    GizmoSolidMaterial solidMaterial = GizmoSolidMaterial.Get;
                    solidMaterial.ResetValuesToSensibleDefaults();
                    solidMaterial.SetCullModeOff();
                    solidMaterial.SetLit(false);
                    solidMaterial.SetColor(lookAndFeel.Color);
                    solidMaterial.SetPass(0);
                    _arc.RenderArea(camera);
                }

                ArcShape2D.BorderRenderFlags arcWireFlags = ArcShape2D.BorderRenderFlags.None;
                if ((lookAndFeel.FillFlags & GizmoRotationArcFillFlags.ArcBorder) != 0)
                {
                    arcWireFlags |= ArcShape2D.BorderRenderFlags.ArcBorder;
                }
                if ((lookAndFeel.FillFlags & GizmoRotationArcFillFlags.ExtremitiesBorder) != 0)
                {
                    arcWireFlags |= ArcShape2D.BorderRenderFlags.ExtremitiesBorder;
                }

                GizmoLineMaterial lineMaterial = GizmoLineMaterial.Get;
                lineMaterial.ResetValuesToSensibleDefaults();
                lineMaterial.SetColor(lookAndFeel.BorderColor);
                lineMaterial.SetPass(0);
                _arc.RenderBorder(camera);
            }
            else
            if (_type == ArcType.PolyProjected && _projectionPoly != null)
            {
                var arcBorderPoints = PrimitiveFactory.Generate2DArcBorderPoints(_arc.Origin, _arc.StartPoint, _arc.DegreeAngleFromStart, lookAndFeel.UseShortestRotation, NumProjectedPoints);
                arcBorderPoints = PrimitiveFactory.ProjectArcPointsOnPoly2DBorder(_arc.Origin, arcBorderPoints, _projectionPoly.GetPoints());

                if ((lookAndFeel.FillFlags & GizmoRotationArcFillFlags.Area) != 0)
                {
                    GizmoSolidMaterial solidMaterial = GizmoSolidMaterial.Get;
                    solidMaterial.ResetValuesToSensibleDefaults();
                    solidMaterial.SetCullModeOff();
                    solidMaterial.SetLit(false);
                    solidMaterial.SetColor(lookAndFeel.Color);
                    solidMaterial.SetPass(0);

                    GLRenderer.DrawTriangleFan2D(_arc.Origin, arcBorderPoints, camera);
                }

                if (lookAndFeel.FillFlags != GizmoRotationArcFillFlags.None)
                {
                    GizmoLineMaterial lineMaterial = GizmoLineMaterial.Get;
                    lineMaterial.ResetValuesToSensibleDefaults();
                    lineMaterial.SetColor(lookAndFeel.BorderColor);
                    lineMaterial.SetPass(0);

                    if ((lookAndFeel.FillFlags & GizmoRotationArcFillFlags.ArcBorder) != 0)
                    {
                        GLRenderer.DrawLines2D(arcBorderPoints, camera);
                    }

                    if ((lookAndFeel.FillFlags & GizmoRotationArcFillFlags.ExtremitiesBorder) != 0)
                    {
                        GLRenderer.DrawLines2D(new List <Vector2> {
                            _arc.Origin, arcBorderPoints[0], _arc.Origin, arcBorderPoints[arcBorderPoints.Count - 1]
                        }, camera);
                    }
                }
            }
        }
示例#15
0
        public override void RenderBorder(Camera camera)
        {
            var cornerPoints = QuadMath.Calc2DQuadCornerPoints(_center, _size, _rotationDegrees);

            GLRenderer.DrawLineLoop2D(cornerPoints, camera);
        }
 public override void RenderBorder(Camera camera)
 {
     GLRenderer.DrawLineLoop2D(new List <Vector2> {
         BaseLeft, Tip, BaseRight
     }, camera);
 }
 public override void RenderArea(Camera camera)
 {
     GLRenderer.DrawTriangleFan2D(BaseLeft, new List <Vector2> {
         Tip, BaseRight
     }, camera);
 }
 public override void RenderWire()
 {
     GLRenderer.DrawLine3D(_startPoint, _endPoint);
 }
示例#19
0
 public override void RenderArea(Camera camera)
 {
     GLRenderer.DrawTriangleFan2D(GetEncapsulatingRect().center, _cwPolyPoints, camera);
 }
        public override void Render(Camera camera)
        {
            if (!IsVisible)
            {
                return;
            }

            Color color = new Color();

            if (!OverrideColor.IsActive)
            {
                if (Gizmo.IsHovered && Gizmo.HoverInfo.HandleId == HandleId)
                {
                    color = LookAndFeel.HoveredColor;
                }
                else
                {
                    color = LookAndFeel.Color;
                }
            }
            else
            {
                color = OverrideColor.Color;
            }

            if (LookAndFeel.FillMode == GizmoFillMode3D.Filled)
            {
                bool isLit = LookAndFeel.ShadeMode == GizmoShadeMode.Lit;

                GizmoSolidMaterial solidMaterial = GizmoSolidMaterial.Get;
                solidMaterial.ResetValuesToSensibleDefaults();
                solidMaterial.SetLit(isLit);
                if (isLit)
                {
                    solidMaterial.SetLightDirection(camera.transform.forward);
                }
                solidMaterial.SetColor(color);
                solidMaterial.SetPass(0);

                Handle.Render3DSolid();
            }
            else
            {
                GizmoLineMaterial lineMaterial = GizmoLineMaterial.Get;
                lineMaterial.ResetValuesToSensibleDefaults();
                lineMaterial.SetColor(color);
                lineMaterial.SetPass(0);

                Handle.Render3DWire();
            }

            if (LookAndFeel.CapType == GizmoCap3DType.Sphere && LookAndFeel.IsSphereBorderVisible)
            {
                GizmoLineMaterial lineMaterial = GizmoLineMaterial.Get;
                lineMaterial.ResetValuesToSensibleDefaults();
                lineMaterial.SetColor(LookAndFeel.SphereBorderColor);
                lineMaterial.SetPass(0);

                GLRenderer.DrawSphereBorder(camera, Position, GetRealSphereRadius(GetZoomFactor(camera)), LookAndFeel.NumSphereBorderPoints);
            }
        }