public void Render(GizmoRotationArc3DLookAndFeel lookAndFeel)
        {
            _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.RenderSolid();
            }

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

            GizmoLineMaterial lineMaterial = GizmoLineMaterial.Get;

            lineMaterial.ResetValuesToSensibleDefaults();
            lineMaterial.SetColor(lookAndFeel.BorderColor);
            lineMaterial.SetPass(0);
            _arc.RenderWire();
        }
        public override void Render(Camera camera)
        {
            if (IsRotating && LookAndFeel.PlaneType == GizmoPlane3DType.Circle && LookAndFeel.IsRotationArcVisible)
            {
                _rotationArc.RotationAngle = TotalDragRotation;
                _rotationArc.Radius        = GetRealCircleRadius(GetZoomFactor(camera));
                _rotationArc.Render(LookAndFeel.RotationArcLookAndFeel);
            }

            if (IsVisible)
            {
                Color color = new Color();
                if (!IsHovered)
                {
                    color = LookAndFeel.Color;
                }
                else
                {
                    color = LookAndFeel.HoveredColor;
                }

                GizmoSolidMaterial solidMaterial = GizmoSolidMaterial.Get;
                solidMaterial.ResetValuesToSensibleDefaults();
                solidMaterial.SetCullModeOff();
                solidMaterial.SetLit(LookAndFeel.ShadeMode == GizmoShadeMode.Lit);
                if (solidMaterial.IsLit)
                {
                    solidMaterial.SetLightDirection(camera.transform.forward);
                }
                solidMaterial.SetColor(color);
                solidMaterial.SetPass(0);

                if (LookAndFeel.PlaneType == GizmoPlane3DType.Quad)
                {
                    Handle.Render3DSolid(_quadIndex);
                }
                else if (LookAndFeel.PlaneType == GizmoPlane3DType.RATriangle)
                {
                    Handle.Render3DSolid(_raTriangleIndex);
                }
                else if (LookAndFeel.PlaneType == GizmoPlane3DType.Circle)
                {
                    Handle.Render3DSolid(_circleIndex);
                }
            }

            if (LookAndFeel.PlaneType == GizmoPlane3DType.Quad)
            {
                _quadBorder.Render(camera);
            }
            else if (LookAndFeel.PlaneType == GizmoPlane3DType.RATriangle)
            {
                _raTriangleBorder.Render(camera);
            }
            else if (LookAndFeel.PlaneType == GizmoPlane3DType.Circle)
            {
                _circleBorder.Render(camera);
            }
        }
Esempio n. 3
0
        public override void Render(Camera camera)
        {
            if (!IsVisible)
            {
                return;
            }

            if (LookAndFeel.FillMode == GizmoFillMode2D.FilledAndBorder ||
                LookAndFeel.FillMode == GizmoFillMode2D.Filled)
            {
                Color fillColor = new Color();
                if (!_overrideFillColor.IsActive)
                {
                    fillColor = LookAndFeel.Color;
                    if (Gizmo.HoverHandleId == HandleId)
                    {
                        fillColor = LookAndFeel.HoveredColor;
                    }
                }
                else
                {
                    fillColor = _overrideFillColor.Color;
                }

                GizmoSolidMaterial solidMaterial = GizmoSolidMaterial.Get;
                solidMaterial.ResetValuesToSensibleDefaults();
                solidMaterial.SetLit(false);
                solidMaterial.SetColor(fillColor);
                solidMaterial.SetPass(0);

                Handle.Render2DSolid(camera);
            }

            if (LookAndFeel.FillMode == GizmoFillMode2D.FilledAndBorder ||
                LookAndFeel.FillMode == GizmoFillMode2D.Border)
            {
                Color borderColor = new Color();
                if (!_overrideFillColor.IsActive)
                {
                    borderColor = LookAndFeel.BorderColor;
                    if (Gizmo.HoverHandleId == HandleId)
                    {
                        borderColor = LookAndFeel.HoveredBorderColor;
                    }
                }
                else
                {
                    borderColor = _overrideBorderColor.Color;
                }

                GizmoLineMaterial lineMaterial = GizmoLineMaterial.Get;
                lineMaterial.ResetValuesToSensibleDefaults();
                lineMaterial.SetColor(borderColor);
                lineMaterial.SetPass(0);

                Handle.Render2DWire(camera);
            }
        }
