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

            ShadowDepthTarget = RenderTarget2D.New(_graphicsDevice, width, height, PixelFormat.R16G16.Float);

            _spriteBatch = new SpriteBatch(_graphicsDevice);
            _shadowBlurEffect = vContent.LoadPlainEffect("ShadowEffects/Blur");
            _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(50, 50);
        }
Beispiel #2
0
 public TerrainPlane(VisionContent vContent)
 {
     Effect = vContent.LoadPlainEffect("Effects/TerrainEffects");
     _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);
 }
Beispiel #3
0
 public DrawableBox(VisionContent vContent, Matrix world, Vector3 size, float texScale = 1)
     : base(vContent.LoadPlainEffect("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;
 }
Beispiel #4
0
 public CxBillboard(
     VisionContent vContent,
     Matrix world,
     Texture2D texture,
     float width,
     float height)
     : base(vContent.LoadPlainEffect("Billboards/CxBillboard", vContent.GraphicsDevice.SamplerStates.LinearClamp))
 {
     _world = world;
     _texture = texture;
     _billboardWidth = width;
     _billboardHeight = height;
 }
 public SimpleBillboards(
     VisionContent vContent, 
     Matrix world,
     Texture2D texture,
     List<Vector3> positions, 
     float width,
     float height)
     : base(vContent.LoadPlainEffect("Effects/BillboardEffect"))
 {
     World = world;
     _treeTexture = texture;
     Width = width;
     Height = height;
     Effect.Parameters["AllowedRotDir"].SetValue(Vector3.Up);
     createBillboardVerticesFromList(positions);
 }
Beispiel #6
0
        protected override void LoadContent()
        {
            // Instantiate a SpriteBatch
            spriteBatch = ToDisposeContent(new SpriteBatch(GraphicsDevice));

            // Loads a sprite font
            // The [Arial16.xml] file is defined with the build action [ToolkitFont] in the project
            //arial16Font = Content.Load<SpriteFont>("Arial16");

            var lightVec = new Vector3(1, 0, 5);
            lightVec.Normalize();
            // Creates a basic effect
            //basicEffect = ToDisposeContent(new VBasicEffect(GraphicsDevice));
            var vContent = new VisionContent(GraphicsDevice, Content);
            //basicEffect = ToDisposeContent(new VBasicEffect(GraphicsDevice));
            //_textureEffect = vContent.LoadPlainEffect("effects/simpletextureeffect");
            _textureEffect = vContent.LoadPlainEffect("effects/simpletextureeffect");
            _exampleEffect = vContent.LoadPlainEffect("exempeleffect");
            _textureEffect.SunlightDirection = lightVec;
            _exampleEffect.SunlightDirection = lightVec;
            _textureEffect.Texture = Content.Load<Texture2D>("textures/brick_texture_map");
            _exampleEffect.Texture = Content.Load<Texture2D>("textures/brick_texture_map");
             //_textureEffect.Parameters["BumpMap"].SetResource(Content.Load<Texture2D>("textures/brick_normal_map"));
            _exampleEffect.Parameters["BumpMap"].SetResource(Content.Load<Texture2D>("textures/brick_normal_map"));

            //var be = (BasicEffect)basicEffect.Effect;
            //be.PreferPerPixelLighting = true;
            //be.EnableDefaultLighting();
            //be.LightingEnabled = _lighting;

            // Creates torus primitive
            primitive =
                ToDisposeContent(new SpherePrimitive<VertexPositionNormalTangentTexture>(GraphicsDevice,
                    (p, n, t, tx) => new VertexPositionNormalTangentTexture(p, n, t, tx), 2));

            base.LoadContent();
        }