public override void UpdateTransforms(float zoomFactor) { GizmoPlaneSlider3DLookAndFeel lookAndFeel = _data.PlaneSlider.LookAndFeel; Vector3 quadRight = _data.TargetQuad.Right; Vector3 quadUp = _data.TargetQuad.Up; Vector3 quadNormal = _data.TargetQuad.Normal; float quadWidth = _data.TargetQuad.Width; float quadHeight = _data.TargetQuad.Height; System.Collections.Generic.List <Vector3> corners = _data.TargetQuad.GetCornerPoints(); Vector3 topLeft = corners[(int)QuadCorner.TopLeft]; Vector3 topRight = corners[(int)QuadCorner.TopRight]; Vector3 bottomRight = corners[(int)QuadCorner.BottomRight]; Vector3 bottomLeft = corners[(int)QuadCorner.BottomLeft]; float boxHeight = _data.Border.GetRealBoxHeight(zoomFactor); float boxDepth = _data.Border.GetRealBoxDepth(zoomFactor); BoxShape3D topLeftBox = _data.TopLeftBox; topLeftBox.AlignHeight(quadNormal); topLeftBox.AlignWidth(quadRight); topLeftBox.Width = boxDepth; topLeftBox.Height = boxHeight; topLeftBox.Depth = boxDepth; topLeftBox.SetFaceCenter(BoxFace.Left, topLeft - quadUp * topLeftBox.GetSizeAlongDirection(quadUp) * 0.5f); BoxShape3D topRightBox = _data.TopRightBox; topRightBox.AlignHeight(quadNormal); topRightBox.AlignWidth(quadRight); topRightBox.Width = boxDepth; topRightBox.Height = boxHeight; topRightBox.Depth = boxDepth; topRightBox.SetFaceCenter(BoxFace.Right, topRight - quadUp * topRightBox.GetSizeAlongDirection(quadUp) * 0.5f); BoxShape3D bottomRightBox = _data.BottomRightBox; bottomRightBox.AlignHeight(quadNormal); bottomRightBox.AlignWidth(quadRight); bottomRightBox.Width = boxDepth; bottomRightBox.Height = boxHeight; bottomRightBox.Depth = boxDepth; bottomRightBox.SetFaceCenter(BoxFace.Right, bottomRight + quadUp * bottomRightBox.GetSizeAlongDirection(quadUp) * 0.5f); BoxShape3D bottomLeftBox = _data.BottomLeftBox; bottomLeftBox.AlignHeight(quadNormal); bottomLeftBox.AlignWidth(quadRight); bottomLeftBox.Width = boxDepth; bottomLeftBox.Height = boxHeight; bottomLeftBox.Depth = boxDepth; bottomLeftBox.SetFaceCenter(BoxFace.Left, bottomLeft + quadUp * bottomLeftBox.GetSizeAlongDirection(quadUp) * 0.5f); BoxShape3D topBox = _data.TopBox; topBox.AlignHeight(quadNormal); topBox.AlignWidth(quadRight); topBox.Width = quadWidth - 2.0f * topLeftBox.GetSizeAlongDirection(quadRight); topBox.Height = boxHeight; topBox.Depth = boxDepth; topBox.SetFaceCenter(BoxFace.Left, topLeftBox.GetFaceCenter(BoxFace.Right)); BoxShape3D rightBox = _data.RightBox; rightBox.AlignHeight(quadNormal); rightBox.AlignWidth(quadUp); rightBox.Width = quadHeight - 2.0f * topRightBox.GetSizeAlongDirection(quadUp); rightBox.Height = boxHeight; rightBox.Depth = boxDepth; rightBox.SetFaceCenter(BoxFace.Right, topRightBox.GetFaceCenter(BoxFace.Back)); BoxShape3D bottomBox = _data.BottomBox; bottomBox.AlignHeight(quadNormal); bottomBox.AlignWidth(quadRight); bottomBox.Width = quadWidth - 2.0f * bottomRightBox.GetSizeAlongDirection(quadRight); bottomBox.Height = boxHeight; bottomBox.Depth = boxDepth; bottomBox.SetFaceCenter(BoxFace.Left, bottomLeftBox.GetFaceCenter(BoxFace.Right)); BoxShape3D leftBox = _data.LeftBox; leftBox.AlignHeight(quadNormal); leftBox.AlignWidth(quadUp); leftBox.Width = quadHeight - 2.0f * topLeftBox.GetSizeAlongDirection(quadUp); leftBox.Height = boxHeight; leftBox.Depth = boxDepth; leftBox.SetFaceCenter(BoxFace.Right, topLeftBox.GetFaceCenter(BoxFace.Back)); }
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); } } } }