コード例 #1
0
ファイル: BannerSign.cs プロジェクト: danbystrom/VisionQuest
        protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
        {
            if (drawingReason != DrawingReason.Normal)
                return true;

            var ray = camera.GetPickingRay();

            foreach (var tpd in _tpds)
            {
                if (tpd.DistanceSquared < 5000 || tpd.DotProduct < 0)  // too close or facing away
                    continue;

                Effect.World = Matrix.BillboardRH(tpd.Pos, camera.Position, -camera.Up, camera.Front);
                Effect.DiffuseColor = tpd.BoundingBox.Intersects(ref ray)
                    ? Color.Yellow.ToVector4()
                    : Color.White.ToVector4();
                _spriteBatch.Begin(SpriteSortMode.Deferred, Effect.GraphicsDevice.BlendStates.NonPremultiplied, null, Effect.GraphicsDevice.DepthStencilStates.DepthRead, null, Effect.Effect);
                _spriteBatch.DrawString(_spriteFont, tpd.Text, Vector2.Zero, Color.Black, 0, _spriteFont.MeasureString(tpd.Text) / 2, TextSize, 0, 0);
                _spriteBatch.End();
            }

            Effect.GraphicsDevice.SetDepthStencilState(Effect.GraphicsDevice.DepthStencilStates.Default);
            Effect.GraphicsDevice.SetBlendState(Effect.GraphicsDevice.BlendStates.Opaque);

            return true;
        }
コード例 #2
0
ファイル: TerrainBase.cs プロジェクト: danbystrom/VisionQuest
        protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
        {
            var anyPartIsVisible = _slices.Aggregate(false,
                (current, slice) => current | (slice.Visible = camera.BoundingFrustum.Contains(slice.BoundingSphere) != ContainmentType.Disjoint));

            if (!anyPartIsVisible)
                return false;

            for (var i = 0; i < 9; i++)
            {
                var ep = Effect.Parameters["Texture" + (char)(48 + i)];
                if (ep != null)
                    ep.SetResource(Textures[i]);
            }

            Effect.Parameters["HeightsMap"].SetResource(HeightsMap);
            Effect.Parameters["NormalsMap"].SetResource(NormalsMap);
            Effect.Parameters["WeightsMap"].SetResource(WeightsMap);

            camera.UpdateEffect(Effect);

            foreach (var slice in _slices.Where(slice => slice.Visible))
            {
                Effect.Parameters["TexOffsetAndScale"].SetValue(slice.TexOffsetAndScale);
                VContent.TerrainPlane.Draw(camera, slice.World, drawingReason);
            }

            return true;
        }
コード例 #3
0
ファイル: CxBillboard.cs プロジェクト: danbystrom/VisionQuest
        protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
        {
            if (_vertexBuffer == null)
                return false;

            camera.UpdateEffect(Effect);
            Effect.World = _world;
            Effect.Texture = _texture;

            Effect.GraphicsDevice.SetVertexBuffer(_vertexBuffer);
            Effect.GraphicsDevice.SetVertexInputLayout(_vertexInputLayout);

            Effect.Parameters["WindTime"].SetValue(_time);
            Effect.Parameters["BillboardWidth"].SetValue(_billboardWidth);
            Effect.Parameters["BillboardHeight"].SetValue(_billboardHeight);

            //pass one
            Effect.Parameters["AlphaTestDirection"].SetValue(1f);
            Effect.Effect.CurrentTechnique.Passes[0].Apply();
            Effect.GraphicsDevice.Draw(PrimitiveType.TriangleList, _vertexBuffer.ElementCount);

            if (drawingReason == DrawingReason.Normal)
            {
                //pass two
                Effect.GraphicsDevice.SetDepthStencilState(Effect.GraphicsDevice.DepthStencilStates.DepthRead);
                Effect.GraphicsDevice.SetBlendState(Effect.GraphicsDevice.BlendStates.NonPremultiplied);
                Effect.Parameters["AlphaTestDirection"].SetValue(-1f);
                Effect.Effect.CurrentTechnique.Passes[0].Apply();
                Effect.GraphicsDevice.Draw(PrimitiveType.TriangleList, _vertexBuffer.ElementCount);
                Effect.GraphicsDevice.SetDepthStencilState(Effect.GraphicsDevice.DepthStencilStates.Default);
                Effect.GraphicsDevice.SetBlendState(Effect.GraphicsDevice.BlendStates.Default);
            }

            return true;
        }
