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 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);
        }
Beispiel #3
0
 public void PlayAround(IVEffect effect, IVDrawable sphere)
 {
     //foreach (var tpd in _tpds)
     //{
     //    effect.World = Matrix.Scaling(tpd.BoundingSphere.Radius)*Matrix.Translation(tpd.BoundingSphere.Center);
     //    sphere.Draw(effect);
     //}
 }
Beispiel #4
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);
 }
        public TerrainWalker(
            LarvContent lcontent,
            IVEffect effect,
            Ground ground)
            : base(effect)
        {
            _sphere = lcontent.Sphere;

            _texture = lcontent.Load<Texture2D>(@"models/frogskin");
            _ground = ground;
            _position1 = new Vector3(11, 0, -3);
        }
Beispiel #6
0
 public void PlayAround(IVEffect effect, IVDrawable thing)
 {
     //foreach (var vc in Children.Cast<CodeIsland>().SelectMany(_ => _.Classes.Values))
     //{
     //    effect.World = Matrix.Scaling(vc.SignClickBoundingSphere.Radius * 2) * Matrix.Translation(vc.SignClickBoundingSphere.Center);
     //    thing.Draw(effect);
     //}
     //foreach (var ci in Children.Cast<CodeIsland>())
     //{
     //    effect.World = Matrix.Scaling(ci.BoundingSphere.Radius * 2) * Matrix.Translation(ci.BoundingSphere.Center);
     //    effect.World = Matrix.Scaling(10) * ci.World;
     //    thing.Draw(effect);
     //}
 }
Beispiel #7
0
        public Frog(
            LarvContent lcontent,
            IVEffect effect,
            Serpents serpents)
            : base(effect)
        {
            _model = lcontent.Load<Model>(@"Models/frog");
            _modelRotation = Matrix.RotationY(MathUtil.Pi)*Matrix.Scaling(0.1f);

            _texture = lcontent.Load<Texture2D>(@"models/frogskin");
            _serpents = serpents;
            _ground = lcontent.Ground;
            Restart();
        }
Beispiel #8
0
        public static void Draw(
            IVEffect effect,
            Texture2D skin,
            Vector4 diffuseColor,
            IVDrawable sphere,
            Matrix translation,
            Direction direction)
        {
            var t = direction.IsNorthSouth ? NorthSouthScale : EastWestScale;
            var off = direction.DirectionAsVector3()*-0.3f;
            t *= Matrix.Translation(off);

            effect.World = t*translation;
            effect.Texture = skin;
            effect.DiffuseColor = diffuseColor;
            sphere.Draw(effect);
        }
Beispiel #9
0
 public Egg(
     IVEffect effect,
     IVDrawable sphere,
     Texture2D eggSkin,
     Vector4 diffuseColor,
     Matrix world,
     Whereabouts whereabouts,
     float timeToHatch)
     : base(effect)
 {
     _sphere = sphere;
     _eggSkin = eggSkin;
     _diffuseColor = diffuseColor;
     _world = world * Matrix.Translation(0, -0.2f, 0);
     Whereabouts = whereabouts;
     _timeToHatch = timeToHatch;
 }
