Example #1
0
File: Cloud.cs Project: Mcfli/Moai
    // Use this for initialization
    void Start () {
        Player = GameObject.FindGameObjectWithTag("Player");
        SkyScript = GameObject.FindGameObjectWithTag("Sky").GetComponent<Sky>();
        float radial_offset = 2 * Random.value * placement_radius;
        float angle = 2*Random.value * Mathf.PI;
        transform.eulerAngles = new Vector3(0,Random.Range(0,360),0); //random rotation

        pos_offset = new Vector3(radial_offset*Mathf.Cos(angle),
            height_base+2*Random.value*height_variation-height_variation,
            radial_offset * Mathf.Sin(angle));
        cur_opacity = 0.0f;
        dissipating = false;
        rend = GetComponent<Renderer>();
        rend.material.color *= new Color (1,1,1,0.0f);
	}
Example #2
0
        public MainForm()
        {
            InitializeComponent();
            m_earthMap = axEarthCtrl1.getEarthMap();
            m_earthMap.maxThreadsNum = 10;//设置可用线程上限

            m_earthRoot = axEarthCtrl1.getEarthRoot();

            m_sky = new Sky();
            axEarthCtrl1.setActiveSky( m_sky );

            addVPAsia();
            axEarthCtrl1.setHomeViewpoint( vpAsia );

            axEarthCtrl1.run();

            tileSourceGDAL = new TileSourceGDAL();
            tileSourceTMS = new TileSourceTMS();
            vectorSourceGeom = new VectorSourceGeom();
            featureSourceOGR = new FeatureSourceOGR();
        }
Example #3
0
        // toggle for constellation visual effect
        /*public GUIUtil.SelectionGridForEnum<Sky.ConstellationMode>
            toggleConstellationMode
            = new GUIUtil.SelectionGridForEnum<Sky.ConstellationMode>();*/

        // slider for percentage of stars to edge vs. vertex
        //public float sliderPercentEdge;

        protected override void Start()
        {
            base.Start();

            constellationToggles = new bool[Enum.GetNames(typeof(Sky.ConstellationType)).Length];

            sky = GameObject.FindObjectOfType<Sky>();

            sliderNumVertexStars = data.numVertexStars;
            sliderNumEdgeStars = data.numEdgeStars;

            sliderStarVelocityMin = data.minVelocity;
            sliderStarVelocityMax = data.maxVelocity;

            sliderStarSizeMin = data.minSizeVertex;
            sliderStarSizeMax = data.maxSizeVertex;
            sliderEdgeStarSizeMin = data.minSizeEdge;
            sliderEdgeStarSizeMax = data.maxSizeEdge;

            sliderVertexTwinkleSpeed = data.twinkleSpeedVertex;
            sliderEdgeTwinkleSpeed = data.twinkleSpeedEdge;

            sliderLifespan = data.lifespan;

            sliderTimeToFade = data.timeToFade;

            sliderVertexStarMinDistance = data.vertexStarMinDistance;

            // set all toggles to true to start
            for(int i = 0; i < constellationToggles.Length; i++)
            {
                constellationToggles[i] = true;
            }

            sliderMeshAlpha = data.meshAlpha;

            sliderConstellationCount = data.constellationCount;
            sliderMeshQuality = data.quality;

            //sliderPercentEdge = data.percentEdge;

            starRenderer = star.GetComponent<Renderer>();

            // starting starColor
            Color newColVertex;
            if (ColorUtility.TryParseHtmlString(data.vertexStarColor, out newColVertex))
            {
                starColor = newColVertex;
            }

            Color newEdgeCol;
            if (ColorUtility.TryParseHtmlString(data.edgeStarColor, out newEdgeCol))
            {
                edgeStarColor = newEdgeCol;
            }

            starColorUpdate.SetValueCPUOnly(starColor);
            starColorUpdate.SetToMaterial(starRenderer.sharedMaterial);

            edgeStarColorUpdate.SetValueCPUOnly(edgeStarColor);
            edgeStarColorUpdate.SetToMaterial(starRenderer.sharedMaterial);

            base.showButtons.save = true;
            base.showButtons.load = true;
            base.autoSaveOnClose = false;

            base.Start();
        }
