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.CircleBorderType == GizmoCircle3DBorderType.Thin) { GizmoCircularMaterial circularMaterial = GizmoCircularMaterial.Get; circularMaterial.CircularType = GizmoCircularMaterial.Type.Circle; circularMaterial.ResetValuesToSensibleDefaults(); circularMaterial.SetCamera(camera); circularMaterial.SetShapeCenter(_targetCircle.Center); circularMaterial.SetCullAlphaScale(_planeSlider.LookAndFeel.BorderCircleCullAlphaScale); circularMaterial.SetColor(color); circularMaterial.SetPass(0); _targetHandle.Render3DWire(_borderCircleIndex); } else if (_planeSlider.LookAndFeel.CircleBorderType == GizmoCircle3DBorderType.Torus) { float zoomFactor = GetZoomFactor(camera); float torusThickness = GetRealTorusThickness(zoomFactor); bool renderFilled = _planeSlider.LookAndFeel.BorderFillMode == GizmoFillMode3D.Filled; GizmoCircularMaterial circularMaterial = GizmoCircularMaterial.Get; circularMaterial.CircularType = renderFilled ? GizmoCircularMaterial.Type.Torus : GizmoCircularMaterial.Type.Circle; circularMaterial.ResetValuesToSensibleDefaults(); circularMaterial.SetCamera(camera); circularMaterial.SetShapeCenter(_targetCircle.Center); circularMaterial.SetCullAlphaScale(_planeSlider.LookAndFeel.BorderCircleCullAlphaScale); circularMaterial.SetColor(color); circularMaterial.SetTorusCoreRadius((_controllers[(int)GizmoCircle3DBorderType.Torus] as GizmoTorusCircle3DBorderController).GetTorusCoreRadius(zoomFactor)); circularMaterial.SetTorusTubeRadius(torusThickness * 0.5f); circularMaterial.SetLit(_planeSlider.LookAndFeel.BorderShadeMode == GizmoShadeMode.Lit); if (circularMaterial.IsLit) { circularMaterial.SetLightDirection(camera.transform.forward); } circularMaterial.SetPass(0); if (renderFilled) { _targetHandle.Render3DSolid(_borderTorusIndex); } else { _borderTorus.WireRenderDesc.NumAxialSlices = _planeSlider.LookAndFeel.NumBorderTorusWireAxialSlices; _targetHandle.Render3DWire(_borderTorusIndex); } } else if (_planeSlider.LookAndFeel.CircleBorderType == GizmoCircle3DBorderType.CylindricalTorus) { float zoomFactor = GetZoomFactor(camera); float torusWidth = GetRealCylTorusWidth(zoomFactor); float torusHeight = GetRealCylTorusHeight(zoomFactor); bool renderFilled = _planeSlider.LookAndFeel.BorderFillMode == GizmoFillMode3D.Filled; GizmoCircularMaterial circularMaterial = GizmoCircularMaterial.Get; circularMaterial.CircularType = renderFilled ? GizmoCircularMaterial.Type.CylindricalTorus : GizmoCircularMaterial.Type.Circle; circularMaterial.ResetValuesToSensibleDefaults(); circularMaterial.SetCamera(camera); circularMaterial.SetShapeCenter(_targetCircle.Center); circularMaterial.SetCullAlphaScale(_planeSlider.LookAndFeel.BorderCircleCullAlphaScale); circularMaterial.SetColor(color); circularMaterial.SetTorusCoreRadius((_controllers[(int)GizmoCircle3DBorderType.CylindricalTorus] as GizmoCylindricalTorusCircle3DBorderController).GetTorusCoreRadius(zoomFactor)); circularMaterial.SetCylindricalTorusRadii(torusWidth * 0.5f, torusHeight * 0.5f); circularMaterial.SetLit(_planeSlider.LookAndFeel.BorderShadeMode == GizmoShadeMode.Lit); if (circularMaterial.IsLit) { circularMaterial.SetLightDirection(camera.transform.forward); } circularMaterial.SetPass(0); if (renderFilled) { _targetHandle.Render3DSolid(_borderCylTorusIndex); } else { _targetHandle.Render3DWire(_borderCylTorusIndex); } } }
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); } } } }