Example #1
0
        public ShadowMap(
            VisionContent vContent,
            int width,
            int height,
            int nearPlane = 1,
            int farPlane = 200)
        {
            _graphicsDevice = vContent.GraphicsDevice;

            ShadowDepthTarget = RenderTarget2D.New(_graphicsDevice, width, height, PixelFormat.R16G16.Float);
            DepthStencilTarget = DepthStencilBuffer.New(_graphicsDevice, width, height, DepthFormat.Depth16);

            _spriteBatch = new SpriteBatch(_graphicsDevice);
            _shadowBlurEffect = vContent.LoadEffect("Effects/Blur");
            _shadowBlurEffect.Parameters["dx"].SetValue(1f/width);
            _shadowBlurEffect.Parameters["dy"].SetValue(1f/height);
            _shadowBlurTarg = RenderTarget2D.New(_graphicsDevice, width, height, PixelFormat.R16G16.Float);

            ShadowNearPlane = nearPlane;
            ShadowFarPlane = farPlane;
            Camera = new Camera(
                new Vector2(width, height),
                Vector3.Zero,
                Vector3.Up,
                ShadowNearPlane,
                ShadowFarPlane);
            UpdateProjection(60, 60);
        }
Example #2
0
        public Signs(
            VisionContent vContent,
            Matrix world,
            Texture2D texture,
            List<VisionClass> vclasses,
            float width,
            float height)
            : base(vContent, world, texture, width, height, 0)
        {
            _signTextEffect = vContent.LoadEffect("effects/signtexteffect");
            _spriteBatch = new SpriteBatch(Effect.GraphicsDevice);
            _spriteFont = vContent.Load<SpriteFont>("fonts/BlackCastle");
            _vclasses = vclasses;

            foreach (var vc in vclasses)
            {
                vc.GroundBoundingSphere = new BoundingSphere(
                    vc.Position + world.TranslationVector,
                    vc.R);
                vc.SignClickBoundingSphere = new BoundingSphere(
                    vc.Position + world.TranslationVector + new Vector3(0, TextDistanceAboveGround - 2, 0),
                    2);
            }
            AddPositionsWithSameNormal(Vector3.Up, vclasses.Select(vc => vc.Position - world.TranslationVector).ToArray());
            CreateVertices(false);
        }
Example #3
0
 public ShipModel(VisionContent vContent)
     : base(vContent.LoadEffect("effects/SimpleTextureEffect"))
 {
     _model = vContent.Load<Model>(@"Models/galleonmodel");
     _texture = vContent.Load<Texture2D>(@"Models/galleon");
     _boundingSphere = _model.CalculateBounds();
 }
Example #4
0
 public FloatingTexts(VisionContent vcontent, SpriteBatch spriteBatch, SpriteFont font)
     : base(vcontent.LoadEffect("effects/signtexteffect"))
 {
     VContent = vcontent;
     SpriteBatch = spriteBatch;
     Font = font;
 }
Example #5
0
        public Bridge(VisionContent vContent, Matrix world)
            : base(vContent.LoadEffect("effects/SimpleTextureEffect"))
        {
            _model = vContent.Load<Model>(@"Models/bridge");
            _texture = vContent.Load<Texture2D>("textures/bigstone");
            World = world * Matrix.Scaling(0.05f);

            foreach (var part in _model.Meshes.SelectMany(mesh => mesh.MeshParts))
                part.Effect = Effect.Effect;
        }
Example #6
0
 public DrawableBox(VisionContent vContent, Matrix world, Vector3 size, float texScale = 1)
     : base(vContent.LoadEffect("effects/SimpleTextureEffect"))
 {
     _texture = vContent.Load<Texture2D>("textures/brick_texture_map");
     _bumpMap = vContent.Load<Texture2D>("textures/brick_normal_map");
     _cube = new CubePrimitive<VertexPositionNormalTexture>(
         Effect.GraphicsDevice,
         (p,n,t) => createVertex(p,n,t,size,texScale),
         1);
     World = world;
 }
Example #7
0
 public TerrainPlane(VisionContent vContent)
 {
     Effect = vContent.LoadEffect("Effects/Terrain");
     _loPlane = new PlanePrimitive<TerrainVertex>(
         Effect.GraphicsDevice,
         (x, y, w, h) => new TerrainVertex(
             new Vector3(x, 0, y),
             new Vector2(x/SquareSize, y/SquareSize),
             x/SquareSize),
         SquareSize, SquareSize, 5);
 }
 public StaticBillboard(
     VisionContent vContent,
     Matrix world,
     Texture2D texture,
     float width,
     float height)
     : base(vContent.LoadEffect("Billboards/StaticBillboard", vContent.GraphicsDevice.SamplerStates.LinearClamp))
 {
     _world = world;
     _texture = texture;
     _billboardWidth = width;
     _billboardHeight = height;
 }
Example #9
0
        public Windmill(VisionContent vContent, Vector3 location)
            : base(vContent.LoadEffect("effects/SimpleTextureEffect"))
        {
            World = Matrix.RotationY(-MathUtil.PiOverTwo)*Matrix.Scaling(0.005f)*Matrix.Translation(location);
            _model = vContent.Load<Model>("models/windmill");
            _texture = vContent.Load<Texture2D>("textures/windmill_diffuse");
            _bones = new Matrix[_model.Bones.Count];
            _model.CopyAbsoluteBoneTransformsTo(_bones);

            //foreach (var mesh in _model.Meshes)
            //    foreach (var part in mesh.MeshParts)
            //        part.Effect = Effect.Effect;

            _animation = new ObjectAnimation(new Vector3(0, 875, 0), new Vector3(0, 875, 0),
                Vector3.Zero, new Vector3(0, 0, MathUtil.TwoPi),
                TimeSpan.FromSeconds(10), true);
        }
