/// <summary>
        /// Create a shape instance
        /// </summary>
        /// <returns></returns>
        public override ShapeBase CreateShapeInstance()
        {
            // create a shape
            FmodCollisionMeshShape shape = new FmodCollisionMeshShape("Fmod - CollisionMesh");

            shape.Position = EditorManager.Scene.CurrentShapeSpawnPosition;
            return(shape);
        }
        public override ShapeBase Clone()
        {
            FmodCollisionMeshShape copy = (FmodCollisionMeshShape)base.Clone();

            System.Diagnostics.Debug.Assert(!copy.Selected); // turned off in ShapeBase

            return(copy);
        }
Exemplo n.º 3
0
        void MigrateSoundCollisionShapeProperties(ShapeObject3D oldShape, FmodCollisionMeshShape newShape)
        {
            MigrateBaseProperties(oldShape, newShape);

            // Sound-Collision specific
            newShape.MeshFilename    = (string)oldShape.GetType().GetProperty("ModelFilename").GetValue(oldShape, null);
            newShape.DirectOcclusion = (float)oldShape.GetType().GetProperty("DirectOcclusion").GetValue(oldShape, null);
            newShape.ReverbOcclusion = (float)oldShape.GetType().GetProperty("ReverbOcclusion").GetValue(oldShape, null);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        void MigrateSoundCollisionShapeProperties(ShapeObject3D oldShape, FmodCollisionMeshShape newShape)
        {
            MigrateBaseProperties(oldShape, newShape);

              // Sound-Collision specific
              newShape.MeshFilename = (string)oldShape.GetType().GetProperty("ModelFilename").GetValue(oldShape, null);
              newShape.DirectOcclusion = (float)oldShape.GetType().GetProperty("DirectOcclusion").GetValue(oldShape, null);
              newShape.ReverbOcclusion = (float)oldShape.GetType().GetProperty("ReverbOcclusion").GetValue(oldShape, null);
        }
 /// <summary>
 /// Create a shape instance
 /// </summary>
 /// <returns></returns>
 public override ShapeBase CreateShapeInstance()
 {
     // create a shape
       FmodCollisionMeshShape shape = new FmodCollisionMeshShape("Fmod - CollisionMesh");
       shape.Position = EditorManager.Scene.CurrentShapeSpawnPosition;
       return shape;
 }
Exemplo n.º 7
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);
        }