Beispiel #10
0
        public WaterSurface(
            GraphicsDevice graphicsDevice,
            InitInfo initInfo)
        {
            Effect = new VisionEffect(initInfo.Fx, graphicsDevice.SamplerStates.LinearClamp)
            {
                SunlightDirection = VisionContent.SunlightDirection - new Vector3(0, VisionContent.SunlightDirection.Y/2, 0)
            };

            _waveBumpMapVelocity0 = initInfo.waveBumpMapVelocity0;
            _waveBumpMapVelocity1 = initInfo.waveBumpMapVelocity1;
            _waveDispMapVelocity0 = initInfo.waveDispMapVelocity0;
            _waveDispMapVelocity1 = initInfo.waveDispMapVelocity1;

            _hiPolyPlane = generatePlane(graphicsDevice, initInfo.SquareSize, initInfo.dx, initInfo.dz,
                                         initInfo.texScale);

            _lakePlane = generatePlane(graphicsDevice, 1, initInfo.SquareSize*512, initInfo.SquareSize*512, initInfo.texScale*512);

            buildFx(initInfo);

            var targetWidth = graphicsDevice.BackBuffer.Width;
            var targetHeight = graphicsDevice.BackBuffer.Height;
            _reflectionTarget = RenderTarget2D.New(
                graphicsDevice,
                targetWidth,
                targetHeight*11/10, //compensate for displaced waves
                graphicsDevice.BackBuffer.Format);

            _reflectionCamera = new Camera(
                new Vector2(targetWidth, targetHeight),
                null,
                null,
                null,
                Vector3.Zero,
                Vector3.Up);

            Update(10);
        }
        public GotoBoardState(Serpents serpents, int scene)
        {
            _serpents = serpents;
            _scene = scene;
            _signEffect = _serpents.LContent.LoadEffect("effects/signtexteffect");

            HomingDevice.Attach(serpents).CanTurnAround = true;
            _serpents.PlayerCave.OpenDoor = true;

            _signPosition = _serpents.LContent.Ground.SignPosition + Vector3.Up*1.5f;
            var direction = Vector3.Left;
            var toCameraPosition = _signPosition + direction*2.4f;

            #if !DEBUG
            const float time1 = 10f;
            const float time2 = 0.25f;
            #else
            var time1 = 2.5f;
            var time2 = 2f;
            #endif
            // move to the board in an arc
            _actions.AddDurable(() => new MoveCameraArc(_serpents.Camera, time1.UnitsPerSecond(), toCameraPosition, Vector3.Right, 5));

            // look at the board for two seconds, while resetting the playing field
            _actions.AddOneShot(time2, () =>
            {
                _serpents.Restart(_scene);
                HomingDevice.Attach(_serpents);
            });

            Vector3 toPosition, toLookAt;
            _serpents.PlayingField.GetCameraPositionForLookingAtPlayerCave(out toPosition, out toLookAt);

            // turn around the camera to look at the cave
            _actions.AddDurable(
                () => new MoveCameraYaw(_serpents.Camera, 2f.Time(), toPosition, StartSerpentState.GetPlayerInitialLookAt(_serpents.PlayingField)));
        }
Beispiel #12
0
 protected VDrawable(IVEffect effect)
 {
     Effect = effect;
 }
Beispiel #13
0
 public void UpdateEffect(IVEffect effect)
 {
     effect.View = View;
     effect.Projection = Projection;
     effect.CameraPosition = Position;
 }
Beispiel #14
0
        protected BaseSerpent(
            LarvContent lcontent,
            PlayingField playingField,
            Texture2D serpentSkin,
            Texture2D serpentHeadSkin,
            Texture2D serpentBump,
            Texture2D eggSkin)
            : base(lcontent.BumpEffect)
        {
            Restart(playingField, playingField.EnemyWhereaboutsStart);
            _sphere = lcontent.Sphere;
            _serpentSkin = serpentSkin;
            _serpentHeadSkin = serpentHeadSkin;
            _serpentBump = serpentBump;
            _eggSkin = eggSkin;
            _textureEffect = lcontent.TextureEffect;

            _headRotation.Add(Direction.East, Matrix.RotationY(MathUtil.Pi));
            _headRotation.Add(Direction.West, Matrix.Identity);
            _headRotation.Add(Direction.North, Matrix.RotationY(MathUtil.PiOverTwo));
            _headRotation.Add(Direction.South, Matrix.RotationY(-MathUtil.PiOverTwo));
        }
Beispiel #15
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();
        }
Beispiel #16
0
 protected ClipDrawable(IVEffect effect)
 {
     Effect = effect;
 }
 public ClipDrawableInstance(IVEffect effect, IVDrawable thing, Matrix world )
     : base(effect)
 {
     Thing = thing;
     World = world;
 }