コード例 #4
0
ファイル: Signs.cs プロジェクト: danbystrom/VisionQuest
        protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
        {
            base.draw(camera, drawingReason, shadowMap);

            if (drawingReason != DrawingReason.Normal)
                return true;

            camera.UpdateEffect(_signTextEffect);
            var world = World*Matrix.Translation(0, TextDistanceAboveGround - 2, 0);
            _signTextEffect.DiffuseColor = Color.WhiteSmoke.ToVector4();

            foreach (var vc in _vclasses)
            {
                var pos = Vector3.TransformCoordinate(vc.Position, world);
                var viewDirection = Vector3.Normalize(pos - camera.Position);

                if (Vector3.DistanceSquared(pos, camera.Position) > 200000 || Vector3.Dot(viewDirection, camera.Front) < 0)
                    continue;

                var text = vc.VClass.Name;
                _signTextEffect.World = createConstrainedBillboard(pos - viewDirection*0.2f, viewDirection, Vector3.Down);
                _spriteBatch.Begin(SpriteSortMode.Deferred, null, null, Effect.GraphicsDevice.DepthStencilStates.DepthRead, null, _signTextEffect.Effect);
                _spriteBatch.DrawString(_spriteFont, text, Vector2.Zero, Color.Black, 0, _spriteFont.MeasureString(text)/2, TextSize, 0, 0);
                _spriteBatch.End();
            }

            Effect.GraphicsDevice.SetDepthStencilState(Effect.GraphicsDevice.DepthStencilStates.Default);
            Effect.GraphicsDevice.SetBlendState(Effect.GraphicsDevice.BlendStates.Opaque);

            return true;
        }
コード例 #5
0
 protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
 {
     camera.UpdateEffect(Effect);
     Effect.World = World;
     Thing.Draw(Effect);
     return true;
 }
コード例 #6
0
ファイル: SkySphere.cs プロジェクト: danbystrom/VisionQuest
 protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
 {
     if (drawingReason == DrawingReason.ShadowDepthMap)
         return false;
     camera.UpdateEffect(Effect);
     Effect.World = Matrix.Scaling(1, 0.5f, 1)*Matrix.Translation(camera.Position);
     _sphere.Draw(Effect);
     return true;
 }
コード例 #7
0
ファイル: CaveModel.cs プロジェクト: danbystrom/VisionQuest
 protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
 {
     camera.UpdateEffect(Effect);
     Effect.DiffuseColor = new Vector4(0.6f, 0.6f, 0.6f, 1);
     Effect.Texture = _texture;
     _caveModel.Draw(Effect.GraphicsDevice, CaveWorld, camera.View, camera.Projection, Effect.Effect);
     Effect.Texture = _gratingTexture;
     _gratingModel.Draw(Effect.GraphicsDevice, GratingWorld, camera.View, camera.Projection, Effect.Effect);
     return true;
 }
コード例 #8
0
ファイル: Windmill.cs プロジェクト: danbystrom/VisionQuest
        protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
        {
            camera.UpdateEffect(Effect);

            if (drawingReason != DrawingReason.ShadowDepthMap)
                Effect.Texture = _texture;
            _model.Draw(Effect.GraphicsDevice, World, camera.View, camera.Projection, Effect.Effect);

            return true;
        }
コード例 #9
0
ファイル: DrawableBox.cs プロジェクト: danbystrom/VisionQuest
 protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
 {
     camera.UpdateEffect(Effect);
     Effect.World = World;
     if (drawingReason != DrawingReason.ShadowDepthMap)
     {
         Effect.Texture = _texture;
     //TODO                Effect.Parameters["BumpMap"].SetResource(_bumpMap);
     }
     _cube.Draw(Effect);
     return true;
 }
コード例 #10
0
ファイル: ShipModel.cs プロジェクト: danbystrom/VisionQuest
        protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
        {
            var testSphere = new BoundingSphere(Vector3.TransformCoordinate(_boundingSphere.Center, World), _boundingSphere.Radius);
            if (camera.BoundingFrustum.Contains(testSphere) == ContainmentType.Disjoint)
                return false;

            camera.UpdateEffect(Effect);
            Effect.Texture = _texture;

            var world = Matrix.RotationZ((float) _bob1.Value)*Matrix.RotationX((float) _bob2.Value)*World;
            _model.Draw(Effect.GraphicsDevice, world, camera.View, camera.Projection, Effect.Effect);

            return true;
        }
