Esempio n. 1
0
        private void EditorManager_CustomSceneSerialization(object sender, CustomSceneSerializationArgs e)
        {
            if (e.CustomSceneObjects.IsSaving)
              {
            if (m_settingsDictionary != null)
            {
              e.CustomSceneObjects.AddObject("HavokAiEditorPlugin.EditorPlugin", m_settingsDictionary);
            }
              }
              else
              {
            if (m_settingsDictionary != null)
            {
              m_settingsCreatedDuringSceneLoad = true;
            }

            HavokNavMeshGlobalSettingsDictionary serializedSettingsCollection =
              (HavokNavMeshGlobalSettingsDictionary)e.CustomSceneObjects.FindObject("HavokAiEditorPlugin.EditorPlugin", typeof(HavokNavMeshGlobalSettingsDictionary));
            if (serializedSettingsCollection != null && serializedSettingsCollection.Count > 0) // ignore empty settings collection
            {
              // replace with serialized copy.
              m_settingsDictionary = serializedSettingsCollection;
              m_settingsDictionary.Parent = this;
            }
              }
        }
Esempio n. 2
0
        public override bool SaveToFile()
        {
            if (!base.SaveToFile())
              {
            return false;
              }

              // No need to continue if no scene (but, can this ever happen?)
              if (EditorManager.Scene == null)
              {
            return true;
              }

              if (_currentSettings._skyConfig != null && EditorManager.Scene != null)
              {
            _currentSettings._skyConfig.SaveSky(EditorManager.Scene.AbsoluteFileName + ".Layers\\");
              }

              // Collect any custom scene objects from plug-ins...
              _customSceneObjects = new CustomSceneObjectCollection(true, this);
              CustomSceneSerializationArgs customObjArg = new CustomSceneSerializationArgs(_customSceneObjects);
              EditorManager.OnCustomSceneSerialization(customObjArg); // collect the objects

              // ...and save them to separate files (one for each plug-in)
              bool bResult = true;
              foreach (KeyValuePair<string, ArrayList> pair in _customSceneObjects)
              {
            if (String.IsNullOrEmpty(pair.Key) || pair.Value == null || pair.Value.Count < 1)
            {
              continue;
            }

            string customObjectFileName = EditorManager.Scene.AbsoluteFileName + ".Layers\\" + pair.Key + ".PluginData";
            if (!SaveCustomObjectsToFile(customObjectFileName, pair.Value))
            {
              bResult = false;
              break;
            }
              }
              _customSceneObjects = null;

              return bResult;
        }
        void EditorManager_CustomSceneSerialization(object sender, CustomSceneSerializationArgs e)
        {
            if (e.CustomSceneObjects.IsSaving)
              {
            if (TerrainEditor.CurrentTerrain != null) // only save data when a terrain is used
            {
              // get data from panel
              TerrainPanelSettings brushes = new TerrainPanelSettings();
              brushes.HeightmapCursor_Elevate = this._heightmapCursor_Elevate;
              brushes.HeightmapCursor_Flatten = this._heightmapCursor_Flatten;
              brushes.HeightmapCursor_Smooth = this._heightmapCursor_Smooth;
              brushes.HeightmapCursor_Holes = this._heightmapCursor_Holes;
              brushes.DetailTextureCursor = this._detailTextureCursor;
              brushes.VegetationCursor = this._decorationCursor;

              e.CustomSceneObjects.AddObject("TerrainEditorPlugin.EditorPlugin", brushes);
            }
              }
              else
              {
            TerrainPanelSettings brushes =
              (TerrainPanelSettings)e.CustomSceneObjects.FindObject("TerrainEditorPlugin.EditorPlugin", typeof(TerrainPanelSettings));
            if (brushes != null)
            {
              if (brushes.HeightmapCursor_Elevate != null) this._heightmapCursor_Elevate = brushes.HeightmapCursor_Elevate;
              if (brushes.HeightmapCursor_Flatten != null) this._heightmapCursor_Flatten = brushes.HeightmapCursor_Flatten;
              if (brushes.HeightmapCursor_Smooth != null) this._heightmapCursor_Smooth = brushes.HeightmapCursor_Smooth;
              if (brushes.HeightmapCursor_Holes != null) this._heightmapCursor_Holes = brushes.HeightmapCursor_Holes;
              if (brushes.DetailTextureCursor != null) this._detailTextureCursor = brushes.DetailTextureCursor;
              if (brushes.VegetationCursor != null) this._decorationCursor = brushes.VegetationCursor;
            }
              }
        }
