Ejemplo n.º 1
0
        public void InitSceneControl(EditorItemSelection selection)
        {
            this.selection = selection;

            // subscribe to our editor select change events
            selection.SelectionChanged += Selection_SelectionChanged;
            sceneTreeView.AfterSelect  += SceneTreeView_AfterSelect;
        }
Ejemplo n.º 2
0
        public bool TransformGizmoMove(System.Drawing.Point mouseDelta, EditorCamera cam, EditorItemSelection selectedItems)
        {
            bool result = false;

            // Returns false if no actual movement happened
            if (!Enabled)
            {
                return(false);
            }

            float xChange = mouseDelta.X / 2 * cam.MoveSpeed;
            float yChange = mouseDelta.Y / 2 * cam.MoveSpeed;

            if (xChange == 0 && yChange == 0)
            {
                return(false);
            }

            Item    firstItem       = selectedItems.Get(0);
            Vector2 gizmoMouseInput = new Vector2(xChange, yChange);

            switch (Mode)
            {
            case TransformMode.TRANFORM_MOVE:
                // Move selected items
                foreach (Item item in selectedItems.Items)
                {
                    Vertex backuppos = item.Position.Clone();
                    item.Position = Move(gizmoMouseInput,
                                         item.Position.ToVector3(), cam).ToVertex();
                    // Update item bounds
                    if (item is LevelItem)
                    {
                        LevelItem levelItem = item as LevelItem;
                        Vertex    newpos    = item.Position;
                        levelItem.Bounds.Center.X += newpos.X - backuppos.X;
                        levelItem.Bounds.Center.Y += newpos.Y - backuppos.Y;
                        levelItem.Bounds.Center.Z += newpos.Z - backuppos.Z;
                    }
                    result = true;
                }
                // Update gizmo position
                SetGizmo(
                    ((Pivot == Pivot.CenterOfMass) ? firstItem.Bounds.Center : firstItem.Position).ToVector3(),
                    firstItem.TransformMatrix);
                return(result);

            case TransformMode.TRANSFORM_ROTATE:
                // rotate all of our editor selected items
                foreach (Item item in selectedItems.Items)
                {
                    item.Rotation = Rotate(gizmoMouseInput, cam, item.Rotation);
                    result        = true;
                }
                SetGizmo(
                    ((Pivot == Pivot.CenterOfMass) ? firstItem.Bounds.Center : firstItem.Position).ToVector3(),
                    firstItem.TransformMatrix);
                return(result);

            case TransformMode.TRANSFORM_SCALE:
                // scale all of our editor selected items
                foreach (Item item in selectedItems.Items)
                {
                    if (item is IScaleable scalableItem)
                    {
                        // Scaling speed for SET items
                        float speed = 1.0f;

                        // Non-SET items should have slower scaling
                        if (item is LevelItem || item is DeathZoneItem)
                        {
                            speed = 0.01f;
                        }

                        scalableItem.SetScale(Scale(gizmoMouseInput, scalableItem.GetScale(), cam, true, 0, speed));
                    }
                    result = true;
                }
                SetGizmo(
                    ((Pivot == Pivot.CenterOfMass) ? firstItem.Bounds.Center : firstItem.Position).ToVector3(),
                    firstItem.TransformMatrix);
                return(result);

            case TransformMode.NONE:
            default:
                return(false);
            }
        }
Ejemplo n.º 3
0
        private void Selection_SelectionChanged(EditorItemSelection sender)
        {
            if (suppressSelectionEvents)
            {
                return;
            }

            // match our tree to our editor selection
            List <TreeNode> selectedNodes = new List <TreeNode>();

            foreach (Item item in sender.Items)
            {
                if (item is LevelItem)
                {
                    LevelItem levelItem = (LevelItem)item;

                    // find the index of the level item
                    int index = LevelData.GetIndexOfItem(levelItem);

                    selectedNodes.Add(levelItemNode.Nodes[index]);
                }
                else if (item is LevelAnim)
                {
                    LevelAnim levelAnim = (LevelAnim)item;

                    // find the index of the level animation
                    int index = LevelData.GetIndexOfItem(levelAnim);

                    selectedNodes.Add(levelAnimNode.Nodes[index]);
                }
                else if (item is DeathZoneItem)
                {
                    DeathZoneItem deathZoneItem = (DeathZoneItem)item;

                    int index = LevelData.DeathZones.IndexOf(deathZoneItem);

                    selectedNodes.Add(deathZoneNode.Nodes[index]);
                }
                else if (item is MissionSETItem)
                {
                    MissionSETItem miSetItem = (MissionSETItem)item;

                    int index = LevelData.MissionSETItems[LevelData.Character].IndexOf(miSetItem);

                    selectedNodes.Add(missionSETNode.Nodes[index]);
                }
                else if (item is SETItem)
                {
                    SETItem setItem = (SETItem)item;

                    int index = LevelData.GetIndexOfSETItem(LevelData.Character, setItem);                    //LevelData.SETItems[LevelData.Character].IndexOf(setItem);

                    selectedNodes.Add(setNode.Nodes[index]);
                }
                else if (item is CAMItem)
                {
                    CAMItem camItem = (CAMItem)item;

                    int index = LevelData.CAMItems[LevelData.Character].IndexOf(camItem);

                    selectedNodes.Add(camNode.Nodes[index]);
                }
                else if (item is SplineData)
                {
                    SplineData spline = (SplineData)item;

                    int index = LevelData.LevelSplines.IndexOf(spline);

                    selectedNodes.Add(splineNode.Nodes[index]);
                }
            }

            sceneTreeView.SelectedNodes = selectedNodes;
        }
Ejemplo n.º 4
0
 public DuplicateTo(EditorItemSelection items)
 {
     InitializeComponent();
     this.items = items;
 }