コード例 #1
0
        public object Clone()
        {
            DecorationModelResource copy = (DecorationModelResource)this.MemberwiseClone();

            copy._viewObject = null;
            return(copy);
        }
コード例 #2
0
 public void AddLODVersion(DecorationModelResource res)
 {
     if (_LODVersions == null)
     {
         _LODVersions = new List <DecorationModelResource>();
     }
     if (!_LODVersions.Contains(res))
     {
         _LODVersions.Add(res);
     }
     res._LODOrigin = this;
 }
コード例 #3
0
 public void UpdateDecorationModelProperties(DecorationModelResource model)
 {
     Debug.Assert(DecorationModels.Contains(model));
       Modified = true;
       if (HasEngineInstance())
     EngineTerrain.UpdateDecorationModelProperties(model, true);
       EditorManager.ActiveView.UpdateView(false);
 }
コード例 #4
0
        public void DeleteDecorationModelResource(DecorationModelResource model)
        {
            Debug.Assert(DecorationModels.Contains(model));
              DecorationModelResource oldparent = model._LODOrigin;
              DecorationModels.Remove(model);
              EngineTerrain.DeleteDecorationModel(model);
              model.SafeRemoveFromLODParent();
              if (oldparent != null)
            EngineTerrain.UpdateDecorationModelProperties(oldparent, false);

              // also remove LOD children
              if (model._LODVersions != null)
            foreach (DecorationModelResource child in model._LODVersions)
              if (DecorationModels.Contains(child))
              {
            EngineTerrain.DeleteDecorationModel(child);
            DecorationModels.Remove(child);
              }

              Modified = true;
        }
コード例 #5
0
 public DecorationModelResource CreateDecorationModelResource()
 {
     DecorationModelResource model = new DecorationModelResource(this, GetNewDecorationID());
       return model;
 }
コード例 #6
0
        public void AddDecorationModelResource(DecorationModelResource model)
        {
            Debug.Assert(!DecorationModels.Contains(model));
              DecorationModels.Add(model);
              if (model._LODOrigin != null && DecorationModels.Contains(model._LODOrigin))
            model._LODOrigin.AddLODVersion(model);
              else
            model._LODOrigin = null;

              // also add LOD children
              if (model._LODVersions != null)
            foreach (DecorationModelResource child in model._LODVersions)
              if (!DecorationModels.Contains(child))
            DecorationModels.Add(child);

              Modified = true;
        }
