コード例 #1
0
        public SortShapesIntoZonesAction(ShapeCollection shapes, ZoneCollection zones)
            : base("Sort shapes into zones")
        {
            _zones = zones;
            if (_zones == null)
            {
                _zones = EditorManager.Scene.Zones;
            }

            foreach (ShapeBase shape in shapes)
            {
                Layer layer            = GetBestLayer(shape);
                bool  bIsExternalLayer = !EditorManager.Scene.Layers.Contains(shape.ParentLayer);

                if (layer == shape.ParentLayer) // do not re-assign, just leave in the layer
                {
                    continue;
                }
                if (layer == null)
                {
                    layer = GetBestLayer(shape); // see again why this failed (debug)
                    layer = GetUnAssignedLayer(shape);
                }

                if (bIsExternalLayer)
                {
                    shape.ChildIndex = -1;
                    this.Add(AddShapeAction.CreateAddShapeAction(shape, layer.Root, layer, false));
                }
                else
                {
                    this.Add(new SetShapeParentAction(shape, layer.Root));
                }
            }
        }
コード例 #2
0
        public override void ExecutePlugin()
        {
            string modelFile = null;

            // when running tests we don't want file selection dialog to pop up.
            if (!TestManager.IsRunning)
            {
                modelFile = @"Models\curtainmedi.V3O"; // default model file
                if (!EditorManager.EngineManager.File_Exists(modelFile))
                {
                    // show a file open dialog to select a model file
                    OpenFileDlg fileDlg = new OpenFileDlg();
                    fileDlg.Caption          = "Selecting the Cloth Model File";
                    fileDlg.Description      = "Please select the cloth model file you want to use and press OK to continue.";
                    fileDlg.InitialDirectory = EditorManager.Project.ProjectDir;
                    fileDlg.Filter           = new string[] { ".model" };
                    if (fileDlg.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                    modelFile = fileDlg.FileName;
                }
            }
            ClothObjectShape shape = new ClothObjectShape("ClothObject", modelFile);

            shape.Position = EditorManager.Scene.CurrentShapeSpawnPosition;
            Layer layer = EditorManager.Scene.ActiveLayer;

            EditorManager.Actions.Add(AddShapeAction.CreateAddShapeAction(shape, layer.ActiveShape, layer, true));
        }
コード例 #3
0
        void AddVolumeVertex(CustomVolumeShape volume, Vector3F position)
        {
            CustomVolumeVertex vertex = new CustomVolumeVertex();

            EditorManager.Actions.Add(AddShapeAction.CreateAddShapeAction(vertex, volume, volume.ParentLayer, true));
            vertex.CreateEngineInstance(true);
            vertex.Position = position;
        }
コード例 #4
0
        void LoadEntityShapeTestScene()
        {
            TestManager.Helpers.OpenSceneFromFile(Path.Combine(TestManager.Helpers.TestDataDir, @"EntityShapeTest\EntityShapeTest.scene"));

            _entityShape = new EntityShape("TestEntity");
            Layer layer = EditorManager.Scene.ActiveLayer;

            EditorManager.Actions.Add(AddShapeAction.CreateAddShapeAction(_entityShape, null, layer, false));
        }
コード例 #5
0
        public void TestVolumeStaticMesh()
        {
            TestManager.Helpers.OpenSceneFromFile(Path.Combine(TestManager.Helpers.TestDataDir, @"CustomVolumeShapeTests\empty.scene"));

            CustomVolumeShape volume = new CustomVolumeShape();
            Layer             layer  = EditorManager.Scene.ActiveLayer;

            EditorManager.Actions.Add(AddShapeAction.CreateAddShapeAction(volume, null, layer, false));
            volume.Preview          = true;
            volume.CustomStaticMesh = true;
            volume.StaticMeshPath   = "Meshes\\kugel.vmesh";
            volume.Scaling          = new Vector3F(20.0f, 20.0f, 20.0f);

            DynLightShape light = new DynLightShape("test light");

            light.LightType = LightSourceType_e.Point;
            light.Position  = EditorManager.Scene.CurrentShapeSpawnPosition;
            EditorManager.Actions.Add(AddShapeAction.CreateAddShapeAction(light, null, layer, false));

            ShapeComponent component = CreateLightClippingComponent(volume);

            EditorManager.Actions.Add(new AddShapeComponentAction(light, component));

            for (int i = 0; i < 60; i++)
            {
                EditorManager.ActiveView.UpdateView(true);
            }

            bool success = EditorManager.Scene.SaveAs("volume.scene");

            Assert.IsTrue(success);
            EditorManager.Scene.Close();
            TestManager.Helpers.OpenSceneFromFile(Path.Combine(TestManager.Helpers.TestDataDir, @"CustomVolumeShapeTests\volume.scene"));

            for (int i = 0; i < 60; i++)
            {
                EditorManager.EngineManager.WriteText2D(10.0f, 10.0f, "This is the saved version", VisionColors.White);
                EditorManager.ActiveView.UpdateView(true);
            }

            EditorManager.Scene.ExportScene(null, null);
            EditorManager.Scene.Close();
            EditorManager.Scene = null;
            TestManager.Helpers.LoadExportedScene("volume.vscene");
            for (int i = 0; i < 60; i++)
            {
                EditorManager.EngineManager.WriteText2D(10.0f, 10.0f, "This is the exported version", VisionColors.White);
                EditorManager.ActiveView.UpdateView(true);
            }

            EditorManager.EditorMode = EditorManager.Mode.EM_NONE;
            TestManager.Helpers.CloseExportedScene();
            TestManager.Helpers.CloseActiveProject();
        }
コード例 #6
0
        /// <summary>
        /// Overridden function to insert a vertex
        /// </summary>
        /// <param name="view"></param>
        public override void OnClicked(VisionViewBase view)
        {
            base.OnClicked(view);

            CustomVolumeVertex newVertex = new CustomVolumeVertex();

            newVertex.ChildIndex = _insert;
            EditorManager.Actions.Add(AddShapeAction.CreateAddShapeAction(newVertex, Volume, Volume.ParentLayer, false));
            newVertex.Position = Position;

            EditorManager.ActiveView.Gizmo.SetSingleShape(newVertex, false);
        }
コード例 #7
0
        public override bool OnMouseClick()
        {
            bool bUpdate = base.OnMouseClick();

            if (_keyMod == KeyModifier.Ctrl)
            {
                Vector3F startRay, endRay;
                Vector3F hitPoint = new Vector3F();
                EditorManager.EngineManager.GetRayAtScreenPos(out startRay, out endRay, MouseX, MouseY, EditorManager.Settings.MaxPickingDistance);
                if (EditorManager.EngineManager.GetTraceHit(startRay, endRay, ref hitPoint))
                {
                    CustomVolumeVertex vertex = new CustomVolumeVertex();
                    EditorManager.Actions.Add(AddShapeAction.CreateAddShapeAction(vertex, _shape, _shape.ParentLayer, true));
                    vertex.CreateEngineInstance(true);
                    vertex.Position = hitPoint;
                    bUpdate         = true;
                }
            }

            return(bUpdate);
        }
コード例 #8
0
        /// <summary>
        /// This function converts all shapes from the old SoundPlugin to the corresponding shapes of the new FmodPlugin
        /// </summary>
        void MigrateToFmodShapes()
        {
            // If old Sound plugin is not loaded, don't do anything
            IEditorPluginModule soundPlugin = EditorManager.GetPluginByName("SoundEditorPlugin.EditorPlugin");

            if (soundPlugin == null || !soundPlugin.Initialized)
            {
                return;
            }

            // collect all sound specific shapes
            ShapeCollection soundShapes = new ShapeCollection();

            foreach (Layer layer in EditorManager.Scene.Layers)
            {
                if (layer.Modifiable && layer.Loaded)
                {
                    AddSoundShapesRecursive(soundShapes, layer.Root);
                }
            }

            if (soundShapes.Count == 0)
            {
                return;
            }

            // prompt a dialog
            DialogResult res = EditorManager.ShowMessageBox("Shapes from old Sound Plugin have been found in loaded layers.\n\nShould these be permanently converted to the corresponding shapes of the Fmod Plugin?", "Old Sound Plugin and Fmod Plugin are both loaded", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (res != DialogResult.Yes)
            {
                return;
            }

            ShapeCollection newShapes       = new ShapeCollection();
            int             iConvertedCount = 0;

            if (soundShapes.Count > 0)
            {
                GroupAction actions = new GroupAction("Migrate Sound shapes");
                foreach (ShapeObject3D oldShape in soundShapes)
                {
                    ShapeObject3D newShape = null;
                    if (oldShape.GetType().FullName == "SoundEditorPlugin.SoundShape")
                    {
                        newShape = new FmodSoundShape(oldShape.ShapeName);
                        MigrateSoundShapeProperties(oldShape, (FmodSoundShape)newShape);

                        actions.Add(AddShapeAction.CreateAddShapeAction(newShape, oldShape.Parent, oldShape.ParentLayer, false));

                        actions.Add(new MigrateSoundLinksAction(oldShape, (FmodSoundShape)newShape));
                        actions.Add(new MigrateChildrenAction(oldShape, newShape));
                        actions.Add(RemoveShapeAction.CreateRemoveShapeAction(oldShape));
                        newShapes.Add(newShape);
                    }
                    else if (oldShape.GetType().FullName == "SoundEditorPlugin.SoundCollisionShape")
                    {
                        newShape = new FmodCollisionMeshShape(oldShape.ShapeName);
                        MigrateSoundCollisionShapeProperties(oldShape, (FmodCollisionMeshShape)newShape);

                        actions.Add(AddShapeAction.CreateAddShapeAction(newShape, oldShape.Parent, oldShape.ParentLayer, false));
                        actions.Add(new MigrateChildrenAction(oldShape, newShape));
                        actions.Add(RemoveShapeAction.CreateRemoveShapeAction(oldShape));
                        newShapes.Add(newShape);
                    }
                    if (newShape == null)
                    {
                        continue;
                    }

                    iConvertedCount++;
                }

                // EditorManager.Actions.Add() is not used, in order to prevent a undo of the conversion
                actions.Do();
            }

            // ensure, that all migrated childs have valid engine instances
            foreach (ShapeBase shape in newShapes)
            {
                foreach (ShapeBase child in shape.ChildCollection)
                {
                    child.ReCreateEngineInstance(true);
                }
            }

            EditorManager.ShowMessageBox(iConvertedCount.ToString() + " Shape(s) have been successfully converted.", "Sound to Fmod shapes conversion", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }