Пример #1
0
        public override void CreateScene()
        {
            // Set some camera params
            camera.FarClipDistance = 30000;
            camera.NearClipDistance = 20;

            camera.SetPosition(20000, 500, 20000);
            camera.SetDirection(1, 0, 0);

            // Create our text area for display SkyX parameters
            CreateTextArea();

            manager = new SkyManager(base.sceneMgr, base.camera);
            manager.Create();

            // Add our ground atmospheric scattering pass to terrain material
            MaterialPtr material = MaterialManager.Singleton.GetByName(TerrainMaterialName);

            manager.GPUManager.AddGroundPass(material.GetTechnique(0).CreatePass(),5000,SceneBlendType.SBT_TRANSPARENT_COLOUR);

            // Create our terrain
            sceneMgr.SetWorldGeometry("Terrain.cfg");

            // Add a basic cloud layer
            manager.CloudsManager.Add(new CloudLayer.LayerOptions());

            //Add frame evnet
            root.FrameStarted += new FrameListener.FrameStartedHandler(FrameStarted);
        }
Пример #2
0
        //Entities entities = new Entities();
        //SceneNodes nodes = new SceneNodes();
        private void SceneCreating()
        {
            SceneManager sm = OgreWindow.Instance.mSceneMgr;
            Root root = OgreWindow.Instance.mRoot;
            Camera camera = OgreWindow.Instance.mCamera;
            Viewport vp = OgreWindow.Instance.mViewport;
            OgreWindow.Instance.mSceneMgr.SetShadowUseInfiniteFarPlane(true);
            sm.AmbientLight = ColourValue.Black;



            #region shadows
            //sm.ShadowTechnique = ShadowTechnique.SHADOWTYPE_STENCIL_ADDITIVE;
            //sm.ShadowTechnique = ShadowTechnique.SHADOWTYPE_STENCIL_MODULATIVE;

            sm.ShadowTechnique = ShadowTechnique.SHADOWTYPE_NONE; //skyx breaks when shadows are enabled!
            //sm.ShadowTechnique = ShadowTechnique.SHADOWTYPE_TEXTURE_ADDITIVE;
            //sm.ShadowTechnique = ShadowTechnique.SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED;
            //sm.ShadowTechnique = ShadowTechnique.SHADOWTYPE_TEXTURE_MODULATIVE;
            //sm.ShadowTechnique = ShadowTechnique.SHADOWTYPE_TEXTURE_MODULATIVE_INTEGRATED; 
            #endregion





            camera.FarClipDistance = 30000;
            camera.NearClipDistance = .25f;

            //camera.SetPosition(20000, 500, 20000);
            //camera.SetDirection(1, 0, 0);



            skyManager = new SkyManager(sm, OgreWindow.Instance.mCamera);
            skyManager.Create();


            //manager.GPUManager.AddGroundPass(material.GetTechnique(0).CreatePass(), 5000, SceneBlendType.SBT_TRANSPARENT_COLOUR);

            skyManager.CloudsManager.Add(new CloudLayer.LayerOptions());


            #region MHydrax


            if (!DISABLE_MHYDRAX)
            {



                //hydrax = new MHydrax.MHydrax(sm, camera, vp);

                // Hydrax initialization code ---------------------------------------------
                // ------------------------------------------------------------------------

                // Create Hydrax object
                hydrax = new MHydrax.MHydrax(sm, camera, vp);

                // Set hydrax components.
                hydrax.Components = MHydrax.MHydraxComponent.HYDRAX_COMPONENT_CAUSTICS |
                                    MHydrax.MHydraxComponent.HYDRAX_COMPONENT_DEPTH |
                                    MHydrax.MHydraxComponent.HYDRAX_COMPONENT_FOAM |
                                    MHydrax.MHydraxComponent.HYDRAX_COMPONENT_SMOOTH |
                                    MHydrax.MHydraxComponent.HYDRAX_COMPONENT_SUN |
                                    MHydrax.MHydraxComponent.HYDRAX_COMPONENT_UNDERWATER |
                                    MHydrax.MHydraxComponent.HYDRAX_COMPONENT_UNDERWATER_GODRAYS |
                                    MHydrax.MHydraxComponent.HYDRAX_COMPONENT_UNDERWATER_REFLECTIONS;

                //' Create our projected grid module
                //' Parameters:
                //' Hydrax parent pointer
                //' Noise module
                //' Base plane
                //' Normal mode
                //' Projected grid options
                MHydrax.MProjectedGrid m = new MHydrax.MProjectedGrid(hydrax,
                                                    new MHydrax.MPerlin(new MHydrax.MPerlin.MOptions(8, 0.085f, 0.49f, 1.4f, 1.27f, 2f, new Mogre.Vector3(0.5f, 50f, 150000f))),
                                                    new Plane(new Mogre.Vector3(0, 1, 0), new Mogre.Vector3(0, 0, 0)),
                                                    MHydrax.MMaterialManager.MNormalMode.NM_VERTEX,
                                                    new MHydrax.MProjectedGrid.MOptions(256, 35f, 50f, false, false, true, 3.75f));

                //' Set our module
                hydrax.SetModule(m);

                //' Set all parameters instead of loading all parameters from config file:
                //'hydrax.LoadCfg("ProjectedGridDemo.hdx")
                //' #Main options
                hydrax.Position = new Mogre.Vector3(5000, 0, -5000);
                hydrax.PlanesError = 10.5f;
                hydrax.ShaderMode = MHydrax.MMaterialManager.MShaderMode.SM_HLSL;
                hydrax.FullReflectionDistance = 100000000000;
                hydrax.GlobalTransparency = 0;
                hydrax.NormalDistortion = 0.075f;
                hydrax.WaterColor = new Mogre.Vector3(0.139765f, 0.359464f, 0.425373f);
                //' #Sun parameters
                hydrax.SunPosition = new Mogre.Vector3(0, 10000, 0);
                hydrax.SunStrength = 1.75f;
                hydrax.SunArea = 150;
                hydrax.SunColor = new Mogre.Vector3(1f, 0.9f, 0.6f);
                //' #Foam parameters
                hydrax.FoamMaxDistance = 75000000;
                hydrax.FoamScale = 0.0075f;
                hydrax.FoamStart = 0;
                hydrax.FoamTransparency = 1;
                //' #Depth parameters
                hydrax.DepthLimit = 90;
                //' #Smooth transitions parameters
                hydrax.SmoothPower = 5;
                //' #Caustics parameters
                hydrax.CausticsScale = 135;
                hydrax.CausticsPower = 10.5f;
                hydrax.CausticsEnd = 0.8f;
                //' #God rays parameters
                hydrax.GodRaysExposure = new Mogre.Vector3(0.76f, 2.46f, 2.29f);
                hydrax.GodRaysIntensity = 0.015f;
                hydrax.GodRaysManager.SimulationSpeed = 5;
                hydrax.GodRaysManager.NumberOfRays = 100;
                hydrax.GodRaysManager.RaysSize = 0.03f;
                hydrax.GodRaysManager.ObjectsIntersectionsEnabled = false;
                //' #Rtt quality field(0x0 = Auto)
                //' TODO: RTTManager not wrapped yet.
                //'<size>Rtt_Quality_Reflection=0x0
                //'<size>Rtt_Quality_Refraction=0x0
                //'<size>Rtt_Quality_Depth=0x0
                //'<size>Rtt_Quality_URDepth=0x0
                //'<size>Rtt_Quality_GPUNormalMap=0x0

                //' Create water
                hydrax.Create();

                //' Hydrax initialization code end -----------------------------------------
                //' ------------------------------------------------------------------------

                //sm.AmbientLight = new ColourValue(1, 1, 1);
                //camera.FarClipDistance = 99999 * 6;
                //camera.Position = new Mogre.Vector3(312.902f, 206.419f, 1524.02f);
                //camera.Orientation = new Quaternion(0.998f, -0.0121f, -0.0608f, -0.00074f);
            }
            #endregion

            #region physics
            // create the root object
            OgreWindow.Instance.physics = Physics.Create();
            OgreWindow.Instance.physics.Parameters.SkinWidth = 0.0025f;

            // setup default scene params
            SceneDesc sceneDesc = new SceneDesc();
            sceneDesc.SetToDefault();
            sceneDesc.Gravity = new Mogre.Vector3(0, -9.8f, 0);
            sceneDesc.UpAxis = 1; // NX_Y in c++ (I couldn't find the equivilent enum for C#)

            // your class should implement IUserContactReport to use this
            //sceneDesc.UserContactReport = this;

            OgreWindow.Instance.scene = OgreWindow.Instance.physics.CreateScene(sceneDesc);

            // default material
            OgreWindow.Instance.scene.Materials[0].Restitution = 0.5f;
            OgreWindow.Instance.scene.Materials[0].StaticFriction = 0.5f;
            OgreWindow.Instance.scene.Materials[0].DynamicFriction = 0.5f;

            // begin simulation
            OgreWindow.Instance.scene.Simulate(0);
            #endregion

            OgreWindow.Instance.SceneReady = true;
        }