Example #4
0
    ///
    public void OnGUI()
    {
        GUILayout.BeginArea(new Rect(0, 0, position.width, position.height));
        uiScroll = EditorGUILayout.BeginScrollView(uiScroll, false, false, GUILayout.MinWidth(300), GUILayout.MaxWidth(position.width));

        float rightPad     = 23;
        float minWidth     = 315;
        float sectionWidth = position.width - rightPad;
        float logoSize     = 128;

        Rect logoRect = EditorGUILayout.BeginVertical(); {
            GUILayout.Space(32);
            drawSkyshopLogo(sectionWidth - logoSize, logoRect.y, logoSize);
        } EditorGUILayout.EndVertical();

        uiHideDuringCompute = false;        //EditorGUILayout.Toggle("Hide UI During Compute",uiHideDuringCompute);
        if (!uiHideDuringCompute || !ps.isPlaying())
        {
            // INPUT REF
            EditorGUILayout.BeginVertical(); {
                inSKY.previewWidth = Mathf.Max(328, (int)sectionWidth - 2);
                inSKY.drawGUI();
                outDIM.inputPath = outSIM.inputPath = outSKY.inputPath = inSKY.fullPath;
            } EditorGUILayout.EndVertical();

            // OUTPUT REF
            EditorGUILayout.BeginVertical("HelpBox", GUILayout.Width(sectionWidth), GUILayout.MinWidth(minWidth)); {
                uiRefOptions = EditorGUILayout.Foldout(uiRefOptions, "Output Cubemaps");
                if (uiRefOptions)
                {
                    outSKY.drawGUI(); EditorGUILayout.Space();
                    outDIM.drawGUI(); EditorGUILayout.Space();
                    outSIM.drawGUI(); EditorGUILayout.Space();

                    EditorGUILayout.BeginHorizontal(); {
                        //apply buttons
                        if (GUILayout.Button(new GUIContent("Edit Active", ""), GUILayout.Width(80), GUILayout.Height(32)))
                        {
                            Sky sky = Sky.activeSky;
                            //sky = uiSelectedSky;
                            if (sky)
                            {
                                outSKY.HDR = sky.hdrSky;
                                outDIM.HDR = sky.hdrDiff;
                                outSIM.HDR = sky.hdrSpec;
                                outSKY.setReference(AssetDatabase.GetAssetPath(sky.skyboxCube), false);
                                outDIM.setReference(AssetDatabase.GetAssetPath(sky.diffuseCube), false);
                                outSIM.setReference(AssetDatabase.GetAssetPath(sky.specularCube), true);
                            }
                        }
                        EditorGUI.BeginDisabledGroup(uiSelectedSky == null);
                        if (GUILayout.Button(new GUIContent("Apply to Selected", ""), GUILayout.Width(130), GUILayout.Height(32)))
                        {
                            if (uiSelectedSky)
                            {
                                Undo.RegisterSceneUndo("Apply to Selected Sky");
                                uiSelectedSky.diffuseCube     = outDIM.cube;
                                uiSelectedSky.specularCube    = outSIM.cube;
                                uiSelectedSky.skyboxCube      = outSKY.cube;
                                uiSelectedSky.masterIntensity = 1f;
                                uiSelectedSky.skyIntensity    = 1f;
                                uiSelectedSky.diffIntensity   = 1f;
                                uiSelectedSky.specIntensity   = 1f;
                                uiSelectedSky.hdrSky          = outSKY.HDR;
                                uiSelectedSky.hdrSpec         = outSIM.HDR;
                                uiSelectedSky.hdrDiff         = outDIM.HDR;
                                uiSelectedSky.Apply();                                 //Apply to Selected
                                SceneView.RepaintAll();
                            }
                        }
                        EditorGUI.EndDisabledGroup();
                        if (GUILayout.Button(new GUIContent("Add to Scene", ""), GUILayout.Width(100), GUILayout.Height(32)))
                        {
                            Sky skyScript = addSky();
                            if (skyScript)
                            {
                                skyScript.diffuseCube     = outDIM.cube;
                                skyScript.specularCube    = outSIM.cube;
                                skyScript.skyboxCube      = outSKY.cube;
                                skyScript.masterIntensity = 1f;
                                skyScript.skyIntensity    = 1f;
                                skyScript.diffIntensity   = 1f;
                                skyScript.specIntensity   = 1f;
                                skyScript.hdrSky          = outSKY.HDR;
                                skyScript.hdrSpec         = outSIM.HDR;
                                skyScript.hdrDiff         = outDIM.HDR;
                                skyScript.Apply();                                 //Add to Scene
                                SceneView.RepaintAll();
                            }
                        }
                    } EditorGUILayout.EndHorizontal();
                    EditorGUILayout.Space();
                }                // end if uiRefOptions
            } EditorGUILayout.EndVertical();

            // BASIC
            string tipExposure = "A multiplier on all the pixels in the Input Panorama during computation. Use for uniform brightness adjustment of results.";
            string tipQuality  = "Changes some advanced options to balance between image quality and computation speed.";

            EditorGUILayout.BeginVertical("HelpBox", GUILayout.Width(sectionWidth), GUILayout.MinWidth(minWidth)); {
                uiBasicOptions = EditorGUILayout.Foldout(uiBasicOptions, "Basic Options");
                if (uiBasicOptions)
                {
                    float newExposure = EditorGUILayout.FloatField(new GUIContent("Baked Exposure", "Baked Exposure -\n" + tipExposure), uiExposure, GUILayout.Width(300));
                    newExposure = Mathf.Max(0.0f, newExposure);
                    if (newExposure != uiExposure)
                    {
                        Undo.RegisterUndo(this, "Change Exposure");
                        uiExposure = newExposure;
                    }


                    Quality newQuality = (Quality)EditorGUILayout.EnumPopup(
                        new GUIContent("Quality", "Quality -\n" + tipQuality),
                        (Quality)uiConvoQuality,
                        GUILayout.Width(300)
                        );

                    if (newQuality != uiConvoQuality)
                    {
                        Undo.RegisterUndo(this, "Change Quality");
                        uiConvoQuality = newQuality;
                        switch (uiConvoQuality)
                        {
                        case Quality.ultra:     uiConvoSize = 64; break;

                        case Quality.high:              uiConvoSize = 32; break;

                        case Quality.medium:    uiConvoSize = 16; break;

                        case Quality.low:               uiConvoSize = 8; break;
                        }
                    }

                    /*
                     * uiCubeSize = (TexSize)EditorGUILayout.EnumPopup(
                     *      new GUIContent("Output Size (cube)","Output Size -\n"+tipCubeSize),
                     *      (CubeSize)uiCubeSize,
                     *      GUILayout.Width(300)
                     * );*/

                    EditorGUILayout.Space();
                }                // end if uiBasicOptions
            } EditorGUILayout.EndVertical();

            // PRO MOVES
            string tipConvoSize    = "Resolution the input panorama is downsampled to for convolution, must be power of 2.\n\nWarning: High resolutions can lead to VERY long computation times!";
            string tipMipChain     = "If enabled, different specular gloss exponents are computed and stored in each mipmap level of the Specular Output cube.\n\nThis must be enabled for Gloss Maps to function in Marmoset Shaders.";
            string tipExponent     = "Gloss exponent used in computing the Specular Output cubemap. Value must be a power of 2, lower values result in a blurrier cubemap. Only available when \"Build Mip Chains\" is disabled.";
            string tipExponents    = "Displays a list of the specular gloss exponents used in the various mip levels of the Specular Output cube.";
            string tipResponsiveUI = "Enable if Unity is too unresponsive during computation. Will slow overall computation time.";
            string tipReflection   = "Highest gloss level in the specular mip chain is a polished mirror reflection pulled from the input panorama itself.";

            EditorGUILayout.BeginVertical("HelpBox", GUILayout.Width(sectionWidth), GUILayout.MinWidth(minWidth));
            {
                uiAdvancedOptions = EditorGUILayout.Foldout(uiAdvancedOptions, "Advanced Options");
                if (uiAdvancedOptions)
                {
                    int newConvoSize = EditorGUILayout.IntField(
                        new GUIContent("Convolution Size", "Convolution Size -\n" + tipConvoSize),
                        uiConvoSize,
                        GUILayout.Width(300)
                        );

                    if (newConvoSize < 2)
                    {
                        newConvoSize = 2;
                    }
                    newConvoSize += newConvoSize % 2;

                    if (newConvoSize != uiConvoSize)
                    {
                        Undo.RegisterUndo(this, "Change Convolution Size");
                        uiConvoSize    = newConvoSize;
                        uiConvoQuality = Quality.custom;
                        switch (uiConvoSize)
                        {
                        case 8: uiConvoQuality = Quality.low; break;

                        case 16: uiConvoQuality = Quality.medium; break;

                        case 32: uiConvoQuality = Quality.high; break;

                        case 64: uiConvoQuality = Quality.ultra; break;
                        }
                        ;
                    }
                    EditorGUILayout.Space();
                    CubemapGUI.drawStaticGUI();

                    bool newMipChain = EditorGUILayout.Toggle(new GUIContent("Build Specular Mip Chain", "Specular Mip Chains -\n" + tipMipChain), uiMipChain);
                    if (newMipChain != uiMipChain)
                    {
                        Undo.RegisterUndo(this, "Toggle Specular Mip Chain");
                        uiMipChain = newMipChain;
                    }
                    if (uiMipChain)
                    {
                        bool newRefInSIM = EditorGUILayout.Toggle(new GUIContent("Highest Mip is Reflection", "Highest Mip is Reflection -\n" + tipReflection), uiReflectionInSIM);
                        if (newRefInSIM != uiReflectionInSIM)
                        {
                            Undo.RegisterUndo(this, "Toggle Mip Chain Reflection");
                            uiReflectionInSIM = newRefInSIM;
                        }
                        EditorGUI.BeginDisabledGroup(true);
                        string mipString;
                        if (uiReflectionInSIM)
                        {
                            mipString = "mirror, 128, 64, 32, 16...";
                        }
                        else
                        {
                            mipString = "256, 128, 64, 32, 16, 8...";
                        }
                        EditorGUILayout.TextField(new GUIContent("Specular Exponents", "Specular Exponents -\n" + tipExponents), mipString, GUILayout.Width(300));
                        EditorGUI.EndDisabledGroup();
                    }
                    else
                    {
                        EditorGUI.BeginDisabledGroup(true);
                        EditorGUILayout.Toggle(new GUIContent("Highest Mip is Reflection", "Highest Mip is Reflection -\n" + tipReflection), false);
                        EditorGUI.EndDisabledGroup();
                        int newExponent = EditorGUILayout.IntField(
                            new GUIContent("Specular Exponent", "Specular Exponent -\n" + tipExponent),
                            uiExponent,
                            GUILayout.Width(300)
                            );
                        newExponent = Mathf.Max(1, newExponent);
                        if (newExponent != uiExponent)
                        {
                            Undo.RegisterUndo(this, "Change Specular Exponent");
                            uiExponent = newExponent;
                        }
                    }
                    EditorGUILayout.Space();

                    //TODO: Will anyone ever want this? Marmoset shaders need gamma compression as does sRGB sampling.
                    uiGammaCompress = true;

                    /*
                     * uiGammaCompress = EditorGUILayout.Toggle(new GUIContent(
                     *      "Gamma-Compress RGBM",
                     *      "Gamma-Compress RGBM -\nIf enabled, a gamma of 1/2.2 is applied to HDR data before it is encoded as RGBM. This adds dynamic range but also shader complexity. Leave enabled for Marmoset shaders."),
                     *      uiGammaCompress);
                     */

                    uiResponsiveUI = stepsPerFrame <= 1024 * 16;
                    uiResponsiveUI = EditorGUILayout.Toggle(new GUIContent("Keep UI Responsive", "Keep UI Responsive -\n" + tipResponsiveUI), uiResponsiveUI);
                    ulong newStepsPerFrame = stepsPerFrame;
                    if (uiResponsiveUI)
                    {
                        newStepsPerFrame = 1024 * 16;
                    }
                    else
                    {
                        newStepsPerFrame = 1024 * 256;
                    }

                    if (newStepsPerFrame != stepsPerFrame)
                    {
                        Undo.RegisterUndo(this, "Toggle Responsive UI");
                        stepsPerFrame = newStepsPerFrame;
                    }
                    EditorGUILayout.Space();


                    if (GUILayout.Button("Reset to Default", GUILayout.Width(120)))
                    {
                        uiConvoSize       = Mathf.Min(uiConvoSize, 16);
                        uiMipChain        = true;
                        uiReflectionInSIM = true;
                        uiResponsiveUI    = false;
                        uiGammaCompress   = true;
                    }
                    EditorGUILayout.Space();
                }
            } EditorGUILayout.EndVertical();

            EditorGUILayout.Space();
            EditorGUILayout.Space();
        }

        //GENERATE
        bool generate = false;
        bool cancel   = false;

        EditorGUILayout.BeginHorizontal(); {
            if (ps.isPlaying())
            {
                cancel = GUILayout.Button("Abort", GUILayout.Width(130), GUILayout.Height(50));
            }
            else
            {
                bool valid = true;
                if (inSKY.input == null)
                {
                    valid = false;
                }
                if (outSKY.cube == null && outDIM.cube == null && outSIM.cube == null)
                {
                    valid = false;
                }
                EditorGUI.BeginDisabledGroup(!valid);
                generate = GUILayout.Button("Compute", GUILayout.Width(130), GUILayout.Height(50));
                EditorGUI.EndDisabledGroup();

                if (!valid)
                {
                    EditorGUILayout.BeginVertical();
                    if (inSKY.input == null)
                    {
                        EditorGUILayout.HelpBox("Input Panorama is missing.", MessageType.Error);
                    }
                    if (outSKY.cube == null && outDIM.cube == null && outSIM.cube == null)
                    {
                        EditorGUILayout.HelpBox("An Output Cubemap is needed.", MessageType.Error);
                    }
                    EditorGUILayout.EndVertical();
                }
            }
        } EditorGUILayout.EndHorizontal();
        if (cancel)
        {
            ps.pause();
            Repaint();

            inSKY.locked              =
                outSKY.locked         =
                    outDIM.locked     =
                        outSIM.locked = false;
            inSKY.updateBuffers();
        }

        progressRect       = GUILayoutUtility.GetRect(sectionWidth - 4, 16);
        progressRect.width = sectionWidth;
        progressRect.x     = 4;
        progressRect.y    += 2;

        //uiShowPreview = true;
        if (uiShowPreview)
        {
            EditorGUILayout.LabelField("Convolution Preview");
            float previewWidth  = position.width - rightPad;
            float previewHeight = previewWidth * 0.5f;
            Util.GUILayout.drawTexture(4, 0, previewWidth, previewHeight, "", uiConvoPreview, false);
        }

        if (generate)
        {
            startConvo();
            ps.repaintMetric.begin();
        }

        if (ps.isPlaying())
        {
            if (ps.curr == 0)
            {
                finishSKY();
            }
            if (ps.done())
            {
                ps.repaintMetric.end();
                finishConvo();
                Repaint();
                ps.pause();
            }
            else
            {
                ps.repaintMetric.end();
                //execute a subset of convolution steps, take a break to repaint the gui, then continue convolution
                stepConvo();
                EditorGUI.ProgressBar(progressRect, ps.progress(), "Convolution Progress " + Mathf.Floor(100f * ps.progress()) + "%");
                Repaint();
                ps.pendingRepaint = false;
                ps.repaintMetric.begin();
            }
        }

        if (ps.isPlaying() && !ps.done())
        {
            EditorGUI.ProgressBar(progressRect, ps.progress(), "Convolution Progress " + Mathf.Floor(100f * ps.progress()) + "%");
        }

        //DEBUG OPTIONS

        /*
         * EditorGUILayout.BeginVertical("HelpBox", GUILayout.Width(sectionWidth), GUILayout.MinWidth(minWidth)); {
         *      uiPerfReport = EditorGUILayout.Foldout(uiPerfReport,"Debug");
         *      if( uiPerfReport ) {
         *              uiShowPreview = EditorGUILayout.Toggle("Show Preview", uiShowPreview, GUILayout.Height(16));
         *              EditorGUILayout.Space();
         *
         *              string report = "Performance Report\n";
         *              report += ps.totalMetric.getString("Total",0);
         *              report += ps.initMetric.getString("Init",1);
         *              report += ps.blockMetric.getString("Coroutine Step",1);
         *              report += ps.passWriteMetric.getString("Cube Write",2);
         *              report += ps.repaintMetric.getString("Repaint", 1);
         *              report += ps.finishMetric.getString("Finalize", 1);
         *              EditorGUILayout.SelectableLabel(report, "HelpBox", GUILayout.Height(360));
         *              EditorGUILayout.Space();
         *              selectTest();
         *      }
         * }EditorGUILayout.EndVertical();
         */

        EditorGUILayout.BeginVertical("HelpBox", GUILayout.Width(sectionWidth), GUILayout.MinWidth(minWidth));
        {
            uiGIOptions = EditorGUILayout.Foldout(uiGIOptions, "Beast Global Illum Options");
            if (uiGIOptions)
            {
                BeastConfig.DrawGUI();
                EditorGUILayout.Space();
            }
        } EditorGUILayout.EndVertical();


        EditorGUILayout.EndScrollView();
        GUILayout.EndArea();

        //GUIUtility.ExitGUI();
    }
