Exemplo n.º 1
0
        public static void AttachObjects(PositionedObject child, PositionedObject parent)
        {
            if (parent == null || parent == child)
            {
                return;
            }

            if (child.Parent != null)
            {
                child.Detach();
            }

            if (child.IsParentOf(parent))
            {
                // A parent is trying to attach to its child.  Not allowed!
                System.Windows.Forms.MessageBox.Show("The current object is a parent of " + parent.Name + ". This operation is not allowed");
                return;
            }

            child.AttachTo(parent, true);

            GuiData.ToolsWindow.attachSprite.Unpress();
            GuiData.ToolsWindow.detachSpriteButton.Enabled    = true;
            GuiData.ToolsWindow.setRootAsControlPoint.Enabled = true;
        }
        void OnRemoveAllAnimationOk(Window callingWindow)
        {
            SelectedObject.Animate = false;

            for (int i = SelectedObject.Children.Count - 1; i > -1; i--)
            {
                PositionedObject child = SelectedObject.Children[i];

                if (!string.IsNullOrEmpty(child.ParentBone))
                {
                    child.Detach();
                }
            }
        }
Exemplo n.º 3
0
        void OnDrag(object sender, EventArgs e)
        {
            if (InputManager.Mouse.IsOwnerFocused)
            {
                //If there is an element
                if (mCurrentSelectedElementRuntime != null)
                {
                    if (mCurrentAction == ActionType.Scale)
                    {
                        mScalingHandles.Scale();
                    }
                    //Move
                    else if (mCurrentAction == ActionType.Move)
                    {
                        //If the element is something else (such as part of an entity)
                        if (mCurrentSelectedElementRuntime.DirectObjectReference != null && mCurrentSelectedElementRuntime.DirectObjectReference is PositionedObject && mCurrentSelectedElementRuntime.ReferencedFileRuntimeList.LoadedScenes.Count == 0 && mCurrentSelectedElementRuntime.ReferencedFileRuntimeList.LoadedShapeCollections.Count == 0)
                        {
                            PositionedObject element = (PositionedObject)mCurrentSelectedElementRuntime.DirectObjectReference;
                            PositionedObject parent  = element.Parent;

                            element.Detach();
                            element.X += GuiManager.Cursor.WorldXChangeAt(0, mLayers[entityControlControls.LayerComboBox.SelectedIndex]);
                            element.Y += GuiManager.Cursor.WorldYChangeAt(0, mLayers[entityControlControls.LayerComboBox.SelectedIndex]);
                            element.AttachTo(parent, true);
                        }
                        //Else, just move the element
                        else
                        {
                            PositionedObject parent = mCurrentSelectedElementRuntime.Parent;
                            mCurrentSelectedElementRuntime.Detach();
                            mCurrentSelectedElementRuntime.X += GuiManager.Cursor.WorldXChangeAt(0, mLayers[entityControlControls.LayerComboBox.SelectedIndex]);
                            mCurrentSelectedElementRuntime.Y += GuiManager.Cursor.WorldYChangeAt(0, mLayers[entityControlControls.LayerComboBox.SelectedIndex]);
                            mCurrentSelectedElementRuntime.AttachTo(parent, true);
                        }
                    }
                    //Rotate
                    else if (mCurrentAction == ActionType.Rotate)
                    {
                    }
                }
            }
        }
Exemplo n.º 4
0
        private static void DetachAndMoveParentToOrigin(PositionedObject asPositionedObject, PositionedObject parent, ref Vector3 oldParentPosition, ref Matrix oldParentRotation)
        {
            if (parent != null)
            {
                asPositionedObject.Detach();

                oldParentPosition = parent.Position;
                oldParentRotation = parent.RotationMatrix;

                parent.Position = new Vector3();

                if (parent is Camera)
                {
                    parent.Z = 40;
                }
                parent.RotationMatrix = Matrix.Identity;
            }
        }