コード例 #1
0
        /// <summary>
        /// Overridden StringConverter function: Returns the standard values that the dropdown should have
        /// </summary>
        /// <param name="context">The descriptor context</param>
        /// <returns>Collection of standard values</returns>
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            // get the AI panel
            string[]     settingNames = null;
            HavokAiPanel aiPanel      = HavokAiPanel.GetInstance();

            System.Diagnostics.Debug.Assert(aiPanel != null);

            settingNames = aiPanel.GetGlobalSettingsNameCollection();
            return(new StandardValuesCollection(settingNames));
        }
コード例 #2
0
        private HavokNavMeshGlobalSettings GetGlobalSettings()
        {
            HavokNavMeshGlobalSettings settings = null;

            // get the AI panel
            HavokAiPanel aiPanel = HavokAiPanel.GetInstance();

            System.Diagnostics.Debug.Assert(aiPanel != null);

            settings = aiPanel.GetGlobalSettings(m_navMeshGlobalSettingsName);
            return(settings);
        }
コード例 #3
0
        public HavokNavMeshShape(string name)
            : base(name)
        {
            AddHint(HintFlags_e.NoRotation);
            AddHint(HintFlags_e.NoScale);
            AddHint(HintFlags_e.RetainPositionAtCreation);
            AddHint(HintFlags_e.HideGizmo);
            AddHint(HintFlags_e.NoUserTransform);

            // check to see if there's HavokNavMeshGlobalSettings and default to that shape
            // get the AI panel
            HavokAiPanel aiPanel = HavokAiPanel.GetInstance();

            System.Diagnostics.Debug.Assert(aiPanel != null);

            HavokNavMeshGlobalSettings settings = aiPanel.GetOrCreateDefaultGlobalSettings();

            m_navMeshGlobalSettingsName = settings.Name;
        }
コード例 #4
0
        /// <summary>
        /// Overridden function that gets called when the plugin is loaded. Registers all creator plugins
        /// </summary>
        /// <returns></returns>
        public override bool InitPluginModule()
        {
            EDITOR_PLUGIN_INFO.NativePluginNames = new string[] { "Havok Ai" };
            HavokAiManaged.ManagedModule.InitManagedModule();

            // register shape class
            creators = new IShapeCreatorPlugin[]
            {
                new HavokNavMeshShapeCreator(),
                new HavokNavMeshCarverShapeCreator(),
                new HavokNavMeshSeedPointShapeCreator(),
                new HavokNavMeshLocalSettingsShapeCreator(),
                new HavokNavMeshTestPathShapeCreator()
            };
            foreach (IShapeCreatorPlugin plugin in creators)
            {
                EditorManager.ShapeCreatorPlugins.Add(plugin);
            }

            // create and activate panel
            _panel = new HavokAiPanel(EditorManager.ApplicationLayout.DockingArea);
            _panel.ShowDockable();
            _panel.Enabled = false;

            // register callbacks
            IScene.ShapeChanged                 += new ShapeChangedEventHandler(IScene_ShapeChanged);
            IScene.PropertyChanged              += new PropertyChangedEventHandler(IScene_PropertyChanged);
            IScene.EngineInstancesChanged       += new EngineInstancesChangedEventHandler(IScene_EngineInstancesChanged);
            EditorManager.SceneChanged          += new SceneChangedEventHandler(EditorManager_SceneChanged);
            EditorManager.ShapeSelectionChanged += new ShapeSelectionChangedEventHandler(EditorManager_ShapeSelectionChanged);
            EditorManager.EditorModeChanged     += new EditorModeChangedEventHandler(EditorManager_EditorModeChanged);

            // Register automated tests
            TestSuiteBuilder testBuilder = new TestSuiteBuilder();
            TestSuite        testSuite   = testBuilder.Build(typeof(EditorPlugin).Assembly.FullName);

            TestManager.AddTestSuite(testSuite);

            return(true);
        }
コード例 #5
0
        /// <summary>
        /// Overridden function that gets called when the plugin is loaded. Registers all creator plugins
        /// </summary>
        /// <returns></returns>
        public override bool DeInitPluginModule()
        {
            HavokAiManaged.ManagedModule.DeInitManagedModule();

            foreach (IShapeCreatorPlugin plugin in creators)
            {
                EditorManager.ShapeCreatorPlugins.Remove(plugin);
            }

            _panel.Close();
            _panel.Dispose();
            _panel = null;

            EditorManager.EditorModeChanged     -= new EditorModeChangedEventHandler(EditorManager_EditorModeChanged);
            EditorManager.ShapeSelectionChanged -= new ShapeSelectionChangedEventHandler(EditorManager_ShapeSelectionChanged);
            EditorManager.SceneChanged          -= new SceneChangedEventHandler(EditorManager_SceneChanged);
            IScene.EngineInstancesChanged       -= new EngineInstancesChangedEventHandler(IScene_EngineInstancesChanged);
            IScene.PropertyChanged -= new PropertyChangedEventHandler(IScene_PropertyChanged);
            IScene.ShapeChanged    -= new ShapeChangedEventHandler(IScene_ShapeChanged);

            return(true);
        }
