コード例 #1
0
        public override void Render(Camera camera)
        {
            var sgLookAndFeel = _sceneGizmo.LookAndFeel;
            RTSceneGizmoCamera sceneGizmoCamera = _sceneGizmo.SceneGizmoCamera;

            _cap.Render(camera);

            if (_axisDesc.IsPositive)
            {
                GizmoLabelMaterial labelMaterial = GizmoLabelMaterial.Get;
                labelMaterial.SetZWriteEnabled(false);
                labelMaterial.SetZTestLessEqual();
                labelMaterial.SetColor(ColorEx.KeepAllButAlpha(sgLookAndFeel.AxesLabelTint, _color.Value.a));
                labelMaterial.SetTexture(_labelTexture);
                labelMaterial.SetPass(0);

                Vector3 gizmoAxis  = _sceneGizmo.Gizmo.Transform.GetAxis3D(_axisDesc);
                Vector3 labelScale = Vector3Ex.FromValue(sgLookAndFeel.GetAxesLabelWorldSize(sceneGizmoCamera.Camera, _cap.Position));
                Vector3 labelPos   = _cap.Position + gizmoAxis * (labelScale.x * 0.5f);

                Vector2 labelScreenPos   = sceneGizmoCamera.Camera.WorldToScreenPoint(labelPos);
                Vector2 midAxisScreenPos = sceneGizmoCamera.Camera.WorldToScreenPoint(_sceneGizmo.SceneGizmoCamera.LookAtPoint);
                Vector2 labelScreenDir   = (labelScreenPos - midAxisScreenPos).normalized;

                float absDotCamLook = Mathf.Abs(Vector3Ex.AbsDot(sceneGizmoCamera.Look, gizmoAxis));
                labelScreenPos = labelScreenPos + Vector2.Scale(labelScreenDir, Vector2Ex.FromValue(SceneGizmoLookAndFeel.AxisLabelScreenSize)) * absDotCamLook;
                labelPos       = sceneGizmoCamera.Camera.ScreenToWorldPoint(new Vector3(labelScreenPos.x, labelScreenPos.y, (labelPos - sceneGizmoCamera.WorldPosition).magnitude));

                Quaternion labelRotation     = Quaternion.LookRotation(sceneGizmoCamera.Look, sceneGizmoCamera.Up);
                Matrix4x4  labelTransformMtx = Matrix4x4.TRS(labelPos, labelRotation, labelScale);

                Graphics.DrawMeshNow(MeshPool.Get.UnitQuadXY, labelTransformMtx);
            }
        }
コード例 #2
0
 public override void RenderArea(Camera camera)
 {
     if (_areModelBorderPointsDirty)
     {
         CalcModelBorderPoints();
     }
     GLRenderer.DrawTriangleFan2D(ModelCenter, _modelBorderPoints, _center, Vector2Ex.FromValue(_radius), camera);
 }
コード例 #3
0
 public override void RenderBorder(Camera camera)
 {
     if (_areModelBorderPointsDirty)
     {
         CalcModelBorderPoints();
     }
     GLRenderer.DrawLines2D(_modelBorderPoints, _center, Vector2Ex.FromValue(_radius), camera);
 }
コード例 #4
0
        public static Rect FromPoints(IEnumerable <Vector2> points)
        {
            Rect rect = new Rect();

            Vector2 minPt = Vector2Ex.FromValue(float.MaxValue), maxPt = Vector2Ex.FromValue(float.MinValue);

            foreach (var pt in points)
            {
                minPt = Vector2.Min(pt, minPt);
                maxPt = Vector2.Max(pt, maxPt);
            }

            rect.xMin = minPt.x;
            rect.yMin = minPt.y;
            rect.xMax = maxPt.x;
            rect.yMax = maxPt.y;

            return(rect);
        }
コード例 #5
0
        public override void UpdateEpsilons()
        {
            var quad = _data.Quad;

            quad.SizeEps = Vector2Ex.FromValue(_data.Slider.Settings.AreaHoverEps);
        }
コード例 #6
0
 public override void UpdateEpsilons()
 {
     _data.Quad.SizeEps = Vector2Ex.FromValue(_data.Slider.Settings.BoxHoverEps);
 }
 public override void UpdateEpsilons(float zoomFactor)
 {
     _data.Quad.SizeEps    = Vector2Ex.FromValue(_data.Slider.Settings.AreaHoverEps * zoomFactor);
     _data.Quad.ExtrudeEps = _data.Slider.Settings.ExtrudeHoverEps * zoomFactor;
 }