Beispiel #1
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            CameraFirstPerson CameraFirstPerson = new CameraFirstPerson(true, GraphicInfo);

            Texture2D   tMap = factory.GetTexture2D("Textures//hmap_10243");
            QuadTerrain q    = new PloobsEngine.Material.QuadTerrain(factory, tMap, 33, 513, 10, 3f);

            DeferredTerrainMaterial mat = new DeferredTerrainMaterial(q);

            //Set various terrain stats.
            mat.diffuseScale      = q.flatScale / 4;
            mat.detailScale       = q.flatScale / 100;
            mat.detailMapStrength = 2;
            mat.textureBlend      = factory.GetTexture2D("Textures//hmap_256blend");
            mat.textureDetail     = factory.GetTexture2D("Textures//coolgrass2DOT3");
            mat.textureRed        = factory.GetTexture2D("Textures//TexR");
            mat.textureGreen      = factory.GetTexture2D("Textures//TexG");
            mat.textureBlue       = factory.GetTexture2D("Textures//TexB");
            mat.textureBlack      = factory.GetTexture2D("Textures//TexBase");

            TerrainObject to = new TerrainObject(factory, Vector3.Zero, Matrix.Identity, q.getHeightMap(), MaterialDescription.DefaultBepuMaterial());

            IObject obj3 = new IObject(mat, null, to);

            this.World.AddObject(obj3);

            LightThrowBepu lt = new LightThrowBepu(this.World, factory);

            #region NormalLight
            DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White);
            DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White);
            DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White);
            DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White);
            DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White);
            float li = 0.5f;
            ld1.LightIntensity = li;
            ld2.LightIntensity = li;
            ld3.LightIntensity = li;
            ld4.LightIntensity = li;
            ld5.LightIntensity = li;
            this.World.AddLight(ld1);
            this.World.AddLight(ld2);
            this.World.AddLight(ld3);
            this.World.AddLight(ld4);
            this.World.AddLight(ld5);
            #endregion


            this.World.CameraManager.AddCamera(CameraFirstPerson);
            CameraFirstPerson.FarPlane = 20000;

            SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//cubemap");
            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc);
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            CameraFirstPerson CameraFirstPerson = new CameraFirstPerson(true, GraphicInfo);

            Texture2D tMap = factory.GetTexture2D("Textures//hmap_10243");
            QuadTerrain q = new PloobsEngine.Material.QuadTerrain(factory, tMap, 33, 513, 10, 3f);

            DeferredTerrainMaterial mat = new DeferredTerrainMaterial(q);

            //Set various terrain stats.
            mat.diffuseScale = q.flatScale / 4;
            mat.detailScale = q.flatScale / 100;
            mat.detailMapStrength = 2;
            mat.textureBlend = factory.GetTexture2D("Textures//hmap_256blend");
            mat.textureDetail = factory.GetTexture2D("Textures//coolgrass2DOT3");
            mat.textureRed = factory.GetTexture2D("Textures//TexR");
            mat.textureGreen = factory.GetTexture2D("Textures//TexG");
            mat.textureBlue = factory.GetTexture2D("Textures//TexB");
            mat.textureBlack = factory.GetTexture2D("Textures//TexBase");

            TerrainObject to = new TerrainObject(factory,Vector3.Zero, Matrix.Identity, q.getHeightMap() ,MaterialDescription.DefaultBepuMaterial());            
                        
            IObject obj3 = new IObject(mat, null, to);
            this.World.AddObject(obj3);

            LightThrowBepu lt = new LightThrowBepu(this.World, factory);

            #region NormalLight
            DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White);
            DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White);
            DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White);
            DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White);
            DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White);
            float li = 0.5f;
            ld1.LightIntensity = li;
            ld2.LightIntensity = li;
            ld3.LightIntensity = li;
            ld4.LightIntensity = li;
            ld5.LightIntensity = li;
            this.World.AddLight(ld1);
            this.World.AddLight(ld2);
            this.World.AddLight(ld3);
            this.World.AddLight(ld4);
            this.World.AddLight(ld5);
            #endregion


            this.World.CameraManager.AddCamera(CameraFirstPerson);
            CameraFirstPerson.FarPlane = 20000;

            SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//cubemap");
            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc);

        }
        public DeferredTerrainMaterial(QuadTerrain QuadTerrain, float lod = 3.5f)
        {
            TerrainShader = QuadTerrain.factory.GetEffect("terrainShader", false, true);
            getDepth = QuadTerrain.factory.GetEffect("ShadowDepth", false, true);
            this.QuadTerrain = QuadTerrain;
            CanAppearOfReflectionRefraction = false;
            CanCreateShadow = false;
            IsVisible = true;
            LOD = lod;

            WorldMatrix = TerrainShader.Parameters["World"];
            ViewMatrix = TerrainShader.Parameters["View"];
            ProjectionMatrix = TerrainShader.Parameters["Projection"];            
        }
        public ForwardTerrainMaterial(QuadTerrain QuadTerrain,float lod = 3.5f)
        {
            TerrainShader = QuadTerrain.factory.GetEffect("terrainShader", false, true);
            this.QuadTerrain = QuadTerrain;
            CanAppearOfReflectionRefraction = false;
            CanCreateShadow = false;
            IsVisible = true;            
            LOD = lod;

            WorldMatrix = TerrainShader.Parameters["World"];
            ViewMatrix = TerrainShader.Parameters["View"];
            ProjectionMatrix = TerrainShader.Parameters["Projection"];
            sunDir = TerrainShader.Parameters["sunlightVector"];
            sunCol = TerrainShader.Parameters["lightColour"];
            ambCol = TerrainShader.Parameters["ambientColour"];
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            CameraFirstPerson CameraFirstPerson = new CameraFirstPerson(true, GraphicInfo);

            Texture2D   tMap = factory.GetTexture2D("Textures//hmap_10243");
            QuadTerrain q    = new PloobsEngine.Material.QuadTerrain(factory, tMap, 33, 513, 10, 3f);

            ForwardTerrainMaterial mat = new ForwardTerrainMaterial(q);

            //Set various terrain stats.
            mat.diffuseScale      = q.flatScale / 4;
            mat.detailScale       = q.flatScale / 100;
            mat.detailMapStrength = 2;
            mat.textureBlend      = factory.GetTexture2D("Textures//hmap_256blend");
            mat.textureDetail     = factory.GetTexture2D("Textures//coolgrass2DOT3");
            mat.textureRed        = factory.GetTexture2D("Textures//TexR");
            mat.textureGreen      = factory.GetTexture2D("Textures//TexG");
            mat.textureBlue       = factory.GetTexture2D("Textures//TexB");
            mat.textureBlack      = factory.GetTexture2D("Textures//TexBase");

            mat.sunlightVector = Vector3.Normalize(new Vector3(.5f, .5f, .8f));
            mat.sunlightColour = new Vector3(2.3f, 2f, 1.8f);
            TerrainObject to = new TerrainObject(factory, Vector3.Zero, Matrix.Identity, q.getHeightMap(), MaterialDescription.DefaultBepuMaterial());

            IObject obj3 = new IObject(mat, null, to);

            this.World.AddObject(obj3);

            LightThrowBepu lt = new LightThrowBepu(this.World, factory);

            this.World.CameraManager.AddCamera(CameraFirstPerson);
            CameraFirstPerson.FarPlane = 20000;

            SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//cubemap");

            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc);
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            CameraFirstPerson CameraFirstPerson = new CameraFirstPerson(true, GraphicInfo);

            Texture2D tMap = factory.GetTexture2D("Textures//hmap_10243");
            QuadTerrain q = new PloobsEngine.Material.QuadTerrain(factory, tMap, 33, 513, 10, 3f);

            ForwardTerrainMaterial mat = new ForwardTerrainMaterial(q);

            //Set various terrain stats.
            mat.diffuseScale = q.flatScale / 4;
            mat.detailScale = q.flatScale / 100;
            mat.detailMapStrength = 2;
            mat.textureBlend = factory.GetTexture2D("Textures//hmap_256blend");
            mat.textureDetail = factory.GetTexture2D("Textures//coolgrass2DOT3");
            mat.textureRed = factory.GetTexture2D("Textures//TexR");
            mat.textureGreen = factory.GetTexture2D("Textures//TexG");
            mat.textureBlue = factory.GetTexture2D("Textures//TexB");
            mat.textureBlack = factory.GetTexture2D("Textures//TexBase");

            mat.sunlightVector = Vector3.Normalize(new Vector3(.5f, .5f, .8f));
            mat.sunlightColour = new Vector3(2.3f, 2f, 1.8f);
            TerrainObject to = new TerrainObject(factory,Vector3.Zero, Matrix.Identity, q.getHeightMap() ,MaterialDescription.DefaultBepuMaterial());            
                        
            IObject obj3 = new IObject(mat, null, to);
            this.World.AddObject(obj3);

            LightThrowBepu lt = new LightThrowBepu(this.World, factory);
                        
            this.World.CameraManager.AddCamera(CameraFirstPerson);
            CameraFirstPerson.FarPlane = 20000;

            SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//cubemap");
            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc);

        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager)
        {
            PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld;

            base.LoadContent(GraphicInfo, factory, contentManager);

            Texture2D tMap = factory.GetTexture2D("Textures//hmap_10243");
            QuadTerrain q = new PloobsEngine.Material.QuadTerrain(factory, tMap, 33, 513, 10, 3f);

            ForwardTerrainMaterial mat = new ForwardTerrainMaterial(q);

            //Set various terrain stats.
            mat.diffuseScale = q.flatScale / 4;
            mat.detailScale = q.flatScale / 100;
            mat.detailMapStrength = 2;
            mat.textureBlend = factory.GetTexture2D("Textures//hmap_256blend");
            mat.textureDetail = factory.GetTexture2D("Textures//coolgrass2DOT3");
            mat.textureRed = factory.GetTexture2D("Textures//TexR");
            mat.textureGreen = factory.GetTexture2D("Textures//TexG");
            mat.textureBlue = factory.GetTexture2D("Textures//TexB");
            mat.textureBlack = factory.GetTexture2D("Textures//TexBase");

            mat.sunlightVector = Vector3.Normalize(new Vector3(.5f, .5f, .8f));
            mat.sunlightColour = new Vector3(2.3f, 2f, 1.8f);
            float[,] f = q.getHeightMap();
            int v = 513;
            var samples = new HeightFieldSample[v * v];

            for (int r = 0; r < v; r++)
            {
                for (int c = 0; c < v ; c++)
                {
                    var sample = new HeightFieldSample()
                    {
                        Height = (short)f[r, c],                        
                        //Height = 5,                        
                        TessellationFlag = 1,
                        MaterialIndex0 = 1,
                        MaterialIndex1 = 0
                    };

                    samples[r * v + c] = sample;
                }
            }

            var heightFieldDesc = new HeightFieldDescription()
            {
                NumberOfRows = v,
                NumberOfColumns = v,                                
                ConvexEdgeThreshold = 0f,

            };
            heightFieldDesc.SetSamples(samples);
            
            var heightField = PhysxPhysicWorld.Core.CreateHeightField(heightFieldDesc);
            
            heightFieldDesc.Dispose();

            var heightFieldShapeDesc = new HeightFieldShapeDescription()
            {
                HeightField = heightField,
                HeightScale = 1.0f,
                RowScale = 1,
                ColumnScale = 1,
            };
            heightFieldShapeDesc.LocalPose = StillDesign.PhysX.MathPrimitives.Matrix.Identity;

            var actorDesc = new ActorDescription()
            {
                GlobalPose = Matrix.Identity.AsPhysX(),
                Shapes = { heightFieldShapeDesc },                
            };

            actor = PhysxPhysicWorld.Scene.CreateActor(actorDesc);

            IObject obj3 = new IObject(mat, null, new PhysxGhostObject());
            this.World.AddObject(obj3);            
            
            BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory);
            this.AttachCleanUpAble(BallThrowBullet);

            CameraFirstPerson CameraFirstPerson = new CameraFirstPerson(GraphicInfo);
            CameraFirstPerson.FarPlane = 20000;
            this.World.CameraManager.AddCamera(CameraFirstPerson);
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld;

            base.LoadContent(GraphicInfo, factory, contentManager);

            Texture2D   tMap = factory.GetTexture2D("Textures//hmap_10243");
            QuadTerrain q    = new PloobsEngine.Material.QuadTerrain(factory, tMap, 33, 513, 10, 3f);

            ForwardTerrainMaterial mat = new ForwardTerrainMaterial(q);

            //Set various terrain stats.
            mat.diffuseScale      = q.flatScale / 4;
            mat.detailScale       = q.flatScale / 100;
            mat.detailMapStrength = 2;
            mat.textureBlend      = factory.GetTexture2D("Textures//hmap_256blend");
            mat.textureDetail     = factory.GetTexture2D("Textures//coolgrass2DOT3");
            mat.textureRed        = factory.GetTexture2D("Textures//TexR");
            mat.textureGreen      = factory.GetTexture2D("Textures//TexG");
            mat.textureBlue       = factory.GetTexture2D("Textures//TexB");
            mat.textureBlack      = factory.GetTexture2D("Textures//TexBase");

            mat.sunlightVector = Vector3.Normalize(new Vector3(.5f, .5f, .8f));
            mat.sunlightColour = new Vector3(2.3f, 2f, 1.8f);
            float[,] f         = q.getHeightMap();
            int v       = 513;
            var samples = new HeightFieldSample[v * v];

            for (int r = 0; r < v; r++)
            {
                for (int c = 0; c < v; c++)
                {
                    var sample = new HeightFieldSample()
                    {
                        Height = (short)f[r, c],
                        //Height = 5,
                        TessellationFlag = 1,
                        MaterialIndex0   = 1,
                        MaterialIndex1   = 0
                    };

                    samples[r * v + c] = sample;
                }
            }

            var heightFieldDesc = new HeightFieldDescription()
            {
                NumberOfRows        = v,
                NumberOfColumns     = v,
                ConvexEdgeThreshold = 0f,
            };

            heightFieldDesc.SetSamples(samples);

            var heightField = PhysxPhysicWorld.Core.CreateHeightField(heightFieldDesc);

            heightFieldDesc.Dispose();

            var heightFieldShapeDesc = new HeightFieldShapeDescription()
            {
                HeightField = heightField,
                HeightScale = 1.0f,
                RowScale    = 1,
                ColumnScale = 1,
            };

            heightFieldShapeDesc.LocalPose = StillDesign.PhysX.MathPrimitives.Matrix.Identity;

            var actorDesc = new ActorDescription()
            {
                GlobalPose = Matrix.Identity.AsPhysX(),
                Shapes     = { heightFieldShapeDesc },
            };

            actor = PhysxPhysicWorld.Scene.CreateActor(actorDesc);

            IObject obj3 = new IObject(mat, null, new PhysxGhostObject());

            this.World.AddObject(obj3);

            BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory);

            this.AttachCleanUpAble(BallThrowBullet);

            CameraFirstPerson CameraFirstPerson = new CameraFirstPerson(GraphicInfo);

            CameraFirstPerson.FarPlane = 20000;
            this.World.CameraManager.AddCamera(CameraFirstPerson);
        }