コード例 #7
0
 DecorationModelResource(SerializationInfo info, StreamingContext context)
 {
     _Name = info.GetString("_Name");
       _Filename = info.GetString("_Filename");
       ID = info.GetInt32("ID");
       if (SerializationHelper.HasElement(info, "_NearClipDistance"))
     _NearClipDistance = info.GetSingle("_NearClipDistance");
       if (SerializationHelper.HasElement(info, "_FarClipDistance"))
     _FarClipDistance = info.GetSingle("_FarClipDistance");
       if (SerializationHelper.HasElement(info, "_fRelFadeStart"))
     _fRelFadeStart = info.GetSingle("_fRelFadeStart");
       if (SerializationHelper.HasElement(info, "_visibleBitmask"))
     _visibleBitmask = (FlagsInt32_e)info.GetValue("_visibleBitmask", typeof(FlagsInt32_e));
       if (SerializationHelper.HasElement(info, "_alignment"))
     _alignment = (TerrainAlignment)info.GetValue("_alignment", typeof(TerrainAlignment));
       if (SerializationHelper.HasElement(info, "_sizeVariation"))
     _sizeVariation = info.GetSingle("_sizeVariation");
       if (SerializationHelper.HasElement(info, "_averageScale"))
     _averageScale = info.GetSingle("_averageScale");
       if (SerializationHelper.HasElement(info, "_density"))
     _density = info.GetSingle("_density");
       if (SerializationHelper.HasElement(info, "_randomness"))
     _randomness = info.GetSingle("_randomness");
       if (SerializationHelper.HasElement(info, "_pivotHeight"))
     _pivotHeight = info.GetSingle("_pivotHeight");
       if (SerializationHelper.HasElement(info, "_customLightmapCasterMesh"))
     _customLightmapCasterMesh = info.GetString("_customLightmapCasterMesh");
       if (SerializationHelper.HasElement(info, "_applyWind"))
     _applyWind = info.GetSingle("_applyWind");
       if (SerializationHelper.HasElement(info, "_applyConstraint"))
     _applyConstraint = info.GetSingle("_applyConstraint");
       if (SerializationHelper.HasElement(info, "_collisionCapsuleRadius"))
     _collisionCapsuleRadius = info.GetSingle("_collisionCapsuleRadius");
       if (SerializationHelper.HasElement(info, "_castLightmapShadows"))
     _castLightmapShadows = info.GetBoolean("_castLightmapShadows");
       if (SerializationHelper.HasElement(info, "_castDynamicShadows"))
     _castDynamicShadows = info.GetBoolean("_castDynamicShadows");
       if (SerializationHelper.HasElement(info, "_ExportFilename"))
     _ExportFilename = info.GetString("_ExportFilename");
       if (SerializationHelper.HasElement(info, "_iSectorX1"))
       {
     _iSectorX1 = info.GetInt32("_iSectorX1");
     _iSectorY1 = info.GetInt32("_iSectorY1");
     _iSectorX2 = info.GetInt32("_iSectorX2");
     _iSectorY2 = info.GetInt32("_iSectorY2");
       }
       if (SerializationHelper.HasElement(info, "_LODOrigin"))
     _LODOrigin = (DecorationModelResource)info.GetValue("_LODOrigin", typeof(DecorationModelResource));
 }
コード例 #8
0
 protected AddDecorationModelAction(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     _terrain = (TerrainShape)info.GetValue("_terrain", typeof(TerrainShape));
       _model = (DecorationModelResource)info.GetValue("_model", typeof(DecorationModelResource));
 }
コード例 #9
0
 public PaintDecorationAction(TerrainShape terrain, DecorationModelResource model)
     : base(terrain.EngineTerrain, "Edit decoration")
 {
     _model = model;
 }