Example #5
0
        public int Load(SceneNode _node, ShaderType type)
        {
            BaseShader shader = null;
            switch (type)
            {
                case ShaderType.Sky:
                    if (Reference.Viewer.IsDrawSky)
                    {
                        shader = new Sky(Reference.Viewer, ParentNode);
                    }
                    break;

                case ShaderType.Sea:
                    if (Reference.Viewer.IsDrawSea)
                    {
                        if (Reference.Viewer.SeaQuality == Viewer.ShaderLevelType.Low)
                            shader = new Sea(Reference.Viewer, ParentNode);
                    }
                    break;

                case ShaderType.AdvancedSea:
                    if (Reference.Viewer.IsDrawSea)
                    {
                        if (Reference.Viewer.SeaQuality == Viewer.ShaderLevelType.High)
                            shader = new AdvancedSea(Reference.Viewer, ParentNode);
                    }
                    break;

                case ShaderType.Shadow:
                    if (Reference.Viewer.IsDrawSky)
                    {
                    }
                    break;
            }

            int res = -1;
            if (shader != null)
            {
                // Load shader.
                //Reference.Device.FileSystem.WorkingDirectory = Util.ApplicationDataDirectory + @"\media";
                res = shader.Load();
                if (res > 0)
                {
                    if (shaders.ContainsKey(type))
                    {
                        Reference.Log.Debug("[SHADER]: " + type.ToString() + " Read multi.");
                    }
                    else
                    {
                        lock (shaders)
                        {
                            shaders.Add(type, shader);
                        }

                        lock (shaderIndex)
                        {
                            shaderIndex.Add(type, res);
                        }
                    }
                }
                else
                {
                    Reference.Log.Debug("[SHADER]: " + type.ToString() + " Shader don't load.");
                }
            }

            return res;
        }
