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) { 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 (_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; }
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; }
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) { camera.UpdateEffect(Effect); Effect.World = World; if (drawingReason != DrawingReason.ShadowDepthMap) { Effect.Texture = _texture; //TODO Effect.Parameters["BumpMap"].SetResource(_bumpMap); } _cube.Draw(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(); }
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; }
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; }
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); }
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); 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; }
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 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; }
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) { camera.UpdateEffect(Effect); Draw(Effect, _eggSkin, _diffuseColor, _sphere, _world, Whereabouts.Direction); 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; }