コード例 #10
0
 DecorationModelResource(SerializationInfo info, StreamingContext context)
 {
     _Name     = info.GetString("_Name");
     _Filename = info.GetString("_Filename");
     ID        = info.GetInt32("ID");
     if (SerializationHelper.HasElement(info, "_NearClipDistance"))
     {
         _NearClipDistance = info.GetSingle("_NearClipDistance");
     }
     if (SerializationHelper.HasElement(info, "_FarClipDistance"))
     {
         _FarClipDistance = info.GetSingle("_FarClipDistance");
     }
     if (SerializationHelper.HasElement(info, "_fRelFadeStart"))
     {
         _fRelFadeStart = info.GetSingle("_fRelFadeStart");
     }
     if (SerializationHelper.HasElement(info, "_visibleBitmask"))
     {
         _visibleBitmask = (FlagsInt32_e)info.GetValue("_visibleBitmask", typeof(FlagsInt32_e));
     }
     if (SerializationHelper.HasElement(info, "_alignment"))
     {
         _alignment = (TerrainAlignment)info.GetValue("_alignment", typeof(TerrainAlignment));
     }
     if (SerializationHelper.HasElement(info, "_sizeVariation"))
     {
         _sizeVariation = info.GetSingle("_sizeVariation");
     }
     if (SerializationHelper.HasElement(info, "_averageScale"))
     {
         _averageScale = info.GetSingle("_averageScale");
     }
     if (SerializationHelper.HasElement(info, "_density"))
     {
         _density = info.GetSingle("_density");
     }
     if (SerializationHelper.HasElement(info, "_randomness"))
     {
         _randomness = info.GetSingle("_randomness");
     }
     if (SerializationHelper.HasElement(info, "_pivotHeight"))
     {
         _pivotHeight = info.GetSingle("_pivotHeight");
     }
     if (SerializationHelper.HasElement(info, "_customLightmapCasterMesh"))
     {
         _customLightmapCasterMesh = info.GetString("_customLightmapCasterMesh");
     }
     if (SerializationHelper.HasElement(info, "_applyWind"))
     {
         _applyWind = info.GetSingle("_applyWind");
     }
     if (SerializationHelper.HasElement(info, "_applyConstraint"))
     {
         _applyConstraint = info.GetSingle("_applyConstraint");
     }
     if (SerializationHelper.HasElement(info, "_collisionCapsuleRadius"))
     {
         _collisionCapsuleRadius = info.GetSingle("_collisionCapsuleRadius");
     }
     if (SerializationHelper.HasElement(info, "_castLightmapShadows"))
     {
         _castLightmapShadows = info.GetBoolean("_castLightmapShadows");
     }
     if (SerializationHelper.HasElement(info, "_castDynamicShadows"))
     {
         _castDynamicShadows = info.GetBoolean("_castDynamicShadows");
     }
     if (SerializationHelper.HasElement(info, "_ExportFilename"))
     {
         _ExportFilename = info.GetString("_ExportFilename");
     }
     if (SerializationHelper.HasElement(info, "_iSectorX1"))
     {
         _iSectorX1 = info.GetInt32("_iSectorX1");
         _iSectorY1 = info.GetInt32("_iSectorY1");
         _iSectorX2 = info.GetInt32("_iSectorX2");
         _iSectorY2 = info.GetInt32("_iSectorY2");
     }
     if (SerializationHelper.HasElement(info, "_LODOrigin"))
     {
         _LODOrigin = (DecorationModelResource)info.GetValue("_LODOrigin", typeof(DecorationModelResource));
     }
 }
コード例 #11
0
        public bool CopyPropertiesFrom(DecorationModelResource other, bool bTriggerChangedEvent)
        {
            bool bAnyChanged = false;

            if (_Name != other._Name)
            {
                _Name = other._Name; bAnyChanged = true;
            }
            if (_ExportFilename != other._ExportFilename)
            {
                _ExportFilename = other._ExportFilename; bAnyChanged = true;
            }
            if (_Filename != other._Filename)
            {
                _Filename = other._Filename; bAnyChanged = true;
            }
            if (_FarClipDistance != other._FarClipDistance)
            {
                _FarClipDistance = other._FarClipDistance; bAnyChanged = true;
            }
            if (_NearClipDistance != other._NearClipDistance)
            {
                _NearClipDistance = other._NearClipDistance; bAnyChanged = true;
            }
            if (_fRelFadeStart != other._fRelFadeStart)
            {
                _fRelFadeStart = other._fRelFadeStart; bAnyChanged = true;
            }
            if (_visibleBitmask != other._visibleBitmask)
            {
                _visibleBitmask = other._visibleBitmask; bAnyChanged = true;
            }
            if (_averageScale != other._averageScale)
            {
                _averageScale = other._averageScale; bAnyChanged = true;
            }
            if (_sizeVariation != other._sizeVariation)
            {
                _sizeVariation = other._sizeVariation; bAnyChanged = true;
            }
            if (_applyWind != other._applyWind)
            {
                _applyWind = other._applyWind; bAnyChanged = true;
            }
            if (_applyConstraint != other._applyConstraint)
            {
                _applyConstraint = other._applyConstraint; bAnyChanged = true;
            }
            if (_collisionCapsuleRadius != other._collisionCapsuleRadius)
            {
                _collisionCapsuleRadius = other._collisionCapsuleRadius; bAnyChanged = true;
            }
            if (_castLightmapShadows != other._castLightmapShadows)
            {
                _castLightmapShadows = other._castLightmapShadows; bAnyChanged = true;
            }
            if (_castDynamicShadows != other._castDynamicShadows)
            {
                _castDynamicShadows = other._castDynamicShadows; bAnyChanged = true;
            }
            if (_alignment != other._alignment)
            {
                _alignment = other._alignment; bAnyChanged = true;
            }
            if (_density != other._density)
            {
                _density = other._density; bAnyChanged = true;
            }
            if (_randomness != other._randomness)
            {
                _randomness = other._randomness; bAnyChanged = true;
            }
            if (_pivotHeight != other._pivotHeight)
            {
                _pivotHeight = other._pivotHeight; bAnyChanged = true;
            }
            if (_customLightmapCasterMesh != other._customLightmapCasterMesh)
            {
                _customLightmapCasterMesh = other._customLightmapCasterMesh; bAnyChanged = true;
            }

            if (bTriggerChangedEvent && bAnyChanged)
            {
                TriggerPropertyChangedEvent();
            }
            return(bAnyChanged);
        }