Example #6
0
        public override void LoadContent()
        {
            switchCamera();

            midTerrain = new Vector3(terrain.terrainWidth / 2, waterLevel, terrain.terrainLength / 2);

              //Create water
            water = new WaterBase(midTerrain, waterLevel, new Vector2(terrain.TerrainWidth, terrain.TerrainLength), baseWaterKey, waveKey, baseWaterRowX, baseWaterRowY, "water", amountWaves, Game);
            Game.Components.Add(water);

            //Adding the models
            Models.AddModels addModels = new Models.AddModels(Game, models, terrain, modelmapKey, Game.Content);

            foreach (Models.LFModel model in models)
                if (!Game.Components.Contains(model))
                    Game.Components.Add(model);

            //Load songs.
            this.smallFireSong = Game.Assets.Load<Song>("flamesmall");
            this.mediumFireSong = Game.Assets.Load<Song>("flamemedium");
            this.bigFireSong = Game.Assets.Load<Song>("flamebig");
            this.songPlayTimeCounter = 0;
            this.currentlyPlaying = this.smallFireSong;
            MediaPlayer.Play(this.currentlyPlaying);

            //Load Soundeffects.
            SoundEffect s = Game.Assets.Load<SoundEffect>("collectmeteor");
            this.collectMeteorInstance = s.CreateInstance();
            s = Game.Assets.Load<SoundEffect>("treefall");
            this.treeFallInstance = s.CreateInstance();
            s = Game.Assets.Load<SoundEffect>("watersplash");
            this.waterSplash = s.CreateInstance();
            s = Game.Assets.Load<SoundEffect>("burnsomething");
            this.burnSomething = s.CreateInstance();
            s = Game.Assets.Load<SoundEffect>("collectstar");
            this.collectStarInstance = s.CreateInstance();

            foreach (Models.LFModel model in models) {
                if (model is Coal) {
                    Vector3 pos = model.Position + new Vector3(0, 0.5f, -1.5f);
                    BillBoard.HorizontalBillboarding circle = new BillBoard.HorizontalBillboarding(pos, pos.Y, new Vector2(6), Game.Assets.Load<Texture2D>("circle"), 1, 1, Game.GraphicsDevice, Game.Content, Game);
                    Game.Components.Add(circle);
                } else if (model is Meteoriet) {
                    Vector3 pos = model.Position + new Vector3(0, 32, 0);
                    BillBoard.VerticalBillBoard beam = new BillBoard.VerticalBillBoard(pos, pos.Y, new Vector2(6, 50), Game.Assets.Load<Texture2D>("lightbeam"), 1, 1, Game.GraphicsDevice, Game.Content, Game);
                    Game.Components.Add(beam);
                } else if (model is Tree && this is States.GreenHills.Tutorial) {
                    Vector3 pos = model.Position + new Vector3(0, 0.5f, 0f);
                    BillBoard.HorizontalBillboarding circle = new BillBoard.HorizontalBillboarding(pos, pos.Y, new Vector2(7), Game.Assets.Load<Texture2D>("circletree"), 1, 1, Game.GraphicsDevice, Game.Content, Game);
                    Game.Components.Add(circle);
                }
            }

            foreach (Models.LFModel model in models) {
                if (model is Meteoriet) {
                    Vector3 pos = model.Position + new Vector3(0.5f, 0.5f, 0f);
                    BillBoard.HorizontalBillboarding circle = new BillBoard.HorizontalBillboarding(pos, pos.Y, new Vector2(8), Game.Assets.Load<Texture2D>("circle"), 1, 1, Game.GraphicsDevice, Game.Content, Game);
                    Game.Components.Add(circle);
                }
            }

            // If there is a load file, load the game from that point.
            if (loadName != "") {
                loadProgress(loadName);
            }

            //Set the player's position
            player.Position = this.terrain.GetHeightAtPosition(startPosition.X, startPosition.Z, 0);

            //Create the sky
            sky = new Sky(Game, Game.Assets.Load<TextureCube>("sky"));
            Game.Components.Add(sky);
        }
Example #7
0
 public World()
 {
     Sky    = new Sky();
     Name   = "world";
     Chunks = new Dictionary <ChunkLocation, Chunk>();
 }
Example #8
0
 protected BaseSkySim(Sky sky)
 {
     Sky = sky;
 }
Example #9
0
 public ChangeSkyEA(Sky sky)
 {
     Sky = sky;
 }
Example #10
0
        public override bool Init()
        {
            if (!base.Init())
            {
                return(false);
            }

            Effects.InitAll(Device);
            InputLayouts.InitAll(Device);
            RenderStates.InitAll(Device);

            _sky = new Sky(Device, "Textures/grasscube1024.dds", 5000.0f);
            Patch.InitPatchData(Terrain.CellsPerPatch, Device);
            var tii = new InitInfo {
                HeightMapFilename = "Textures/terrain.raw",
                LayerMapFilename0 = "textures/grass.dds",
                LayerMapFilename1 = "textures/darkdirt.dds",
                LayerMapFilename2 = "textures/stone.dds",
                LayerMapFilename3 = "Textures/lightdirt.dds",
                LayerMapFilename4 = "textures/snow.dds",
                BlendMapFilename  = "textures/blend.dds",
                HeightScale       = 50.0f,
                HeightMapWidth    = 2049,
                HeightMapHeight   = 2049,
                CellSpacing       = 0.5f
            };

            _terrain = new Terrain();
            _terrain.Init(Device, ImmediateContext, tii);

            _camera.Height = _terrain.Height;
            _txMgr         = new TextureManager();
            _txMgr.Init(Device);
            _treeModel     = new BasicModel(Device, _txMgr, "Models/tree.x", "Textures");
            _treeInstances = new List <BasicModelInstance>();


            for (var i = 0; i < NumTrees; i++)
            {
                var good = false;
                var x    = MathF.Rand(0, _terrain.Width);
                var z    = MathF.Rand(0, _terrain.Depth);
                while (!good)
                {
                    if (_terrain.Height(x, z) < 12.0f)
                    {
                        good = true;
                    }
                    x = MathF.Rand(-_terrain.Width / 2, _terrain.Width / 2);
                    z = MathF.Rand(-_terrain.Depth / 2, _terrain.Depth / 2);
                }
                var treeInstance = new BasicModelInstance(_treeModel)
                {
                    World = Matrix.RotationX(MathF.PI / 2) * Matrix.Translation(x, _terrain.Height(x, z), z)
                };
                _treeInstances.Add(treeInstance);
            }
            BuildInstancedBuffer();

            return(true);
        }
Example #11
0
        public override void Create()
        {
            base.Create();

            Music.Instance.Play(Assets.HAPPY, true);
            Music.Instance.Volume(1f);

            uiCamera.Visible = false;

            var w = pdsharp.noosa.Camera.Main.CameraWidth;
            var h = pdsharp.noosa.Camera.Main.CameraHeight;

            var archs = new Archs();

            archs.Reversed = true;
            archs.SetSize(w, h);
            Add(archs);

            var vx = Align((w - WIDTH) / 2);
            var vy = Align((h - HEIGHT) / 2);

            var s = pdsharp.noosa.Camera.Main.CameraToScreen(vx, vy);

            _viewport = new pdsharp.noosa.Camera(s.X, s.Y, WIDTH, HEIGHT, defaultZoom);
            pdsharp.noosa.Camera.Add(_viewport);

            var window = new Group();

            window.Camera = _viewport;
            Add(window);

            var dayTime = !Dungeon.NightMode;

            var sky = new Sky(dayTime);

            sky.Scale.Set(WIDTH, HEIGHT);
            window.Add(sky);

            if (!dayTime)
            {
                for (var i = 0; i < Nstars; i++)
                {
                    var size = pdsharp.utils.Random.Float();
                    var star = new ColorBlock(size, size, Color.Argb(255, 255, 255, 255));
                    star.X  = pdsharp.utils.Random.Float(WIDTH) - size / 2;
                    star.Y  = pdsharp.utils.Random.Float(HEIGHT) - size / 2;
                    star.Am = size * (1 - star.Y / HEIGHT);
                    window.Add(star);
                }
            }

            const float range = HEIGHT * 2 / 3;

            for (var i = 0; i < Nclouds; i++)
            {
                var cloud = new Cloud((Nclouds - 1 - i) * (range / Nclouds) + pdsharp.utils.Random.Float(range / Nclouds), dayTime);
                window.Add(cloud);
            }

            var nPatches = (int)(sky.Width / GrassPatch.WIDTH + 1);

            for (var i = 0; i < nPatches * 4; i++)
            {
                var patch = new GrassPatch((i - 0.75f) * GrassPatch.WIDTH / 4, HEIGHT + 1, dayTime);
                patch.Brightness(dayTime ? 0.7f : 0.4f);
                window.Add(patch);
            }

            var a = new Avatar(Dungeon.Hero.heroClass);

            a.X = Align((WIDTH - a.Width) / 2);
            a.Y = HEIGHT - a.Height + 1;
            window.Add(a);

            var pet = new Pet();

            pet.Rm = pet.Gm = pet.Bm = 1.2f;
            pet.X  = WIDTH / 2 + 2;
            pet.Y  = HEIGHT - pet.Height;
            window.Add(pet);

            if (dayTime)
            {
                a.Brightness(1.2f);
                pet.Brightness(1.2f);
            }

            //window.Add(new TouchArea(sky) { protected void OnClick(Touch touch) { pet.Jump(); }; });

            for (var i = 0; i < nPatches; i++)
            {
                var patch = new GrassPatch((i - 0.5f) * GrassPatch.WIDTH, HEIGHT, dayTime);
                patch.Brightness(dayTime ? 1.0f : 0.8f);
                window.Add(patch);
            }

            var frame = new Image(Assets.SURFACE);

            if (!dayTime)
            {
                frame.Hardlight(0xDDEEFF);
            }

            frame.Frame(0, 0, 88, 125);
            frame.X = vx - 4;
            frame.Y = vy - 9;
            Add(frame);

            var gameOver = new RedButton("Game Over");

            gameOver.ClickAction = GameOverClickAction;
            gameOver.SetSize(WIDTH - 10, 20);
            gameOver.SetPos(5 + frame.X + 4, frame.Y + frame.Height + 4);
            Add(gameOver);

            Badge.ValidateHappyEnd();

            FadeIn();
        }