Esempio n. 4
0
        public override void Render(Camera camera)
        {
            if (!IsVisible && !IsBorderVisible)
            {
                return;
            }

            if (IsRotating && LookAndFeel.IsRotationArcVisible &&
                (LookAndFeel.PlaneType == GizmoPlane2DType.Circle || LookAndFeel.PlaneType == GizmoPlane2DType.Polygon) &&
                camera == Gizmo.FocusCamera)
            {
                _rotationArc.RotationAngle = TotalDragRotation;
                _rotationArc.Render(LookAndFeel.RotationArcLookAndFeel, camera);
            }

            if (IsVisible &&
                (LookAndFeel.FillMode == GizmoFillMode2D.Filled ||
                 LookAndFeel.FillMode == GizmoFillMode2D.FilledAndBorder))
            {
                Color fillColor = LookAndFeel.Color;
                if (Gizmo.HoverHandleId == HandleId)
                {
                    fillColor = LookAndFeel.HoveredColor;
                }

                GizmoSolidMaterial solidMaterial = GizmoSolidMaterial.Get;
                solidMaterial.ResetValuesToSensibleDefaults();
                solidMaterial.SetLit(false);
                solidMaterial.SetColor(fillColor);
                solidMaterial.SetPass(0);
                Handle.Render2DSolid(camera);
            }

            if (IsBorderVisible &&
                (LookAndFeel.FillMode == GizmoFillMode2D.Border ||
                 LookAndFeel.FillMode == GizmoFillMode2D.FilledAndBorder))
            {
                if (LookAndFeel.PlaneType == GizmoPlane2DType.Quad)
                {
                    _quadBorder.Render(camera);
                }
                else if (LookAndFeel.PlaneType == GizmoPlane2DType.Circle)
                {
                    _circleBorder.Render(camera);
                }
                else if (LookAndFeel.PlaneType == GizmoPlane2DType.Polygon)
                {
                    _polygonBorder.Render(camera);
                }
            }
        }
        /// <summary>
        /// Renders the slider with the specified camera. This function should be called
        /// directly or indirectly from a Monobehaviour's 'OnRenderObject' function.
        /// </summary>
        public override void Render(Camera camera)
        {
            if (!IsVisible && !Is3DCapVisible)
            {
                return;
            }

            Color color = new Color();

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

            if (LookAndFeel.IsRotationArcVisible && IsRotating)
            {
                _rotationArc.RotationAngle = _rotationDrag.TotalRotation;
                _rotationArc.Radius        = GetRealLength(GetZoomFactor(camera));
                _rotationArc.Render(LookAndFeel.RotationArcLookAndFeel);
            }

            bool renderCapFirst = !camera.IsPointFacingCamera(GetRealEndPosition(GetZoomFactor(camera)), GetRealDirection());

            if (Is3DCapVisible && renderCapFirst)
            {
                _cap3D.Render(camera);
            }

            if (IsVisible)
            {
                if (LookAndFeel.FillMode == GizmoFillMode3D.Filled)
                {
                    bool isLit = LookAndFeel.ShadeMode == GizmoShadeMode.Lit && LookAndFeel.LineType != GizmoLine3DType.Thin;

                    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 (Is3DCapVisible && !renderCapFirst)
            {
                _cap3D.Render(camera);
            }
        }
        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)
            {
                List <Vector2> 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);
                    }
                }
            }
        }
