//FIXME [HS:6411] [Test] public void CreatingTerrain() { //Check whether terrain shape is in scene Assert.IsTrue(IsTerrainInScene()); //Remove Terrain EditorManager.Actions.Add(RemoveShapeAction.CreateRemoveShapeAction(TerrainEditor.CurrentTerrain)); //Check that terrain shape is NOT in scene Assert.IsTrue(!IsTerrainInScene()); //Add again EditorManager.GetShapeCreatorPluginByNameAndCategory("Geometry", "Terrain").ExecutePlugin(); TestManager.Helpers.ProcessEvents(); //Undo of Add Terrain is unsupported! EditorManager.Actions.Reset(); //Check whether terrain shape is in scene Assert.IsTrue(IsTerrainInScene()); // Test the various painting methods PaintTerrain(TerrainManaged.HeightmapEditMode_e.Elevate, 300, 128, 4); PaintTerrain(TerrainManaged.HeightmapEditMode_e.Flatten, 300, 128, 4); PaintTerrain(TerrainManaged.HeightmapEditMode_e.Elevate, 300, 128, 3); PaintTerrain(TerrainManaged.HeightmapEditMode_e.Flatten, 300, 128, 3); PaintTerrain(TerrainManaged.HeightmapEditMode_e.Elevate, 300, 128, 3); SmoothTerrain(300, 128); //Toggle lighting bool lighting = TerrainEditor.DirectionalLighting; TerrainEditor.DirectionalLighting = !TerrainEditor.DirectionalLighting; Assert.AreEqual(TerrainEditor.DirectionalLighting, !lighting); EditorManager.ActiveView.UpdateView(true); TerrainEditor.DirectionalLighting = !TerrainEditor.DirectionalLighting; Assert.AreEqual(TerrainEditor.DirectionalLighting, lighting); EditorManager.ActiveView.UpdateView(true); //Change lighting dir & color Vector3F dir = new Vector3F(0.0f, 0.2f, -0.8f); dir.Normalize(); TerrainEditor.CurrentTerrain.EngineTerrain.SetDirectionalLightProperties(dir, System.Drawing.Color.FromArgb(96, 64, 32), System.Drawing.Color.FromArgb(196, 128, 96)); //Undo/redo test (everything) while (EditorManager.Actions.Undo()) { } while (EditorManager.Actions.Redo()) { } //Verify redone state (e.g. at least that the terrain exists) Assert.IsTrue(IsTerrainInScene()); }
/// <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); }