コード例 #6
0
        protected HavokNavMeshShape(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            m_saveInputSnapshot = info.GetBoolean("SaveInputSnapshot");
            m_snapshotFilename  = info.GetString("SnapshotFilename");
            if (SerializationHelper.HasElement(info, "NavmeshFilename"))
            {
                m_navMeshFilename = info.GetString("NavmeshFilename");
            }
            if (SerializationHelper.HasElement(info, "DebugRenderOffset"))
            {
                m_debugRenderOffset = info.GetSingle("DebugRenderOffset");
            }
            if (SerializationHelper.HasElement(info, "NavMeshSectionID"))
            {
                m_sectionID = info.GetUInt32("NavMeshSectionID");
            }

            // check if it has a reference to a global settings shape already
            if (SerializationHelper.HasElement(info, "NavMeshGlobalSettingsName"))
            {
                m_navMeshGlobalSettingsName = info.GetString("NavMeshGlobalSettingsName");
            }
            else
            {
                // get the AI panel
                HavokAiPanel aiPanel = HavokAiPanel.GetInstance();
                System.Diagnostics.Debug.Assert(aiPanel != null);

                // if not, this is from an old version of the scene, so create a new settings struct and transfer all settings to this struct
                HavokNavMeshGlobalSettings globalSettings = aiPanel.CreateGlobalSettings(this.ToString() + "_GlobalSettings", false);
                m_navMeshGlobalSettingsName = globalSettings.Name;
                System.Diagnostics.Debug.Assert(globalSettings != null);

                // Nav Mesh Generation Settings
                globalSettings.CharacterHeight  = info.GetSingle("CharacterHeight");
                globalSettings.MaxWalkableSlope = info.GetSingle("MaxWalkableSlope");
                globalSettings.MinRegionArea    = info.GetSingle("MinRegionArea");
                if (SerializationHelper.HasElement(info, "MinDistanceToSeedPoints"))
                {
                    globalSettings.MinDistanceToSeedPoints = info.GetSingle("MinDistanceToSeedPoints");
                }
                if (SerializationHelper.HasElement(info, "BorderPreservationTolerance"))
                {
                    globalSettings.BorderPreservationTolerance = info.GetSingle("BorderPreservationTolerance");
                }
                globalSettings.MinCharacterWidth   = info.GetSingle("MinCharacterWidth");
                globalSettings.CharacterWidthUsage = (eCharacterWidthUsage)info.GetValue("CharacterWidthUsage", typeof(eCharacterWidthUsage));
                if (SerializationHelper.HasElement(info, "RestrictToZoneGeometry"))
                {
                    globalSettings.RestrictToInputGeometryFromSameZone = info.GetBoolean("RestrictToZoneGeometry");
                }

                // Nav Mesh Generation Settings (Advanced)
                globalSettings.QuantizationGridSize     = info.GetSingle("QuantizationGridSize");
                globalSettings.DegenerateAreaThreshold  = info.GetSingle("DegenerateAreaThreshold");
                globalSettings.DegenerateWidthThreshold = info.GetSingle("DegenerateWidthThreshold");
                globalSettings.ConvexThreshold          = info.GetSingle("ConvexThreshold");
                globalSettings.MaxNumEdgesPerFace       = info.GetInt32("MaxNumEdgesPerFace");
                globalSettings.WeldInputVertices        = info.GetBoolean("WeldInputVertices");
                globalSettings.WeldThreshold            = info.GetSingle("WeldThreshold");

                // Nav Mesh Edge Matching Settings
                globalSettings.EdgeConnectionIterations = info.GetInt32("EdgeConnectionIterations");
                globalSettings.EdgeMatchingMetric       = (eEdgeMatchingMetric)info.GetValue("EdgeMatchingMetric", typeof(eEdgeMatchingMetric));
                globalSettings.MaxStepHeight            = info.GetSingle("MaxStepHeight");
                globalSettings.MaxSeparation            = info.GetSingle("MaxSeparation");
                globalSettings.MaxOverhang            = info.GetSingle("MaxOverhang");
                globalSettings.PlanarAlignmentAngle   = info.GetSingle("PlanarAlignmentAngle");
                globalSettings.VerticalAlignmentAngle = info.GetSingle("VerticalAlignmentAngle");
                globalSettings.MinEdgeOverlap         = info.GetSingle("MinEdgeOverlap");

                // Nav Mesh Simplification Settings
                globalSettings.EnableSimplification         = info.GetBoolean("EnableSimplification");
                globalSettings.MaxBorderSimplifyArea        = info.GetSingle("MaxBorderSimplifyArea");
                globalSettings.MaxConcaveBorderSimplifyArea = info.GetSingle("MaxConcaveBorderSimplifyArea");
                globalSettings.UseHeightPartitioning        = info.GetBoolean("UseHeightPartitioning");
                globalSettings.MaxPartitionHeightError      = info.GetSingle("MaxPartitionHeightError");

                // Nav Mesh Simplification Settings (Advanced)
                globalSettings.MinCorridorWidth                  = info.GetSingle("MinCorridorWidth");
                globalSettings.MaxCorridorWidth                  = info.GetSingle("MaxCorridorWidth");
                globalSettings.HoleReplacementArea               = info.GetSingle("HoleReplacementArea");
                globalSettings.MaxLoopShrinkFraction             = info.GetSingle("MaxLoopShrinkFraction");
                globalSettings.MaxBorderHeightError              = info.GetSingle("MaxBorderHeightError");
                globalSettings.MaxBorderDistanceError            = info.GetSingle("MaxBorderDistanceError");
                globalSettings.MaxPartitionSize                  = info.GetInt32("MaxPartitionSize");
                globalSettings.UseConservativeHeightPartitioning = info.GetBoolean("UseConservativeHeightPartitioning");
                globalSettings.HertelMehlhornHeightError         = info.GetSingle("HertelMehlhornHeightError");
                globalSettings.PlanarityThreshold                = info.GetSingle("PlanarityThreshold");
                globalSettings.NonconvexityThreshold             = info.GetSingle("NonconvexityThreshold");
                globalSettings.BoundaryEdgeFilterThreshold       = info.GetSingle("BoundaryEdgeFilterThreshold");
                globalSettings.MaxSharedVertexHorizontalError    = info.GetSingle("MaxSharedVertexHorizontalError");
                globalSettings.MaxSharedVertexVerticalError      = info.GetSingle("MaxSharedVertexVerticalError");
                globalSettings.MaxBoundaryVertexHorizontalError  = info.GetSingle("MaxBoundaryVertexHorizontalError");
                globalSettings.MaxBoundaryVertexVerticalError    = info.GetSingle("MaxBoundaryVertexVerticalError");
                globalSettings.MergeLongestEdgesFirst            = info.GetBoolean("MergeLongestEdgesFirst");

                // Nav Mesh Split Generation Settings
                if (SerializationHelper.HasElement(info, "NumTilesX"))
                {
                    globalSettings.NumTilesX = info.GetInt32("NumTilesX");
                }
                if (SerializationHelper.HasElement(info, "NumTilesY"))
                {
                    globalSettings.NumTilesY = info.GetInt32("NumTilesY");
                }
                if (SerializationHelper.HasElement(info, "SplitGenerationMethod"))
                {
                    globalSettings.SplitGenerationMethod = (eSplitGenerationMethod)info.GetValue("SplitGenerationMethod", typeof(eSplitGenerationMethod));
                }
                if (SerializationHelper.HasElement(info, "ShelverType"))
                {
                    globalSettings.ShelverType = (eShelverType)info.GetValue("ShelverType", typeof(eShelverType));
                }

                // Nav Mesh Link Settings
                if (SerializationHelper.HasElement(info, "LinkEdgeMatchTolerance"))
                {
                    globalSettings.LinkEdgeMatchTolerance = info.GetSingle("LinkEdgeMatchTolerance");
                }

                if (SerializationHelper.HasElement(info, "LinkMaxStepHeight"))
                {
                    globalSettings.LinkMaxStepHeight = info.GetSingle("LinkMaxStepHeight");
                }

                if (SerializationHelper.HasElement(info, "LinkMaxSeparation"))
                {
                    globalSettings.LinkMaxSeparation = info.GetSingle("LinkMaxSeparation");
                }

                if (SerializationHelper.HasElement(info, "LinkMaxOverhang"))
                {
                    globalSettings.LinkMaxOverhang = info.GetSingle("LinkMaxOverhang");
                }

                if (SerializationHelper.HasElement(info, "LinkPlanarAlignmentAngle"))
                {
                    globalSettings.LinkPlanarAlignmentAngle = info.GetSingle("LinkPlanarAlignmentAngle");
                }

                if (SerializationHelper.HasElement(info, "LinkVerticalAlignmentAngle"))
                {
                    globalSettings.LinkVerticalAlignmentAngle = info.GetSingle("LinkVerticalAlignmentAngle");
                }

                if (SerializationHelper.HasElement(info, "LinkMinEdgeOverlap"))
                {
                    globalSettings.LinkMinEdgeOverlap = info.GetSingle("LinkMinEdgeOverlap");
                }
            }
        }