Example #12
0
        public void LoadScenario(Scenario st, TagBase scenario_data)
        {
            this.version = scenario_data.Header.GameVersion;
            int i;

            instanceCollection.Clear();

            //Process palettes
            scenarioTag = st;

            //load bipeds
            for (i = 0; i < st.ScenarioValues.Bipeds.Count; i++)
            {
                CreateInstance(st.ScenarioValues.Bipeds[i]);
            }

            //load decals
            //for(i=0; i<st.ScenarioValues.Decals.Count; i++)
            //  CreateInstance(st.ScenarioValues.Decals[i]);

            //load light fixtures
            for (i = 0; i < st.ScenarioValues.LightFixtures.Count; i++)
            {
                CreateInstance(st.ScenarioValues.LightFixtures[i]);
            }

            //load scenery
            for (i = 0; i < st.ScenarioValues.Scenery.Count; i++)
            {
                CreateInstance(st.ScenarioValues.Scenery[i]);
            }

            //load vehicles
            for (i = 0; i < st.ScenarioValues.Vehicles.Count; i++)
            {
                CreateInstance(st.ScenarioValues.Vehicles[i]);
            }

            //load netgame equipment
            for (i = 0; i < st.ScenarioValues.NetgameEquipment.Count; i++)
            {
                CreateInstance(st.ScenarioValues.NetgameEquipment[i]);
            }

            //load sound scenery
            for (i = 0; i < st.ScenarioValues.SoundScenery.Count; i++)
            {
                CreateInstance(st.ScenarioValues.SoundScenery[i]);
            }

            //load player spawns
            for (i = 0; i < st.ScenarioValues.PlayerStartingLocations.Count; i++)
            {
                CreateInstance(st.ScenarioValues.PlayerStartingLocations[i]);
            }

            //load netgame flags
            for (i = 0; i < st.ScenarioValues.NetgameFlags.Count; i++)
            {
                CreateInstance(st.ScenarioValues.NetgameFlags[i]);
            }


            if (st.ScenarioValues.StructureBsps.Count >= 1)
            {
                //get BSP filename
                TagFileName bsp_filename = new TagFileName(st.ScenarioValues.StructureBsps[0].StructureBsp.Value,
                                                           "sbsp", scenario_data.Header.GameVersion);

                //get Sky filename
                TagFileName sky_filename = new TagFileName(st.ScenarioValues.Skies[0].Sky.Value, "sky ", scenario_data.Header.GameVersion);
                TagBase     sky_data     = new TagBase();
                sky_data.LoadTagBuffer(sky_filename);
                BinaryReader sky_br  = new BinaryReader(sky_data.Stream);
                Sky          sky_tag = new Sky();
                sky_tag.Read(sky_br);
                sky_tag.ReadChildData(sky_br);

                MdxRender.RGB fog = new MdxRender.RGB();
                fog.R = sky_tag.SkyValues.OutdoorFogColor.R;
                fog.G = sky_tag.SkyValues.OutdoorFogColor.G;
                fog.B = sky_tag.SkyValues.OutdoorFogColor.B;
                MdxRender.FogColor = fog;

                /// Not sure how these units equate to d3d units - * 2.5 seems to be pretty good.
                MdxRender.FogStart   = sky_tag.SkyValues.OutdoorFogStartDistance.Value * 2.5f;
                MdxRender.FogEnd     = sky_tag.SkyValues.OutdoorFogOpaqueDistance.Value * 2.5f;
                MdxRender.FogDensity = sky_tag.SkyValues.OutdoorFogMaximumDensity.Value;

                MdxRender.ClearColor = Color.FromArgb(
                    (int)(sky_tag.SkyValues.OutdoorAmbientRadiosityColor.R * 255),
                    (int)(sky_tag.SkyValues.OutdoorAmbientRadiosityColor.G * 255),
                    (int)(sky_tag.SkyValues.OutdoorAmbientRadiosityColor.B * 255));

                MdxRender.FogEnabled = true;

                TagFileName sky_model_tfn;

                if (this.version == MapfileVersion.XHALO1)
                {
                    sky_model_tfn = new TagFileName(sky_tag.SkyValues.Model.Value, "mode", scenario_data.Header.GameVersion);
                }
                else
                {
                    sky_model_tfn = new TagFileName(sky_tag.SkyValues.Model.Value, "mod2", scenario_data.Header.GameVersion);
                }

                MdxRender.LoadBsp(bsp_filename, sky_model_tfn);

                //Load up them thar lights for Radiosity
                ProjectManager.RadiosityLights.Clear();
                //sky_tag
                for (int l = 0; l < sky_tag.SkyValues.Lights.Count; l++)
                {
                    RadiosityLight rl = new RadiosityLight();
                    rl.color[0] = sky_tag.SkyValues.Lights[l].Color.R;
                    rl.color[1] = sky_tag.SkyValues.Lights[l].Color.G;
                    rl.color[2] = sky_tag.SkyValues.Lights[l].Color.B;
                    rl.power    = sky_tag.SkyValues.Lights[l].Power.Value;

                    //don't know how this is turned into a vector, but we'll figure it out
                    //for now get x,y from yaw and z component from pitch (make sure Z component is negative)
                    rl.direction.Z = -1;
                    double y, p;
                    y = sky_tag.SkyValues.Lights[l].Direction.Y;
                    p = sky_tag.SkyValues.Lights[l].Direction.P;
                    rl.direction.X = -(float)Math.Cos(y);
                    rl.direction.Y = -(float)Math.Sin(y);
                    rl.direction.Z = -(float)Math.Sin(p);
                    ProjectManager.RadiosityLights.Add(rl);
                    MdxRender.AddGlobalLight(0, rl);
                }
            }

            instanceCollection.UpdateObjectColors();
        }
Example #13
0
 public Day10p1(string inputPath)
 {
     this.inputPath = inputPath;
     sky            = new Sky();
     ReadInput();
 }
Example #14
0
 public void SetSky(Sky s)
 {
     this.sky = knownSkies[s];
 }
