private BasicEffect2 SetupRenderEffect() { GraphicsDevice device = Engine.Device; if (_effect == null) { _effect = new BasicEffect2(); if (Race.Current.ConfigFile.DepthCueMode == DepthCueMode.Dark) { GameVars.FogColor = new Color(0, 0, 0); } else if (Race.Current.ConfigFile.DepthCueMode == DepthCueMode.Fog) { GameVars.FogColor = new Color(245, 245, 245); } else { Trace.Assert(false); } _effect.FogEnabled = true; _effect.FogColor = GameVars.FogColor.ToVector3(); _effect.FogEnd = Engine.DrawDistance * 6 * (1 / Race.Current.ConfigFile.FogAmount); _effect.FogStart = _effect.FogEnd - 200; _effect.TextureEnabled = true; _effect.TexCoordsMultiplier = 1; _effect.PreferPerPixelLighting = true; _effect.LightingEnabled = false; } Engine.Device.RenderState.AlphaTestEnable = true; Engine.Device.RenderState.ReferenceAlpha = 200; Engine.Device.RenderState.AlphaFunction = CompareFunction.Greater; if (GameVars.CullingOff) { Engine.Device.RenderState.CullMode = CullMode.None; } else { Engine.Device.RenderState.CullMode = CullMode.CullClockwiseFace; } _effect.View = Engine.Camera.View; _effect.Projection = Engine.Camera.Projection; _effect.Begin(SaveStateMode.None); return(_effect); }
public void Render(Vector3 position) { if (_pixmaps.Count == 0) { return; } Update(); BeginBatch(); Matrix world = Matrix.CreateScale(0.03f) * Matrix.CreateBillboard(position, GameEngine.Camera.Position, Vector3.Up, Vector3.Forward); BasicEffect2 effect = GameVars.CurrentEffect; effect.World = _scaleMatrix * world; effect.Texture = _pixmaps[_currentFrame].Texture; GameEngine.Device.RasterizerState.CullMode = CullMode.None; GameEngine.Device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2); EndBatch(); }
public void Render() { Matrix world = Matrix.CreateConstrainedBillboard(Position, Engine.Camera.Position, Vector3.Up, null, null); PedestrianFrame frame = _inLoopingFrames ? _currentSequence.LoopingFrames[_frameIndex] : _currentSequence.InitialFrames[_frameIndex]; if (frame.Texture == null) { return; } Vector3 scale = new Vector3(frame.Texture.Width, frame.Texture.Height, 1); if (!IsPowerup) { scale *= 0.015f; } else { scale *= 0.02f; } if (frame.Flipped) { world = Matrix.CreateRotationY(MathHelper.Pi) * world; } world = Matrix.CreateScale(scale) * Matrix.CreateRotationZ(_hitCurrentSpin) * world * Matrix.CreateTranslation(frame.Offset) * Matrix.CreateTranslation(0, scale.Y * 0.5f, 0); BasicEffect2 effect = GameVars.CurrentEffect; effect.World = world; effect.Texture = frame.Texture; effect.CommitChanges(); Engine.Device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2); }
private BasicEffect2 SetupRenderEffect() { GraphicsDevice device = Engine.Device; if (_effect == null) { _effect = new BasicEffect2(); if (Race.Current.ConfigFile.DepthCueMode == DepthCueMode.Dark) { GameVars.FogColor = new Color(0, 0, 0); } else if (Race.Current.ConfigFile.DepthCueMode == DepthCueMode.Fog) { GameVars.FogColor = new Color(245, 245, 245); } else { Trace.Assert(false); } _effect.FogEnabled = true; _effect.FogColor = GameVars.FogColor.ToVector3(); _effect.FogEnd = Engine.DrawDistance * 6 * (1 / Race.Current.ConfigFile.FogAmount); _effect.FogStart = _effect.FogEnd - 200; _effect.TextureEnabled = true; _effect.TexCoordsMultiplier = 1; _effect.PreferPerPixelLighting = true; _effect.LightingEnabled = false; } Engine.Device.RenderState.AlphaTestEnable = true; Engine.Device.RenderState.ReferenceAlpha = 200; Engine.Device.RenderState.AlphaFunction = CompareFunction.Greater; if (GameVars.CullingOff) Engine.Device.RenderState.CullMode = CullMode.None; else Engine.Device.RenderState.CullMode = CullMode.CullClockwiseFace; _effect.View = Engine.Camera.View; _effect.Projection = Engine.Camera.Projection; _effect.Begin(SaveStateMode.None); return _effect; }