public MobileWaterShape(string name) : base(name) { AddHint(HintFlags_e.NoScale); AddHint(HintFlags_e.OnlyYawRotation); _shaderFX = new ShaderEffectConfig(this); // remember to add the same stuff in the serialization constructor _shaderFX.OnShaderEffectChanged += new CSharpFramework.Scene.ShaderEffectConfig.ShaderEffectChangedEventHandler(_shaderFX_OnShaderEffectChanged); }
/// <summary> /// Constructor /// </summary> /// <param name="name"></param> public MirrorShape(string name) : base(name) { this._fSizeX *= EditorManager.Settings.GlobalUnitScaling; this._fSizeY *= EditorManager.Settings.GlobalUnitScaling; _shaderFX = new ShaderEffectConfig(this); // remember to add the same stuff in the serialization constructor _shaderFX.OnShaderEffectChanged += new CSharpFramework.Scene.ShaderEffectConfig.ShaderEffectChangedEventHandler(_shaderFX_OnShaderEffectChanged); }
protected override void DisposeObject() { if (_shaderFX != null) _shaderFX.Dispose(); _shaderFX = null; base.DisposeObject(); }
/// <summary> /// Called when deserializing /// </summary> /// <param name="info"></param> /// <param name="context"></param> protected MirrorShape(SerializationInfo info, StreamingContext context) : base(info, context) { _fSizeX = info.GetSingle("_fSizeX"); _fSizeY = info.GetSingle("_fSizeY"); _shaderFX = (ShaderEffectConfig)info.GetValue("_shaderFX",typeof(ShaderEffectConfig)); _shaderFX.OnShaderEffectChanged += new CSharpFramework.Scene.ShaderEffectConfig.ShaderEffectChangedEventHandler(_shaderFX_OnShaderEffectChanged); _shaderFX.Owner = this; if (SerializationHelper.HasElement(info,"_iResolution")) _iResolution = info.GetInt32("_iResolution"); if (SerializationHelper.HasElement(info,"_modelFile")) _modelFile = info.GetString("_modelFile"); if (SerializationHelper.HasElement(info,"_farClipDist")) _farClipDist = info.GetSingle("_farClipDist"); if (SerializationHelper.HasElement(info,"_iContextBitmask")) _iContextBitmask = (FlagsInt32_e)info.GetValue("_iContextBitmask", typeof(FlagsInt32_e)); if (SerializationHelper.HasElement(info, "_reflectionShaderMode")) _reflectionShaderMode = (ReflectionShaderMode)info.GetValue("_reflectionShaderMode", typeof(ReflectionShaderMode)); if (SerializationHelper.HasElement(info, "_bRenderExtObj")) _bRenderExtObj = info.GetBoolean("_bRenderExtObj"); if (SerializationHelper.HasElement(info, "_fFovScale")) _fFovScale = info.GetSingle("_fFovScale"); if (SerializationHelper.HasElement(info, "_fObliqueClippingPlaneOffset")) _fObliqueClippingPlaneOffset = info.GetSingle("_fObliqueClippingPlaneOffset"); if (SerializationHelper.HasElement(info, "_bLODFromRefContext")) _bLODFromRefContext = info.GetBoolean("_bLODFromRefContext"); if (SerializationHelper.HasElement(info, "_bUseHDR")) _bUseHDR = info.GetBoolean("_bUseHDR"); if (SerializationHelper.HasElement(info, "_renderHook3")) { _renderHook = (RenderOrderBits_e)info.GetValue("_renderHook3", typeof(RenderOrderBits_e)); } else if (SerializationHelper.HasElement(info, "_renderHook2")) { RenderOrderBits_e eRH; eRH = (RenderOrderBits_e)info.GetValue("_renderHook2", typeof(RenderOrderBits_e)); // toggle VRH_ADDITIVE_PARTICLES with VRH_TRANSLUCENT_VOLUMES so that the VRenderHook_e enum order matches the execution order if (eRH == RenderOrderBits_e.AdditiveParticles) _renderHook = RenderOrderBits_e.TranslucentVolumes; else if (eRH == RenderOrderBits_e.TranslucentVolumes) _renderHook = RenderOrderBits_e.AdditiveParticles; else _renderHook = eRH; } else if (SerializationHelper.HasElement(info, "_renderHook")) { int oldValue = info.GetInt32("_renderHook"); _renderHook = ConversionUtils.UpdateRenderOrderBits(oldValue); } // backwards compatibility if (!SerializationHelper.HasElement(info, "SupportScaling")) SetScaling_Internal(1.0f, 1.0f, 1.0f); if (LinkTargets.Count==0) // old version this.CreateAllLinks(); }
/// <summary> /// Called when deserializing /// </summary> /// <param name="info"></param> /// <param name="context"></param> protected TerrainShape(SerializationInfo info, StreamingContext context) : base(info, context) { _terrainConfig = (TerrainConfig)info.GetValue("_terrainConfig", typeof(TerrainConfig)); _decorationModels = (ArrayList)info.GetValue("_decorationModels",typeof(ArrayList)); _iDecorationID = info.GetInt32("_iDecorationID"); if (SerializationHelper.HasElement(info, "_iVisibleBitmask")) _iVisibleBitmask = info.GetUInt32("_iVisibleBitmask"); if (SerializationHelper.HasElement(info, "_bVisibleInsideVisZones")) _bVisibleInsideVisZones = info.GetBoolean("_bVisibleInsideVisZones"); if (SerializationHelper.HasElement(info, "_fLODScaling")) _fLODScaling = info.GetSingle("_fLODScaling"); if (SerializationHelper.HasElement(info, "_fMirrorLODBias")) _fMirrorLODBias = info.GetSingle("_fMirrorLODBias"); if (SerializationHelper.HasElement(info, "_lodMetric")) _lodMetric = (TerrainLODMetric_e)info.GetValue("_lodMetric", typeof(TerrainLODMetric_e)); if (SerializationHelper.HasElement(info,"_iDetailTextureID")) _iDetailTextureID = info.GetInt32("_iDetailTextureID"); if (SerializationHelper.HasElement(info, "_detailTextures")) _detailTextures = (ArrayList)info.GetValue("_detailTextures", typeof(ArrayList)); if (SerializationHelper.HasElement(info, "_eLightmapSize")) _eLightmapSize = (LightmapSize_e)info.GetValue("_eLightmapSize", typeof(LightmapSize_e)); if (SerializationHelper.HasElement(info, "_bCastStaticShadows")) _bCastStaticShadows = info.GetBoolean("_bCastStaticShadows"); if (SerializationHelper.HasElement(info, "_iLightInfluenceBitmask")) _iLightInfluenceBitmask = info.GetUInt16("_iLightInfluenceBitmask"); if (SerializationHelper.HasElement(info, "_shaderFX")) _pendingConfig = (ShaderEffectConfig)info.GetValue("_shaderFX", typeof(ShaderEffectConfig)); if (SerializationHelper.HasElement(info, "_minimapTexture")) _minimapTexture = info.GetString("_minimapTexture"); if (SerializationHelper.HasElement(info, "_heightmapExport")) _heightmapExport = info.GetString("_heightmapExport"); if (SerializationHelper.HasElement(info, "_bNormalizeHeightmapExport")) _bNormalizeHeightmapExport = info.GetBoolean("_bNormalizeHeightmapExport"); if (SerializationHelper.HasElement(info, "_bExportAsEditable")) _bExportAsEditable = info.GetBoolean("_bExportAsEditable"); if (SerializationHelper.HasElement(info, "_bFastUpdate")) _bFastUpdate = info.GetBoolean("_bFastUpdate"); if (SerializationHelper.HasElement(info, "_cachedDectorIDs")) _cachedSectorIDs = (uint[])info.GetValue("_cachedDectorIDs", typeof(uint[])); else _cachedSectorIDs = null; if (SerializationHelper.HasElement(info, "_savedZoneBoxes")) _savedZoneBoxes = (BoundingBox[])info.GetValue("_savedZoneBoxes", typeof(BoundingBox[])); else _savedZoneBoxes = null; if (SerializationHelper.HasElement(info, "_bSortDetailTextures")) _bSortDetailTextures = info.GetBoolean("_bSortDetailTextures"); if (SerializationHelper.HasElement(info, "_meshExportSettings")) _meshExportSettings = (TerrainMeshExport)info.GetValue("_meshExportSettings", typeof(TerrainMeshExport)); _bBakeMode = TerrainEditor.TextureBakedView; // fall back to editor setting if (SerializationHelper.HasElement(info, "_bBakeMode")) _bBakeMode = info.GetBoolean("_bBakeMode"); if (SerializationHelper.HasElement(info, "_bIsReference")) _bIsReference = info.GetBoolean("_bIsReference"); if (SerializationHelper.HasElement(info, "_bSceneSpecificLightmaps")) _bSceneSpecificLightmaps = info.GetBoolean("_bSceneSpecificLightmaps"); // Make sure detail texture resources contain valid sector index information // (just in case an older vForge version wrote out wrong values after the terrain was resized) this.ClampDetailTextureSectorsToValidRange(); }
public TerrainShape(string name) : base(name) { AddHint(HintFlags_e.NoRotation | HintFlags_e.NoScale | HintFlags_e.RetainPositionAtCreation); _terrainConfig.TerrainFolder = System.IO.Path.GetFileNameWithoutExtension(EditorManager.Scene.FileName); // start with the defaults ShaderConfig = new ShaderEffectConfig(this); _terrainShaderProperties = new TerrainShaderProperties(this); _shaderFX._libFilename = @"\Shaders\Terrain.ShaderLib"; _shaderFX._effectName = "Terrain"; _shaderFX._shadermode = ISurface.SHADERMODE.AUTO; }
void _shaderFX_OnShaderEffectChanged(object sender, ShaderEffectConfig.ShaderEffectChangedArgs e) { if (!HasEngineInstance()) return; // Modified = true; EngineTerrain.SetShaderEffect(ShaderConfig); }
protected override void DisposeObject() { if (_shaderFX != null) { _shaderFX.Dispose(); _shaderFX = null; } if (_pendingConfig != null) { _pendingConfig.Dispose(); _pendingConfig = null; } base.DisposeObject(); }
public override void OnDeserialization() { base.OnDeserialization(); AddHint(HintFlags_e.NoRotation | HintFlags_e.NoScale); if (string.IsNullOrEmpty(_terrainConfig.TerrainFolder)) _terrainConfig.TerrainFolder = this.ShapeName; foreach (DecorationModelResource model in _decorationModels) { if (model.ID == 0) model.ID = GetNewDecorationID(); //OLD scene file fix model._ownerTerrain = this; } bool bFirst = true; foreach (DetailTextureResource tex in _detailTextures) { tex._ownerTerrain = this; tex._bIsBaseTexture = bFirst; bFirst = false; } EnumDetailTextures(); if (_pendingConfig == null) { _pendingConfig = new ShaderEffectConfig(this); _pendingConfig._libFilename = @"\Shaders\Terrain.ShaderLib"; _pendingConfig._effectName = "Terrain"; _pendingConfig._shadermode = ISurface.SHADERMODE.AUTO; } ShaderConfig = _pendingConfig; // register callbacks etc. _terrainShaderProperties = new TerrainShaderProperties(this); // force update the minimap: string _tex = _minimapTexture; _minimapTexture = null; this.MinimapTexture = _tex; if (HasChildren()) { //foreach (ShapeBase shape in ChildCollection) } //if (_materialProvider==null) //_materialProvider = new TerrainMaterialProvider(this); if (_meshExportSettings != null) _meshExportSettings.Owner = this; if (_bIsReference) _bBakeMode = true; TerrainEditor.TextureBakedView = _bBakeMode; // dir light shape saved with the file? foreach (ShapeBase child in ChildCollection) if (child is TerrainDirectionalLight) { _dirLightShape = (TerrainDirectionalLight)child; _dirLightShape.OwnerTerrain = this; break; } }
void _shaderFX_OnShaderEffectChanged(object sender, ShaderEffectConfig.ShaderEffectChangedArgs e) { if (HasEngineInstance()) EngineProjector.SetCustomShaderEffect(_shaderFX); }
/// <summary> /// Overridden clone function that removes the hotspots again /// </summary> /// <returns></returns> public override ShapeBase Clone() { ProjectorShape copy = base.Clone() as ProjectorShape; copy._hotSpotConeAngleX = null; copy._hotSpotConeAngleY = null; copy._hotSpotLength = null; copy._hotSpotFadeOutDist1 = null; copy._hotSpotFadeOutDist2 = null; if (copy._shaderFX != null) this._shaderFX = (ShaderEffectConfig)copy._shaderFX.Clone(); return copy; }
/// <summary> /// Called when deserializing /// </summary> /// <param name="info"></param> /// <param name="context"></param> protected ProjectorShape(SerializationInfo info, StreamingContext context) : base(info, context) { _textureFile = info.GetString("_textureFile"); _transp = (TransparencyType)info.GetValue("_transp",typeof(TransparencyType)); _fConeAngleX = info.GetSingle("_fConeAngleX"); _fConeAngleY = info.GetSingle("_fConeAngleY"); _fLength = info.GetSingle("_fLength"); _fFadeOutDist = info.GetSingle("_fFadeOutDist"); _iIntensity = info.GetByte("_iIntensity"); _color = (Color)info.GetValue("_color",typeof(Color)); if (SerializationHelper.HasElement(info,"_bLightmapped")) _bLightmapped = info.GetBoolean("_bLightmapped"); if (SerializationHelper.HasElement(info, "_geomTypeFilter")) _geomTypeFilter = (GeometryTypeMask)info.GetValue("_geomTypeFilter", typeof(GeometryTypeMask)); else _geomTypeFilter = GeometryTypeMask.All; // backwards compatibility if (SerializationHelper.HasElement(info, "_fFarClipDistance")) _fFarClipDistance = info.GetSingle("_fFarClipDistance"); // backwards compatibility if (!SerializationHelper.HasElement(info, "SupportScaling")) SetScaling_Internal(1.0f, 1.0f, 1.0f); if (SerializationHelper.HasElement(info, "_iInfluenceBitmask")) _iInfluenceBitmask = (FlagsInt32_e)info.GetValue("_iInfluenceBitmask", typeof(FlagsInt32_e)); else _iInfluenceBitmask = FlagsInt32_e.All; if (SerializationHelper.HasElement(info, "_shaderFX")) _shaderFX = (ShaderEffectConfig)info.GetValue("_shaderFX", typeof(ShaderEffectConfig)); }
/// <summary> /// Called when deserializing /// </summary> /// <param name="info"></param> /// <param name="context"></param> protected MobileWaterShape(SerializationInfo info, StreamingContext context) : base(info, context) { AddHint(HintFlags_e.NoScale); AddHint(HintFlags_e.OnlyYawRotation); _size = (Vector2F)info.GetValue("_size", typeof(Vector2F)); _useRadialGrid = info.GetBoolean("_useRadialGrid"); _textureTiling = (Vector2F)info.GetValue("_textureTiling", typeof(Vector2F)); _gridSubdivisions = (Vector2I)info.GetValue("_gridSubdivisions", typeof(Vector2I)); _renderHook = (RenderOrderBits_e)info.GetValue("_renderHook", typeof(RenderOrderBits_e)); _shaderFX = (ShaderEffectConfig)info.GetValue("_shaderFX", typeof(ShaderEffectConfig)); if (SerializationHelper.HasElement(info, "_useStaticLighting")) _useStaticLighting = info.GetBoolean("_useStaticLighting"); _shaderFX.OnShaderEffectChanged += new CSharpFramework.Scene.ShaderEffectConfig.ShaderEffectChangedEventHandler(_shaderFX_OnShaderEffectChanged); _shaderFX.Owner = this; }