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 void Render(Camera camera)
        {
            if (!IsVisible)
            {
                return;
            }

            Color color = _planeSlider.LookAndFeel.BorderColor;

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

            GizmoLineMaterial lineMaterial = GizmoLineMaterial.Get;

            lineMaterial.ResetValuesToSensibleDefaults();
            lineMaterial.SetColor(color);
            lineMaterial.SetPass(0);

            if (_planeSlider.LookAndFeel.PolygonBorderType == GizmoPolygon2DBorderType.Thin)
            {
                _targetHandle.Render2DWire(camera, _borderPolygonIndex);
            }
            else if (_planeSlider.LookAndFeel.PolygonBorderType == GizmoPolygon2DBorderType.Thick)
            {
                _targetHandle.Render2DWire(camera, _thickBorderPolygonIndex);
            }
        }
Пример #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);
            }
        }
Пример #4
0
        public void Render(IEnumerable <GameObject> gameObjects, Camera camera)
        {
            if (gameObjects == null)
            {
                return;
            }

            GizmoLineMaterial material = GizmoLineMaterial.Get;

            material.ResetValuesToSensibleDefaults();

            foreach (GameObject 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);
            }
        }
Пример #5
0
        public override void OnGizmoRender(Camera camera)
        {
            GizmoLineMaterial boxWireMaterial = GizmoLineMaterial.Get;

            boxWireMaterial.ResetValuesToSensibleDefaults();
            boxWireMaterial.SetColor(LookAndFeel3D.BoxWireColor);
            boxWireMaterial.SetPass(0);
            GraphicsEx.DrawWireBox(new OBB(BoxCenter, _boxSize, BoxRotation));

            if (RTGizmosEngine.Get.NumRenderCameras > 1)
            {
                UpdateTickPositions();
            }

            _leftTick.Render(camera);
            _rightTick.Render(camera);
            _topTick.Render(camera);
            _bottomTick.Render(camera);
            _frontTick.Render(camera);
            _backTick.Render(camera);
        }
        public void Render(Camera camera)
        {
            if (!IsVisible)
            {
                return;
            }

            Color color = _planeSlider.LookAndFeel.BorderColor;

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

            GizmoLineMaterial lineMaterial = GizmoLineMaterial.Get;

            lineMaterial.ResetValuesToSensibleDefaults();
            lineMaterial.SetColor(color);
            lineMaterial.SetPass(0);

            _targetHandle.Render2DWire(camera, _borderCircleIndex);
        }
Пример #7
0
        public override void OnGizmoRender(Camera camera)
        {
            GizmoLineMaterial boxWireMaterial = GizmoLineMaterial.Get;

            boxWireMaterial.ResetValuesToSensibleDefaults();
            boxWireMaterial.SetColor(LookAndFeel3D.BoxWireColor);
            boxWireMaterial.SetPass(0);
            GraphicsEx.DrawWireBox(OBB);

            bool multipleRenderCams = RTGizmosEngine.Get.NumRenderCameras > 1;

            if (multipleRenderCams)
            {
                _extrudeSliders.ApplyZoomFactor(camera);
                UpdateExtrudeSliderTransforms();
            }

            List <GizmoLineSlider3D> sortedSliders = _extrudeSliders.GetRenderSortedSliders(camera);

            foreach (GizmoLineSlider3D slider in sortedSliders)
            {
                slider.Render(camera);
            }
        }
        public void Render(Camera camera)
        {
            if (!IsVisible)
            {
                return;
            }

            Color color = _planeSlider.LookAndFeel.BorderColor;

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

            if (_planeSlider.LookAndFeel.RATriangleBorderType == GizmoRATriangle3DBorderType.Thin)
            {
                GizmoLineMaterial lineMaterial = GizmoLineMaterial.Get;
                lineMaterial.ResetValuesToSensibleDefaults();
                lineMaterial.SetColor(color);
                lineMaterial.SetPass(0);

                _targetHandle.Render3DWire(_borderTriangleIndex);
            }
        }
Пример #9
0
        /// <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);
            }
        }
Пример #10
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)
            {
                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);
                    }
                }
            }
        }
Пример #11
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);
            }
        }
Пример #12
0
        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);
        }
Пример #13
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);
                    }
                }
            }
        }