Esempio n. 4
0
        /// <summary>
        /// Overridden version
        /// </summary>
        public override void OnDeserialization()
        {
            base.OnDeserialization();
              if (_renderer != null)
            _renderer.Owner = this;

              if (_customSceneObjects != null)
              {
            CustomSceneSerializationArgs customObjArg = new CustomSceneSerializationArgs(_customSceneObjects);
            EditorManager.OnCustomSceneSerialization(customObjArg); // notify the tools
            _customSceneObjects = null;
              }

              try
              {
            MigrateRendererProperties(_renderer); // this can be removed later

            // new renderer type properties
            if (RendererNodeClass == IRendererNodeManager.RENDERERNODECLASS_NONE)
            {
              RendererNodeClass = IRendererNodeManager.RENDERERNODECLASS_SIMPLE;
            }

            {
              DynamicPropertyCollection oldProperties = _currentSettings._rendererSetup._rendererProperties;
              DynamicPropertyCollectionType propertiesType = EditorManager.RendererNodeManager.NodeClassTypeManager.GetCollectionType(RendererNodeClass);
              bool bAddSun = false;
              if (propertiesType != null)
              {
            if (_currentSettings._rendererSetup._rendererProperties == null)
              _currentSettings._rendererSetup._rendererProperties = propertiesType.CreateInstance(this);
            else
              _currentSettings._rendererSetup._rendererProperties = propertiesType.CreateMigratedCollection(oldProperties);
              }
              else
            _currentSettings._rendererSetup._rendererProperties = EditorManager.RendererNodeManager.NodeClassTypeManager.CreateMigratedCollection(oldProperties);
              if (_currentSettings._rendererSetup._rendererProperties != null)
            _currentSettings._rendererSetup._rendererProperties.Owner = this;

              // Vision 8.1: Migrate old time of day properties to a light source that is added to the scene
              if (RendererNodeClass == IRendererNodeManager.RENDERERNODECLASS_DEFERRED && oldProperties != null)
              {
            // migrate old depth fog
            MigrateFogProperties();

            object sun = oldProperties.GetPropertyValue("SunLight", false);
            if (sun is bool) // seems an 8.0 scene
            {
              bAddSun = (bool)sun;
              if (bAddSun)
              {
                // assume that the other properties are there as well:
                DynLightShape lightShape = new DynLightShape("Sun Light");
                lightShape.MakeTimeOfDayLight(
                  (float)oldProperties.GetPropertyValue("SunIntensity", false),
                  (bool)oldProperties.GetPropertyValue("Corona", false),
                  (string)oldProperties.GetPropertyValue("CoronaFilename", false)
                  );
                // add shadowmaps?
                object sunShadow = oldProperties.GetPropertyValue("SunShadowsEnabled", false);
                if ((sunShadow is bool) && ((bool)sunShadow) == true)
                {
                  ShapeComponentType t = (ShapeComponentType)EditorManager.EngineManager.ComponentClassManager.GetCollectionType("VShadowMapComponentSpotDirectional");
                  System.Diagnostics.Debug.Assert(t != null, "Cannot create component of type VShadowMapComponentSpotDirectional");
                  if (t != null)
                  {
                    ShapeComponent comp = (ShapeComponent)t.CreateInstance(this);
                    float fRange = (float)oldProperties.GetPropertyValue("ShadowRange", false);
                    object oldCascades = oldProperties.GetPropertyValue("ShadowCascades", false); // there might be old maps without this property
                    int iCascades = (oldCascades == null) ? 1 : (int)oldCascades;
                    float fOffset = (float)oldProperties.GetPropertyValue("ShadowOffset", false);
                    comp.SetPropertyValue("CascadeCount", iCascades);
                    if (iCascades == 1) fRange *= 2.0f;
                    comp.SetPropertyValue("CascadeRange[0]", fRange * 0.5f);
                    comp.SetPropertyValue("CascadeRange[1]", fRange);
                    object oldInterval = oldProperties.GetPropertyValue("ShadowCenterUpdateDistance", false);
                    if (oldInterval is float)
                      comp.SetPropertyValue("CameraUpdateInterval", (float)oldInterval, false);
                    comp.SetPropertyValue("ShadowMapSize", (int)oldProperties.GetPropertyValue("ShadowTextureSize", false), false);
                    comp.SetPropertyValue("Bias[0]", fOffset, false);
                    comp.SetPropertyValue("Bias[1]", fOffset, false);
                    object oldMask = oldProperties.GetPropertyValue("ShadowContextFilterBitmask", false);
                    if (oldMask is int)
                      comp.SetPropertyValue("FilterBitmask", (int)oldMask, false);
                    // more properties from lighting pp component?

                    lightShape.AddComponentInternal(comp);
                  }
                }

                AddPendingAction(AddShapeAction.CreateAddShapeAction(lightShape, this.Root, this, true));
              }
            }
            object backLight = oldProperties.GetPropertyValue("BackLight", false);
            if ((backLight is bool) && ((bool)backLight) == true)
            {
              DynLightShape backLightShape = new DynLightShape("Back Light");
              AddPendingAction(AddShapeAction.CreateAddShapeAction(backLightShape, this.Root, this, true));
            }

              }
            }

              }
              catch (Exception ex)
              {
            EditorManager.DumpException(ex, true);
              }

              if (_currentSettings._rendererSetup._rendererComponents != null)
            _currentSettings._rendererSetup._rendererComponents.MigrateProperties(this, EditorManager.EngineManager.ComponentClassManager);
        }
 private void SerializeMe(object sender, CustomSceneSerializationArgs args)
 {
     if (args.CustomSceneObjects.IsSaving)
       {
     // Save our settings object in the vForge scene file
     args.CustomSceneObjects.AddObject("ScenePropertiesPlugin.EditorPlugin", panel.SceneSettings);
       }
       else
       {
     // Retrieve our settings from the scene file (if available)
     SceneSettingInfo info = args.CustomSceneObjects.FindObject(
       "ScenePropertiesPlugin.EditorPlugin", typeof(SceneSettingInfo)) as SceneSettingInfo;
     panel.SceneSettings = info;
       }
 }
 void EditorManager_CustomSceneSerialization(object sender, CustomSceneSerializationArgs e)
 {
     if (e.CustomSceneObjects.IsSaving)
       {
     // get data from panel
     HavokPhysicsPanelSettings physSettings = new HavokPhysicsPanelSettings();
     e.CustomSceneObjects.AddObject("HavokEditorPlugin.EditorPlugin", physSettings);
       }
       else
       {
     HavokPhysicsPanelSettings physSettings =
       (HavokPhysicsPanelSettings)e.CustomSceneObjects.FindObject("HavokEditorPlugin.EditorPlugin", typeof(HavokPhysicsPanelSettings));
     if (physSettings != null)
     {
       GetHavokPhysicsParams();
       GetWorldRuntimeCollisionParams();
     }
       }
 }
 private void SerializeMe(object sender, CustomSceneSerializationArgs args)
 {
     if (args.CustomSceneObjects.IsSaving)
       {
     // Save our settings object in the vForge scene file
     args.CustomSceneObjects.AddObject("SimpleCustomSaveScenePlugin.EditorPlugin", _additionalGameData);
       }
       else
       {
     // Retrieve our settings from the scene file (if available)
     AdditionalGameData loadedData = args.CustomSceneObjects.FindObject(
       "SimpleCustomSaveScenePlugin.EditorPlugin", typeof(AdditionalGameData)) as AdditionalGameData;
     if (loadedData != null)
       _additionalGameData = loadedData;
       }
 }