Example #15
0
        /// <summary>
        /// Отрисовка всех объектов для каждой камеры
        /// </summary>
        public void Render()
        {
            // Очистка сцены
            GL.ClearColor(BackColor);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            // Параметры
            GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest);
            GL.Enable(EnableCap.Texture2D);
            GL.Enable(EnableCap.CullFace);
            GL.CullFace(CullFaceMode.Back);

            // Отрисовка камеры
            if (Camera != null)
            {
                Camera.Setup();
                if (Sky != null)
                {
                    Camera.LoadSkyMatrix();
                    Sky.Render();
                }
                Camera.LoadMatrix();
                GL.Enable(EnableCap.DepthTest);
                GL.DepthFunc(DepthFunction.Lequal);
            }

            // Расположение камеры
            Vec3 cameraPos = Camera.Position;

            // Сборка объектов
            bool needAlphaPass = false, needBlendPass = false;
            List <RenderableGroup>       opaqueGroups = new List <RenderableGroup>();
            List <RenderableGroup>       alphaTestGroups = new List <RenderableGroup>();
            List <RangedRenderableGroup> alphaBlendGroups = new List <RangedRenderableGroup>();

            foreach (Entity e in Entities)
            {
                if (e.Visible)
                {
                    Matrix4               entityMatrix = e.RenditionMatrix;
                    RenderableGroup       opaque       = new RenderableGroup();
                    RenderableGroup       alphaTest    = new RenderableGroup();
                    RangedRenderableGroup alphaBlend   = new RangedRenderableGroup();

                    IEnumerable <EntityComponent> components = e.GetVisualComponents();
                    foreach (EntityComponent c in components)
                    {
                        switch (c.RenditionPass)
                        {
                        case EntityComponent.TransparencyPass.AlphaTest:
                            alphaTest.Components.Add(c);
                            break;

                        case EntityComponent.TransparencyPass.Blend:
                            alphaBlend.Components.Add(c);
                            break;

                        default:
                            opaque.Components.Add(c);
                            break;
                        }
                    }

                    if (opaque.Components.Count > 0)
                    {
                        opaque.Matrix = entityMatrix;
                        opaqueGroups.Add(opaque);
                    }
                    if (alphaTest.Components.Count > 0)
                    {
                        alphaTest.Matrix = entityMatrix;
                        alphaTestGroups.Add(alphaTest);
                        needAlphaPass = true;
                    }
                    if (alphaBlend.Components.Count > 0)
                    {
                        alphaBlend.Matrix   = entityMatrix;
                        alphaBlend.Distance = (e.Position - cameraPos).LengthSquared;
                        alphaBlendGroups.Add(alphaBlend);
                        needBlendPass = true;
                    }
                }
            }


            // Непрозрачный проход
            foreach (RenderableGroup g in opaqueGroups)
            {
                g.Render();
            }

            // Альфа-проходы
            if (needAlphaPass || needBlendPass)
            {
                // Включение смешивания
                GL.Enable(EnableCap.Blend);
                GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

                // Альфатест-проход
                if (needAlphaPass)
                {
                    // Включение альфатеста
                    if (GraphicalCaps.ShaderPipeline)
                    {
                        ShaderSystem.IsAlphaTest = true;
                    }
                    else
                    {
                        GL.Enable(EnableCap.AlphaTest);
                        GL.AlphaFunc(AlphaFunction.Gequal, 0.9f);
                    }

                    // Отрисовка поверхностей
                    foreach (RenderableGroup g in alphaTestGroups)
                    {
                        g.Render();
                    }

                    // Отключение альфатеста
                    if (GraphicalCaps.ShaderPipeline)
                    {
                        ShaderSystem.IsAlphaTest = false;
                    }
                    else
                    {
                        GL.Disable(EnableCap.AlphaTest);
                    }
                }

                // Отключение смешивания
                if (needBlendPass)
                {
                    // Сначала - сортировка всех объектов от дальних к ближним
                    alphaBlendGroups.Sort((a, b) => {
                        return(b.Distance.CompareTo(a.Distance));
                    });

                    // Отключение записи в буфер глубины
                    GL.DepthMask(false);

                    // Отрисовка всех поверхностей
                    foreach (RangedRenderableGroup rg in alphaBlendGroups)
                    {
                        rg.Render();
                    }

                    // Включение буффера глубины
                    GL.DepthMask(true);
                }

                // Отключение смешивания
                GL.Disable(EnableCap.Blend);
            }

            // Отключение состояний
            GL.Disable(EnableCap.DepthTest);
        }
Example #16
0
 public void ChangeSky(Sky sky)
 {
     this.levelData.Sky = sky;
     this.OnSkyChanged();
 }
Example #17
0
 public void Load()
 {
     sky = FmbUtil.ReadObject <Sky>(OutputPath.OutputPathDir + "skies/" + LevelManager.Instance.loaded.SkyName.ToLower() + ".xnb");
     InitializeSky();
 }
