Exemplo n.º 1
0
        /// <summary>
        /// Resolve missing plugins errors when loading the scene files.
        /// (Try to find them from our list of loaded plugins instead)
        /// </summary>
        private static System.Reflection.Assembly SceneLoader_AssemblyResolve(object sender, ResolveEventArgs args)
        {
            // extract simple plugin name from the passed "qualified full name"
            string[] splitSet         = args.Name.Split(",".ToCharArray());
            string   pluginModuleName = splitSet[0];

            // try to find the plugin in the list of global editor plugins
            IEditorPluginModule pluginModule = EditorManager.GetPluginByName(pluginModuleName);

            if (pluginModule != null)
            {
                return(pluginModule.GetType().Assembly);
            }

            return(null);
        }
Exemplo n.º 2
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.º 3
0
        /// <summary>
        /// This function converts all physX related entities/components to new Havok plugin
        /// </summary>
        void MigrateToHavokComponents()
        {
            // PhysX plugin is still loaded? Then don't do anything
            IEditorPluginModule physXPlugin = EditorManager.GetPluginByName("PhysXEditorPlugin.EditorPlugin");

            if (physXPlugin != null && physXPlugin.Initialized)
            {
                return;
            }

            // collect all physX specific components
            ShapeComponentCollection physXComponents = new ShapeComponentCollection();
            ShapeCollection          physXEntities   = new ShapeCollection();

            foreach (Layer layer in EditorManager.Scene.Layers)
            {
                if (layer.Modifiable && layer.Loaded)
                {
                    AddPhysXComponentsRecursive(physXComponents, physXEntities, layer.Root);
                }
            }

            if (physXComponents.Count == 0 && physXEntities.Count == 0)
            {
                return;
            }

            // prompt a dialog
            DialogResult res = EditorManager.ShowMessageBox("nVidia PhysX binding specific components/entities have been found in loaded layers.\n\nShould these be permanently converted to Havok components?", "nVidia PhysX plugin not loaded", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

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

            int iConvertedCount = 0;

            // build a list of actions for the component replacement
            if (physXComponents.Count > 0)
            {
                GroupAction actions = new GroupAction("Migrate to Havok components");
                foreach (ShapeComponent oldComp in physXComponents)
                {
                    ShapeComponent newComp = null;
                    if (oldComp.DisplayName == "vPhysXRigidBody")
                    {
                        newComp = (ShapeComponent)EditorManager.EngineManager.ComponentClassManager.CreateCollection(null, "vHavokRigidBody");
                        MigrateRigidBodyProperties(oldComp, newComp);
                    }
                    else if (oldComp.DisplayName == "vPhysXCharacterController")
                    {
                        newComp = (ShapeComponent)EditorManager.EngineManager.ComponentClassManager.CreateCollection(null, "vHavokCharacterController");
                        MigrateCharacterControllerProperties(oldComp, newComp);
                    }
                    if (newComp == null)
                    {
                        continue;
                    }
                    // action to remove the old component and add the new one
                    actions.Add(new RemoveShapeComponentAction((ShapeBase)oldComp.Owner, oldComp));
                    actions.Add(new AddShapeComponentAction((ShapeBase)oldComp.Owner, newComp));
                    iConvertedCount++;
                }
                // trigger the conversion action
                EditorManager.Actions.Add(actions);
            }

            if (physXEntities.Count > 0)
            {
                GroupAction actions = new GroupAction("Migrate entities classes");
                foreach (EntityShape entity in physXEntities)
                {
                    ShapeComponent newComp = null;
                    if (entity.EntityClass == "vPhysXEntity")
                    {
                        newComp = (ShapeComponent)EditorManager.EngineManager.ComponentClassManager.CreateCollection(null, "vHavokRigidBody");
                        MigratePhysXEntityProperties(entity.EntityProperties, newComp);
                    }
                    else if (entity.EntityClass == "LineFollowerEntity_cl")
                    {
                        newComp = (ShapeComponent)EditorManager.EngineManager.ComponentClassManager.CreateCollection(null, "VLineFollowerComponent");
                        MigrateLineFollowerEntityProperties(entity.EntityProperties, newComp);
                    }
                    if (newComp == null)
                    {
                        continue;
                    }
                    // we convert to base entity class and attach a component instead
                    actions.Add(SetPropertyAction.CreateSetPropertyAction(entity, "EntityClass", "VisBaseEntity_cl"));
                    actions.Add(new AddShapeComponentAction(entity, newComp));
                    iConvertedCount++;
                }
                // trigger the conversion action
                EditorManager.Actions.Add(actions);
            }

            EditorManager.ShowMessageBox(iConvertedCount.ToString() + " Component(s) have been successfully converted.\n\nSince physics engine have quite different behavior, the parameters might have to be tweaked to match old behavior.", "PhysX to Havok component conversion", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }