protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap) { camera.UpdateEffect(Effect); Effect.World = World; Thing.Draw(Effect); return true; }
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; }
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; }
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; }
public void Kill(WaterSurface water, ShadowMap shadow) { foreach (var island in Children) { water.ReflectedObjects.Remove(island); shadow.ShadowCastingObjects.Remove(island); island.Dispose(); } Children.Clear(); }
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; }
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; }
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; }
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(); }
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; }
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; }
public LarvContent(GraphicsDevice graphicsDevice, ContentManager content, IEnumerable<string> sceneDescription) : base(graphicsDevice, content) { SpriteBatch = new SpriteBatch(graphicsDevice); Font = Load<SpriteFont>("fonts/BlackCastle"); SignTextEffect = LoadEffect("effects/signtexteffect"); TextureEffect = LoadEffect("effects/simpletextureeffect"); BumpEffect = LoadEffect("effects/simplebumpeffect"); Sphere = new SpherePrimitive<VertexPositionNormalTangentTexture>(GraphicsDevice, (p, n, t, tx) => new VertexPositionNormalTangentTexture(p, n, t, tx), 2, 10); Sky = new SkySphere(this, Load<TextureCube>(@"Textures\clouds")); Ground = new Ground(this); ShadowMap = new ShadowMap(this, 800, 800, 1, 50); ShadowMap.UpdateProjection(50, 30); HallOfFame = HofStorage.Load(); PlayingFieldInfos = PlayingFieldsDecoder.Create(sceneDescription); }
public Archipelag( VisionContent vContent, VProgram vprogram, WaterSurface water, ShadowMap shadow) : base((IVEffect)null) { var codeIslands = CodeIsland.Create(vContent, this, vprogram.VAssemblies); foreach (var codeIsland in codeIslands) { water.ReflectedObjects.Add(codeIsland); shadow.ShadowCastingObjects.Add(codeIsland); Children.Add(codeIsland); } _bannerSign = new BannerSign(vContent, codeIslands); _arcs = new Arcs(vContent, this); }
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); }
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; }
protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap) { camera.UpdateEffect(Effect); Draw(Effect, _eggSkin, _diffuseColor, _sphere, _world, Whereabouts.Direction); return true; }
public void Draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap) { _serpents.Draw(camera,drawingReason,shadowMap); }
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(); }
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); }
protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap) { var p = Position; var slinger = p.X + p.Z; p += wormTwist(ref slinger); camera.UpdateEffect(Effect); var worlds = new List<Matrix> { _headRotation[HeadDirection]* Matrix.Scaling(HeadSize)* Matrix.Translation(p.X, HeadSize + p.Y + _ascendToHeaven, p.Z) }; // p is the the loc of the last segement - which is the head on the first round var segment = _tail; while (true) { var p2 = segment.Position + wormTwist(ref slinger); worlds.Add( Matrix.Scaling(SegmentSize)* Matrix.Translation( (p.X + p2.X)/2, SegmentSize + (p.Y + p2.Y)/2 + _ascendToHeaven, (p.Z + p2.Z)/2)); worlds.Add( Matrix.Scaling(SegmentSize)* Matrix.Translation( p2.X, SegmentSize + p2.Y + _ascendToHeaven, p2.Z)); p = p2; if (segment.Next == null) break; segment = segment.Next; } if (_pendingEatenSegments <= SegmentEatTreshold/2) worlds.RemoveAt(worlds.Count - 1); if (_layingEgg > 0 && worlds.Count >= 3) { Effect.Texture = _eggSkin; _eggWorld = worlds.Last(); Egg.Draw(_textureEffect, _eggSkin, TintColor(), _sphere, _eggWorld, segment.Whereabouts.Direction); //move the last two spheres so that they slowly dissolves into the serpent var factor = MathUtil.Clamp(_layingEgg/TimeForLayingEggProcess - 0.5f, 0, 1); var world1 = worlds.Last(); worlds.RemoveAt(worlds.Count - 1); var world2 = worlds.Last(); worlds.RemoveAt(worlds.Count - 1); var world3 = worlds.Last(); world2.TranslationVector = Vector3.Lerp(world2.TranslationVector, world3.TranslationVector, factor); world1.TranslationVector = Vector3.Lerp(world1.TranslationVector, world2.TranslationVector, factor); worlds.Add(world2); worlds.Add(world1); } Effect.Parameters["BumpMap"].SetResource(_serpentBump); Effect.DiffuseColor = TintColor(); Effect.Texture = _serpentHeadSkin; Effect.World = worlds.First(); _sphere.Draw(Effect); Effect.Texture = _serpentSkin; foreach (var world in worlds.Skip(1)) { Effect.World = world; _sphere.Draw(Effect); } Effect.DiffuseColor = Vector4.One; return true; }
protected abstract bool draw( Camera camera, DrawingReason drawingReason, ShadowMap shadowMap);
protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap) { return false; }
protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap) { return VAssembly.Is3DParty ? DrawableBox.Draw(camera, drawingReason, shadowMap) : base.draw(camera, drawingReason, shadowMap); }
protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap) { camera.UpdateEffect(Effect); Effect.World = Matrix.Translation(-0.5f, 0, -0.5f); Effect.Texture = _texture; Effect.GraphicsDevice.SetVertexInputLayout(VertexInputLayout); Effect.DiffuseColor = Vector4.One; Effect.GraphicsDevice.SetVertexBuffer(VertexBuffer); Effect.ForEachPass(() => Effect.GraphicsDevice.Draw( PrimitiveType.TriangleList, VertexBuffer.ElementCount)); if (VertexBufferShadow != null) { Effect.DiffuseColor = new Vector4(0.4f, 0.4f, 0.4f, 1); Effect.GraphicsDevice.SetVertexBuffer(VertexBufferShadow); Effect.ForEachPass(() => Effect.GraphicsDevice.Draw( PrimitiveType.TriangleList, VertexBufferShadow.ElementCount)); } return true; }
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; }
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; }
protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap) { camera.UpdateEffect(Effect); Effect.Texture = _texture; Effect.DiffuseColor = Vector4.One; Effect.World = Matrix.Scaling(0.1f) * Matrix.Translation(_position1); _sphere.Draw(Effect); Effect.DiffuseColor = Vector4.Zero; Effect.World = Matrix.Scaling(0.1f) * Matrix.Translation(_position2); _sphere.Draw(Effect); Effect.World = Matrix.Scaling(0.1f) * Matrix.Translation(_position3); _sphere.Draw(Effect); Effect.World = Matrix.Scaling(0.1f) * Matrix.Translation(_position4); _sphere.Draw(Effect); Effect.World = Matrix.Scaling(0.1f) * Matrix.Translation(_position5); _sphere.Draw(Effect); return true; }