public SceneGizmoAxisCap(SceneGizmo sceneGizmo, int id, AxisDescriptor gizmoAxisDesc)
            : base(sceneGizmo, id)
        {
            _axisDesc       = gizmoAxisDesc;
            _midAxisBoxFace = _axisDesc.GetAssociatedBoxFace();
            _cap.SetZoomFactorTransform(_zoomFactorTransform);

            if (_axisDesc.IsPositive)
            {
                if (_axisDesc.Index == 0)
                {
                    _labelTexture = TexturePool.Get.XAxisLabel;
                }
                else if (_axisDesc.Index == 1)
                {
                    _labelTexture = TexturePool.Get.YAxisLabel;
                }
                else
                {
                    _labelTexture = TexturePool.Get.ZAxisLabel;
                }
            }

            _colorTransition            = new ColorTransition(_color);
            _cap.Gizmo.PreUpdateBegin  += OnGizmoPreUpdateBegin;
            _cap.Gizmo.PreHandlePicked += OnGizmoHandlePicked;
            _sceneGizmo.LookAndFeel.ConnectAxisCapLookAndFeel(_cap, _axisDesc.Index, _axisDesc.Sign);
        }
Esempio n. 2
0
 public PlaneDescriptor(PlaneId planeId, PlaneQuadrantId planeQuadrant)
 {
     _id                   = planeId;
     _quadrant             = planeQuadrant;
     _firstAxisDescriptor  = PlaneIdHelper.GetFirstAxisDescriptor(planeId, planeQuadrant);
     _secondAxisDescriptor = PlaneIdHelper.GetSecondAxisDescriptor(planeId, planeQuadrant);
 }
        public Vector2 GetAxis2D(AxisDescriptor axisDesc)
        {
            Vector2 axis = _axes2D[axisDesc.Index];

            if (axisDesc.IsNegative)
            {
                axis = -axis;
            }
            return(axis);
        }
Esempio n. 4
0
        public void Map(GizmoTransform transform, int axisIndex, AxisSign axisSign)
        {
            if (transform == null || axisIndex > 1)
            {
                return;
            }

            _mappedAxisDesc = new AxisDescriptor(axisIndex, axisSign);
            _transform      = transform;
        }
Esempio n. 5
0
        public void AlignToQuadrant(GizmoTransform transform, PlaneId planeId, PlaneQuadrantId quadrantId, bool alignXToFirstAxis)
        {
            Plane plane = transform.GetPlane3D(planeId, quadrantId);

            if (alignXToFirstAxis)
            {
                AxisDescriptor secondAxisDesc = PlaneIdHelper.GetSecondAxisDescriptor(planeId, quadrantId);
                Vector3        secondAxis     = Gizmo.Transform.GetAxis3D(secondAxisDesc);
                _transform.Rotation3D = Quaternion.LookRotation(plane.normal, secondAxis);
            }
            else
            {
                AxisDescriptor firstAxisDesc = PlaneIdHelper.GetFirstAxisDescriptor(planeId, quadrantId);
                Vector3        firstAxis     = Gizmo.Transform.GetAxis3D(firstAxisDesc);
                _transform.Rotation3D = Quaternion.LookRotation(plane.normal, firstAxis);
            }
        }
        public static Vector3 GetLocalAxis(this Transform transform, AxisDescriptor axisDesc)
        {
            Vector3 axis = transform.right;

            if (axisDesc.Index == 1)
            {
                axis = transform.up;
            }
            else if (axisDesc.Index == 2)
            {
                axis = transform.forward;
            }

            if (axisDesc.Sign == AxisSign.Negative)
            {
                axis = -axis;
            }
            return(axis);
        }
        public override void OnAttached()
        {
            _sceneGizmoCamera = RTGizmosEngine.Get.CreateSceneGizmoCamera(RTFocusCamera.Get.TargetCamera, new SceneGizmoCamViewportUpdater(this));

            // Create the mid axis handle
            _midAxisHandle = new SceneGizmoMidCap(this);
            _renderSortedHandles.Add(_midAxisHandle);

            // Create the axes handles
            AxisDescriptor[] axesDescriptors = new AxisDescriptor[]
            {
                new AxisDescriptor(0, AxisSign.Positive), new AxisDescriptor(1, AxisSign.Positive),
                new AxisDescriptor(2, AxisSign.Positive), new AxisDescriptor(0, AxisSign.Negative),
                new AxisDescriptor(1, AxisSign.Negative), new AxisDescriptor(2, AxisSign.Negative)
            };
            int[] handleIds = new int[]
            {
                GizmoHandleId.SceneGizmoPositiveXAxis, GizmoHandleId.SceneGizmoPositiveYAxis,
                GizmoHandleId.SceneGizmoPositiveZAxis, GizmoHandleId.SceneGizmoNegativeXAxis,
                GizmoHandleId.SceneGizmoNegativeYAxis, GizmoHandleId.SceneGizmoNegativeZAxis
            };
            for (int axisIndex = 0; axisIndex < axesDescriptors.Length; ++axisIndex)
            {
                _axesHandles[axisIndex] = new SceneGizmoAxisCap(this, handleIds[axisIndex], axesDescriptors[axisIndex]);
                _renderSortedHandles.Add(_axesHandles[axisIndex]);
            }

            // Create the camera projection switch handle
            _camPrjSwitchLabel = new SceneGizmoCamPrjSwitchLabel(this);

            // Establish the scene gizmo's transform. These will remain unchanged.
            Gizmo.Transform.Position3D = _sceneGizmoCamera.LookAtPoint;
            Gizmo.Transform.Rotation3D = Quaternion.identity;

            // We want the scene gizmo to have the highest hover priority. This way, whatever
            // other gizmo lies behind it, the scene gizmo will be the one hovered by the cursor.
            Gizmo.GenericHoverPriority.MakeHighest();
            Gizmo.HoverPriority2D.MakeHighest();
            Gizmo.HoverPriority3D.MakeHighest();
        }