コード例 #11
0
        public void Draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
        {
            _serpents.Draw(camera, drawingReason, shadowMap);

            camera.UpdateEffect(_signEffect);

            var sb = _serpents.LContent.SpriteBatch;
            var font = _serpents.LContent.Font;
            var text = string.Format("Entering scene {0}", 1 + _scene);
            _signEffect.World = Matrix.BillboardRH(_signPosition + Vector3.Left * 0.1f, _signPosition + Vector3.Left, -camera.Up, Vector3.Right);
            _signEffect.DiffuseColor = new Vector4(0.5f, 0.4f, 0.3f, 1);
            sb.Begin(SpriteSortMode.Deferred, _signEffect.GraphicsDevice.BlendStates.NonPremultiplied, null, _signEffect.GraphicsDevice.DepthStencilStates.DepthRead, null, _signEffect.Effect);
            sb.DrawString(font, text, Vector2.Zero, Color.Black, 0, font.MeasureString(text) / 2, 0.010f, 0, 0);
            sb.End();
        }
コード例 #12
0
ファイル: VDrawable.cs プロジェクト: danbystrom/VisionQuest
 public bool Draw(
     Camera camera,
     DrawingReason drawingReason = DrawingReason.Normal,
     ShadowMap shadowMap = null)
 {
     if (Effect != null)
     {
         Effect.SetTechnique(drawingReason);
         Effect.SetShadowMapping(drawingReason != DrawingReason.ShadowDepthMap ? shadowMap : null);
         if (!draw(camera, drawingReason, shadowMap))
             return false;
     }
     Children.ForEach(cd => cd.Draw(camera, drawingReason, shadowMap));
     return true;
 }
コード例 #13
0
ファイル: Windmill.cs プロジェクト: danbystrom/VisionQuest
        protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
        {
            camera.UpdateEffect(Effect);

            if (drawingReason != DrawingReason.ShadowDepthMap)
                Effect.Texture = _texture;

            foreach (var mesh in _model.Meshes)
            {
                Effect.World = _bones[mesh.ParentBone.Index]*World;
                //Effect.Apply();
                mesh.Draw(Effect.GraphicsDevice, null, Effect.Effect);
            }

            return true;
        }
コード例 #14
0
 protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
 {
     camera.UpdateEffect(Effect);
     if (drawingReason == DrawingReason.ShadowDepthMap)
         Effect.CameraPosition = shadowMap.RealCamera.Position;
     Effect.World = World;
     Effect.Parameters["WindTime"].SetValue(Time);
     Effect.Parameters["BillboardWidth"].SetValue(Width);
     Effect.Parameters["BillboardHeight"].SetValue(Height);
     Effect.Texture = _treeTexture;
     Effect.GraphicsDevice.SetVertexInputLayout(_vertexInputLayout);
     Effect.GraphicsDevice.SetVertexBuffer(_vertexBuffer);
     Effect.Effect.CurrentTechnique.Passes[0].Apply();
     Effect.GraphicsDevice.Draw(PrimitiveType.TriangleList, _vertexBuffer.ElementCount);
     return true;
 }
コード例 #15
0
        public void Draw(Camera camera, Matrix world, DrawingReason drawingReason)
        {
            camera.UpdateEffect(Effect);
            Effect.World = world;

            var distance = Vector3.Distance(camera.Position, world.TranslationVector);
            var lod = 3;
            if (distance < 1800)
                lod = 2;
            if (distance < 600)
                lod = 1;
            if (distance < 300)
                lod = 0;
            if (drawingReason != DrawingReason.Normal)
                lod++;
            _loPlane.Draw(Effect, lod);
        }
コード例 #16
0
ファイル: Bridge.cs プロジェクト: danbystrom/VisionQuest
        protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
        {
            camera.UpdateEffect(Effect);
            Effect.World = World;

            //if (drawingReason != DrawingReason.ShadowDepthMap)
            //    Effect.Texture = _texture;

            //Effect.Apply();
            //foreach (var mesh in _model.Meshes)
            //    mesh.Draw(Effect.GraphicsDevice);

            //Effect.World = World*Matrix.Translation(21.68f, 0, 0);
            //foreach (var mesh in _model.Meshes)
            //    mesh.Draw(Effect.GraphicsDevice);

            return true;
        }