Esempio n. 7
0
        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);
            }
        }
        public override void Render(Camera camera)
        {
            if (!IsVisible && !Is2DCapVisible)
            {
                return;
            }

            if (LookAndFeel.IsRotationArcVisible && IsRotating)
            {
                _rotationArc.RotationAngle = _rotationDrag.TotalRotation;
                _rotationArc.Render(LookAndFeel.RotationArcLookAndFeel, camera);
            }

            if (IsVisible)
            {
                if (LookAndFeel.LineType == GizmoLine2DType.Thin ||
                    LookAndFeel.FillMode == GizmoFillMode2D.FilledAndBorder ||
                    LookAndFeel.FillMode == GizmoFillMode2D.Filled)
                {
                    Color fillColor = new Color();
                    if (!_overrideFillColor.IsActive)
                    {
                        fillColor = LookAndFeel.Color;
                        if (Gizmo.HoverHandleId == HandleId)
                        {
                            fillColor = LookAndFeel.HoveredColor;
                        }
                    }
                    else
                    {
                        fillColor = _overrideFillColor.Color;
                    }

                    GizmoSolidMaterial solidMaterial = GizmoSolidMaterial.Get;
                    solidMaterial.ResetValuesToSensibleDefaults();
                    solidMaterial.SetLit(false);
                    solidMaterial.SetColor(fillColor);
                    solidMaterial.SetPass(0);

                    Handle.Render2DSolid(camera);
                }

                if (LookAndFeel.LineType != GizmoLine2DType.Thin &&
                    (LookAndFeel.FillMode == GizmoFillMode2D.FilledAndBorder || LookAndFeel.FillMode == GizmoFillMode2D.Border))
                {
                    Color borderColor = new Color();
                    if (!_overrideFillColor.IsActive)
                    {
                        borderColor = LookAndFeel.BorderColor;
                        if (Gizmo.HoverHandleId == HandleId)
                        {
                            borderColor = LookAndFeel.HoveredBorderColor;
                        }
                    }
                    else
                    {
                        borderColor = _overrideBorderColor.Color;
                    }

                    GizmoLineMaterial lineMaterial = GizmoLineMaterial.Get;
                    lineMaterial.ResetValuesToSensibleDefaults();
                    lineMaterial.SetColor(borderColor);
                    lineMaterial.SetPass(0);

                    Handle.Render2DWire(camera);
                }
            }

            _cap2D.Render(camera);
        }
Esempio n. 9
0
        public void Render(Camera camera)
        {
            if (!IsVisible)
            {
                return;
            }

            GizmoPlaneSlider3DLookAndFeel lookAndFeel = _planeSlider.LookAndFeel;
            Color color = lookAndFeel.BorderColor;

            if (Gizmo.HoverHandleId == _targetHandle.Id)
            {
                color = lookAndFeel.HoveredBorderColor;
            }

            if (lookAndFeel.QuadBorderType == GizmoQuad3DBorderType.Thin)
            {
                GizmoLineMaterial lineMaterial = GizmoLineMaterial.Get;
                lineMaterial.ResetValuesToSensibleDefaults();
                lineMaterial.SetColor(color);
                lineMaterial.SetPass(0);

                _targetHandle.Render3DWire(_borderQuadIndex);
            }
            else
            {
                GizmoSolidMaterial solidMaterial = GizmoSolidMaterial.Get;
                solidMaterial.ResetValuesToSensibleDefaults();
                solidMaterial.SetColor(color);
                solidMaterial.SetLit(lookAndFeel.BorderShadeMode == GizmoShadeMode.Lit);
                if (solidMaterial.IsLit)
                {
                    solidMaterial.SetLightDirection(camera.transform.forward);
                }
                solidMaterial.SetPass(0);

                Vector3 camPos = camera.transform.position;
                _sortedBoxIndices.Sort(delegate(int i0, int i1)
                {
                    BoxShape3D b0 = _targetHandle.Get3DShape(i0) as BoxShape3D;
                    BoxShape3D b1 = _targetHandle.Get3DShape(i1) as BoxShape3D;

                    float d0 = (b0.Center - camPos).sqrMagnitude;
                    float d1 = (b1.Center - camPos).sqrMagnitude;

                    return(d1.CompareTo(d0));
                });

                if (lookAndFeel.BorderFillMode == GizmoFillMode3D.Filled)
                {
                    foreach (int boxIndex in _sortedBoxIndices)
                    {
                        _targetHandle.Render3DSolid(boxIndex);
                    }
                }
                else
                {
                    foreach (int boxIndex in _sortedBoxIndices)
                    {
                        _targetHandle.Render3DWire(boxIndex);
                    }
                }
            }
        }