Esempio n. 8
0
        public override bool SaveToFile()
        {
            if (!base.SaveToFile())
              {
            return false;
              }

              // No need to continue if no scene (but, can this ever happen?)
              if (EditorManager.Scene == null)
              {
            return true;
              }

              if (_currentSettings._skyConfig != null && EditorManager.Scene != null)
              {
            _currentSettings._skyConfig.SaveSky(EditorManager.Scene.AbsoluteFileName + ".Layers\\");
              }

              var oldCustomObjects = _customSceneObjects;

              // Collect any custom scene objects from plug-ins...
              _customSceneObjects = new CustomSceneObjectCollection(true, this);

              if (oldCustomObjects != null && !oldCustomObjects.IsLegacyMode)
              {
            // Reuse the empty array lists from loading in order to keep serialization stable
            foreach (var pair in oldCustomObjects)
            {
              _customSceneObjects.SetObjects(pair.Key, pair.Value);
            }
              }

              CustomSceneSerializationArgs customObjArg = new CustomSceneSerializationArgs(_customSceneObjects);
              EditorManager.OnCustomSceneSerialization(customObjArg); // collect the objects

              // ...and save them to separate files (one for each plug-in)
              bool bResult = true;
              foreach (KeyValuePair<string, ArrayList> pair in _customSceneObjects)
              {
            if (String.IsNullOrEmpty(pair.Key) || pair.Value == null || pair.Value.Count < 1)
            {
              continue;
            }

            string customObjectFileName = EditorManager.Scene.AbsoluteFileName + ".Layers\\" + pair.Key + ".PluginData";
            if (!SaveCustomObjectsToFile(customObjectFileName, pair.Value))
            {
              bResult = false;
              break;
            }
              }

              // Clear lists to prevent memory leaks, but keep the ArrayLists around to preserve object identity across serialization
              foreach (var pair in _customSceneObjects)
              {
            pair.Value.Clear();
              }

              return bResult;
        }