Example #1
0
        public TerrainScreen()
        {
            camera = new FirstPersonCamera(new Vector3(867, 198, -1215));
            projectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, aspectRatio, 1, 10000);

            islandShader = new MultiTextured();
            {
                islandShader.ProjectionMatrix = projectionMatrix;
                islandShader.ViewMatrix = camera.View;
                islandShader.InitParameters();
            }

            mvpshader = new JustMvp();
            {
                mvpshader.ProjectionMatrix = projectionMatrix;
                mvpshader.ViewMatrix = camera.View;
                mvpshader.InitParameters();
            }

            shipShader = new BasicEffect(BaseClass.Device);
            {
                shipShader.Projection = projectionMatrix;
                shipShader.View = camera.View;
            }

            scatteringShader = new Scattaring();
            {
                scatteringShader.ProjectionMatrix = projectionMatrix;
                scatteringShader.ViewMatrix = camera.View;
                scatteringShader.InitParameters();
            }

            waterShader = new WaterShader();
            {
                waterShader.ProjectionMatrix = projectionMatrix;
                waterShader.ViewMatrix = camera.View;
                waterShader.InitParameters();
            }

            cloudShader = new CloudShader();
            {
                cloudShader.ProjectionMatrix = projectionMatrix;
                cloudShader.ViewMatrix = camera.View;
                cloudShader.InitParameters();
            }

            rainShader = new RainShader();
            {
                rainShader.ProjectionMatrix = projectionMatrix;
                rainShader.ViewMatrix = camera.View;
                rainShader.InitParameters();
            }

            rainDropsShader = new RainDropsShader();
            {
                rainDropsShader.InitParameters();
            }

            fogShader = new Pirates.Shaders.Fog();
            {
                fogShader.InitParameters();
            }

            rs = new RasterizerState();
            rs.CullMode = CullMode.None;
            //rs.FillMode = FillMode.WireFrame;

            cloudManager = new CloudManager();
            rainManager = new RainManager();

            Vector3 minBox = new Vector3(-5000f, 300f, -5000f);
            Vector3 maxBox = new Vector3(5000f, 1500f, 5000f);

            int[] allCloudSprites = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
            cloudManager.AddCloud(1000, minBox, maxBox, 0.75f, allCloudSprites);
            cloudManager.Instancer.Update();

            minBox = new Vector3(-800, 320f, -800f);
            maxBox = new Vector3(800f, 0f, 800f);
            rainManager.AddDrop(250000, minBox, maxBox);
            cloudManager.Instancer.Update();

            island = new Terrain("island4", 10, 1);

            water = new Terrain("map2", 30, 1);
            water.Translate(0, 40, 0);
            water.Update();
            reflectionPlane = CreatePlane(40, new Vector3(0, -1, 0), true);
            reflectionMatrix = Matrix.CreateReflection(reflectionPlane);

            skydome = new ObjectSkydome(scatteringShader);
            skydome.Scale(3200);
            skydome.Rotate(-90, new Vector3(1, 0, 0));
            skydome.Update();

            Wind.Direction = MathFunctions.AngleToVector(45);
            //Wind.Force = 1000000f;

            ship = new ObjectShip();
            ship.Translate(-288, 20, -486);
            ship.Update();
            ship.Physics = new ObjectPhysics(50, ship.ModelMatrix);

            if (island.IsOnHeightmap(ship.ModelMatrix.Translation))
            {
                ship.Physics.material = MaterialType.Island;
                island.ColisionWithTerrain(ship);
            }
            else
            {
                ship.Physics.material = MaterialType.Water;
                water.GetObjectPositionOnWater(ship, waterShader);
            }
        }
Example #2
0
        public TerrainScreen(SerializationInfo info, StreamingContext ctxt)
        {
            this.camera = (FirstPersonCamera)info.GetValue("Camera", typeof(FirstPersonCamera));
            this.aspectRatio = (float)info.GetValue("AspectRatio", typeof(float));
            this.projectionMatrix = (Matrix)info.GetValue("ProjectionMatrix", typeof(Matrix));
            this.rs = new RasterizerState();

            islandShader = new MultiTextured();
            {
                islandShader.ProjectionMatrix = projectionMatrix;
                islandShader.ViewMatrix = camera.View;

                islandShader.InitParameters();
            }

            mvpshader = new JustMvp();
            {
                mvpshader.ProjectionMatrix = projectionMatrix;
                mvpshader.ViewMatrix = camera.View;
                mvpshader.InitParameters();
            }

            scatteringShader = new Scattaring();
            {
                scatteringShader.ProjectionMatrix = projectionMatrix;
                scatteringShader.ViewMatrix = camera.View;
                scatteringShader.InitParameters();
            }

            waterShader = new WaterShader();
            {
                waterShader.ProjectionMatrix = projectionMatrix;
                waterShader.ViewMatrix = camera.View;
                waterShader.InitParameters();
            }

            rs = new RasterizerState();
            rs.CullMode = CullMode.None;
            rs.FillMode = FillMode.WireFrame;

            island = new Terrain("island4", 2, 1);
            water = new Terrain("map2", 1, 1);
            water.Translate(0, 30, 0);
            water.Update();

            DepthStencilState depthStencilState = new DepthStencilState();
            depthStencilState.DepthBufferFunction = CompareFunction.LessEqual;
            BaseClass.Device.DepthStencilState = depthStencilState;
        }