Ejemplo n.º 1
0
        public void SetShowDirectionalLightShape(bool bShow)
        {
            if (_bDirLightUpdateInProgress)
            return;

              _bDirLightUpdateInProgress = true;
              if (_dirLightShape == null)
              {
            _dirLightShape = new TerrainDirectionalLight("Terrain Directional Light");
            _dirLightShape.OwnerTerrain = this;
            _dirLightShape.SetParent(this, false); // it is a non-serialized child shape
            _dirLightShape.OnAddedToScene();
              }

              if (_dirLightShape.Selected == bShow)
              {
            _bDirLightUpdateInProgress = false;
            return;
              }

              GizmoBase gizmo = EditorManager.ActiveView.Gizmo;
              if (!bShow)
              {
            gizmo.Clear();
            _bDirLightUpdateInProgress = false;
            return;
              }

              // set light shape in front of the camera
              _dirLightShape.Position = EditorManager.ActiveView.CameraPosition + EditorManager.ActiveView.CameraDirection * EditorManager.Settings.GlobalUnitScaling * 500.0f;
              gizmo.SetSingleShape(_dirLightShape, false);
              gizmo.DragMode = ShapeDragMode.ROTATE; // for directional light
              EditorManager.ActiveView.SetDefaultContext();
              _bDirLightUpdateInProgress = false;
        }
Ejemplo n.º 2
0
        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;
            }
        }