コード例 #17
0
        public void Draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
        {
            _serpents.Draw(camera, drawingReason, shadowMap);

            var gd = _serpents.LContent.GraphicsDevice;
            var sb = _serpents.LContent.SpriteBatch;
            var font = _serpents.LContent.Font;

            const string text = "GAME OVER";
            var fsize = _serpents.LContent.FontScaleRatio*6;
            var ssize = new Vector2(gd.BackBuffer.Width, gd.BackBuffer.Height);

            sb.Begin(SpriteSortMode.Deferred, gd.BlendStates.NonPremultiplied);
            sb.DrawString(font, text, (ssize - fsize * font.MeasureString(text)) / 2, Color.LightYellow, 0, Vector2.Zero, fsize, SpriteEffects.None, 0);
            sb.End();

            gd.SetDepthStencilState(gd.DepthStencilStates.Default);
            gd.SetBlendState(gd.BlendStates.Opaque);
        }
コード例 #18
0
        protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
        {
            if (drawingReason != DrawingReason.Normal)
                return true;

            camera.UpdateEffect(Effect);
            foreach (var item in Items)
            {
                Effect.World = Matrix.BillboardRH(item.Target.Position + item.GetOffset(item), camera.Position, -camera.Up, camera.Front);
                Effect.DiffuseColor = item.GetColor(item);
                SpriteBatch.Begin(SpriteSortMode.Deferred, Effect.GraphicsDevice.BlendStates.NonPremultiplied, null, Effect.GraphicsDevice.DepthStencilStates.DepthRead, null, Effect.Effect);
                SpriteBatch.DrawString(Font, item.Text, Vector2.Zero, Color.Black, 0, Font.MeasureString(item.Text) / 2, item.GetSize(item), 0, 0);
                SpriteBatch.End();
            }

            Effect.GraphicsDevice.SetDepthStencilState(Effect.GraphicsDevice.DepthStencilStates.Default);
            Effect.GraphicsDevice.SetBlendState(Effect.GraphicsDevice.BlendStates.Opaque);

            return true;
        }
コード例 #19
0
ファイル: Arcs.cs プロジェクト: danbystrom/VisionQuest
        protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
        {
            try
            {
                camera.UpdateEffect(Effect);
                Effect.Parameters["Time"].SetValue(_time);
                Effect.Apply();

                Effect.GraphicsDevice.SetVertexBuffer(_vertexBuffer);
                Effect.GraphicsDevice.SetVertexInputLayout(_vertexInputLayout);
                Effect.GraphicsDevice.SetDepthStencilState(Effect.GraphicsDevice.DepthStencilStates.DepthRead);

                if (Archipelag.SelectedClass != null)
                    drawArchsFromClass(Archipelag.SelectedClass, 2);
                else
                    Effect.GraphicsDevice.Draw(PrimitiveType.LineList, _vertexBuffer.ElementCount);
            }
            catch (Exception)
            {
            }
            return true;
        }
コード例 #20
0
ファイル: Archipelag.cs プロジェクト: danbystrom/VisionQuest
 protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
 {
     return false;
 }
コード例 #21
0
ファイル: CodeIsland.cs プロジェクト: danbystrom/VisionQuest
 protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
 {
     return VAssembly.Is3DParty
         ? DrawableBox.Draw(camera, drawingReason, shadowMap)
         : base.draw(camera, drawingReason, shadowMap);
 }
コード例 #22
0
ファイル: Frog.cs プロジェクト: danbystrom/VisionQuest
        protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
        {
            camera.UpdateEffect(Effect);
            var t = _modelRotation*_rotation*Matrix.Translation(_position);

            Effect.World = t;
            Effect.Texture = _texture;
            Effect.DiffuseColor = Vector4.One;
            _model.Draw(Effect.GraphicsDevice, t, camera.View, camera.Projection, Effect.Effect);

            return true;
        }
コード例 #23
0
ファイル: IVEffect.cs プロジェクト: danbystrom/VisionQuest
 public void SetTechnique(DrawingReason drawingReason)
 {
 }
コード例 #24
0
ファイル: TerrainBase.cs プロジェクト: danbystrom/VisionQuest
        protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
        {
            //if (camera.BoundingFrustum.Intersects(ref _boundingSphere))
            //    return false;
            var anyPartIsVisible = _slices.Aggregate(false,
                (current, slice) => current | (slice.Visible = camera.BoundingFrustum.Contains(slice.BoundingSphere) != ContainmentType.Disjoint));

            if (!anyPartIsVisible)
                return false;

            for (var i = 0; i < 9; i++)
                Effect.Parameters["Texture" + (char) (48 + i)].SetResource(Textures[i]);

            Effect.Parameters["HeightsMap"].SetResource(HeightsMap);
            Effect.Parameters["NormalsMap"].SetResource(NormalsMap);
            Effect.Parameters["WeightsMap"].SetResource(WeightsMap);

            camera.UpdateEffect(Effect);

            foreach (var slice in _slices.Where(slice => slice.Visible))
            {
                Effect.Parameters["TexOffsetAndScale"].SetValue(slice.TexOffsetAndScale);
                TerrainPlane.Draw(camera, slice.World, drawingReason);
                //DrawableBox.World = slice.World * Matrix.Translation(0,10,0);
                //DrawableBox.Draw(camera, drawingReason, shadowMap);
            }

            return true;
        }
