public override void RenderArea(Camera camera) { if (_areModelBorderPointsDirty) { CalcModelBorderPoints(); } GLRenderer.DrawTriangleFan2D(ModelCenter, _modelBorderPoints, _center, Vector2Ex.FromValue(_radius), camera); }
public override void RenderArea(Camera camera) { if (_areBorderPointsDirty) { OnBorderPointsFoundDirty(); } GLRenderer.DrawTriangleFan2D(_origin, _borderPoints, camera); }
public override void RenderBorder(Camera camera) { if (_areModelBorderPointsDirty) { CalcModelBorderPoints(); } GLRenderer.DrawLines2D(_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 void Render(Color fillColor, Color borderColor, Camera camera) { if (!_isVisible) { return; } Material material = MaterialPool.Get.SimpleColor; material.SetColor(fillColor); material.SetCullModeOff(); material.SetPass(0); GLRenderer.DrawRect2D(_enclosingRect, camera); material.SetColor(borderColor); material.SetPass(0); GLRenderer.DrawRectBorder2D(_enclosingRect, camera); }
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) { if (_borderRenderDesc.BorderType == Shape2DBorderType.Thin) GLRenderer.DrawLines2D(_cwPolyPoints, camera); else { if (_isThickBorderDirty) CalculateThickBorderPoints(); if (_borderRenderDesc.FillMode == ThickBorderFillMode.Border) { GLRenderer.DrawLines2D(_cwPolyPoints, camera); GLRenderer.DrawLines2D(_thickCwBorderPoints, camera); } else { PrimitiveFactory.PolyBorderDirection borderDir = _borderRenderDesc.Direction == Shape2DBorderDirection.Inward ? PrimitiveFactory.PolyBorderDirection.Inward : PrimitiveFactory.PolyBorderDirection.Outward; List<Vector2> quadPts = PrimitiveFactory.Generate2DPolyBorderQuadsCW(_cwPolyPoints, _thickCwBorderPoints, borderDir, _isClosed); GLRenderer.DrawQuads2D(quadPts, camera); } } }
public override void RenderBorder(Camera camera) { var points = GetPoints(); GLRenderer.DrawLineLoop2D(points, camera); }
public override void RenderBorder(Camera camera) { var cornerPoints = QuadMath.Calc2DQuadCornerPoints(_center, _size, _rotationDegrees); GLRenderer.DrawLineLoop2D(cornerPoints, camera); }
public void Render() { if (_sharedLookAndFeel == null) { return; } if (IsActive) { Material material = MaterialPool.Get.SimpleColor; if (_sharedLookAndFeel.DrawBoxes) { material.SetColor(_sharedLookAndFeel.BoxLineColor); material.SetZTestEnabled(true); material.SetPass(0); var boundsQConfig = GetObjectBoundsQConfig(); foreach (var targetObject in _targetObjects) { if (targetObject == null) { continue; } OBB worldOBB = ObjectBounds.CalcWorldOBB(targetObject, boundsQConfig); if (worldOBB.IsValid) { GraphicsEx.DrawWireBox(worldOBB); } } } Camera camera = Camera.current; Vector2 screenSnapPivot = camera.WorldToScreenPoint(_snapPivotPoint); if (_sharedLookAndFeel.PivotShapeType == PivotPointShapeType.Circle) { material.SetZTestEnabled(false); material.SetColor(_sharedLookAndFeel.PivotPointFillColor); material.SetPass(0); const int numCirclePoints = 100; List <Vector2> pivotCirclePoints = PrimitiveFactory.Generate2DCircleBorderPointsCW(screenSnapPivot, _sharedLookAndFeel.PivotCircleRadius, numCirclePoints); GLRenderer.DrawTriangleFan2D(screenSnapPivot, pivotCirclePoints, camera); if (_sharedLookAndFeel.DrawPivotBorder) { material.SetColor(_sharedLookAndFeel.PivotPointBorderColor); material.SetPass(0); GLRenderer.DrawLineLoop2D(pivotCirclePoints, camera); } } else if (_sharedLookAndFeel.PivotShapeType == PivotPointShapeType.Square) { material.SetZTestEnabled(false); material.SetColor(_sharedLookAndFeel.PivotPointFillColor); material.SetPass(0); Rect pivotRect = RectEx.FromCenterAndSize(screenSnapPivot, Vector2Ex.FromValue(_sharedLookAndFeel.PivotSquareSideLength)); GLRenderer.DrawRect2D(pivotRect, camera); if (_sharedLookAndFeel.DrawPivotBorder) { material.SetColor(_sharedLookAndFeel.PivotPointBorderColor); material.SetPass(0); GLRenderer.DrawRectBorder2D(pivotRect, 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); } }
public void Render() { if (SharedLookAndFeel == null) { return; } if (IsActive && _grabSurfaceInfo.SurfaceType != GrabSurfaceType.Invalid) { Material material = MaterialPool.Get.SimpleColor; if (SharedLookAndFeel.DrawAnchorLines) { List <Vector3> linePoints = new List <Vector3>(_grabTargets.Count * 2); foreach (GrabTarget grabTarget in _grabTargets) { linePoints.Add(grabTarget.Transform.position); linePoints.Add(_grabSurfaceInfo.AnchorPoint); } material.SetZTestAlways(); material.SetColor(_sharedLookAndFeel.AnchorLineColor); material.SetPass(0); GLRenderer.DrawLines3D(linePoints); } if (SharedLookAndFeel.DrawObjectBoxes) { material.SetZTestLess(); material.SetColor(SharedLookAndFeel.ObjectBoxWireColor); material.SetPass(0); ObjectBounds.QueryConfig boundsQConfig = GetObjectBoundsQConfig(); foreach (GrabTarget grabTarget in _grabTargets) { OBB obb = ObjectBounds.CalcHierarchyWorldOBB(grabTarget.GameObject, boundsQConfig); if (obb.IsValid) { GraphicsEx.DrawWireBox(obb); } } } if (SharedLookAndFeel.DrawObjectPosTicks) { material.SetColor(SharedLookAndFeel.ObjectPosTickColor); material.SetPass(0); foreach (GrabTarget grabTarget in _grabTargets) { Vector2 screenPos = Camera.current.WorldToScreenPoint(grabTarget.Transform.position); GLRenderer.DrawRect2D(RectEx.FromCenterAndSize(screenPos, Vector2Ex.FromValue(SharedLookAndFeel.ObjectPosTickSize)), Camera.current); } } if (SharedLookAndFeel.DrawAnchorPosTick) { material.SetColor(SharedLookAndFeel.AnchorPosTickColor); material.SetPass(0); Vector2 anchorScreenPos = Camera.current.WorldToScreenPoint(_grabSurfaceInfo.AnchorPoint); GLRenderer.DrawRect2D(RectEx.FromCenterAndSize(anchorScreenPos, Vector2Ex.FromValue(SharedLookAndFeel.AnchorPosTickSize)), Camera.current); } } }
public override void RenderWire() { GLRenderer.DrawLine3D(_startPoint, _endPoint); }
public override void RenderArea(Camera camera) { GLRenderer.DrawLine2D(_startPoint, _endPoint, camera); }
public override void RenderArea(Camera camera) { GLRenderer.DrawTriangleFan2D(GetEncapsulatingRect().center, _cwPolyPoints, 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); } } } }
public override void RenderArea(Camera camera) { GLRenderer.DrawTriangleFan2D(BaseLeft, new List <Vector2> { Tip, BaseRight }, camera); }
public override void RenderBorder(Camera camera) { GLRenderer.DrawLineLoop2D(new List <Vector2> { BaseLeft, Tip, BaseRight }, camera); }
public override void RenderBorder(Camera camera) { System.Collections.Generic.List <Vector2> cornerPoints = QuadMath.Calc2DQuadCornerPoints(_center, _size, _rotationDegrees); GLRenderer.DrawLineLoop2D(cornerPoints, camera); }