Example #1
0
        public void ToggleEnabled(bool Enable)
        {
            HandleX.GetNode <CollisionShape>("CollisionShape").Disabled = !Enable;
            HandleY.GetNode <CollisionShape>("CollisionShape").Disabled = !Enable;
            HandleZ.GetNode <CollisionShape>("CollisionShape").Disabled = !Enable;

            // Set the handles to invisible.
            HandleX.Visible = Enable;
            HandleY.Visible = Enable;
            HandleZ.Visible = Enable;
        }
Example #2
0
        /// <summary>
        /// Populates the handle variables with the relevant static bodies and
        /// sets the collision masking and visual masking.
        /// </summary>
        public void SetDefaults()
        {
            SetProcess(true);
            SetProcessPriority(0);
            EditorViewport = GetNode <Viewport>("/root/main/UI/AppWindow/EnvironmentContainer/4WayViewport/VerticalSplit/HSplit1/Viewport1/Viewport");

            HandleX = GetNode <Godot.StaticBody>("HandleX");
            HandleY = GetNode <Godot.StaticBody>("HandleY");
            HandleZ = GetNode <Godot.StaticBody>("HandleZ");

            // Set collision layers to layer 2 so the handles don't
            // collide with anything.
            HandleX.CollisionMask  = 0b11;
            HandleX.CollisionLayer = 0b11;

            HandleY.CollisionMask  = 0b11;
            HandleY.CollisionLayer = 0b11;

            HandleZ.CollisionMask  = 0b11;
            HandleZ.CollisionLayer = 0b11;

            // Set visual layers to draw handles over whole environment.
            HandleX.GetNode <MeshInstance>("Handle").Layers = 0b10;
            HandleY.GetNode <MeshInstance>("Handle").Layers = 0b10;
            HandleZ.GetNode <MeshInstance>("Handle").Layers = 0b10;

            HandleX.SetProcessUnhandledInput(true);
            HandleY.SetProcessUnhandledInput(true);
            HandleZ.SetProcessUnhandledInput(true);

            // Connect mouse enter/exit signals
            HandleX.Connect("mouse_entered", this, "OnXHandleMouseEnter");
            HandleY.Connect("mouse_entered", this, "OnYHandleMouseEnter");
            HandleZ.Connect("mouse_entered", this, "OnZHandleMouseEnter");

            HandleX.Connect("mouse_exited", this, "OnXHandleMouseExit");
            HandleY.Connect("mouse_exited", this, "OnYHandleMouseExit");
            HandleZ.Connect("mouse_exited", this, "OnZHandleMouseExit");

            HandleX.Connect("input_event", this, "InputEvent");
            HandleY.Connect("input_event", this, "InputEvent");
            HandleZ.Connect("input_event", this, "InputEvent");

            if (!EnabledByDefault)
            {
                Disable();
            }
        }
Example #3
0
        /// <summary>
        /// Similar to HighlightHandle, this sets the Material override of the specified handle to the default
        /// material for the handle.
        /// </summary>
        /// <param name="handle">
        /// Handles enum describing what handle to reset
        /// </param>
        public void UnhighlightHandle(Axis handle)
        {
            switch (handle)
            {
            case Axis.X:
                HandleX.GetNode <MeshInstance>("Handle").MaterialOverride = Materials.XHandle;
                break;

            case Axis.Y:
                HandleY.GetNode <MeshInstance>("Handle").MaterialOverride = Materials.YHandle;
                break;

            case Axis.Z:
                HandleZ.GetNode <MeshInstance>("Handle").MaterialOverride = Materials.ZHandle;
                break;

            default:
                break;
            }
        }