コード例 #12
0
 public IDecorationResourcePGView_Billboards(DecorationModelResource owner)
     : base(owner)
 {
 }
コード例 #13
0
 public IDecorationResourcePGView_Speedtree(DecorationModelResource owner)
     : base(owner)
 {
 }
コード例 #14
0
        DecorationModelResource CreateNewModel(DecorationModelResource lodOrigin, string name)
        {
            if (TerrainEditor.CurrentTerrain == null)
            return null;

              DecorationModelResource model = TerrainEditor.CurrentTerrain.CreateDecorationModelResource();

              // pick the model file
              OpenFileDlg fileDlg = new OpenFileDlg();
              fileDlg.InitialDirectory = EditorManager.Project.ProjectDir;
              fileDlg.Text = "Select model file";
              fileDlg.Caption = fileDlg.Text;
              fileDlg.Filter = new string[] { ".model", ".srt", ".atlas" }; // TODO: get via available plugins?
              fileDlg.FileName = model.Filename;

              if (fileDlg.ShowDialog(this) != DialogResult.OK)
            return null;

              model._LODOrigin = lodOrigin;
              model.Filename = EditorManager.Project.MakeRelative(fileDlg.FileName);
              if (string.IsNullOrEmpty(name))
            model.Name = System.IO.Path.GetFileNameWithoutExtension(model.Filename);
              else
            model.Name = name;
              EditorManager.Actions.Add(new AddDecorationModelAction(TerrainEditor.CurrentTerrain, model));
              return model;
        }
コード例 #15
0
 public IDecorationResourcePGView(DecorationModelResource owner)
 {
     _owner = owner;
 }
コード例 #16
0
        private void listView_VegetationModels_DoubleClick(object sender, EventArgs e)
        {
            if (TerrainEditor.CurrentDecorationModel == null)
            return;

              if (TerrainEditor.CurrentTerrain == null || TerrainEditor.CurrentTerrain.IsReference || !TerrainEditor.CurrentTerrain.Modifiable)
            return;

              using(PropertyGridDlg dlg = new PropertyGridDlg("Edit properties of '" + TerrainEditor.CurrentDecorationModel.Name + "'",
            "Edit all properties of this vegetation model at once so update of the terrain only happens when changes are confirmed"))
              {
            DecorationModelResource other = new DecorationModelResource(null, 0);
            other.CopyPropertiesFrom(TerrainEditor.CurrentDecorationModel, false);
            dlg.DataObjectNoClone = other.ViewObject;
            if (dlg.ShowDialog(this) != DialogResult.OK)
              return;

            TerrainEditor.CurrentDecorationModel.CopyPropertiesFrom(other, true);
              }
        }
コード例 #17
0
 public IDecorationResourcePGView_Basic(DecorationModelResource owner)
     : base(owner)
 {
 }
コード例 #18
0
 protected PaintDecorationAction(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     _model = (DecorationModelResource)info.GetValue("_model", typeof(DecorationModelResource));
 }
コード例 #19
0
 public AddDecorationModelAction(TerrainShape terrain, DecorationModelResource model)
 {
     _model = model;
       _terrain = terrain;
 }