Example #10
0
        public BannerSign(VisionContent vContent, IEnumerable<CodeIsland> islands)
            : base(vContent.LoadEffect("effects/signtexteffect"))
        {
            _spriteBatch = new SpriteBatch(Effect.GraphicsDevice);
            _spriteFont = vContent.Load<SpriteFont>("fonts/BlackCastle");
            _tpds = islands.Select(_ =>
                new TextAndPosAndDistance
                {
                    Text = _.VAssembly.Name,
                    Pos = new Vector3(_.World.M41 + (float) _.GroundExtentX/2, HeightAboveOcean, _.World.M43 + (float) _.GroundExtentZ/2)
                }).ToList();

            foreach (var tpd in _tpds)
            {
                var sz = _spriteFont.MeasureString(tpd.Text)/4*TextSize;
                var extent = new Vector3(sz.X, sz.Y, sz.X);
                tpd.BoundingBox = new BoundingBox(tpd.Pos - extent, tpd.Pos + extent);
            }
        }
Example #11
0
        public Arcs(
            VisionContent vContent,
            Archipelag archipelag)
            : base(vContent.LoadEffect("Effects/ArcsEffect"))
        {
            Archipelag = archipelag;
            Effect.World = Matrix.Identity;

            var lines = new List<ArcVertex>();

            var modules = archipelag.CodeIslands.ToDictionary(ci => ci.VAssembly.Name, ci => ci);
            foreach (var island in modules.Values)
                processOneIsland(lines, island, island.VAssembly.VProgram, modules);

            if (lines.Any())
            {
                _vertexBuffer = Buffer.Vertex.New(vContent.GraphicsDevice, lines.ToArray());
                _vertexInputLayout = VertexInputLayout.FromBuffer(0, _vertexBuffer);
            }
        }
Example #12
0
        protected override void LoadContent()
        {
            base.LoadContent();

            _spriteBatch = ToDisposeContent(new SpriteBatch(GraphicsDevice));

            _vContent = new VisionContent(_graphicsDeviceManager.GraphicsDevice, Content);
            _arial16Font = Content.Load<SpriteFont>("Fonts/Arial16");

            _basicEffect = new VBasicEffect(_graphicsDeviceManager.GraphicsDevice);
            _basicEffect.EnableDefaultLighting();

            _ball = new SpherePrimitive<VertexPositionNormalTexture>(GraphicsDevice, (p, n, t, tx) => new VertexPositionNormalTexture(p, n, tx), 1);
            var x = _vContent.LoadEffect("effects/simpletextureeffect");
            x.Texture = _vContent.Load<Texture2D>("terraintextures/sand");
            _ballInstance = new VDrawableInstance(x, _ball, Matrix.Translation(10, 2, 10));

            Sky = new SkySphere(_vContent, _vContent.Load<TextureCube>(@"Textures\clouds"));
            _movingShip = new MovingShip(new ShipModel(_vContent));

            _water = WaterFactory.Create(_vContent);
            _water.ReflectedObjects.Add(_movingShip._shipModel);
            _water.ReflectedObjects.Add(_ballInstance);
            _water.ReflectedObjects.Add(Sky);

            _camera = new Camera(
                _vContent.ClientSize,
                new KeyboardManager(this),
                new MouseManager(this),
                null, //new PointerManager(this),
                new Vector3(0, 15, 0),
                new Vector3(-10, 15, 0));

            _rasterizerState = RasterizerState.New(GraphicsDevice, new RasterizerStateDescription
            {
                FillMode = FillMode.Solid,
                CullMode = CullMode.Back,
                IsFrontCounterClockwise = false,
                DepthBias = 0,
                SlopeScaledDepthBias = 0.0f,
                DepthBiasClamp = 0.0f,
                IsDepthClipEnabled = true,
                IsScissorEnabled = false,
                IsMultisampleEnabled = false,
                IsAntialiasedLineEnabled = false
            });

            _shadow = new ShadowMap(_vContent, 1024, 1024);
            //_shadow.ShadowCastingObjects.Add(_sailingShip);
            //_shadow.ShadowCastingObjects.Add(reimersTerrain);
            //_shadow.ShadowCastingObjects.Add(generatedTerrain);
            //_shadow.ShadowCastingObjects.Add(bridge);

            //_archipelag = new Archipelag(_vContent, _water, _shadow);

            _data.VContent = _vContent;
            _data.Camera = _camera;
            _data.Water = _water;
            _data.Shadow = _shadow;

            _q = new CxBillboard(_vContent, Matrix.Identity, _vContent.Load<Texture2D>("billboards/wheat_billboard"), 20, 10, 0.5f);
            _q.AddPositionsWithSameNormal(Vector3.Up,
                Vector3.Zero,
                Vector3.Left*10.5f, Vector3.Up,
                Vector3.Right*10.4f, Vector3.Up,
                Vector3.ForwardRH*3.45f, Vector3.Up,
                Vector3.BackwardRH*2.9f, Vector3.Up);
            _q.CreateVertices();
        }