Example #18
0
    // Binds IBL data, exposure, and a skybox texture globally.
    public void Apply()
    {
        #if UNITY_3_5
        if (this.enabled && this.gameObject.active)
        {
        #else
        if (this.enabled && this.gameObject.activeInHierarchy)
        {
        #endif
            //turn off previously bound sky
            if (Sky.activeSky != null)
            {
                Sky.activeSky.UnApply();
            }
            Sky.activeSky = this;

            //bind cubemaps
            if (diffuseCube)
            {
                Shader.SetGlobalTexture("_DiffCubeIBL", diffuseCube);
            }
            else
            {
                Shader.SetGlobalTexture("_DiffCubeIBL", blackCube);
            }

            if (specularCube)
            {
                Shader.SetGlobalTexture("_SpecCubeIBL", specularCube);
            }
            else
            {
                Shader.SetGlobalTexture("_SpecCubeIBL", blackCube);
            }

            if (showSkybox)
            {
                if (skyboxCube)
                {
                    Shader.SetGlobalTexture("_SkyCubeIBL", skyboxCube);
                }
                else
                {
                    Shader.SetGlobalTexture("_SkyCubeIBL", blackCube);
                }
            }

            //build exposure values for shader, HDR skies need the RGBM expansion constant 6.0 in there
            exposures.x = masterIntensity * diffIntensity;
            exposures.y = masterIntensity * specIntensity;
            exposures.z = masterIntensity * skyIntensity * camExposure;         //exposure baked right into skybox exposure
            exposures.w = camExposure;

            //prepare exposure values for gamma correction
            float toLinear = 2.2f;
            float toSRGB   = 1 / toLinear;
            float hdrScale = 6f;
            if (linearSpace)
            {
                //HDR scale needs to be applied in linear space
                hdrScale = Mathf.Pow(6f, toLinear);
            }
            else
            {
                //Exposure values are treated as being in linear space, but the shader is working in sRGB space.
                //Move exposure into sRGB as well before applying.
                exposures.x = Mathf.Pow(exposures.x, toSRGB);
                exposures.y = Mathf.Pow(exposures.y, toSRGB);
                exposures.z = Mathf.Pow(exposures.z, toSRGB);
                exposures.w = Mathf.Pow(exposures.w, toSRGB);
            }
            //RGBM cubemaps need a scalar added to their exposure
            if (hdrDiff)
            {
                exposures.x *= hdrScale;
            }
            if (hdrSpec)
            {
                exposures.y *= hdrScale;
            }
            if (hdrSky)
            {
                exposures.z *= hdrScale;
            }

            Shader.SetGlobalVector("_ExposureIBL", exposures);

            //upload the sky transform to the shader
            ApplySkyTransform();

            //enable any lights parented to this sky
            toggleChildLights(true);

            //NOTE: this causes scene changes on sky selection, may not be desireable in the editor!
            if (showSkybox)
            {
                RenderSettings.skybox = skyboxMaterial;
            }
            else
            {
                if (RenderSettings.skybox &&
                    RenderSettings.skybox.name == "Internal IBL Skybox")
                {
                    RenderSettings.skybox = null;
                }
            }

            //toggle between linear-space (gamma-corrected) and gamma-space (uncorrected) shader permutations
            Shader.DisableKeyword("MARMO_GAMMA");
            Shader.DisableKeyword("MARMO_LINEAR");
            if (linearSpace)
            {
                Shader.EnableKeyword("MARMO_LINEAR");
            }
            else
            {
                Shader.EnableKeyword("MARMO_GAMMA");
            }

            //this is a hint for the Beast Lightmapper, rendering is unaffected
            Shader.SetGlobalFloat("_EmissionLM", 1f);
        }
    }
Example #19
0
    public override void OnInspectorGUI()
    {
        bool dirty = false;
        Sky  sky   = target as Sky;

        //sync GUI from sky
        camExposure     = sky.camExposure;
        masterIntensity = sky.masterIntensity;
        skyIntensity    = sky.skyIntensity;
        diffIntensity   = sky.diffIntensity;
        specIntensity   = sky.specIntensity;

        //sync and sync from CubeGUIs
        dirty |= updateCube(ref sky.skyboxCube, ref sky.hdrSky, refSKY);
        dirty |= updateCube(ref sky.diffuseCube, ref sky.hdrDiff, refDIM);
        dirty |= updateCube(ref sky.specularCube, ref sky.hdrSpec, refSIM);

        bool showSkybox = EditorGUILayout.Toggle(new GUIContent("Show Skybox", "Toggles rendering the background image"), sky.showSkybox);

        if (showSkybox != sky.showSkybox)
        {
            Undo.RegisterUndo(sky, "Skybox Toggle");
            sky.showSkybox = showSkybox;
            // if we're toggling skyboxes off, clear the render settings material
            if (!sky.showSkybox)
            {
                RenderSettings.skybox = null;
            }
            dirty = true;
        }

        bool detect = EditorGUILayout.Toggle(new GUIContent("Auto-Detect Color Space", "If enabled, attempts to detect the project's gamma correction setting and enables/disables the Linear Space option accordingly"), sky.autoDetectColorSpace);

        if (detect != sky.autoDetectColorSpace)
        {
            Undo.RegisterUndo(sky, "Color-Space Detection Change");
            sky.autoDetectColorSpace = detect;
        }

        bool prevLinear = sky.linearSpace;

        if (sky.autoDetectColorSpace)
        {
            sky.linearSpace = PlayerSettings.colorSpace == ColorSpace.Linear;
        }
        EditorGUI.BeginDisabledGroup(sky.autoDetectColorSpace);
        bool userLinearSpace = EditorGUILayout.Toggle(new GUIContent("Linear Space", "Enable if gamma correction is enabled for this project (Edit -> Project Settings -> Player -> Color Space: Linear)"), sky.linearSpace);

        if (userLinearSpace != sky.linearSpace)
        {
            Undo.RegisterUndo(sky, "Color-Space Change");
            sky.linearSpace = userLinearSpace;
        }
        EditorGUI.EndDisabledGroup();
        if (prevLinear != sky.linearSpace)
        {
            dirty = true;
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        //sync sky from GUI
        EditorGUILayout.LabelField(new GUIContent("Master Intensity", "Multiplier on the Sky, Diffuse, and Specular cube intensities"));
        masterIntensity = EditorGUILayout.Slider(masterIntensity, 0f, 10f);
        if (sky.masterIntensity != masterIntensity)
        {
            Undo.RegisterUndo(sky, "Intensity Change");
            sky.masterIntensity = masterIntensity;
            dirty = true;
        }

        EditorGUILayout.LabelField(new GUIContent("Skybox Intensity", "Brightness of the skybox"));
        skyIntensity = EditorGUILayout.Slider(skyIntensity, 0f, 10f);
        if (sky.skyIntensity != skyIntensity)
        {
            Undo.RegisterUndo(sky, "Intensity Change");
            sky.skyIntensity = skyIntensity;
            dirty            = true;
        }

        EditorGUILayout.LabelField(new GUIContent("Diffuse Intensity", "Multiplier on the diffuse light put out by this sky"));
        diffIntensity = EditorGUILayout.Slider(diffIntensity, 0f, 10f);
        if (sky.diffIntensity != diffIntensity)
        {
            Undo.RegisterUndo(sky, "Intensity Change");
            sky.diffIntensity = diffIntensity;
            dirty             = true;
        }

        EditorGUILayout.LabelField(new GUIContent("Specular Intensity", "Multiplier on the specular light put out by this sky"));
        specIntensity = EditorGUILayout.Slider(specIntensity, 0f, 10f);
        if (sky.specIntensity != specIntensity)
        {
            Undo.RegisterUndo(sky, "Intensity Change");
            sky.specIntensity = specIntensity;
            dirty             = true;
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        EditorGUILayout.LabelField(new GUIContent("Camera Exposure", "Multiplier on all light coming into the camera, including IBL, direct light, and glow maps"));
        camExposure = EditorGUILayout.Slider(camExposure, 0f, 10f);
        if (sky.camExposure != camExposure)
        {
            Undo.RegisterUndo(sky, "Exposure Change");
            sky.camExposure = camExposure;
            dirty           = true;
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        dirty |= GUI.changed;

        if (forceDirty)
        {
            forceDirty = false;
            dirty      = true;
        }

        //guess input path
        if (dirty)
        {
            string inPath = refSKY.fullPath;
            if (inPath.Length == 0)
            {
                inPath = refDIM.fullPath;
            }
            if (inPath.Length == 0)
            {
                inPath = refSIM.fullPath;
            }
            if (inPath.Length > 0)
            {
                int uscore = inPath.LastIndexOf("_");
                if (uscore > -1)
                {
                    inPath = inPath.Substring(0, uscore);
                }
                else
                {
                    inPath = Path.GetDirectoryName(inPath) + "/" + Path.GetFileNameWithoutExtension(inPath);
                }
                refSKY.inputPath         =
                    refDIM.inputPath     =
                        refSIM.inputPath = inPath;
            }
            else
            {
                refSKY.inputPath         =
                    refDIM.inputPath     =
                        refSIM.inputPath = "";
            }
        }

        //if the active sky is not whats selected, see whats up with that and try rebinding (catches re-activating disabled skies)
        if (Sky.activeSky != sky)
        {
            dirty = true;
        }

        if (!Application.isPlaying)
        {
            //if any of the cubemaps have changed, refresh the viewport
            if (dirty)
            {
                sky.Apply();                 //SkyInspector dirty
                SceneView.RepaintAll();
            }
            else
            {
                sky.ApplySkyTransform();
            }
        }
    }
Example #20
0
        public override bool Init()
        {
            if (!base.Init())
            {
                return(false);
            }

            Effects.InitAll(Device);
            InputLayouts.InitAll(Device);
            RenderStates.InitAll(Device);
            Patch.InitPatchData(Terrain.CellsPerPatch, Device);

            _sky = new Sky(Device, "Textures/grasscube1024.dds", 5000.0f);

            var tii = new InitInfo {
                HeightMapFilename = null,
                LayerMapFilename0 = "textures/grass.dds",
                LayerMapFilename1 = "textures/darkdirt.dds",
                LayerMapFilename2 = "textures/stone.dds",
                LayerMapFilename3 = "Textures/lightdirt.dds",
                LayerMapFilename4 = "textures/snow.dds",
                BlendMapFilename  = null,
                HeightScale       = 50.0f,
                HeightMapWidth    = 2049,
                HeightMapHeight   = 2049,
                CellSpacing       = 0.5f,

                Seed         = 0,
                NoiseSize1   = 3.0f,
                Persistence1 = 0.7f,
                Octaves1     = 7,
                NoiseSize2   = 2.5f,
                Persistence2 = 0.8f,
                Octaves2     = 3,
            };

            _terrain = new Terrain();
            //_terrain.DebugQuadTree = true;
            _terrain.Init(Device, ImmediateContext, tii);

            _camera.Height = _terrain.Height;


            _camera.SetLens(0.25f * MathF.PI, AspectRatio, 1.0f, 1000.0f);
            _ssao = new Ssao(Device, ImmediateContext, ClientWidth, ClientHeight, _camera.FovY, _camera.FarZ);

            _whiteTex = ShaderResourceView.FromFile(Device, "Textures/white.dds");

            _sMap = new ShadowMap(Device, SMapSize, SMapSize);

            _sceneBounds = new BoundingSphere(new Vector3(), MathF.Sqrt(_terrain.Width * _terrain.Width + _terrain.Depth * _terrain.Depth) / 2);

            _minimap = new Minimap(Device, ImmediateContext, MinimapSize, MinimapSize, _terrain, _camera);

            _sphereModel = new BasicModel();
            _sphereModel.CreateSphere(Device, 0.25f, 10, 10);
            _sphereModel.Materials[0] = new Material {
                Ambient  = Color.Red,
                Diffuse  = Color.Red,
                Specular = new Color4(32, 1.0f, 1.0f, 1.0f)
            };
            _sphereModel.DiffuseMapSRV[0] = _whiteTex;

            _sphere    = new BasicModelInstance(_sphereModel);
            _spherePos = new Vector3(float.MaxValue);
            _path      = null;
            return(true);
        }
Example #21
0
 public SkyTime()
 {
     _Sky = new Sky(AssetsManager.GetShader("Sky"));
     Environment.AmbienceColor = Color4.FloralWhite;
     Environment.FogColor      = Color4.SkyBlue;
 }
Example #22
0
        void Import(List <string> lines, ref SimObject parent)
        {
            SimObject curobj = null;
            var       status = new ImportStatus();

            status = ImportStatus.Properties;

            int bracestartindex = 0;
            int braceendindex   = 0;
            int curpos          = 0;

            int braceskip = 0;

            foreach (var line in lines)
            {
                string l = line;

                if (l.Contains("new") && status == ImportStatus.Properties)
                {
                    var raw      = l.Split(' ')[1];
                    var objclass = raw.Substring(0, raw.IndexOf('('));
                    var name     = raw.Substring(raw.IndexOf('(') + 1, raw.IndexOf(')') - raw.IndexOf('(') - 1);
                    switch (objclass)
                    {
                    case "SimGroup":
                        curobj = new SimGroup()
                        {
                            objname = name
                        };
                        break;

                    case "ScriptObject":
                        curobj = new ScriptObject(name);
                        break;

                    case "Sky":
                        curobj = new Sky()
                        {
                            objname = name
                        };
                        break;

                    case "Sun":
                        curobj = new Sun()
                        {
                            objname = name
                        };
                        break;

                    case "Item":
                        curobj = new Item()
                        {
                            objname = name
                        };
                        break;

                    case "InteriorInstance":
                        curobj = new InteriorInstance()
                        {
                            objname = name
                        };
                        break;

                    case "Path":
                        curobj = new Path()
                        {
                            objname = name
                        };
                        break;

                    case "Marker":
                        curobj = new Marker()
                        {
                            objname = name
                        };
                        break;

                    case "PathedInterior":
                        curobj = new PathedInterior()
                        {
                            objname = name
                        };
                        break;

                    case "Trigger":
                        curobj = new Trigger()
                        {
                            objname = name
                        };
                        break;

                    case "StaticShape":
                        curobj = new StaticShape()
                        {
                            objname = name
                        };
                        break;

                    default:
                        curobj = new SimObject()
                        {
                            objname = name
                        };
                        break;
                    }
                    status = ImportStatus.BracesStart;
                    (parent as SimGroup).Add(curobj);
                }

                if (status == ImportStatus.BracesStart)
                {
                    if (l.Contains("{"))
                    {
                        bracestartindex = curpos;
                        status          = ImportStatus.BracesEnd;
                    }
                }
                if (status == ImportStatus.BracesEnd)
                {
                    if (l.Contains("{"))
                    {
                        braceskip++;
                    }

                    if (l.Contains("};"))
                    {
                        if (braceskip == 1)
                        {
                            braceendindex = curpos;
                            status        = ImportStatus.Children;
                            var childlines = lines.GetRange(bracestartindex + 1, braceendindex - bracestartindex - 1);
                            Import(childlines, ref curobj);
                            status = ImportStatus.Properties;
                        }
                        braceskip--;
                    }
                }

                if (l.Contains("=") && status == ImportStatus.Properties)
                {
                    var property = l.Substring(0, l.IndexOf("=")).Trim();
                    var value    = l.Substring(l.IndexOf("=") + 1, l.IndexOf(";") - l.IndexOf("=") - 1).Trim();
                    value            = value.Trim('"');
                    parent[property] = value;
                }
                curpos++;
            }
        }
Example #23
0

        
        public Level(ITerrain terrain)
        {
            characters = new List<Character>();
            enemies = new List<Enemy>();
            commandos = new List<Commando>();
            objects = new List<ILevelObject>();


            this.terrain = terrain;

            Vector3 skySize = new Vector3(
                this.terrain.Width,
                5 * (this.terrain.maxY - this.terrain.minY),
                this.terrain.Height);
            skySize *= 3;

            this.sky = new Sky(
                this.terrain.Center,
                skySize);



            patches = new List<TerrainPatch>();
            foreach (TerrainPatch tp in this.terrain.Patches)
                patches.Add(tp);

            this.map = new LevelMap(this, 100,100,2);


            //tecnicas de optimizacion

            //plane discard
            planeDiscard = new PlaneDiscard();

            planeDiscard.charactersIn = this.characters;
            planeDiscard.patchesIn = this.patches;

            //regular grid
            regularGrid = new RegularGrid(this.terrain);

            regularGrid.objectsIn = this.objects;
            regularGrid.charactersIn = planeDiscard.charactersOut;
            regularGrid.patchesIn = planeDiscard.patchesOut;


            //renderizado

            this.Renderer = new DefaultRenderer();
            this.Renderer.objects = regularGrid.objectsOut;
            this.Renderer.characters = regularGrid.charactersOut;
            this.Renderer.patches = regularGrid.patchesOut;
        }
Example #25
0
 protected void Start()
 {
     sky = GetComponent <Sky>();
 }
Example #26
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            levelData.models = new List<GameModel>();
            //levelData.positions = new List<Vector3>();
            camera = new FPSCamera(GraphicsDevice.Viewport);
            FPS_Counter_On = config.SettingGroups["DebugFeatures"].Settings["FPSCounterOn"].GetValueAsBool();

            string name = config.SettingGroups["Filenames"].Settings["person"].GetValueAsString();
            person1 = new DrawableModel(Content.Load<Model>(name), Matrix.Identity);

            name = config.SettingGroups["Filenames"].Settings["terrain"].GetValueAsString();
            terrain = new Model();
            terrain = Content.Load<Model>(name);

            sky = Content.Load<Sky>("Models\\sky1");
            // Comment this to remove the framerate counter
            if (FPS_Counter_On == true)
            {
                Components.Add(new FrameRateCounter(this));
            }

            base.Initialize();
        }
Example #27
0
        /// <summary>
        /// Erzeugt eine neue Instanz eines CreativeModeScreen-Objekts und initialisiert diese mit einem Knot3Game-Objekt game, sowie einem Knoten knot.
        /// </summary>
        public CreativeModeScreen(GameCore game, Knot knot)
            : base(game)
        {
            // die Spielwelt
            world = new World (screen: this, drawOrder: DisplayLayer.GameWorld, bounds: Bounds);
            // der Input-Handler
            knotInput = new KnotInputHandler (screen: this, world: world);
            // das Overlay zum Debuggen
            overlay = new Overlay (screen: this, world: world);
            // der Mauszeiger
            pointer = new MousePointer (screen: this);
            // der Maus-Handler für die 3D-Modelle
            modelMouseHandler = new ModelMouseHandler (screen: this, world: world);

            // der Knoten-Renderer
            knotRenderer = new KnotRenderer (screen: this, position: Vector3.Zero);
            world.Add (knotRenderer);

            // visualisiert die BoundingSpheres
            debugBoundings = new DebugBoundings (screen: this, position: Vector3.Zero);
            world.Add (debugBoundings);

            // der Input-Handler zur Kanten-Verschiebung
            edgeMovement = new EdgeMovement (screen: this, world: world, knotRenderer : knotRenderer, position: Vector3.Zero);
            edgeMovement.KnotMoved = OnKnotMoved;

            // der Input-Handler zur Kanten-Einfärbung
            edgeColoring = new EdgeColoring (screen: this);

            // Flächen zwischen Kanten
            edgeRectangles = new EdgeRectangles (screen: this);

            // assign the specified knot
            Knot = knot;

            // Hintergrund
            Sky skyCube = new Sky (screen: this, position: Vector3.Zero);
            world.Add (skyCube);

            // Sonne
            Sun sun = new Sun (screen: this);
            world.Add (sun);

            // Undo-Button
            undoButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Undo",
                onClick: (time) => OnUndo ()
            );
            undoButton.SetCoordinates (left: 0.05f, top: 0.900f, right: 0.15f, bottom: 0.95f);
            undoButton.AlignX = HorizontalAlignment.Center;
            undoButton.IsVisible = false;

            undoButtonBorder = new Border (screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                                           widget: undoButton, lineWidth: 2, padding: 0);

            // Redo-Button
            redoButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Redo",
                onClick: (time) => OnRedo ()
            );
            redoButton.SetCoordinates (left: 0.20f, top: 0.900f, right: 0.30f, bottom: 0.95f);
            redoButton.AlignX = HorizontalAlignment.Center;
            redoButton.IsVisible = false;

            redoButtonBorder = new Border (screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                                           widget: redoButton, lineWidth: 2, padding: 0);

            invisible = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "menu",
            onClick: (time) => {
                // erstelle einen neuen Pausedialog
                knotInput.IsEnabled = false;
                Dialog pauseDialog = new CreativePauseDialog (screen: this, drawOrder: DisplayLayer.Dialog, knot: Knot);
                // füge ihn in die Spielkomponentenliste hinzu
                pauseDialog.Close += (t) => knotInput.IsEnabled = true;
                AddGameComponents (time, pauseDialog);
            }
            );
            invisible.SetCoordinates (left: 1.00f, top: 1.00f, right: 1.10f, bottom: 1.10f);
            invisible.IsVisible = true;
            invisible.AddKey (Keys.Escape);
        }