コード例 #25
0
 public void Draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
 {
     _serpents.Draw(camera,drawingReason,shadowMap);
 }
コード例 #26
0
ファイル: Serpents.cs プロジェクト: danbystrom/VisionQuest
        protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
        {
            PlayerCave.Draw(camera, drawingReason, shadowMap);
            EnemyCave.Draw(camera, drawingReason, shadowMap);
            Windmill.Draw(camera, drawingReason, shadowMap);
            LContent.Ground.Draw(camera, drawingReason, shadowMap);
            PlayingField.Draw(camera, drawingReason, shadowMap);
            LContent.Sky.Draw(camera, drawingReason, shadowMap);

            if (PlayerEgg != null)
                PlayerEgg.Draw(camera, drawingReason, shadowMap);
            foreach (var egg in EnemyEggs)
                egg.Draw(camera, drawingReason, shadowMap);
            foreach (var frog in Frogs)
                frog.Draw(camera, drawingReason, shadowMap);

            var allSerpents = new List<BaseSerpent> {PlayerSerpent};
            allSerpents.AddRange(Enemies);

            foreach (var serpent in allSerpents.Where(_ => _.SerpentStatus == SerpentStatus.Alive))
                serpent.Draw(camera, drawingReason, shadowMap);

            if (drawingReason != DrawingReason.Normal)
                return true;

            if (allSerpents.Any(_ => _.SerpentStatus == SerpentStatus.Ghost))
            {
                LContent.GraphicsDevice.SetBlendState(LContent.GraphicsDevice.BlendStates.AlphaBlend);
                foreach (var serpent in allSerpents.Where(_ => _.SerpentStatus == SerpentStatus.Ghost))
                    serpent.Draw(camera, drawingReason, shadowMap);
                LContent.GraphicsDevice.SetBlendState(LContent.GraphicsDevice.BlendStates.Default);
            }

            var w = LContent.GraphicsDevice.BackBuffer.Width;
            const float fsize = 1.2f;
            LContent.SpriteBatch.Begin();
            LContent.DrawString("Score: {0:000 000}".Fmt(Score), new Vector2(10, 5), fsize);
            LContent.DrawString("Scene: {0}".Fmt(Scene + 1), new Vector2(w/2f, 5), fsize, 0.5f);
            LContent.DrawString("Lives left: {0}".Fmt(LivesLeft), new Vector2(w - 10, 5), fsize, 1);
            LContent.SpriteBatch.End();

            FloatingTexts.Draw(camera, drawingReason, shadowMap);

            Effect.GraphicsDevice.SetDepthStencilState(Effect.GraphicsDevice.DepthStencilStates.Default);
            Effect.GraphicsDevice.SetBlendState(Effect.GraphicsDevice.BlendStates.Opaque);

            return true;
        }
コード例 #27
0
 public void Draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
 {
     _serpents.Draw(camera, drawingReason, shadowMap);
     using (_serpents.LContent.UsingSpriteBatch())
         _hofPainter.Paint(Color.LightYellow, _entryIndex, _cursorFlash < 0.5f);
 }
コード例 #28
0
 public void SetTechnique(DrawingReason drawingReason )
 {
     switch ( drawingReason )
     {
         case DrawingReason.Normal:
             Effect.CurrentTechnique = _techStandard;
             break;
         case DrawingReason.ReflectionMap:
             Effect.CurrentTechnique = _techClipPlane;
             break;
         case DrawingReason.ShadowDepthMap:
             Effect.CurrentTechnique = _techDepthMap;
             break;
     }
 }
コード例 #29
0
ファイル: Egg.cs プロジェクト: danbystrom/VisionQuest
 protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
 {
     camera.UpdateEffect(Effect);
     Draw(Effect, _eggSkin, _diffuseColor, _sphere, _world, Whereabouts.Direction);
     return true;
 }
コード例 #30
0
 protected abstract bool draw(
     Camera camera,
     DrawingReason drawingReason,
     ShadowMap shadowMap);